'Insufficient permissions.' ), 403); } // Check if nonce is set and valid if (! isset($_REQUEST['nonce']) || ! wp_verify_nonce($_REQUEST['nonce'], 'st-admin-js')) { wp_send_json_error(array( 'message' => 'Invalid or missing nonce.' ), 403); } if (isset($_GET['stags_action']) && 'helper_js_collection' === $_GET['stags_action']) { self::ajax_local_tags(); } } /** * Display a javascript collection for autocompletion script ! * * @return void * @author WebFactory Ltd */ public static function ajax_local_tags() { status_header(200); // Send good header HTTP header('Content-Type: application/json; charset=' . get_bloginfo('charset')); $taxonomy = 'post_tag'; if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])) {// && $taxonomy = sanitize_text_field($_REQUEST['taxonomy']); } if (taxonomy_exists($taxonomy) && (int) wp_count_terms($taxonomy, array( 'hide_empty' => false )) === 0) { // No tags to suggest echo wp_json_encode(array()); exit(); } // Prepare search $search = (isset($_GET['term'])) ? trim(stripslashes(sanitize_text_field($_GET['term']))) : ''; $exclude_term = isset($_REQUEST['exclude_term']) ? (int) $_REQUEST['exclude_term'] : 0; // Get all terms, or filter with search $terms = SimpleTags_Admin::getTermsForAjax($taxonomy, $search); if (empty($terms)) { echo wp_json_encode(array()); exit(); } // Format $results = array(); foreach ((array) $terms as $term) { if ((int) $term->term_id === $exclude_term) { continue; } $term->name = stripslashes($term->name); $original_name = $term->name; $is_mass_edit_page = isset($_GET['page']) && $_GET['page'] === 'st_mass_terms'; $show_slug = SimpleTags_Plugin::get_option_value('enable_mass-edit_terms_slug'); if ($is_mass_edit_page && $show_slug && ! empty($term->slug)) { $term->name = $term->name . ' (' . $term->slug . ')'; } if ($taxonomy === 'linked_term_taxonomies') { $term->name = $term->name . ' (' . $term->taxonomy . ')'; } $term->name = str_replace(array( "\r\n", "\r", "\n" ), '', $term->name); // Decode any HTML entities for display in autocomplete widgets. $display_name = html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo('charset') ); $results[] = array( 'id' => $term->term_id, 'label' => $display_name, 'value' => $display_name, 'taxonomy' => $term->taxonomy, 'name' => $original_name, ); } echo wp_json_encode($results); exit(); } /** * Content of custom meta box of TaxoPress * * @param object $post * * @return void * @author WebFactory Ltd */ public static function metabox($post) { // Get options $autocomplete_min = 0 ?>