__( 'Please select an attribute for add', 'a3-portfolio' ), 'remove_attribute' => __( 'Remove this attribute?', 'a3-portfolio' ), 'new_attribute_prompt' => __( 'Enter a name for the new attribute term:', 'a3-portfolio' ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'add_attribute_nonce' => wp_create_nonce( 'add-attribute' ), 'save_attributes_nonce' => wp_create_nonce( 'save-attributes' ), 'post_id' => isset( $post->ID ) ? $post->ID : '', ); wp_localize_script( 'a3-portfolio-metabox-admin-script', 'a3_portfolio_admin_meta_boxes', $params ); do_action( 'a3_portfolio_metabox_include_scripts' ); } /** * Output the metabox */ public function output( $post ) { global $a3_portfolio_item_cards_settings, $a3_portfolio_item_posts_settings; $thepostid = $post->ID; $this->include_js(); $card_desc = esc_html( get_post_meta( $thepostid, '_a3_portfolio_card_desc', true ) ); $layout_column = trim( get_post_meta( $thepostid, '_a3_portfolio_meta_layout_column', true ) ); if ( '' == $layout_column ){ $layout_column = $a3_portfolio_item_posts_settings['portfolio_single_layout_column']; } if ( '' == $layout_column ) $layout_column = 2; $wide = trim( get_post_meta( $thepostid, '_a3_portfolio_meta_gallery_wide', true ) ); if ( '' == $wide ){ $wide = $a3_portfolio_item_posts_settings['portfolio_inner_container_single_main_image_width']; } if ( '' == $wide ) $wide = 70; $thumb_pos = trim( get_post_meta( $thepostid, '_a3_portfolio_meta_thumb_position', true ) ); if ( '' == $thumb_pos ){ $thumb_pos = $a3_portfolio_item_posts_settings['portfolio_inner_container_single_thumb_position']; } $button_visit = trim( get_post_meta( $thepostid, '_a3_portfolio_launch_site_url', true ) ); $button_text = trim( esc_attr( get_post_meta( $thepostid, '_a3_portfolio_launch_button_text', true ) ) ); $button_text = apply_filters( 'a3_portfolio_backend_launch_button_text', $button_text, $thepostid ); if ( '' == $button_text ) { $button_text = a3_portfolio_ei_ict_t__( 'Launch Site Button Text', __( 'LAUNCH SITE', 'a3-portfolio' ) ); } $launch_open_type = trim( esc_attr( get_post_meta( $thepostid, '_a3_portfolio_launch_open_type', true ) ) ); $viewmore_button_text = trim( esc_attr( get_post_meta( $thepostid, '_a3_portfolio_viewmore_button_text', true ) ) ); $viewmore_button_text = apply_filters( 'a3_portfolio_backend_viewmore_button_text', $viewmore_button_text, $thepostid ); if ( '' == $viewmore_button_text ) { $viewmore_button_text = apply_filters( 'a3_portfolio_viewmore_button_text', a3_portfolio_ei_ict_t__( 'View More Button Text', __( 'View More', 'a3-portfolio' ) ), $thepostid ); } ?>
/>
%
0 ) { ?>

$attribute ) { $taxonomy = ''; $metabox_class = array(); $taxonomy = a3_portfolio_attribute_taxonomy_name_by_id( $attribute_id ); if ( '' != $taxonomy ) { if ( ! taxonomy_exists( $taxonomy ) ) { continue; } if ( ! isset( $attributes['is_visible_expander'] ) ) { $attributes['is_visible_expander'] = apply_filters( 'a3_portfolio_attribute_default_visible_expander', 1 ); } if ( ! isset( $attributes['is_visible_post'] ) ) { $attributes['is_visible_post'] = apply_filters( 'a3_portfolio_attribute_default_visible_post', 1 ); } $attribute_taxonomy = $a3_portfolio_attributes[ $taxonomy ]; $metabox_class[] = 'taxonomy'; $metabox_class[] = $taxonomy; $attribute_label = a3_portfolio_attribute_label( $taxonomy ); include( 'views/html-portfolio-attribute.php' ); $position++; } } } ?>

Portfolio Attribute', 'a3-portfolio' ), admin_url('edit.php?post_type=a3-portfolio&page=portfolio-attributes') ); ?>

/>
/>
$attribute_name ) { $is_visible_expander = isset( $attribute_visibility[ $attribute_id ]['expander'] ) ? 1 : 0; $is_visible_post = isset( $attribute_visibility[ $attribute_id ]['post'] ) ? 1 : 0; $is_attribute_have_terms = false; if ( isset( $attribute_values[ $attribute_id ] ) ) { // Select based attributes - Format values (posted values are slugs) if ( is_array( $attribute_values[ $attribute_id ] ) ) { $values = array_map( 'sanitize_title', $attribute_values[ $attribute_id ] ); // Remove empty items in the array $values = array_filter( $values, 'strlen' ); $is_attribute_have_terms = true; // Text based attributes - Posted values are term names - don't change to slugs } else { $values = stripslashes( strip_tags( $attribute_values[ $attribute_id ] ) ); } } else { $values = ''; } // Update post terms if ( $is_attribute_have_terms && taxonomy_exists( $attribute_name ) ) { foreach( $values as $key => $value ) { $term = get_term_by( 'slug', trim( $value ), $attribute_name ); if ( $term ) { $values[ $key ] = intval( $term->term_id ); } else { $term = wp_insert_term( trim( $value ), $attribute_name ); if ( isset( $term->term_id ) ) { $values[ $key ] = intval($term->term_id); } } } wp_set_object_terms( $post_id, $values, $attribute_name ); } if ( ! empty( $values ) ) { // Add attribute to array, but don't set values $attributes[ $attribute_id ] = array( 'value' => '', 'is_visible_expander' => $is_visible_expander, 'is_visible_post' => $is_visible_post, ); if ( ! $is_attribute_have_terms ) { $attributes[ $attribute_id ]['value'] = $values; } } } } } /** * Unset removed attributes by looping over previous values and * unsetting the terms. */ $old_attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_portfolio_attributes', true ) ) ); if ( $old_attributes ) { foreach ( $old_attributes as $attribute_id => $value ) { $taxonomy = a3_portfolio_attribute_taxonomy_name_by_id( $attribute_id ); if ( empty( $attributes[ $attribute_id ] ) && taxonomy_exists( $taxonomy ) ) { wp_set_object_terms( $post_id, array(), $attribute_id ); } } } /** * After removed attributes are unset, we can set the new attribute data. */ update_post_meta( $post_id, '_portfolio_attributes', $attributes ); do_action( 'a3_portfolio_metabox_save', $post_id ); } } $a3_portfolio_data_metabox = new A3_Portfolio_Data_Metabox(); ?>