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/actions/importin...
File: abstract-aioseo-importing-action.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Actions\Importing;
[2] Fix | Delete
[3] Fix | Delete
use Exception;
[4] Fix | Delete
use Yoast\WP\SEO\Helpers\Aioseo_Helper;
[5] Fix | Delete
use Yoast\WP\SEO\Helpers\Import_Cursor_Helper;
[6] Fix | Delete
use Yoast\WP\SEO\Helpers\Options_Helper;
[7] Fix | Delete
use Yoast\WP\SEO\Helpers\Sanitization_Helper;
[8] Fix | Delete
use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Replacevar_Service;
[9] Fix | Delete
use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Provider_Service;
[10] Fix | Delete
use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Transformer_Service;
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Importing action interface.
[14] Fix | Delete
*/
[15] Fix | Delete
abstract class Abstract_Aioseo_Importing_Action implements Importing_Action_Interface {
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* The plugin the class deals with.
[19] Fix | Delete
*
[20] Fix | Delete
* @var string
[21] Fix | Delete
*/
[22] Fix | Delete
public const PLUGIN = null;
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* The type the class deals with.
[26] Fix | Delete
*
[27] Fix | Delete
* @var string
[28] Fix | Delete
*/
[29] Fix | Delete
public const TYPE = null;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* The AIOSEO helper.
[33] Fix | Delete
*
[34] Fix | Delete
* @var Aioseo_Helper
[35] Fix | Delete
*/
[36] Fix | Delete
protected $aioseo_helper;
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* The import cursor helper.
[40] Fix | Delete
*
[41] Fix | Delete
* @var Import_Cursor_Helper
[42] Fix | Delete
*/
[43] Fix | Delete
protected $import_cursor;
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* The options helper.
[47] Fix | Delete
*
[48] Fix | Delete
* @var Options_Helper
[49] Fix | Delete
*/
[50] Fix | Delete
protected $options;
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* The sanitization helper.
[54] Fix | Delete
*
[55] Fix | Delete
* @var Sanitization_Helper
[56] Fix | Delete
*/
[57] Fix | Delete
protected $sanitization;
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* The replacevar handler.
[61] Fix | Delete
*
[62] Fix | Delete
* @var Aioseo_Replacevar_Service
[63] Fix | Delete
*/
[64] Fix | Delete
protected $replacevar_handler;
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* The robots provider service.
[68] Fix | Delete
*
[69] Fix | Delete
* @var Aioseo_Robots_Provider_Service
[70] Fix | Delete
*/
[71] Fix | Delete
protected $robots_provider;
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* The robots transformer service.
[75] Fix | Delete
*
[76] Fix | Delete
* @var Aioseo_Robots_Transformer_Service
[77] Fix | Delete
*/
[78] Fix | Delete
protected $robots_transformer;
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Abstract_Aioseo_Importing_Action constructor.
[82] Fix | Delete
*
[83] Fix | Delete
* @param Import_Cursor_Helper $import_cursor The import cursor helper.
[84] Fix | Delete
* @param Options_Helper $options The options helper.
[85] Fix | Delete
* @param Sanitization_Helper $sanitization The sanitization helper.
[86] Fix | Delete
* @param Aioseo_Replacevar_Service $replacevar_handler The replacevar handler.
[87] Fix | Delete
* @param Aioseo_Robots_Provider_Service $robots_provider The robots provider service.
[88] Fix | Delete
* @param Aioseo_Robots_Transformer_Service $robots_transformer The robots transfomer service.
[89] Fix | Delete
*/
[90] Fix | Delete
public function __construct(
[91] Fix | Delete
Import_Cursor_Helper $import_cursor,
[92] Fix | Delete
Options_Helper $options,
[93] Fix | Delete
Sanitization_Helper $sanitization,
[94] Fix | Delete
Aioseo_Replacevar_Service $replacevar_handler,
[95] Fix | Delete
Aioseo_Robots_Provider_Service $robots_provider,
[96] Fix | Delete
Aioseo_Robots_Transformer_Service $robots_transformer
[97] Fix | Delete
) {
[98] Fix | Delete
$this->import_cursor = $import_cursor;
[99] Fix | Delete
$this->options = $options;
[100] Fix | Delete
$this->sanitization = $sanitization;
[101] Fix | Delete
$this->replacevar_handler = $replacevar_handler;
[102] Fix | Delete
$this->robots_provider = $robots_provider;
[103] Fix | Delete
$this->robots_transformer = $robots_transformer;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* Sets the AIOSEO helper.
[108] Fix | Delete
*
[109] Fix | Delete
* @required
[110] Fix | Delete
*
[111] Fix | Delete
* @param Aioseo_Helper $aioseo_helper The AIOSEO helper.
[112] Fix | Delete
*
[113] Fix | Delete
* @return void
[114] Fix | Delete
*/
[115] Fix | Delete
public function set_aioseo_helper( Aioseo_Helper $aioseo_helper ) {
[116] Fix | Delete
$this->aioseo_helper = $aioseo_helper;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* The name of the plugin we import from.
[121] Fix | Delete
*
[122] Fix | Delete
* @return string The plugin we import from.
[123] Fix | Delete
*
[124] Fix | Delete
* @throws Exception If the PLUGIN constant is not set in the child class.
[125] Fix | Delete
*/
[126] Fix | Delete
public function get_plugin() {
[127] Fix | Delete
$class = static::class;
[128] Fix | Delete
$plugin = $class::PLUGIN;
[129] Fix | Delete
[130] Fix | Delete
if ( $plugin === null ) {
[131] Fix | Delete
throw new Exception( 'Importing action without explicit plugin' );
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
return $plugin;
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* The data type we import from the plugin.
[139] Fix | Delete
*
[140] Fix | Delete
* @return string The data type we import from the plugin.
[141] Fix | Delete
*
[142] Fix | Delete
* @throws Exception If the TYPE constant is not set in the child class.
[143] Fix | Delete
*/
[144] Fix | Delete
public function get_type() {
[145] Fix | Delete
$class = static::class;
[146] Fix | Delete
$type = $class::TYPE;
[147] Fix | Delete
[148] Fix | Delete
if ( $type === null ) {
[149] Fix | Delete
throw new Exception( 'Importing action without explicit type' );
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
return $type;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
/**
[156] Fix | Delete
* Can the current action import the data from plugin $plugin of type $type?
[157] Fix | Delete
*
[158] Fix | Delete
* @param string|null $plugin The plugin to import from.
[159] Fix | Delete
* @param string|null $type The type of data to import.
[160] Fix | Delete
*
[161] Fix | Delete
* @return bool True if this action can handle the combination of Plugin and Type.
[162] Fix | Delete
*
[163] Fix | Delete
* @throws Exception If the TYPE constant is not set in the child class.
[164] Fix | Delete
*/
[165] Fix | Delete
public function is_compatible_with( $plugin = null, $type = null ) {
[166] Fix | Delete
if ( empty( $plugin ) && empty( $type ) ) {
[167] Fix | Delete
return true;
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
if ( $plugin === $this->get_plugin() && empty( $type ) ) {
[171] Fix | Delete
return true;
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
if ( empty( $plugin ) && $type === $this->get_type() ) {
[175] Fix | Delete
return true;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
if ( $plugin === $this->get_plugin() && $type === $this->get_type() ) {
[179] Fix | Delete
return true;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
return false;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* Gets the completed id (to be used as a key for the importing_completed option).
[187] Fix | Delete
*
[188] Fix | Delete
* @return string The completed id.
[189] Fix | Delete
*/
[190] Fix | Delete
public function get_completed_id() {
[191] Fix | Delete
return $this->get_cursor_id();
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Returns the stored state of completedness.
[196] Fix | Delete
*
[197] Fix | Delete
* @return int The stored state of completedness.
[198] Fix | Delete
*/
[199] Fix | Delete
public function get_completed() {
[200] Fix | Delete
$completed_id = $this->get_completed_id();
[201] Fix | Delete
$importers_completions = $this->options->get( 'importing_completed', [] );
[202] Fix | Delete
[203] Fix | Delete
return ( isset( $importers_completions[ $completed_id ] ) ) ? $importers_completions[ $completed_id ] : false;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
/**
[207] Fix | Delete
* Stores the current state of completedness.
[208] Fix | Delete
*
[209] Fix | Delete
* @param bool $completed Whether the importer is completed.
[210] Fix | Delete
*
[211] Fix | Delete
* @return void
[212] Fix | Delete
*/
[213] Fix | Delete
public function set_completed( $completed ) {
[214] Fix | Delete
$completed_id = $this->get_completed_id();
[215] Fix | Delete
$current_importers_completions = $this->options->get( 'importing_completed', [] );
[216] Fix | Delete
[217] Fix | Delete
$current_importers_completions[ $completed_id ] = $completed;
[218] Fix | Delete
$this->options->set( 'importing_completed', $current_importers_completions );
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
/**
[222] Fix | Delete
* Returns whether the importing action is enabled.
[223] Fix | Delete
*
[224] Fix | Delete
* @return bool True by default unless a child class overrides it.
[225] Fix | Delete
*/
[226] Fix | Delete
public function is_enabled() {
[227] Fix | Delete
return true;
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
/**
[231] Fix | Delete
* Gets the cursor id.
[232] Fix | Delete
*
[233] Fix | Delete
* @return string The cursor id.
[234] Fix | Delete
*/
[235] Fix | Delete
protected function get_cursor_id() {
[236] Fix | Delete
return $this->get_plugin() . '_' . $this->get_type();
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Minimally transforms data to be imported.
[241] Fix | Delete
*
[242] Fix | Delete
* @param string $meta_data The meta data to be imported.
[243] Fix | Delete
*
[244] Fix | Delete
* @return string The transformed meta data.
[245] Fix | Delete
*/
[246] Fix | Delete
public function simple_import( $meta_data ) {
[247] Fix | Delete
// Transform the replace vars into Yoast replace vars.
[248] Fix | Delete
$transformed_data = $this->replacevar_handler->transform( $meta_data );
[249] Fix | Delete
[250] Fix | Delete
return $this->sanitization->sanitize_text_field( \html_entity_decode( $transformed_data ) );
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
/**
[254] Fix | Delete
* Transforms URL to be imported.
[255] Fix | Delete
*
[256] Fix | Delete
* @param string $meta_data The meta data to be imported.
[257] Fix | Delete
*
[258] Fix | Delete
* @return string The transformed URL.
[259] Fix | Delete
*/
[260] Fix | Delete
public function url_import( $meta_data ) {
[261] Fix | Delete
// We put null as the allowed protocols here, to have the WP default allowed protocols, see https://developer.wordpress.org/reference/functions/wp_allowed_protocols.
[262] Fix | Delete
return $this->sanitization->sanitize_url( $meta_data, null );
[263] Fix | Delete
}
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function