Inventory_Presser_Addon_Updater::plugins_api_filter( mixed $_data, string $_action = '', object $_args = null )

Updates information on the “View version x.x details” page with custom data.


Parameters Parameters

$_data

(mixed) (Required)

$_action

(string) (Optional)

Default value: ''

$_args

(object) (Optional)

Default value: null


Top ↑

Return Return

(object) $_data


Top ↑

Source Source

File: includes/class-addon-updater.php

		public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
	
			if ( $_action != 'plugin_information' ) {
	
				return $_data;
	
			}
	
			if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
	
				return $_data;
	
			}
	
			$to_send = array(
				'slug'   => $this->slug,
				'is_ssl' => is_ssl(),
				'fields' => array(
					'banners' => array(),
					'reviews' => false,
					'icons'   => array(),
				)
			);
	
			// Get the transient where we store the api request for this plugin for 24 hours
			$edd_api_request_transient = $this->get_cached_version_info();
	
			//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.
			if ( empty( $edd_api_request_transient ) ) {
	
				$api_response = $this->api_request( 'plugin_information', $to_send );
	
				// Expires in 3 hours
				$this->set_version_info_cache( $api_response );
	
				if ( false !== $api_response ) {
					$_data = $api_response;
				}
	
			} else {
				$_data = $edd_api_request_transient;
			}
	
			// Convert sections into an associative array, since we're getting an object, but Core expects an array.
			if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
				$_data->sections = $this->convert_object_to_array( $_data->sections );
			}
	
			// Convert banners into an associative array, since we're getting an object, but Core expects an array.
			if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
				$_data->banners = $this->convert_object_to_array( $_data->banners );
			}
	
			// Convert icons into an associative array, since we're getting an object, but Core expects an array.
			if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
				$_data->icons = $this->convert_object_to_array( $_data->icons );
			}
	
			// Convert contributors into an associative array, since we're getting an object, but Core expects an array.
			if ( isset( $_data->contributors ) && ! is_array( $_data->contributors ) ) {
				$_data->contributors = $this->convert_object_to_array( $_data->contributors );
			}
	
			if( ! isset( $_data->plugin ) ) {
				$_data->plugin = $this->name;
			}
	
			return $_data;
		}