| Server IP : 151.101.66.159 / Your IP : 216.73.216.66 Web Server : Flywheel/5.1.0 System : Linux wordpress 6.12.113+ #1 SMP Thu Oct 22 02:38:20 UTC 2026 x86_64 User : root ( ) PHP Version : 7.4.33.18 Disable Function : disk_free_space,diskfreespace,dl,exec,fpassthru,getmypid,getmyuid,highlight_file,link,opcache_compile_file,opcache_get_configuration,opcache_is_script_cached,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,phpinfo,popen,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,socket_listen,source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wp-content/plugins/wordpress-seo/src/actions/indexing/ |
Upload File : |
<?php
namespace Yoast\WP\SEO\Actions\Indexing;
/**
* Base class of indexing actions.
*/
abstract class Abstract_Indexing_Action implements Indexation_Action_Interface, Limited_Indexing_Action_Interface {
/**
* The transient name.
*
* This is a trick to force derived classes to define a transient themselves.
*
* @var string
*/
public const UNINDEXED_COUNT_TRANSIENT = null;
/**
* The transient cache key for limited counts.
*
* @var string
*/
public const UNINDEXED_LIMITED_COUNT_TRANSIENT = self::UNINDEXED_COUNT_TRANSIENT . '_limited';
/**
* Builds a query for selecting the ID's of unindexed posts.
*
* @param bool $limit The maximum number of post IDs to return.
*
* @return string The prepared query string.
*/
abstract protected function get_select_query( $limit );
/**
* Builds a query for counting the number of unindexed posts.
*
* @return string The prepared query string.
*/
abstract protected function get_count_query();
/**
* Returns a limited number of unindexed posts.
*
* @param int $limit Limit the maximum number of unindexed posts that are counted.
*
* @return int The limited number of unindexed posts. 0 if the query fails.
*/
public function get_limited_unindexed_count( $limit ) {
$transient = \get_transient( static::UNINDEXED_LIMITED_COUNT_TRANSIENT );
if ( $transient !== false ) {
return (int) $transient;
}
\set_transient( static::UNINDEXED_LIMITED_COUNT_TRANSIENT, 0, ( \MINUTE_IN_SECONDS * 15 ) );
$query = $this->get_select_query( $limit );
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Function get_count_query returns a prepared query.
$unindexed_object_ids = ( $query === '' ) ? [] : $this->wpdb->get_col( $query );
$count = (int) \count( $unindexed_object_ids );
\set_transient( static::UNINDEXED_LIMITED_COUNT_TRANSIENT, $count, ( \MINUTE_IN_SECONDS * 15 ) );
return $count;
}
/**
* Returns the total number of unindexed posts.
*
* @return int|false The total number of unindexed posts. False if the query fails.
*/
public function get_total_unindexed() {
$transient = \get_transient( static::UNINDEXED_COUNT_TRANSIENT );
if ( $transient !== false ) {
return (int) $transient;
}
// Store transient before doing the query so multiple requests won't make multiple queries.
// Only store this for 15 minutes to ensure that if the query doesn't complete a wrong count is not kept too long.
\set_transient( static::UNINDEXED_COUNT_TRANSIENT, 0, ( \MINUTE_IN_SECONDS * 15 ) );
$query = $this->get_count_query();
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Function get_count_query returns a prepared query.
$count = ( $query === '' ) ? 0 : $this->wpdb->get_var( $query );
if ( $count === null ) {
return false;
}
\set_transient( static::UNINDEXED_COUNT_TRANSIENT, $count, \DAY_IN_SECONDS );
/**
* Action: 'wpseo_indexables_unindexed_calculated' - sets an option to timestamp when there are no unindexed indexables left.
*
* @internal
*/
\do_action( 'wpseo_indexables_unindexed_calculated', static::UNINDEXED_COUNT_TRANSIENT, $count );
return (int) $count;
}
}