name; if ($filter_format === 'term_name_taxonomy_name') { $taxonomy = get_taxonomy($term->taxonomy); $text .= ' (' . $taxonomy->labels->singular_name . ')'; } elseif ($filter_format === 'term_name_taxonomy_slug') { $text .= ' (' . $term->taxonomy . ')'; } $results[] = [ 'id' => $term->$field, 'text' => $text, ]; } $response = [ 'results' => $results, ]; echo wp_json_encode($response); exit; } /** * Get the possible terms for a given search query. * * @param string $search Search query. * * @return object */ public static function get_possible_terms_for_search($search, $taxonomy_type = 'public') { if ($taxonomy_type === 'public') { $taxonomies = array_keys(get_taxonomies(['public' => true])); } elseif ($taxonomy_type === 'private') { $taxonomies = array_keys(get_taxonomies(['public' => false])); } else { $taxonomies = array_keys(get_taxonomies()); } $term_args = [ 'taxonomy' => $taxonomies, 'hide_empty' => true, 'number' => apply_filters('taxopress_terms_search_result_limit', 20), 'order_by' => 'name', ]; if (!empty($search)) { $search = str_replace(['\"', "\'"], '', $search); $term_args['search'] = $search; } $terms = get_terms($term_args); return $terms; } public static function set_screen($status, $option, $value) { return $value; } /** Singleton instance */ public static function get_instance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; } /** * Add WP admin menu for Tags * * @return void * @author Olatechpro */ public function admin_menu() { $hook = add_submenu_page( self::MENU_SLUG, esc_html__('Posts', 'simple-tags'), esc_html__('Posts', 'simple-tags'), 'simple_tags', 'st_posts', [ $this, 'page_manage_posts', ] ); if (taxopress_is_screen_main_page()) { add_action("load-$hook", [$this, 'screen_option']); } } /** * Screen options */ public function screen_option() { $option = 'per_page'; $args = [ 'label' => esc_html__('Number of items per page', 'simple-tags'), 'default' => 20, 'option' => 'st_posts_per_page' ]; add_screen_option($option, $args); $this->posts_table = new Taxopress_Posts_List(); } /** * Method for build the page HTML manage tags * * @return void * @author Olatechpro */ public function page_manage_posts() { // Default order if (!isset($_GET['order'])) { $_GET['order'] = 'name-asc'; } settings_errors(__CLASS__); ?>