Inventory_Presser_Addon_Updater::check_update( array $_transient_data )

Check for Updates at the defined API endpoint and modify the update array.


Description

This function dives into the update API just when WordPress creates its update array, then adds a custom API call and injects the custom plugin data retrieved from the API.<br>It is reassembled from parts of the native WordPress plugin update code.<br>See wp-includes/update.php line 121 for the original wp_update_plugins() function.


Parameters

$_transient_data

(array) (Required) Update array build by WordPress.


Return

(array) Modified update array with custom plugin data.


Source

File: includes/addon/class-addon-updater.php

		public function check_update( $_transient_data ) {

			global $pagenow;
			if ( ! is_object( $_transient_data ) ) {
				$_transient_data = new stdClass();
			}

			if ( 'plugins.php' == $pagenow && is_multisite() ) {
				return $_transient_data;
			}

			if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
				return $_transient_data;
			}

			$current = $this->get_repo_api_data();
			if ( false !== $current && is_object( $current ) && isset( $current->new_version ) ) {
				if ( version_compare( $this->version, $current->new_version, '<' ) ) {
					$_transient_data->response[ $this->name ] = $current;
				} else {
					// Populating the no_update information is required to support auto-updates in WordPress 5.5.
					$_transient_data->no_update[ $this->name ] = $current;
				}
			}
			$_transient_data->last_checked           = time();
			$_transient_data->checked[ $this->name ] = $this->version;

			return $_transient_data;
		}