Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/core/componen...
File: Updates.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if ( ! class_exists( 'ET_Core_Updates' ) ):
[2] Fix | Delete
/**
[3] Fix | Delete
* Handles the updates workflow.
[4] Fix | Delete
*
[5] Fix | Delete
* @private
[6] Fix | Delete
*
[7] Fix | Delete
* @package ET\Core\Updates
[8] Fix | Delete
*/
[9] Fix | Delete
final class ET_Core_Updates {
[10] Fix | Delete
protected $core_url;
[11] Fix | Delete
protected $options;
[12] Fix | Delete
protected $account_status;
[13] Fix | Delete
protected $product_version;
[14] Fix | Delete
protected $all_et_products_domains;
[15] Fix | Delete
protected $upgrading_et_product;
[16] Fix | Delete
protected $up_to_date_products_data;
[17] Fix | Delete
[18] Fix | Delete
// class version
[19] Fix | Delete
protected $version;
[20] Fix | Delete
[21] Fix | Delete
private static $_this;
[22] Fix | Delete
[23] Fix | Delete
function __construct( $core_url, $product_version ) {
[24] Fix | Delete
// Don't allow more than one instance of the class
[25] Fix | Delete
if ( isset( self::$_this ) ) {
[26] Fix | Delete
wp_die( sprintf( esc_html__( '%s: You cannot create a second instance of this class.', 'et-core' ),
[27] Fix | Delete
esc_html( get_class( $this ) )
[28] Fix | Delete
) );
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
self::$_this = $this;
[32] Fix | Delete
[33] Fix | Delete
$this->core_url = $core_url;
[34] Fix | Delete
$this->version = '1.2';
[35] Fix | Delete
[36] Fix | Delete
$this->up_to_date_products_data = array();
[37] Fix | Delete
[38] Fix | Delete
$this->product_version = $product_version;
[39] Fix | Delete
[40] Fix | Delete
$this->get_options();
[41] Fix | Delete
[42] Fix | Delete
$this->upgrading_et_product = false;
[43] Fix | Delete
[44] Fix | Delete
$this->update_product_domains();
[45] Fix | Delete
[46] Fix | Delete
$this->maybe_force_update_requests();
[47] Fix | Delete
[48] Fix | Delete
add_filter( 'wp_prepare_themes_for_js', array( $this, 'replace_theme_update_notification' ) );
[49] Fix | Delete
add_filter( 'upgrader_package_options', array( $this, 'check_upgrading_product' ) );
[50] Fix | Delete
add_filter( 'upgrader_pre_download', array( $this, 'update_error_message' ), 20, 2 );
[51] Fix | Delete
[52] Fix | Delete
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_plugins_updates' ) );
[53] Fix | Delete
add_filter( 'plugins_api', array( $this, 'maybe_modify_plugins_changelog' ), 20, 3 );
[54] Fix | Delete
[55] Fix | Delete
add_filter( 'pre_set_site_transient_update_themes', array( $this, 'check_themes_updates' ) );
[56] Fix | Delete
[57] Fix | Delete
add_filter( 'self_admin_url', array( $this, 'change_plugin_changelog_url' ), 10, 2 );
[58] Fix | Delete
add_filter( 'admin_url', array( $this, 'change_plugin_changelog_url' ), 10, 2 );
[59] Fix | Delete
add_filter( 'network_admin_url', array( $this, 'change_plugin_changelog_url' ), 10, 2 );
[60] Fix | Delete
[61] Fix | Delete
add_action( 'admin_notices', array( $this, 'maybe_show_account_notice' ) );
[62] Fix | Delete
[63] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts_styles' ) );
[64] Fix | Delete
[65] Fix | Delete
add_action( 'plugins_loaded', array( $this, 'remove_updater_plugin_actions' ), 30 );
[66] Fix | Delete
[67] Fix | Delete
add_action( 'after_setup_theme', array( $this, 'remove_theme_update_actions' ), 11 );
[68] Fix | Delete
[69] Fix | Delete
add_action( 'admin_init', array( $this, 'remove_plugin_update_actions' ) );
[70] Fix | Delete
[71] Fix | Delete
add_action( 'update_site_option_et_automatic_updates_options', array( $this, 'force_update_requests' ) );
[72] Fix | Delete
add_action( 'update_option_et_automatic_updates_options', array( $this, 'force_update_requests' ) );
[73] Fix | Delete
[74] Fix | Delete
add_action( 'deleted_site_transient', array( $this, 'maybe_reset_et_products_update_transient' ) );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
function check_upgrading_product( $options ) {
[78] Fix | Delete
if ( ! isset( $options['hook_extra'] ) ) {
[79] Fix | Delete
return $options;
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
$hook_name = isset( $options['hook_extra']['plugin'] ) ? 'plugin' : 'theme';
[83] Fix | Delete
[84] Fix | Delete
// set the upgrading_et_product flag if one of ET plugins or themes is about to upgrade
[85] Fix | Delete
if ( isset( $options['hook_extra'][ $hook_name ] ) && in_array( $options['hook_extra'][ $hook_name ], $this->all_et_products_domains[ $hook_name ] ) ) {
[86] Fix | Delete
$this->upgrading_et_product = true;
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
return $options;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
function maybe_append_custom_notification( $plugin_data, $response ) {
[93] Fix | Delete
if ( empty( $response ) ) {
[94] Fix | Delete
$package_available = false;
[95] Fix | Delete
} else {
[96] Fix | Delete
// for themes response is array for plugins - object, so check the format of data to get the correct results
[97] Fix | Delete
$package_available = is_array( $response ) ? ! empty( $response['package'] ) : ! empty( $response->package );
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
if ( $package_available ) {
[101] Fix | Delete
return;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
$message = et_get_safe_localization( __( 'For all Elegant Themes products, please <a href="http://www.elegantthemes.com/gallery/divi/documentation/update/" target="_blank">authenticate your subscription</a> via the Updates tab in your theme & plugin settings to enable product updates. Make sure that your Username and API Key have been entered correctly.', 'et-core' ) );
[105] Fix | Delete
echo "</p><p>{$message}";
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Check if we need to force update options removal in case a customer clicked on "Check Again" button
[110] Fix | Delete
* in the notification area.
[111] Fix | Delete
*/
[112] Fix | Delete
function maybe_force_update_requests() {
[113] Fix | Delete
if ( wp_doing_ajax() ) {
[114] Fix | Delete
return;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
if ( empty( $_GET['et_action'] ) || 'update_account_details' !== $_GET['et_action'] ) {
[118] Fix | Delete
return;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
if ( empty( $_GET['et_update_account_details_nonce'] ) || ! wp_verify_nonce( $_GET['et_update_account_details_nonce'], 'et_update_account_details' )
[122] Fix | Delete
) {
[123] Fix | Delete
return;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
$this->force_update_requests();
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
function replace_theme_update_notification( $themes_array ) {
[130] Fix | Delete
if ( empty( $themes_array ) ) {
[131] Fix | Delete
return $themes_array;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
if ( empty( $this->all_et_products_domains['theme'] ) ) {
[135] Fix | Delete
return $themes_array;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
foreach ( $themes_array as $id => $theme_data ) {
[139] Fix | Delete
// replace default error message with custom message for ET themes.
[140] Fix | Delete
if (
[141] Fix | Delete
in_array( $id, $this->all_et_products_domains['theme'] )
[142] Fix | Delete
&& false !== strpos( $theme_data['update'], 'Automatic update is unavailable for this theme' )
[143] Fix | Delete
) {
[144] Fix | Delete
$themes_array[ $id ]['update'] = sprintf(
[145] Fix | Delete
'<p>%1$s<br/> %2$s</p>',
[146] Fix | Delete
$theme_data['update'],
[147] Fix | Delete
et_get_safe_localization( __( '<em>Before you can receive product updates, you must first authenticate your Elegant Themes subscription. To do this, you need to enter both your Elegant Themes Username and your Elegant Themes API Key into the Updates Tab in your theme and plugin settings. To locate your API Key, <a href="https://www.elegantthemes.com/members-area/api/" target="_blank">log in</a> to your Elegant Themes account and navigate to the <strong>Account > API Key</strong> page. <a href="http://www.elegantthemes.com/gallery/divi/documentation/update/" target="_blank">Learn more here</a></em>. If you still get this message, please make sure that your Username and API Key have been entered correctly', 'et-core' ) )
[148] Fix | Delete
);
[149] Fix | Delete
}
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
return $themes_array;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
function update_error_message( $reply, $package ) {
[156] Fix | Delete
if ( ! $this->upgrading_et_product ) {
[157] Fix | Delete
return $reply;
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
// reset the upgrading_et_product flag
[161] Fix | Delete
$this->upgrading_et_product = false;
[162] Fix | Delete
[163] Fix | Delete
if ( ! empty( $package ) ) {
[164] Fix | Delete
return $reply;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
// output custom error message for ET Products if package is empty
[168] Fix | Delete
$error_message = et_get_safe_localization( __( '<em>Before you can receive product updates, you must first authenticate your Elegant Themes subscription. To do this, you need to enter both your Elegant Themes Username and your Elegant Themes API Key into the Updates Tab in your theme and plugin settings. To locate your API Key, <a href="https://www.elegantthemes.com/members-area/api/" target="_blank">log in</a> to your Elegant Themes account and navigate to the <strong>Account > API Key</strong> page. <a href="http://www.elegantthemes.com/gallery/divi/documentation/update/" target="_blank">Learn more here</a></em>. If you still get this message, please make sure that your Username and API Key have been entered correctly', 'et-core' ) );
[169] Fix | Delete
[170] Fix | Delete
return new WP_Error( 'no_package', $error_message );
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
/**
[174] Fix | Delete
* Get all Elegant Themes products, returned from the API request
[175] Fix | Delete
*/
[176] Fix | Delete
function get_et_api_products() {
[177] Fix | Delete
$products = array(
[178] Fix | Delete
'theme' => array(),
[179] Fix | Delete
'plugin' => array(),
[180] Fix | Delete
);
[181] Fix | Delete
[182] Fix | Delete
$update_transients = array(
[183] Fix | Delete
'et_update_themes',
[184] Fix | Delete
'et_update_all_plugins',
[185] Fix | Delete
);
[186] Fix | Delete
[187] Fix | Delete
foreach ( $update_transients as $update_transient_name ) {
[188] Fix | Delete
$type = 'et_update_themes' === $update_transient_name ? 'theme' : 'plugin';
[189] Fix | Delete
[190] Fix | Delete
if (
[191] Fix | Delete
false !== ( $update_transient = get_site_transient( $update_transient_name ) )
[192] Fix | Delete
&& ! empty( $update_transient->response )
[193] Fix | Delete
&& is_array( $update_transient->response )
[194] Fix | Delete
) {
[195] Fix | Delete
$et_product_stylesheet_names = array_keys( $update_transient->response );
[196] Fix | Delete
[197] Fix | Delete
foreach ( $et_product_stylesheet_names as $et_product_stylesheet_name ) {
[198] Fix | Delete
$products[ $type ][] = $et_product_stylesheet_name;
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
return $products;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
function get_all_et_products() {
[207] Fix | Delete
$checked_et_products = $this->get_et_api_products();
[208] Fix | Delete
[209] Fix | Delete
return $checked_et_products;
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
function remove_theme_update_actions() {
[213] Fix | Delete
remove_filter( 'pre_set_site_transient_update_themes', 'et_check_themes_updates' );
[214] Fix | Delete
remove_filter( 'site_transient_update_themes', 'et_add_themes_to_update_notification' );
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
function remove_plugin_update_actions() {
[218] Fix | Delete
remove_filter( 'pre_set_site_transient_update_plugins', 'et_shortcodes_plugin_check_updates' );
[219] Fix | Delete
remove_filter( 'site_transient_update_plugins', 'et_shortcodes_plugin_add_to_update_notification' );
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* Removes Updater plugin actions and filters,
[224] Fix | Delete
* so it doesn't make additional requests to API
[225] Fix | Delete
*
[226] Fix | Delete
* @return void
[227] Fix | Delete
*/
[228] Fix | Delete
function remove_updater_plugin_actions() {
[229] Fix | Delete
if ( ! class_exists( 'ET_Automatic_Updates' ) ) {
[230] Fix | Delete
return;
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
$updates_class = ET_Automatic_Updates::get_this();
[234] Fix | Delete
[235] Fix | Delete
remove_filter( 'after_setup_theme', array( $updates_class, 'remove_default_updates' ), 11 );
[236] Fix | Delete
[237] Fix | Delete
remove_filter( 'init', array( $updates_class, 'remove_default_plugins_updates' ), 20 );
[238] Fix | Delete
[239] Fix | Delete
remove_action( 'admin_notices', array( $updates_class, 'maybe_display_expired_message' ) );
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
/**
[243] Fix | Delete
* Returns an instance of the object
[244] Fix | Delete
*
[245] Fix | Delete
* @return object
[246] Fix | Delete
*/
[247] Fix | Delete
static function get_this() {
[248] Fix | Delete
return self::$_this;
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
/**
[252] Fix | Delete
* Adds automatic updates data only if Username and API key options are set
[253] Fix | Delete
*
[254] Fix | Delete
* @param array $send_to_api Data sent to server
[255] Fix | Delete
* @return array Modified data set if Username and API key are set, original data if not
[256] Fix | Delete
*/
[257] Fix | Delete
function maybe_add_automatic_updates_data( $send_to_api ) {
[258] Fix | Delete
if ( $this->options && isset( $this->options['username'] ) && isset( $this->options['api_key'] ) ) {
[259] Fix | Delete
$send_to_api['automatic_updates'] = 'on';
[260] Fix | Delete
[261] Fix | Delete
$send_to_api['username'] = urlencode( sanitize_text_field( $this->options['username'] ) );
[262] Fix | Delete
$send_to_api['api_key'] = sanitize_text_field( $this->options['api_key'] );
[263] Fix | Delete
[264] Fix | Delete
$send_to_api = apply_filters( 'et_add_automatic_updates_data', $send_to_api );
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
return $send_to_api;
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
/**
[271] Fix | Delete
* Gets plugin options
[272] Fix | Delete
*
[273] Fix | Delete
* @return void
[274] Fix | Delete
*/
[275] Fix | Delete
function get_options() {
[276] Fix | Delete
if ( ! $this->options = get_site_option( 'et_automatic_updates_options' ) ) {
[277] Fix | Delete
$this->options = get_option( 'et_automatic_updates_options' );
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
if ( ! $this->account_status = get_site_option( 'et_account_status' ) ) {
[281] Fix | Delete
$this->account_status = get_option( 'et_account_status' );
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
function load_scripts_styles( $hook ) {
[286] Fix | Delete
if ( 'plugin-install.php' !== $hook ) {
[287] Fix | Delete
return;
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
wp_enqueue_style( 'et_core_updates', $this->core_url . 'admin/css/updates.css', array(), $this->product_version );
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
function add_up_to_date_products_data( $update_data, $settings = array() ) {
[294] Fix | Delete
$settings = $this->process_request_settings( $settings );
[295] Fix | Delete
[296] Fix | Delete
$products_category = $settings['is_plugin_response'] ? 'plugins' : 'themes';
[297] Fix | Delete
[298] Fix | Delete
if ( ! empty( $this->up_to_date_products_data[ $products_category ] ) ) {
[299] Fix | Delete
$update_data->no_update = $this->up_to_date_products_data[ $products_category ];
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
return $update_data;
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
function merge_et_products_response( $update_transient, $et_update_products_data ) {
[306] Fix | Delete
if (
[307] Fix | Delete
empty( $et_update_products_data )
[308] Fix | Delete
|| (
[309] Fix | Delete
empty( $et_update_products_data->response )
[310] Fix | Delete
&& empty( $et_update_products_data->no_update )
[311] Fix | Delete
)
[312] Fix | Delete
) {
[313] Fix | Delete
return $update_transient;
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
$merge_data_fields = array(
[317] Fix | Delete
'response',
[318] Fix | Delete
'no_update',
[319] Fix | Delete
);
[320] Fix | Delete
[321] Fix | Delete
foreach ( $merge_data_fields as $data_field_name ) {
[322] Fix | Delete
if ( empty( $et_update_products_data->$data_field_name ) ) {
[323] Fix | Delete
continue;
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
$default_response_data = ! empty( $update_transient->$data_field_name ) ? $update_transient->$data_field_name : array();
[327] Fix | Delete
[328] Fix | Delete
$update_transient->$data_field_name = array_merge( $default_response_data, $et_update_products_data->$data_field_name );
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
return $update_transient;
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
function check_plugins_updates( $update_transient ) {
[335] Fix | Delete
global $wp_version;
[336] Fix | Delete
[337] Fix | Delete
if ( ! isset( $update_transient->response ) ) {
[338] Fix | Delete
return $update_transient;
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
$plugins = [];
[342] Fix | Delete
[343] Fix | Delete
$et_update_plugins = get_site_transient( 'et_update_all_plugins' );
[344] Fix | Delete
[345] Fix | Delete
// update_plugins transient gets set two times, so we ensure we make a request once
[346] Fix | Delete
if (
[347] Fix | Delete
isset( $et_update_plugins->last_checked )
[348] Fix | Delete
&& isset( $update_transient->last_checked )
[349] Fix | Delete
&& $et_update_plugins->last_checked > ( $update_transient->last_checked - 60 )
[350] Fix | Delete
) {
[351] Fix | Delete
return $this->merge_et_products_response( $update_transient, $et_update_plugins );
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
$_plugins = get_plugins();
[355] Fix | Delete
[356] Fix | Delete
if ( empty( $_plugins ) ) {
[357] Fix | Delete
return $update_transient;
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
foreach ( $_plugins as $file => $plugin ) {
[361] Fix | Delete
$plugins[ $file ] = $plugin['Version'];
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
do_action( 'et_core_updates_before_request' );
[365] Fix | Delete
[366] Fix | Delete
$send_to_api = array(
[367] Fix | Delete
'action' => 'check_all_plugins_updates',
[368] Fix | Delete
'installed_plugins' => $plugins,
[369] Fix | Delete
'class_version' => $this->version,
[370] Fix | Delete
);
[371] Fix | Delete
[372] Fix | Delete
// Add automatic updates data if Username and API key are set correctly
[373] Fix | Delete
$send_to_api = $this->maybe_add_automatic_updates_data( $send_to_api );
[374] Fix | Delete
[375] Fix | Delete
$options = array(
[376] Fix | Delete
'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
[377] Fix | Delete
'body' => $send_to_api,
[378] Fix | Delete
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
[379] Fix | Delete
);
[380] Fix | Delete
[381] Fix | Delete
$last_update = new stdClass();
[382] Fix | Delete
[383] Fix | Delete
$plugins_request = wp_remote_post( 'https://www.elegantthemes.com/api/api.php', $options );
[384] Fix | Delete
[385] Fix | Delete
if ( is_wp_error( $plugins_request ) ) {
[386] Fix | Delete
$options['body']['failed_request'] = 'true';
[387] Fix | Delete
$plugins_request = wp_remote_post( 'https://cdn.elegantthemes.com/api/api.php', $options );
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
$plugins_response = array();
[391] Fix | Delete
[392] Fix | Delete
if ( ! is_wp_error( $plugins_request ) && wp_remote_retrieve_response_code( $plugins_request ) === 200 ){
[393] Fix | Delete
$plugins_response = maybe_unserialize( wp_remote_retrieve_body( $plugins_request ) );
[394] Fix | Delete
[395] Fix | Delete
if ( ! empty( $plugins_response ) && is_array( $plugins_response ) ) {
[396] Fix | Delete
$request_settings = array( 'is_plugin_response' => true );
[397] Fix | Delete
[398] Fix | Delete
$plugins_response = $this->process_additional_response_settings( $plugins_response, $request_settings );
[399] Fix | Delete
[400] Fix | Delete
$last_update->checked = $plugins;
[401] Fix | Delete
$last_update->response = $plugins_response;
[402] Fix | Delete
[403] Fix | Delete
$last_update = $this->add_up_to_date_products_data( $last_update, $request_settings );
[404] Fix | Delete
}
[405] Fix | Delete
}
[406] Fix | Delete
[407] Fix | Delete
$last_update->last_checked = time();
[408] Fix | Delete
[409] Fix | Delete
$update_transient = $this->merge_et_products_response( $update_transient, $plugins_response );
[410] Fix | Delete
[411] Fix | Delete
set_site_transient( 'et_update_all_plugins', $last_update );
[412] Fix | Delete
[413] Fix | Delete
$this->update_product_domains();
[414] Fix | Delete
[415] Fix | Delete
return $update_transient;
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
public function maybe_modify_plugins_changelog( $false, $action, $args ) {
[419] Fix | Delete
if ( 'plugin_information' !== $action ) {
[420] Fix | Delete
return $false;
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
if ( isset( $args->slug ) ) {
[424] Fix | Delete
$et_update_lb_plugin = get_site_transient( 'et_update_all_plugins' );
[425] Fix | Delete
[426] Fix | Delete
$plugin_basename = sprintf( '%1$s/%1$s.php', sanitize_text_field( $args->slug ) );
[427] Fix | Delete
[428] Fix | Delete
if ( isset( $et_update_lb_plugin->response[ $plugin_basename ] ) ) {
[429] Fix | Delete
$plugin_info = $et_update_lb_plugin->response[ $plugin_basename ];
[430] Fix | Delete
[431] Fix | Delete
if ( isset( $plugin_info->et_sections_used ) && 'on' === $plugin_info->et_sections_used ) {
[432] Fix | Delete
return $plugin_info;
[433] Fix | Delete
}
[434] Fix | Delete
}
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
return $false;
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
function process_account_settings( $response ) {
[441] Fix | Delete
if ( empty( $response['et_account_data'] ) ) {
[442] Fix | Delete
return $response;
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
$additional_settings_fields = array(
[446] Fix | Delete
'et_username_status',
[447] Fix | Delete
'et_api_key_status',
[448] Fix | Delete
'et_expired_subscription',
[449] Fix | Delete
);
[450] Fix | Delete
[451] Fix | Delete
$et_account_data = $response['et_account_data'];
[452] Fix | Delete
[453] Fix | Delete
$additional_settings = array();
[454] Fix | Delete
[455] Fix | Delete
$is_theme_response = is_array( $et_account_data );
[456] Fix | Delete
[457] Fix | Delete
foreach ( $additional_settings_fields as $additional_settings_field ) {
[458] Fix | Delete
$field = '';
[459] Fix | Delete
[460] Fix | Delete
$field_exists = $is_theme_response ? array_key_exists( $additional_settings_field, $et_account_data ) : ! empty( $et_account_data->$additional_settings_field );
[461] Fix | Delete
[462] Fix | Delete
if ( $field_exists ) {
[463] Fix | Delete
$field = $is_theme_response ? $et_account_data[ $additional_settings_field ] : $et_account_data->$additional_settings_field;
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
$additional_settings[ $additional_settings_field ] = $field;
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
if (
[470] Fix | Delete
! empty( $additional_settings[ 'et_username_status' ] )
[471] Fix | Delete
&& in_array( $additional_settings[ 'et_username_status' ], array( 'active', 'expired', 'not_found' ) )
[472] Fix | Delete
) {
[473] Fix | Delete
$this->account_status = sanitize_text_field( $additional_settings['et_username_status'] );
[474] Fix | Delete
} else {
[475] Fix | Delete
// Set the account status to expired if the response array has 'et_expired_subscription' key
[476] Fix | Delete
$this->account_status = ! empty( $additional_settings[ 'et_expired_subscription' ] ) ? 'expired' : 'active';
[477] Fix | Delete
}
[478] Fix | Delete
[479] Fix | Delete
update_site_option( 'et_account_status', $this->account_status );
[480] Fix | Delete
[481] Fix | Delete
if ( ! empty( $additional_settings[ 'et_api_key_status' ] ) ) {
[482] Fix | Delete
update_site_option( 'et_account_api_key_status', sanitize_text_field( $additional_settings['et_api_key_status'] ) );
[483] Fix | Delete
} else {
[484] Fix | Delete
delete_site_option( 'et_account_api_key_status' );
[485] Fix | Delete
}
[486] Fix | Delete
[487] Fix | Delete
unset( $response['et_account_data'] );
[488] Fix | Delete
[489] Fix | Delete
return $response;
[490] Fix | Delete
}
[491] Fix | Delete
[492] Fix | Delete
function process_up_to_date_products_settings( $response, $settings ) {
[493] Fix | Delete
if ( empty( $response['et_up_to_date_products'] ) ) {
[494] Fix | Delete
return $response;
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
$products_category = $settings['is_plugin_response'] ? 'plugins' : 'themes';
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function