';
}
/**
* Generates the model box.
*
* @return void
*/
public function modal_box() {
if ( ! $this->is_dashboard_page() ) {
return;
}
// Adding the thickbox.
add_thickbox();
$blocks = array();
if ( ! $this->has_unprocessed() ) {
$inner_text = sprintf( '
%s
',
esc_html__( 'All your texts are already counted, there is no need to count them again.', 'wordpress-seo' )
);
}
if ( $this->has_unprocessed() ) {
$progress = sprintf(
/* translators: 1: expands to a containing the number of items recalculated. 2: expands to a containing the total number of items. */
__( 'Text %1$s of %2$s processed.', 'wordpress-seo' ),
'0',
sprintf( '%d', $this->get_unprocessed_count() )
);
$inner_text = '';
$inner_text .= sprintf( '
%s
', $progress );
}
$blocks[] = sprintf( '
%s
%s
',
esc_html__( 'Counting links in your texts', 'wordpress-seo' ),
$inner_text
);
?>
', $blocks ); ?>
enqueue_script( 'reindex-links' );
$data = array(
'amount' => $this->get_unprocessed_count(),
'restApi' => array(
'root' => esc_url_raw( rest_url() ),
'endpoint' => WPSEO_Link_Reindex_Post_Endpoint::REST_NAMESPACE . '/' . WPSEO_Link_Reindex_Post_Endpoint::ENDPOINT_QUERY,
'nonce' => wp_create_nonce( 'wp_rest' ),
),
'message' => array(
'indexingCompleted' => $this->message_already_indexed(),
),
'l10n' => array(
'calculationInProgress' => __( 'Calculation in progress...', 'wordpress-seo' ),
'calculationCompleted' => __( 'Calculation completed.', 'wordpress-seo' ),
),
);
wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'reindex-links', 'yoastReindexLinksData', array( 'data' => $data ) );
}
/**
* Checks if the current page is the dashboard page.
*
* @return bool True when current page is the dashboard page.
*/
protected function is_dashboard_page() {
return ( filter_input( INPUT_GET, 'page' ) === 'wpseo_tools' );
}
/**
* Retrieves the string to display when everything has been indexed.
*
* @return string The message to show when everything has been indexed.
*/
public function message_already_indexed() {
return '' . esc_html__( 'Good job! All the links in your texts have been counted.', 'wordpress-seo' );
}
/**
* Returns if there are unprocessed items
*
* @return bool True if there are unprocessed items.
*/
public function has_unprocessed() {
return $this->unprocessed > 0;
}
/**
* Returns the number of unprocessed items.
*
* @return int Number of unprocessed items.
*/
public function get_unprocessed_count() {
return $this->unprocessed;
}
/**
* Retrieves the message to show starting indexation.
*
* @return string The message.
*/
public function message_start_indexing() {
return sprintf(
'%2$s',
175,
esc_attr__( 'Count links in your texts', 'wordpress-seo' )
);
}
/* ********************* DEPRECATED METHODS ********************* */
/**
* Add the indexing interface for links to the dashboard.
*
* @deprecated 7.0
* @codeCoverageIgnore
*
* @return void
*/
public function add_link_index_interface() {
_deprecated_function( __METHOD__, 'WPSEO 7.0' );
$html = '';
$html .= '
' . esc_html__( 'Text link counter', 'wordpress-seo' ) . '
';
$html .= '
' . sprintf(
/* translators: 1: link to yoast.com post about internal linking suggestion. 4: is Yoast.com 3: is anchor closing. */
__( 'The links in all your public texts need to be counted. This will provide insights of which texts need more links to them. If you want to know more about the why and how of internal linking, check out %1$sthe article about internal linking on %2$s%3$s.', 'wordpress-seo' ),
'',
'Yoast.com',
''
) . '