/** * Map the posts to a response array * * @param WP_Post $item The post for which to build the analyzer data. * * @return array */ protected function item_to_response($item) { $focus_keyword = WPSEO_Meta::get_value('focuskw', $item->ID); $content = $item->post_content; /** * Filter the post content for use in the SEO score recalculation. * * @param string $content Content of the post. Modify to reflect front-end content. * @param WP_Post $item The Post object the content comes from. */ $content = apply_filters('wpseo_post_content_for_recalculation', $content, $item); // Apply shortcodes. $content = do_shortcode($content); return array('post_id' => $item->ID, 'text' => $content, 'keyword' => $focus_keyword, 'url' => urldecode($item->post_name), 'pageTitle' => apply_filters('wpseo_title', wpseo_replace_vars($this->get_title($item->ID, $item->post_type), $item)), 'meta' => apply_filters('wpseo_metadesc', wpseo_replace_vars($this->get_meta_description($item->ID, $item->post_type), $item)), 'keyword_usage' => array($focus_keyword => WPSEO_Meta::keyword_usage($focus_keyword, $item->ID))); }
/** * Counting the number of given keyword used for other posts than given post_id * * @return array */ private function get_focus_keyword_usage() { $post = $this->get_metabox_post(); if (is_object($post)) { $keyword = WPSEO_Meta::get_value('focuskw', $post->ID); return array($keyword => WPSEO_Meta::keyword_usage($keyword, $post->ID)); } return array(); }
/** * @param WP_Post $post The post for which to build the analyzer data. * * @return array */ private function post_to_response(WP_Post $post) { $focus_keyword = WPSEO_Meta::get_value('focuskw', $post->ID); return array('post_id' => $post->ID, 'text' => $post->post_content, 'keyword' => $focus_keyword, 'url' => urldecode($post->post_name), 'pageTitle' => apply_filters('wpseo_title', wpseo_replace_vars($this->get_title($post->ID, $post->post_type), $post)), 'meta' => apply_filters('wpseo_metadesc', wpseo_replace_vars($this->get_meta_description($post->ID, $post->post_type), $post)), 'keyword_usage' => array($focus_keyword => WPSEO_Meta::keyword_usage($focus_keyword, $post->ID))); }
/** * Retrieves the keyword for the keyword doubles. */ function ajax_get_keyword_usage() { $post_id = filter_input(INPUT_POST, 'post_id'); $keyword = filter_input(INPUT_POST, 'keyword'); wp_die(WPSEO_Utils::json_encode(WPSEO_Meta::keyword_usage($keyword, $post_id))); }
/** * Retrieves the keyword for the keyword doubles. */ function ajax_get_keyword_usage() { $post_id = filter_input(INPUT_POST, 'post_id'); $keyword = filter_input(INPUT_POST, 'keyword'); if (!current_user_can('edit_post', $post_id)) { die('-1'); } wp_die(wp_json_encode(WPSEO_Meta::keyword_usage($keyword, $post_id))); }
/** * Counting the number of given keyword used for other posts than given post_id * * @return array */ private function get_focus_keyword_usage() { $keyword = WPSEO_Meta::get_value('focuskw', $this->post->ID); return array($keyword => WPSEO_Meta::keyword_usage($keyword, $this->post->ID)); }