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.../inc
File: class-upgrade-history.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Internal
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* This class handles storing the current options for future reference.
[8] Fix | Delete
*
[9] Fix | Delete
* This should only be used during an upgrade routine.
[10] Fix | Delete
*/
[11] Fix | Delete
class WPSEO_Upgrade_History {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Option to use to store/retrieve data from.
[15] Fix | Delete
*
[16] Fix | Delete
* @var string
[17] Fix | Delete
*/
[18] Fix | Delete
protected $option_name = 'wpseo_upgrade_history';
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* WPSEO_Upgrade_History constructor.
[22] Fix | Delete
*
[23] Fix | Delete
* @param string|null $option_name Optional. Custom option to use to store/retrieve history from.
[24] Fix | Delete
*/
[25] Fix | Delete
public function __construct( $option_name = null ) {
[26] Fix | Delete
if ( $option_name !== null ) {
[27] Fix | Delete
$this->option_name = $option_name;
[28] Fix | Delete
}
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Retrieves the content of the history items currently stored.
[33] Fix | Delete
*
[34] Fix | Delete
* @return array<array<string>> The contents of the history option.
[35] Fix | Delete
*/
[36] Fix | Delete
public function get() {
[37] Fix | Delete
$data = get_option( $this->get_option_name(), [] );
[38] Fix | Delete
if ( ! is_array( $data ) ) {
[39] Fix | Delete
return [];
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
return $data;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Adds a new history entry in the storage.
[47] Fix | Delete
*
[48] Fix | Delete
* @param string $old_version The version we are upgrading from.
[49] Fix | Delete
* @param string $new_version The version we are upgrading to.
[50] Fix | Delete
* @param array<string> $option_names The options that need to be stored.
[51] Fix | Delete
*
[52] Fix | Delete
* @return void
[53] Fix | Delete
*/
[54] Fix | Delete
public function add( $old_version, $new_version, array $option_names ) {
[55] Fix | Delete
$option_data = [];
[56] Fix | Delete
if ( $option_names !== [] ) {
[57] Fix | Delete
$option_data = $this->get_options_data( $option_names );
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
// Retrieve current history.
[61] Fix | Delete
$data = $this->get();
[62] Fix | Delete
[63] Fix | Delete
// Add new entry.
[64] Fix | Delete
$data[ time() ] = [
[65] Fix | Delete
'options' => $option_data,
[66] Fix | Delete
'old_version' => $old_version,
[67] Fix | Delete
'new_version' => $new_version,
[68] Fix | Delete
];
[69] Fix | Delete
[70] Fix | Delete
// Store the data.
[71] Fix | Delete
$this->set( $data );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Retrieves the data for the specified option names from the database.
[76] Fix | Delete
*
[77] Fix | Delete
* @param array<string> $option_names The option names to retrieve.
[78] Fix | Delete
*
[79] Fix | Delete
* @return array<int|string|bool|float,array<string|int|bool|float>> The retrieved data.
[80] Fix | Delete
*/
[81] Fix | Delete
protected function get_options_data( array $option_names ) {
[82] Fix | Delete
$wpdb = $this->get_wpdb();
[83] Fix | Delete
[84] Fix | Delete
$results = $wpdb->get_results(
[85] Fix | Delete
$wpdb->prepare(
[86] Fix | Delete
'
[87] Fix | Delete
SELECT %i, %i FROM ' . $wpdb->options . ' WHERE
[88] Fix | Delete
%i IN ( ' . implode( ',', array_fill( 0, count( $option_names ), '%s' ) ) . ' )
[89] Fix | Delete
',
[90] Fix | Delete
array_merge( [ 'option_value', 'option_name', 'option_name' ], $option_names )
[91] Fix | Delete
),
[92] Fix | Delete
ARRAY_A
[93] Fix | Delete
);
[94] Fix | Delete
[95] Fix | Delete
$data = [];
[96] Fix | Delete
foreach ( $results as $result ) {
[97] Fix | Delete
$data[ $result['option_name'] ] = maybe_unserialize( $result['option_value'] );
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
return $data;
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Stores the new history state.
[105] Fix | Delete
*
[106] Fix | Delete
* @param array<array<string>> $data The data to store.
[107] Fix | Delete
*
[108] Fix | Delete
* @return void
[109] Fix | Delete
*/
[110] Fix | Delete
protected function set( array $data ) {
[111] Fix | Delete
// This should not be autoloaded!
[112] Fix | Delete
update_option( $this->get_option_name(), $data, false );
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Retrieves the WPDB object.
[117] Fix | Delete
*
[118] Fix | Delete
* @return wpdb The WPDB object to use.
[119] Fix | Delete
*/
[120] Fix | Delete
protected function get_wpdb() {
[121] Fix | Delete
global $wpdb;
[122] Fix | Delete
[123] Fix | Delete
return $wpdb;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Retrieves the option name to store the history in.
[128] Fix | Delete
*
[129] Fix | Delete
* @return string The option name to store the history in.
[130] Fix | Delete
*/
[131] Fix | Delete
protected function get_option_name() {
[132] Fix | Delete
return $this->option_name;
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function