_new_content_type_notification', true ); $this->maybe_add_notification(); } /** * Update db when a post type is made removed. * * @param array $newly_made_non_public_taxonomies The newly made non public post types. * @return void */ public function clean_new_public_taxonomy( $newly_made_non_public_taxonomies ) { // See if post types that needs review were removed and update option. $needs_review = $this->options->get( 'new_taxonomies', [] ); $new_needs_review = \array_diff( $needs_review, $newly_made_non_public_taxonomies ); if ( \count( $new_needs_review ) !== \count( $needs_review ) ) { $this->options->set( 'new_taxonomies', $new_needs_review ); $this->content_type_dismiss_notifications->maybe_dismiss_notifications( [ 'new_taxonomies' => $new_needs_review ] ); } } /** * Decides if a notification should be added in the notification center. * * @return void */ public function maybe_add_notification() { $notification = $this->notification_center->get_notification_by_id( 'content-types-made-public' ); if ( $notification === null ) { $this->add_notification(); } } /** * Adds a notification to be shown on the next page request since posts are updated in an ajax request. * * @return void */ private function add_notification() { $message = \sprintf( /* translators: 1: Opening tag of the link to the Search appearance settings page, 2: Link closing tag. */ \esc_html__( 'You\'ve added a new type of content. We recommend that you review the corresponding %1$sSearch appearance settings%2$s.', 'wordpress-seo' ), '', '' ); $notification = new Yoast_Notification( $message, [ 'type' => Yoast_Notification::WARNING, 'id' => 'content-types-made-public', 'capabilities' => 'wpseo_manage_options', 'priority' => 0.8, ] ); $this->notification_center->add_notification( $notification ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } by using our improved %1$s First-time configuration%2$s.', 'wordpress-seo' ), '', '' ); } $notice = new Notice_Presenter( $title, $content, 'mirrored_fit_bubble_woman_1_optim.svg', null, true, 'yoast-first-time-configuration-notice' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output from present() is considered safe. echo $notice->present(); // Enable permanently dismissing the notice. echo ''; } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } } ndexing process by setting several database options and removing the indexing notification. * * @return void */ public function prepare() { $this->set_first_time( false ); $this->set_started( $this->date_helper->current_time() ); $this->remove_indexing_notification(); // Do not set_reason here; if the process is cancelled, the reason to start indexing is still valid. } /** * Sets several database options when the indexing process is finished. * * @return void */ public function complete() { $this->set_reason( '' ); $this->set_started( null ); } /** * Sets appropriate flags when the indexing process fails. * * @return void */ public function indexing_failed() { $this->set_reason( Indexing_Reasons::REASON_INDEXING_FAILED ); $this->set_started( null ); } /** * Sets the indexing reason. * * @param string $reason The indexing reason. * * @return void */ public function set_reason( $reason ) { $this->options_helper->set( 'indexing_reason', $reason ); $this->remove_indexing_notification(); } /** * Removes any pre-existing notification, so that a new notification (with a possible new reason) can be added. * * @return void */ protected function remove_indexing_notification() { $this->notification_center->remove_notification_by_id( Indexing_Notification_Integration::NOTIFICATION_ID ); } /** * Determines whether an indexing reason has been set in the options. * * @return bool Whether an indexing reason has been set in the options. */ public function has_reason() { $reason = $this->get_reason(); return ! empty( $reason ); } /** * Returns the indexing reason. The reason why the site-wide indexing process should be run. * * @return string The indexing reason, defaults to the empty string if no reason has been set. */ public function get_reason() { return $this->options_helper->get( 'indexing_reason', '' ); } /** * Sets the start time when the indexing process has started but not completed. * * @param int|bool $timestamp The start time when the indexing process has started but not completed, false otherwise. * * @return void */ public function set_started( $timestamp ) { $this->options_helper->set( 'indexing_started', $timestamp ); } /** * Gets the start time when the indexing process has started but not completed. * * @return int|bool The start time when the indexing process has started but not completed, false otherwise. */ public function get_started() { return $this->options_helper->get( 'indexing_started' ); } /** * Sets a boolean that indicates whether or not a site still has to be indexed for the first time. * * @param bool $is_first_time_indexing Whether or not a site still has to be indexed for the first time. * * @return void */ public function set_first_time( $is_first_time_indexing ) { $this->options_helper->set( 'indexing_first_time', $is_first_time_indexing ); } /** * Gets a boolean that indicates whether or not the site still has to be indexed for the first time. * * @return bool Whether the site still has to be indexed for the first time. */ public function is_initial_indexing() { return $this->options_helper->get( 'indexing_first_time', true ); } /** * Gets a boolean that indicates whether or not the indexing of the indexables has completed. * * @return bool Whether the indexing of the indexables has completed. */ public function is_finished_indexables_indexing() { return $this->options_helper->get( 'indexables_indexing_completed', false ); } /** * Returns the total number of unindexed objects. * * @return int The total number of unindexed objects. */ public function get_unindexed_count() { $unindexed_count = 0; foreach ( $this->indexing_actions as $indexing_action ) { $unindexed_count += $indexing_action->get_total_unindexed(); } return $unindexed_count; } /** * Returns the amount of un-indexed posts expressed in percentage, which will be needed to set a threshold. * * @param int $unindexed_count The number of unindexed objects. * * @return int The amount of unindexed posts expressed in percentage. */ public function get_unindexed_percentage( $unindexed_count ) { // Gets the amount of indexed objects in the site. $indexed_count = $this->indexable_repository->get_total_number_of_indexables(); // The total amount of objects in the site. $total_objects_count = ( $indexed_count + $unindexed_count ); return ( ( $unindexed_count / $total_objects_count ) * 100 ); } /** * Returns whether the SEO optimization button should show. * * @return bool Whether the SEO optimization button should show. */ public function should_show_optimization_button() { // Gets the amount of unindexed objects in the site. $unindexed_count = $this->get_filtered_unindexed_count(); // If the amount of unidexed posts is <10 don't show configuration button. if ( $unindexed_count <= 10 ) { return false; } // If the amount of unidexed posts is >10, but the total amount of unidexed posts is ≤4% of the total amount of objects in the site, don't show configuration button. if ( $this->get_unindexed_percentage( $unindexed_count ) <= 4 ) { return false; } return true; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @return int The total number of unindexed objects. */ public function get_filtered_unindexed_count() { $unindexed_count = $this->get_unindexed_count(); /** * Filter: 'wpseo_indexing_get_unindexed_count' - Allow changing the amount of unindexed objects. * * @param int $unindexed_count The amount of unindexed objects. */ return \apply_filters( 'wpseo_indexing_get_unindexed_count', $unindexed_count ); } /** * Returns a limited number of unindexed objects. * * @param int $limit Limit the number of unindexed objects that are counted. * @param Indexation_Action_Interface[]|Limited_Indexing_Action_Interface[] $actions The actions whose counts will be calculated. * * @return int The total number of unindexed objects. */ public function get_limited_unindexed_count( $limit, $actions = [] ) { $unindexed_count = 0; if ( empty( $actions ) ) { $actions = $this->indexing_actions; } foreach ( $actions as $action ) { $unindexed_count += $action->get_limited_unindexed_count( $limit - $unindexed_count + 1 ); if ( $unindexed_count > $limit ) { return $unindexed_count; } } return $unindexed_count; } /** * Returns the total number of unindexed objects and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects. */ public function get_limited_filtered_unindexed_count( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count' - Allow changing the amount of unindexed objects, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count', $unindexed_count, $limit ); } /** * Returns the total number of unindexed objects that can be indexed in the background and applies a filter for third party integrations. * * @param int $limit Limit the number of unindexed objects that are counted. * * @return int The total number of unindexed objects that can be indexed in the background. */ public function get_limited_filtered_unindexed_count_background( $limit ) { $unindexed_count = $this->get_limited_unindexed_count( $limit, $this->background_indexing_actions ); if ( $unindexed_count > $limit ) { return $unindexed_count; } /** * Filter: 'wpseo_indexing_get_limited_unindexed_count_background' - Allow changing the amount of unindexed objects that can be indexed in the background, * and allow for a maximum number of items counted to improve performance. * * @param int $unindexed_count The amount of unindexed objects. * @param int|false $limit Limit the number of unindexed objects that need to be counted. * False if it doesn't need to be limited. */ return \apply_filters( 'wpseo_indexing_get_limited_unindexed_count_background', $unindexed_count, $limit ); } }
Fatal error: Uncaught Error: Class "Yoast\WP\SEO\Helpers\Indexing_Helper" not found in /htdocs/wp-content/plugins/wordpress-seo/src/generated/container.php:3713 Stack trace: #0 /htdocs/wp-content/plugins/wordpress-seo/src/generated/container.php(3683): Yoast\WP\SEO\Generated\Cached_Container->getIndexingHelperService() #1 /htdocs/wp-content/plugins/wordpress-seo/src/generated/container.php(2042): Yoast\WP\SEO\Generated\Cached_Container->getIndexableHelperService() #2 /htdocs/wp-content/plugins/wordpress-seo/src/generated/container.php(1987): Yoast\WP\SEO\Generated\Cached_Container->getIndexableHierarchyBuilderService() #3 /htdocs/wp-content/plugins/wordpress-seo/src/generated/container.php(5816): Yoast\WP\SEO\Generated\Cached_Container->getIndexableBuilderService() #4 /htdocs/wp-content/plugins/wordpress-seo/vendor_prefixed/symfony/dependency-injection/Container.php(271): Yoast\WP\SEO\Generated\Cached_Container->getIndexableRepositoryService() #5 /htdocs/wp-content/plugins/wordpress-seo/src/surfaces/classes-surface.php(38): YoastSEO_Vendor\Symfony\Component\DependencyInjection\Container->get('Yoast\\WP\\SEO\\Re...') #6 /htdocs/wp-content/plugins/wordpress-seo/inc/class-wpseo-admin-bar-menu.php(133): Yoast\WP\SEO\Surfaces\Classes_Surface->get('Yoast\\WP\\SEO\\Re...') #7 /htdocs/wp-content/plugins/wordpress-seo/inc/wpseo-non-ajax-functions.php(20): WPSEO_Admin_Bar_Menu->__construct() #8 /htdocs/wp-includes/class-wp-hook.php(324): wpseo_initialize_admin_bar('') #9 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #10 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #11 /htdocs/wp-settings.php(749): do_action('wp_loaded') #12 /htdocs/wp-config.php(101): require_once('/htdocs/wp-sett...') #13 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #14 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #15 /htdocs/index.php(17): require('/htdocs/wp-blog...') #16 {main} thrown in /htdocs/wp-content/plugins/wordpress-seo/src/generated/container.php on line 3713