Inventory_Presser_Addon_Updater::show_changelog()
If available, show the changelog for sites in a multisite install.
Source Source
File: includes/addon/class-addon-updater.php
public function show_changelog() {
global $edd_plugin_data;
if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== sanitize_text_field( wp_unslash( $_REQUEST['edd_sl_action'] ) ) ) {
return;
}
if ( empty( $_REQUEST['plugin'] ) ) {
return;
}
if ( empty( $_REQUEST['slug'] ) ) {
return;
}
if ( ! current_user_can( 'update_plugins' ) ) {
wp_die( esc_html__( 'You do not have permission to install plugin updates', 'inventory-presser' ), esc_html__( 'Error', 'inventory-presser' ), array( 'response' => 403 ) );
}
$slug = sanitize_text_field( wp_unslash( $_REQUEST['slug'] ) );
$data = isset( $edd_plugin_data[ $slug ] ) ? $edd_plugin_data[ $slug ] : null;
if ( empty( $data ) ) {
return;
}
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$api_params = array(
'edd_action' => 'get_version',
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
'slug' => $slug,
'author' => $data['author'],
'url' => home_url(),
'beta' => ! empty( $data['beta'] ),
);
$verify_ssl = $this->verify_ssl();
$request = wp_remote_post(
$this->api_url,
array(
'timeout' => 15,
'sslverify' => $verify_ssl,
'body' => $api_params,
)
);
if ( ! is_wp_error( $request ) ) {
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
}
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
$version_info->sections = maybe_unserialize( $version_info->sections );
} else {
$version_info = false;
}
if ( ! empty( $version_info ) ) {
foreach ( $version_info->sections as $key => $section ) {
$version_info->$key = (array) $section;
}
}
$this->set_version_info_cache( $version_info );
// Delete the unneeded option.
$plugin = sanitize_text_field( wp_unslash( $_REQUEST['plugin'] ) );
delete_option( md5( 'edd_plugin_' . sanitize_key( $plugin ) . '_' . $this->beta . '_version_info' ) );
}
if ( isset( $version_info->sections ) ) {
$sections = $this->convert_object_to_array( $version_info->sections );
if ( ! empty( $sections['changelog'] ) ) {
echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
}
}
exit;
}
Expand full source codeCollapse full source codeView on Github