Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../src/integrat.../admin
File: indexing-tool-integration.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Admin;
[2] Fix | Delete
[3] Fix | Delete
use WPSEO_Addon_Manager;
[4] Fix | Delete
use WPSEO_Admin_Asset_Manager;
[5] Fix | Delete
use Yoast\WP\SEO\Conditionals\Migrations_Conditional;
[6] Fix | Delete
use Yoast\WP\SEO\Conditionals\No_Tool_Selected_Conditional;
[7] Fix | Delete
use Yoast\WP\SEO\Conditionals\Yoast_Tools_Page_Conditional;
[8] Fix | Delete
use Yoast\WP\SEO\Helpers\Indexable_Helper;
[9] Fix | Delete
use Yoast\WP\SEO\Helpers\Indexing_Helper;
[10] Fix | Delete
use Yoast\WP\SEO\Helpers\Product_Helper;
[11] Fix | Delete
use Yoast\WP\SEO\Helpers\Short_Link_Helper;
[12] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[13] Fix | Delete
use Yoast\WP\SEO\Presenters\Admin\Indexing_Error_Presenter;
[14] Fix | Delete
use Yoast\WP\SEO\Presenters\Admin\Indexing_List_Item_Presenter;
[15] Fix | Delete
use Yoast\WP\SEO\Routes\Importing_Route;
[16] Fix | Delete
use Yoast\WP\SEO\Routes\Indexing_Route;
[17] Fix | Delete
use Yoast\WP\SEO\Services\Importing\Importable_Detector_Service;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Class Indexing_Tool_Integration. Bridge to the Javascript indexing tool on Yoast SEO Tools page.
[21] Fix | Delete
*
[22] Fix | Delete
* @package Yoast\WP\SEO\Integrations\Admin
[23] Fix | Delete
*/
[24] Fix | Delete
class Indexing_Tool_Integration implements Integration_Interface {
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Represents the admin asset manager.
[28] Fix | Delete
*
[29] Fix | Delete
* @var WPSEO_Admin_Asset_Manager
[30] Fix | Delete
*/
[31] Fix | Delete
protected $asset_manager;
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Represents the indexables helper.
[35] Fix | Delete
*
[36] Fix | Delete
* @var Indexable_Helper
[37] Fix | Delete
*/
[38] Fix | Delete
protected $indexable_helper;
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* The short link helper.
[42] Fix | Delete
*
[43] Fix | Delete
* @var Short_Link_Helper
[44] Fix | Delete
*/
[45] Fix | Delete
protected $short_link_helper;
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Represents the indexing helper.
[49] Fix | Delete
*
[50] Fix | Delete
* @var Indexing_Helper
[51] Fix | Delete
*/
[52] Fix | Delete
protected $indexing_helper;
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* The addon manager.
[56] Fix | Delete
*
[57] Fix | Delete
* @var WPSEO_Addon_Manager
[58] Fix | Delete
*/
[59] Fix | Delete
protected $addon_manager;
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* The product helper.
[63] Fix | Delete
*
[64] Fix | Delete
* @var Product_Helper
[65] Fix | Delete
*/
[66] Fix | Delete
protected $product_helper;
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* The Importable Detector service.
[70] Fix | Delete
*
[71] Fix | Delete
* @var Importable_Detector_Service
[72] Fix | Delete
*/
[73] Fix | Delete
protected $importable_detector;
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* The Importing Route class.
[77] Fix | Delete
*
[78] Fix | Delete
* @var Importing_Route
[79] Fix | Delete
*/
[80] Fix | Delete
protected $importing_route;
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Returns the conditionals based on which this integration should be active.
[84] Fix | Delete
*
[85] Fix | Delete
* @return array The array of conditionals.
[86] Fix | Delete
*/
[87] Fix | Delete
public static function get_conditionals() {
[88] Fix | Delete
return [
[89] Fix | Delete
Migrations_Conditional::class,
[90] Fix | Delete
No_Tool_Selected_Conditional::class,
[91] Fix | Delete
Yoast_Tools_Page_Conditional::class,
[92] Fix | Delete
];
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Indexing_Integration constructor.
[97] Fix | Delete
*
[98] Fix | Delete
* @param WPSEO_Admin_Asset_Manager $asset_manager The admin asset manager.
[99] Fix | Delete
* @param Indexable_Helper $indexable_helper The indexable helper.
[100] Fix | Delete
* @param Short_Link_Helper $short_link_helper The short link helper.
[101] Fix | Delete
* @param Indexing_Helper $indexing_helper The indexing helper.
[102] Fix | Delete
* @param WPSEO_Addon_Manager $addon_manager The addon manager.
[103] Fix | Delete
* @param Product_Helper $product_helper The product helper.
[104] Fix | Delete
* @param Importable_Detector_Service $importable_detector The importable detector.
[105] Fix | Delete
* @param Importing_Route $importing_route The importing route.
[106] Fix | Delete
*/
[107] Fix | Delete
public function __construct(
[108] Fix | Delete
WPSEO_Admin_Asset_Manager $asset_manager,
[109] Fix | Delete
Indexable_Helper $indexable_helper,
[110] Fix | Delete
Short_Link_Helper $short_link_helper,
[111] Fix | Delete
Indexing_Helper $indexing_helper,
[112] Fix | Delete
WPSEO_Addon_Manager $addon_manager,
[113] Fix | Delete
Product_Helper $product_helper,
[114] Fix | Delete
Importable_Detector_Service $importable_detector,
[115] Fix | Delete
Importing_Route $importing_route
[116] Fix | Delete
) {
[117] Fix | Delete
$this->asset_manager = $asset_manager;
[118] Fix | Delete
$this->indexable_helper = $indexable_helper;
[119] Fix | Delete
$this->short_link_helper = $short_link_helper;
[120] Fix | Delete
$this->indexing_helper = $indexing_helper;
[121] Fix | Delete
$this->addon_manager = $addon_manager;
[122] Fix | Delete
$this->product_helper = $product_helper;
[123] Fix | Delete
$this->importable_detector = $importable_detector;
[124] Fix | Delete
$this->importing_route = $importing_route;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
/**
[128] Fix | Delete
* Register hooks.
[129] Fix | Delete
*
[130] Fix | Delete
* @return void
[131] Fix | Delete
*/
[132] Fix | Delete
public function register_hooks() {
[133] Fix | Delete
\add_action( 'wpseo_tools_overview_list_items_internal', [ $this, 'render_indexing_list_item' ], 10 );
[134] Fix | Delete
\add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ], 10 );
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Enqueues the required scripts.
[139] Fix | Delete
*
[140] Fix | Delete
* @return void
[141] Fix | Delete
*/
[142] Fix | Delete
public function enqueue_scripts() {
[143] Fix | Delete
$this->asset_manager->enqueue_script( 'indexation' );
[144] Fix | Delete
$this->asset_manager->enqueue_style( 'admin-css' );
[145] Fix | Delete
$this->asset_manager->enqueue_style( 'monorepo' );
[146] Fix | Delete
[147] Fix | Delete
$data = [
[148] Fix | Delete
'disabled' => ! $this->indexable_helper->should_index_indexables(),
[149] Fix | Delete
'amount' => $this->indexing_helper->get_filtered_unindexed_count(),
[150] Fix | Delete
'firstTime' => ( $this->indexing_helper->is_initial_indexing() === true ),
[151] Fix | Delete
'errorMessage' => $this->render_indexing_error(),
[152] Fix | Delete
'restApi' => [
[153] Fix | Delete
'root' => \esc_url_raw( \rest_url() ),
[154] Fix | Delete
'indexing_endpoints' => $this->get_indexing_endpoints(),
[155] Fix | Delete
'importing_endpoints' => $this->get_importing_endpoints(),
[156] Fix | Delete
'nonce' => \wp_create_nonce( 'wp_rest' ),
[157] Fix | Delete
],
[158] Fix | Delete
];
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* Filter: 'wpseo_indexing_data' Filter to adapt the data used in the indexing process.
[162] Fix | Delete
*
[163] Fix | Delete
* @param array $data The indexing data to adapt.
[164] Fix | Delete
*/
[165] Fix | Delete
$data = \apply_filters( 'wpseo_indexing_data', $data );
[166] Fix | Delete
[167] Fix | Delete
$this->asset_manager->localize_script( 'indexation', 'yoastIndexingData', $data );
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
/**
[171] Fix | Delete
* The error to show if optimization failed.
[172] Fix | Delete
*
[173] Fix | Delete
* @return string The error to show if optimization failed.
[174] Fix | Delete
*/
[175] Fix | Delete
protected function render_indexing_error() {
[176] Fix | Delete
$presenter = new Indexing_Error_Presenter(
[177] Fix | Delete
$this->short_link_helper,
[178] Fix | Delete
$this->product_helper,
[179] Fix | Delete
$this->addon_manager
[180] Fix | Delete
);
[181] Fix | Delete
[182] Fix | Delete
return $presenter->present();
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* Determines if the site has a valid Premium subscription.
[187] Fix | Delete
*
[188] Fix | Delete
* @return bool If the site has a valid Premium subscription.
[189] Fix | Delete
*/
[190] Fix | Delete
protected function has_valid_premium_subscription() {
[191] Fix | Delete
return $this->addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG );
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Renders the indexing list item.
[196] Fix | Delete
*
[197] Fix | Delete
* @return void
[198] Fix | Delete
*/
[199] Fix | Delete
public function render_indexing_list_item() {
[200] Fix | Delete
if ( \current_user_can( 'manage_options' ) ) {
[201] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- The output is correctly escaped in the presenter.
[202] Fix | Delete
echo new Indexing_List_Item_Presenter( $this->short_link_helper );
[203] Fix | Delete
}
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
/**
[207] Fix | Delete
* Retrieves a list of the indexing endpoints to use.
[208] Fix | Delete
*
[209] Fix | Delete
* @return array The endpoints.
[210] Fix | Delete
*/
[211] Fix | Delete
protected function get_indexing_endpoints() {
[212] Fix | Delete
$endpoints = [
[213] Fix | Delete
'prepare' => Indexing_Route::FULL_PREPARE_ROUTE,
[214] Fix | Delete
'terms' => Indexing_Route::FULL_TERMS_ROUTE,
[215] Fix | Delete
'posts' => Indexing_Route::FULL_POSTS_ROUTE,
[216] Fix | Delete
'archives' => Indexing_Route::FULL_POST_TYPE_ARCHIVES_ROUTE,
[217] Fix | Delete
'general' => Indexing_Route::FULL_GENERAL_ROUTE,
[218] Fix | Delete
'indexablesComplete' => Indexing_Route::FULL_INDEXABLES_COMPLETE_ROUTE,
[219] Fix | Delete
'post_link' => Indexing_Route::FULL_POST_LINKS_INDEXING_ROUTE,
[220] Fix | Delete
'term_link' => Indexing_Route::FULL_TERM_LINKS_INDEXING_ROUTE,
[221] Fix | Delete
];
[222] Fix | Delete
[223] Fix | Delete
$endpoints = \apply_filters( 'wpseo_indexing_endpoints', $endpoints );
[224] Fix | Delete
[225] Fix | Delete
$endpoints['complete'] = Indexing_Route::FULL_COMPLETE_ROUTE;
[226] Fix | Delete
[227] Fix | Delete
return $endpoints;
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
/**
[231] Fix | Delete
* Retrieves a list of the importing endpoints to use.
[232] Fix | Delete
*
[233] Fix | Delete
* @return array The endpoints.
[234] Fix | Delete
*/
[235] Fix | Delete
protected function get_importing_endpoints() {
[236] Fix | Delete
$available_actions = $this->importable_detector->detect_importers();
[237] Fix | Delete
$importing_endpoints = [];
[238] Fix | Delete
[239] Fix | Delete
foreach ( $available_actions as $plugin => $types ) {
[240] Fix | Delete
foreach ( $types as $type ) {
[241] Fix | Delete
$importing_endpoints[ $plugin ][] = $this->importing_route->get_endpoint( $plugin, $type );
[242] Fix | Delete
}
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
return $importing_endpoints;
[246] Fix | Delete
}
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function