/** * Convert the given term into a analyzable object. * * @param mixed $item The term for which to build the analyzer data. * * @return array */ protected function item_to_response($item) { $focus_keyword = $this->get_focus_keyword($item); $title = str_replace(' %%page%% ', ' ', $this->get_title($item)); $meta = $this->get_meta_description($item); $description = $item->description; /** * Filter the term description for recalculation. * * @param string $description Content of the term. Modify to reflect front-end content. * @oaram WP_Term $item The term the description comes from. */ $description = apply_filters('wpseo_term_description_for_recalculation', $description, $item); return array('term_id' => $item->term_id, 'taxonomy' => $item->taxonomy, 'text' => $description, 'keyword' => $focus_keyword, 'url' => urldecode($item->slug), 'pageTitle' => apply_filters('wpseo_title', wpseo_replace_vars($title, $item, array('page'))), 'meta' => apply_filters('wpseo_metadesc', wpseo_replace_vars($meta, $item)), 'keyword_usage' => array($focus_keyword => WPSEO_Taxonomy_Meta::get_keyword_usage($focus_keyword, $item->term_id, $item->taxonomy))); }
/** * Pass variables to js for use with the term-scraper * * @return array */ public function localize_term_scraper_script() { $translations = $this->get_scraper_translations(); $term_id = filter_input(INPUT_GET, 'tag_ID'); $term = get_term_by('id', $term_id, $this->get_taxonomy()); $focuskw = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'focuskw'); $taxonomy = get_taxonomy($term->taxonomy); $options = WPSEO_Options::get_all(); $base_url = home_url('/', null); if (!$options['stripcategorybase']) { $base_url = trailingslashit($base_url . $taxonomy->rewrite['slug']); } return array('translations' => $translations, 'base_url' => $base_url, 'taxonomy' => $term->taxonomy, 'keyword_usage' => WPSEO_Taxonomy_Meta::get_keyword_usage($focuskw, $term->term_id, $term->taxonomy), 'search_url' => admin_url('edit-tags.php?taxonomy=' . $term->taxonomy . '&seo_kw_filter={keyword}'), 'post_edit_url' => admin_url('edit-tags.php?action=edit&taxonomy=' . $term->taxonomy . '&tag_ID={id}'), 'title_template' => WPSEO_Taxonomy::get_title_template($term), 'metadesc_template' => WPSEO_Taxonomy::get_metadesc_template($term), 'contentTab' => __('Content:', 'wordpress-seo')); }
/** * Retrieves the keyword for the keyword doubles of the termpages. */ function ajax_get_term_keyword_usage() { $post_id = filter_input(INPUT_POST, 'post_id'); $keyword = filter_input(INPUT_POST, 'keyword'); $taxonomy = filter_input(INPUT_POST, 'taxonomy'); wp_die(WPSEO_Utils::json_encode(WPSEO_Taxonomy_Meta::get_keyword_usage($keyword, $post_id, $taxonomy))); }
/** * Retrieves the keyword for the keyword doubles of the termpages. */ function ajax_get_term_keyword_usage() { $post_id = filter_input(INPUT_POST, 'post_id'); $keyword = filter_input(INPUT_POST, 'keyword'); $taxonomyName = filter_input(INPUT_POST, 'taxonomy'); $taxonomy = get_taxonomy($taxonomyName); if (!$taxonomy) { wp_die(0); } if (!current_user_can($taxonomy->cap->edit_terms)) { wp_die(-1); } $usage = WPSEO_Taxonomy_Meta::get_keyword_usage($keyword, $post_id, $taxonomyName); // Normalize the result so it it the same as the post keyword usage AJAX request. $usage = $usage[$keyword]; wp_die(wp_json_encode($usage)); }
/** * Counting the number of given keyword used for other term than given term_id * * @return array */ private function get_focus_keyword_usage() { $focuskw = WPSEO_Taxonomy_Meta::get_term_meta($this->term, $this->term->taxonomy, 'focuskw'); return WPSEO_Taxonomy_Meta::get_keyword_usage($focuskw, $this->term->term_id, $this->term->taxonomy); }
/** * Retrieves the keyword for the keyword doubles of the termpages. */ function ajax_get_term_keyword_usage() { $post_id = filter_input(INPUT_POST, 'post_id'); $keyword = filter_input(INPUT_POST, 'keyword'); $taxonomy = filter_input(INPUT_POST, 'taxonomy'); if (!current_user_can('edit_terms')) { die('-1'); } $usage = WPSEO_Taxonomy_Meta::get_keyword_usage($keyword, $post_id, $taxonomy); // Normalize the result so it it the same as the post keyword usage AJAX request. $usage = $usage[$keyword]; wp_die(WPSEO_Utils::json_encode($usage)); }