$tag_list) { // Trim data $tag_list = trim(stripslashes($tag_list)); // String to array $tags = explode(',', $tag_list); // Remove empty and trim tag $tags = array_filter($tags, '_delete_empty_element'); $show_slug = SimpleTags_Plugin::get_option_value('enable_mass-edit_terms_slug'); $term_ids = array(); foreach ($tags as $tag) { $tag = trim($tag); if (empty($tag)) { continue; } if ($show_slug && preg_match('/^(.+?)\s*\(([^)]+)\)$/', $tag, $matches)) { $term_name = trim($matches[1]); $term_slug = trim($matches[2]); $term = get_term_by('slug', $term_slug, SimpleTags_Admin::$taxonomy); if ($term) { if ($term->name === $term_name) { $term_ids[] = $term->term_id; } else { $unique_slug = $term_slug; $counter = 1; while (get_term_by('slug', $unique_slug, SimpleTags_Admin::$taxonomy)) { $unique_slug = $term_slug . '-' . $counter; $counter++; } $new_term = wp_insert_term($term_name, SimpleTags_Admin::$taxonomy, array('slug' => $unique_slug)); if (!is_wp_error($new_term)) { $term_ids[] = $new_term['term_id']; } } } else { $new_term = wp_insert_term($term_name, SimpleTags_Admin::$taxonomy, array('slug' => $term_slug)); if (!is_wp_error($new_term)) { $term_ids[] = $new_term['term_id']; } } } else { if ($show_slug) { $tag = trim(preg_replace('/\s*\([^)]+\)$/', '', $tag)); } $term = get_term_by('name', $tag, SimpleTags_Admin::$taxonomy); if ($term) { $term_ids[] = $term->term_id; } else { $new_term = wp_insert_term($tag, SimpleTags_Admin::$taxonomy); if (!is_wp_error($new_term)) { $term_ids[] = $new_term['term_id']; } } } } wp_set_object_terms($object_id, $term_ids, SimpleTags_Admin::$taxonomy); $counter++; // Clean cache clean_post_cache($object_id); } add_settings_error(__CLASS__, __CLASS__, sprintf(esc_html__('%1$s %2$s(s) terms updated with success !', 'simple-tags'), (int) $counter, strtolower(SimpleTags_Admin::$post_type_name)), 'updated taxopress-notice'); return true; } } return false; } /** * Helper function to extract term name (ignoring slug in brackets) */ private static function extractTermName($term) { return trim(preg_replace('/\s*\(.*?\)$/', '', $term)); } /** * WP Page - Mass edit tags * */ public static function pageMassEditTags() { global $wpdb, $wp_locale, $wp_query; list($post_stati, $avail_post_stati) = self::edit_data_query(); if (! isset($_GET['paged'])) { $_GET['paged'] = 1; } // Display message settings_errors(__CLASS__); ?>



add_query_arg('paged', '%#%'), 'format' => '', 'total' => ceil($wp_query->found_posts / $posts_per_page), 'current' => ((int) $_GET['paged']) )); if ($page_links) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo "
" . $page_links . "
"; } ?>
get_results($wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC", SimpleTags_Admin::$post_type)); $month_count = count($arc_result); if (! isset($_GET['m'])) { $_GET['m'] = ''; } if ($month_count && ! (1 == $month_count && 0 == $arc_result[0]->mmonth)) { ?> name, $existing_term->slug); } else { $selected_term_label = $existing_term->name; } } } ?>

array( _x('Published', 'post'), __('Published posts'), _n_noop('Published (%s)', 'Published (%s)') ), 'future' => array( _x('Scheduled', 'post'), __('Scheduled posts'), _n_noop('Scheduled (%s)', 'Scheduled (%s)') ), 'pending' => array( _x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review (%s)', 'Pending Review (%s)') ), 'draft' => array( _x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft (%s)', 'Drafts (%s)') ), 'private' => array( _x('Private', 'post'), __('Private posts'), _n_noop('Private (%s)', 'Private (%s)') ), 'inherit' => array( _x('Inherit', 'post'), __('Inherit posts'), _n_noop('Inherit (%s)', 'Inherit (%s)') ), ); $post_stati = apply_filters('post_stati', $post_stati); $avail_post_stati = get_available_post_statuses(SimpleTags_Admin::$post_type); if ($q['post_type'] === 'attachment') { $q['post_status'] = 'inherit'; } $post_status_q = ''; if (isset($q['post_status']) && in_array($q['post_status'], array_keys($post_stati))) { $post_status_q = '&post_status=' . $q['post_status']; $post_status_q .= '&perm=readable'; } elseif (! isset($q['post_status'])) { $q['post_status'] = ''; } if ('pending' === $q['post_status']) { $order = 'ASC'; $orderby = 'modified'; } elseif ('draft' === $q['post_status']) { $order = 'DESC'; $orderby = 'modified'; } else { $order = 'DESC'; $orderby = 'date'; } $args = array( 'post_type' => $q['post_type'], 'what_to_show' => 'posts', 'posts_per_page' => $q['posts_per_page'], 'paged' => $q['paged'], 'order' => $order, 'orderby' => $orderby, ); if (! empty($q['post_status']) && in_array($q['post_status'], array_keys($post_stati), true)) { $args['post_status'] = $q['post_status']; $args['perm'] = 'readable'; } if (! empty($q['s'])) { $args['s'] = sanitize_text_field($q['s']); } if (! empty($q['m']) && (int) $q['m'] > 0) { $args['m'] = (int) $q['m']; } if (! empty($q['massedit_filter_term'])) { $args['tax_query'] = array( array( 'taxonomy' => SimpleTags_Admin::$taxonomy, 'field' => 'slug', 'terms' => sanitize_text_field($q['massedit_filter_term']), ), ); } $GLOBALS['wp_query'] = new WP_Query(); $GLOBALS['wp_query']->query($args); return array( $post_stati, $avail_post_stati ); } }