Inventory_Presser_Addon_Updater::show_changelog()

If available, show the changelog for sites in a multisite install.


Source Source

File: includes/class-addon-updater.php

		public function show_changelog() {
	
			global $edd_plugin_data;
	
			if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
				return;
			}
	
			if( empty( $_REQUEST['plugin'] ) ) {
				return;
			}
	
			if( empty( $_REQUEST['slug'] ) ) {
				return;
			}
	
			if( ! current_user_can( 'update_plugins' ) ) {
				wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
			}
	
			$data         = $edd_plugin_data[ $_REQUEST['slug'] ];
			$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'       => $_REQUEST['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
				delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['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;
		}