name = stripslashes( $term->name ); $term->name = str_replace( array( "\r\n", "\r", "\n" ), '', $term->name ); $results[] = array( 'id' => $term->term_id, 'label' => $term->name, 'value' => $term->name ); } echo json_encode( $results ); exit(); } /** * Save tags input for old field * * @param string $post_id * @param object $object * * @return boolean * @author Amaury Balmer */ public static function save_post( $post_id = 0, $object = null ) { if ( isset( $_POST['adv-tags-input'] ) ) { // Trim/format data $tags = preg_replace( "/[\n\r]/", ', ', stripslashes( $_POST['adv-tags-input'] ) ); $tags = trim( $tags ); // String to array $tags = explode( ',', $tags ); // Remove empty and trim tag $tags = array_filter( $tags, '_delete_empty_element' ); // Add new tag (no append ! replace !) wp_set_object_terms( $post_id, $tags, 'post_tag' ); // Clean cache clean_post_cache( $post_id ); return true; } return false; } /** * Call meta box public static function for taxonomy tags for each CPT * * @param string $post_type * * @return boolean * @author Amaury Balmer */ public static function add_meta_boxes( $post_type ) { $taxonomies = get_object_taxonomies( $post_type ); if ( in_array( 'post_tag', $taxonomies ) ) { if ( $post_type == 'page' && ! is_page_have_tags() ) { return false; } remove_meta_box( 'post_tag' . 'div', $post_type, 'side' ); remove_meta_box( 'tagsdiv-' . 'post_tag', $post_type, 'side' ); add_meta_box( 'adv-tagsdiv', __( 'Tags (Simple Tags)', 'simpletags' ), array( __CLASS__, 'metabox' ), $post_type, 'side', 'core', array( 'taxonomy' => 'post_tag' ) ); return true; } return false; } /** * Content of custom meta box of Simple Tags * * @param object $post * * @return void * @author Amaury Balmer */ public static function metabox( $post ) { // Get options $autocomplete_min = (int) SimpleTags_Plugin::get_option_value( 'autocomplete_min' ); ?>