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/ninja-fo.../includes/Integrat.../EDD
File: EDD_SL_Plugin_Updater.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// Exit if accessed directly
[2] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) exit;
[3] Fix | Delete
[4] Fix | Delete
/**
[5] Fix | Delete
* Allows plugins to use their own update API.
[6] Fix | Delete
*
[7] Fix | Delete
* @author Easy Digital Downloads
[8] Fix | Delete
* @version 1.6.18
[9] Fix | Delete
*/
[10] Fix | Delete
class EDD_SL_Plugin_Updater {
[11] Fix | Delete
[12] Fix | Delete
private $api_url = '';
[13] Fix | Delete
private $api_data = array();
[14] Fix | Delete
private $name = '';
[15] Fix | Delete
private $slug = '';
[16] Fix | Delete
private $version = '';
[17] Fix | Delete
private $wp_override = false;
[18] Fix | Delete
private $cache_key = '';
[19] Fix | Delete
private $beta = false;
[20] Fix | Delete
private $health_check_timeout = 5;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Class constructor.
[24] Fix | Delete
*
[25] Fix | Delete
* @uses plugin_basename()
[26] Fix | Delete
* @uses hook()
[27] Fix | Delete
*
[28] Fix | Delete
* @param string $_api_url The URL pointing to the custom API endpoint.
[29] Fix | Delete
* @param string $_plugin_file Path to the plugin file.
[30] Fix | Delete
* @param array $_api_data Optional data to send with API calls.
[31] Fix | Delete
*/
[32] Fix | Delete
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
[33] Fix | Delete
[34] Fix | Delete
global $edd_plugin_data;
[35] Fix | Delete
[36] Fix | Delete
$this->api_url = trailingslashit( $_api_url );
[37] Fix | Delete
$this->api_data = $_api_data;
[38] Fix | Delete
$this->name = plugin_basename( $_plugin_file );
[39] Fix | Delete
$this->slug = basename( $_plugin_file, '.php' );
[40] Fix | Delete
$this->version = $_api_data['version'];
[41] Fix | Delete
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
[42] Fix | Delete
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
[43] Fix | Delete
$this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
[44] Fix | Delete
[45] Fix | Delete
$edd_plugin_data[ $this->slug ] = $this->api_data;
[46] Fix | Delete
[47] Fix | Delete
// Set up hooks.
[48] Fix | Delete
$this->init();
[49] Fix | Delete
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* Set up WordPress filters to hook into WP's update process.
[54] Fix | Delete
*
[55] Fix | Delete
* @uses add_filter()
[56] Fix | Delete
*
[57] Fix | Delete
* @return void
[58] Fix | Delete
*/
[59] Fix | Delete
public function init() {
[60] Fix | Delete
[61] Fix | Delete
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
[62] Fix | Delete
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
[63] Fix | Delete
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
[64] Fix | Delete
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
[65] Fix | Delete
add_action( 'admin_init', array( $this, 'show_changelog' ) );
[66] Fix | Delete
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Check for Updates at the defined API endpoint and modify the update array.
[71] Fix | Delete
*
[72] Fix | Delete
* This function dives into the update API just when WordPress creates its update array,
[73] Fix | Delete
* then adds a custom API call and injects the custom plugin data retrieved from the API.
[74] Fix | Delete
* It is reassembled from parts of the native WordPress plugin update code.
[75] Fix | Delete
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
[76] Fix | Delete
*
[77] Fix | Delete
* @uses api_request()
[78] Fix | Delete
*
[79] Fix | Delete
* @param array $_transient_data Update array build by WordPress.
[80] Fix | Delete
* @return array Modified update array with custom plugin data.
[81] Fix | Delete
*/
[82] Fix | Delete
public function check_update( $_transient_data ) {
[83] Fix | Delete
[84] Fix | Delete
global $pagenow;
[85] Fix | Delete
[86] Fix | Delete
if ( ! is_object( $_transient_data ) ) {
[87] Fix | Delete
$_transient_data = new stdClass;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
if ( 'plugins.php' == $pagenow && is_multisite() ) {
[91] Fix | Delete
return $_transient_data;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
[95] Fix | Delete
return $_transient_data;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
$version_info = $this->get_cached_version_info();
[99] Fix | Delete
[100] Fix | Delete
if ( false === $version_info ) {
[101] Fix | Delete
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
[102] Fix | Delete
[103] Fix | Delete
$this->set_version_info_cache( $version_info );
[104] Fix | Delete
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
[108] Fix | Delete
[109] Fix | Delete
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
[110] Fix | Delete
[111] Fix | Delete
$_transient_data->response[ $this->name ] = $version_info;
[112] Fix | Delete
[113] Fix | Delete
// Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
[114] Fix | Delete
$_transient_data->response[ $this->name ]->plugin = $this->name;
[115] Fix | Delete
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
$_transient_data->last_checked = time();
[119] Fix | Delete
$_transient_data->checked[ $this->name ] = $this->version;
[120] Fix | Delete
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
return $_transient_data;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
[128] Fix | Delete
*
[129] Fix | Delete
* @param string $file
[130] Fix | Delete
* @param array $plugin
[131] Fix | Delete
*/
[132] Fix | Delete
public function show_update_notification( $file, $plugin ) {
[133] Fix | Delete
[134] Fix | Delete
if ( is_network_admin() ) {
[135] Fix | Delete
return;
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
if( ! current_user_can( 'update_plugins' ) ) {
[139] Fix | Delete
return;
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
if( ! is_multisite() ) {
[143] Fix | Delete
return;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
if ( $this->name != $file ) {
[147] Fix | Delete
return;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
// Remove our filter on the site transient
[151] Fix | Delete
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
[152] Fix | Delete
[153] Fix | Delete
$update_cache = get_site_transient( 'update_plugins' );
[154] Fix | Delete
[155] Fix | Delete
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
[156] Fix | Delete
[157] Fix | Delete
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
[158] Fix | Delete
[159] Fix | Delete
$version_info = $this->get_cached_version_info();
[160] Fix | Delete
[161] Fix | Delete
if ( false === $version_info ) {
[162] Fix | Delete
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
[163] Fix | Delete
[164] Fix | Delete
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
[165] Fix | Delete
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
[166] Fix | Delete
$version_info->banners = $this->convert_object_to_array( $version_info->banners );
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
[170] Fix | Delete
$version_info->sections = $this->convert_object_to_array( $version_info->sections );
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
[174] Fix | Delete
$version_info->icons = $this->convert_object_to_array( $version_info->icons );
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
$this->set_version_info_cache( $version_info );
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
if ( ! is_object( $version_info ) ) {
[181] Fix | Delete
return;
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
[185] Fix | Delete
[186] Fix | Delete
$update_cache->response[ $this->name ] = $version_info;
[187] Fix | Delete
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
$update_cache->last_checked = time();
[191] Fix | Delete
$update_cache->checked[ $this->name ] = $this->version;
[192] Fix | Delete
[193] Fix | Delete
set_site_transient( 'update_plugins', $update_cache );
[194] Fix | Delete
[195] Fix | Delete
} else {
[196] Fix | Delete
[197] Fix | Delete
$version_info = $update_cache->response[ $this->name ];
[198] Fix | Delete
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
// Restore our filter
[202] Fix | Delete
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
[203] Fix | Delete
[204] Fix | Delete
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
[205] Fix | Delete
[206] Fix | Delete
// build a plugin list row, with update notification
[207] Fix | Delete
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
[208] Fix | Delete
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
[209] Fix | Delete
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
[210] Fix | Delete
echo '<td colspan="3" class="plugin-update colspanchange">';
[211] Fix | Delete
echo '<div class="update-message notice inline notice-warning notice-alt">';
[212] Fix | Delete
[213] Fix | Delete
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
[214] Fix | Delete
[215] Fix | Delete
if ( empty( $version_info->download_link ) ) {
[216] Fix | Delete
printf(
[217] Fix | Delete
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
[218] Fix | Delete
esc_html( $version_info->name ),
[219] Fix | Delete
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
[220] Fix | Delete
esc_html( $version_info->new_version ),
[221] Fix | Delete
'</a>'
[222] Fix | Delete
);
[223] Fix | Delete
} else {
[224] Fix | Delete
printf(
[225] Fix | Delete
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
[226] Fix | Delete
esc_html( $version_info->name ),
[227] Fix | Delete
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
[228] Fix | Delete
esc_html( $version_info->new_version ),
[229] Fix | Delete
'</a>',
[230] Fix | Delete
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
[231] Fix | Delete
'</a>'
[232] Fix | Delete
);
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
[236] Fix | Delete
[237] Fix | Delete
echo '</div></td></tr>';
[238] Fix | Delete
}
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
/**
[242] Fix | Delete
* Updates information on the "View version x.x details" page with custom data.
[243] Fix | Delete
*
[244] Fix | Delete
* @uses api_request()
[245] Fix | Delete
*
[246] Fix | Delete
* @param mixed $_data
[247] Fix | Delete
* @param string $_action
[248] Fix | Delete
* @param object $_args
[249] Fix | Delete
* @return object $_data
[250] Fix | Delete
*/
[251] Fix | Delete
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
[252] Fix | Delete
[253] Fix | Delete
if ( $_action != 'plugin_information' ) {
[254] Fix | Delete
[255] Fix | Delete
return $_data;
[256] Fix | Delete
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
[260] Fix | Delete
[261] Fix | Delete
return $_data;
[262] Fix | Delete
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
$to_send = array(
[266] Fix | Delete
'slug' => $this->slug,
[267] Fix | Delete
'is_ssl' => is_ssl(),
[268] Fix | Delete
'fields' => array(
[269] Fix | Delete
'banners' => array(),
[270] Fix | Delete
'reviews' => false,
[271] Fix | Delete
'icons' => array(),
[272] Fix | Delete
)
[273] Fix | Delete
);
[274] Fix | Delete
[275] Fix | Delete
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
[276] Fix | Delete
[277] Fix | Delete
// Get the transient where we store the api request for this plugin for 24 hours
[278] Fix | Delete
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
[279] Fix | Delete
[280] Fix | Delete
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
[281] Fix | Delete
if ( empty( $edd_api_request_transient ) ) {
[282] Fix | Delete
[283] Fix | Delete
$api_response = $this->api_request( 'plugin_information', $to_send );
[284] Fix | Delete
[285] Fix | Delete
// Expires in 3 hours
[286] Fix | Delete
$this->set_version_info_cache( $api_response, $cache_key );
[287] Fix | Delete
[288] Fix | Delete
if ( false !== $api_response ) {
[289] Fix | Delete
$_data = $api_response;
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
} else {
[293] Fix | Delete
$_data = $edd_api_request_transient;
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
[297] Fix | Delete
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
[298] Fix | Delete
$_data->sections = $this->convert_object_to_array( $_data->sections );
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
[302] Fix | Delete
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
[303] Fix | Delete
$_data->banners = $this->convert_object_to_array( $_data->banners );
[304] Fix | Delete
}
[305] Fix | Delete
[306] Fix | Delete
// Convert icons into an associative array, since we're getting an object, but Core expects an array.
[307] Fix | Delete
if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
[308] Fix | Delete
$_data->icons = $this->convert_object_to_array( $_data->icons );
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
if( ! isset( $_data->plugin ) ) {
[312] Fix | Delete
$_data->plugin = $this->name;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
return $_data;
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
/**
[319] Fix | Delete
* Convert some objects to arrays when injecting data into the update API
[320] Fix | Delete
*
[321] Fix | Delete
* Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
[322] Fix | Delete
* decoding, they are objects. This method allows us to pass in the object and return an associative array.
[323] Fix | Delete
*
[324] Fix | Delete
* @since 3.6.5
[325] Fix | Delete
*
[326] Fix | Delete
* @param stdClass $data
[327] Fix | Delete
*
[328] Fix | Delete
* @return array
[329] Fix | Delete
*/
[330] Fix | Delete
private function convert_object_to_array( $data ) {
[331] Fix | Delete
$new_data = array();
[332] Fix | Delete
foreach ( $data as $key => $value ) {
[333] Fix | Delete
$new_data[ $key ] = $value;
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
return $new_data;
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
/**
[340] Fix | Delete
* Disable SSL verification in order to prevent download update failures
[341] Fix | Delete
*
[342] Fix | Delete
* @param array $args
[343] Fix | Delete
* @param string $url
[344] Fix | Delete
* @return object $array
[345] Fix | Delete
*/
[346] Fix | Delete
public function http_request_args( $args, $url ) {
[347] Fix | Delete
[348] Fix | Delete
$verify_ssl = $this->verify_ssl();
[349] Fix | Delete
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
[350] Fix | Delete
$args['sslverify'] = $verify_ssl;
[351] Fix | Delete
}
[352] Fix | Delete
return $args;
[353] Fix | Delete
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Calls the API and, if successfull, returns the object delivered by the API.
[358] Fix | Delete
*
[359] Fix | Delete
* @uses get_bloginfo()
[360] Fix | Delete
* @uses wp_remote_post()
[361] Fix | Delete
* @uses is_wp_error()
[362] Fix | Delete
*
[363] Fix | Delete
* @param string $_action The requested action.
[364] Fix | Delete
* @param array $_data Parameters for the API action.
[365] Fix | Delete
* @return false|object
[366] Fix | Delete
*/
[367] Fix | Delete
private function api_request( $_action, $_data ) {
[368] Fix | Delete
[369] Fix | Delete
global $wp_version, $edd_plugin_url_available;
[370] Fix | Delete
[371] Fix | Delete
$verify_ssl = $this->verify_ssl();
[372] Fix | Delete
[373] Fix | Delete
// Do a quick status check on this domain if we haven't already checked it.
[374] Fix | Delete
$store_hash = md5( $this->api_url );
[375] Fix | Delete
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
[376] Fix | Delete
$test_url_parts = parse_url( $this->api_url );
[377] Fix | Delete
[378] Fix | Delete
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
[379] Fix | Delete
$host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
[380] Fix | Delete
$port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
[381] Fix | Delete
[382] Fix | Delete
if ( empty( $host ) ) {
[383] Fix | Delete
$edd_plugin_url_available[ $store_hash ] = false;
[384] Fix | Delete
} else {
[385] Fix | Delete
$test_url = $scheme . '://' . $host . $port;
[386] Fix | Delete
$response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) );
[387] Fix | Delete
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
[388] Fix | Delete
}
[389] Fix | Delete
}
[390] Fix | Delete
[391] Fix | Delete
if ( false === $edd_plugin_url_available[ $store_hash ] ) {
[392] Fix | Delete
return;
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
$data = array_merge( $this->api_data, $_data );
[396] Fix | Delete
[397] Fix | Delete
if ( $data['slug'] != $this->slug ) {
[398] Fix | Delete
return;
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
if( $this->api_url == trailingslashit ( home_url() ) ) {
[402] Fix | Delete
return false; // Don't allow a plugin to ping itself
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
$api_params = array(
[406] Fix | Delete
'edd_action' => 'get_version',
[407] Fix | Delete
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
[408] Fix | Delete
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
[409] Fix | Delete
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
[410] Fix | Delete
'version' => isset( $data['version'] ) ? $data['version'] : false,
[411] Fix | Delete
'slug' => $data['slug'],
[412] Fix | Delete
'author' => $data['author'],
[413] Fix | Delete
'url' => home_url(),
[414] Fix | Delete
'beta' => ! empty( $data['beta'] ),
[415] Fix | Delete
);
[416] Fix | Delete
[417] Fix | Delete
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
[418] Fix | Delete
[419] Fix | Delete
if ( ! is_wp_error( $request ) ) {
[420] Fix | Delete
$request = json_decode( wp_remote_retrieve_body( $request ) );
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
if ( $request && isset( $request->sections ) ) {
[424] Fix | Delete
$request->sections = maybe_unserialize( $request->sections );
[425] Fix | Delete
} else {
[426] Fix | Delete
$request = false;
[427] Fix | Delete
}
[428] Fix | Delete
[429] Fix | Delete
if ( $request && isset( $request->banners ) ) {
[430] Fix | Delete
$request->banners = maybe_unserialize( $request->banners );
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
if ( $request && isset( $request->icons ) ) {
[434] Fix | Delete
$request->icons = maybe_unserialize( $request->icons );
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
if( ! empty( $request->sections ) ) {
[438] Fix | Delete
foreach( $request->sections as $key => $section ) {
[439] Fix | Delete
$request->$key = (array) $section;
[440] Fix | Delete
}
[441] Fix | Delete
}
[442] Fix | Delete
[443] Fix | Delete
return $request;
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
public function show_changelog() {
[447] Fix | Delete
[448] Fix | Delete
global $edd_plugin_data;
[449] Fix | Delete
[450] Fix | Delete
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
[451] Fix | Delete
return;
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
if( empty( $_REQUEST['plugin'] ) ) {
[455] Fix | Delete
return;
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
if( empty( $_REQUEST['slug'] ) ) {
[459] Fix | Delete
return;
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
if( ! current_user_can( 'update_plugins' ) ) {
[463] Fix | Delete
wp_die( esc_html__( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
$data = $edd_plugin_data[WPN_Helper::sanitize_text_field($_REQUEST['slug'])];
[467] Fix | Delete
$beta = ! empty( $data['beta'] ) ? true : false;
[468] Fix | Delete
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
[469] Fix | Delete
$version_info = $this->get_cached_version_info( $cache_key );
[470] Fix | Delete
[471] Fix | Delete
if( false === $version_info ) {
[472] Fix | Delete
[473] Fix | Delete
$api_params = array(
[474] Fix | Delete
'edd_action' => 'get_version',
[475] Fix | Delete
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
[476] Fix | Delete
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
[477] Fix | Delete
'slug' => WPN_Helper::sanitize_text_field($_REQUEST['slug']),
[478] Fix | Delete
'author' => $data['author'],
[479] Fix | Delete
'url' => home_url(),
[480] Fix | Delete
'beta' => ! empty( $data['beta'] )
[481] Fix | Delete
);
[482] Fix | Delete
[483] Fix | Delete
$verify_ssl = $this->verify_ssl();
[484] Fix | Delete
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
[485] Fix | Delete
[486] Fix | Delete
if ( ! is_wp_error( $request ) ) {
[487] Fix | Delete
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
[491] Fix | Delete
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
[492] Fix | Delete
$version_info->sections = maybe_unserialize( $version_info->sections );
[493] Fix | Delete
} else {
[494] Fix | Delete
$version_info = false;
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
if( ! empty( $version_info ) ) {
[498] Fix | Delete
foreach( $version_info->sections as $key => $section ) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function