| Server IP : 68.183.124.220 / Your IP : 216.73.216.141 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/wordpress-seo/admin/links/ |
Upload File : |
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Links\Reindex
*/
/**
* Class WPSEO_Link_Reindex_Post_Service.
*/
class WPSEO_Link_Reindex_Post_Service {
/**
* Reindexes the unprocessed posts by REST request.
*
* @return WP_REST_Response The response object.
*/
public function reindex() {
return new WP_REST_Response( $this->process_posts() );
}
/**
* Returns the posts.
*
* @return int The total amount of unprocessed posts.
*/
protected function process_posts() {
if ( ! $this->is_processable() ) {
return 0;
}
$posts = $this->get_unprocessed_posts();
array_walk( $posts, array( $this, 'process_post' ) );
return count( $posts );
}
/**
* Returns all unprocessed posts.
*
* @return array The unprocessed posts.
*/
protected function get_unprocessed_posts() {
$post_types = apply_filters( 'wpseo_link_count_post_types', WPSEO_Post_Type::get_accessible_post_types() );
if ( ! is_array( $post_types ) ) {
return array();
}
return WPSEO_Link_Query::get_unprocessed_posts( $post_types );
}
/**
* Checks if the required tables are accessible.
*
* @return bool True when the tables are accessible.
*/
protected function is_processable() {
return WPSEO_Link_Table_Accessible::is_accessible() && WPSEO_Meta_Table_Accessible::is_accessible();
}
/**
* Processes the post.
*
* @param stdObject $post The post to process.
*
* @return void
*/
protected function process_post( $post ) {
// Some plugins might output data, so let's buffer this to prevent wrong responses.
ob_start();
// Apply the filters to have the same content as shown on the frontend.
$content = apply_filters( 'the_content', $post->post_content );
$content = str_replace( ']]>', ']]>', $content );
ob_end_clean();
$content_processor = $this->get_content_processor();
$content_processor->process( $post->ID, $content );
}
/**
* Returns an instance of the content processor.
*
* @return WPSEO_Link_Content_Processor The instance of the link content processor.
*/
protected function get_content_processor() {
static $content_processor;
if ( $content_processor === null ) {
$content_processor = new WPSEO_Link_Content_Processor( new WPSEO_Link_Storage(), new WPSEO_Meta_Storage() );
}
return $content_processor;
}
}