AnsPress_Prod_Updater::check_theme_update()
Description #
Source #
File: admin/updater.php
	function check_theme_update() {
		$update_data = get_transient( $this->response_key );
		if ( false === $update_data ) {
			$failed = false;
			$api_params = array(
				'edd_action'   => 'get_version',
				'license'      => $this->api_data['license'],
				'name'         => $this->api_data['item_name'],
				'slug'         => $this->slug,
				'author'       => $this->api_data['author'],
				'anspress_ver' => AP_VERSION,
			);
			$response = wp_remote_post(
				$this->api_url, [
					'timeout' => 15,
					'body'    => $api_params,
				]
			);
			// Make sure the response was successful.
			if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
				$failed = true;
			}
			$update_data = json_decode( wp_remote_retrieve_body( $response ) );
			if ( ! is_object( $update_data ) ) {
				$failed = true;
			}
			// If the response failed, try again in 30 minutes
			if ( $failed ) {
				$data              = new stdClass();
				$data->new_version = $this->version;
				set_transient( $this->response_key, $data, strtotime( '+30 minutes' ) );
				return false;
			}
			// If the status is 'ok', return the update arguments
			if ( ! $failed ) {
				$update_data->sections = maybe_unserialize( $update_data->sections );
				set_transient( $this->response_key, $update_data, strtotime( '+12 hours' ) );
			}
		}
		if ( version_compare( $this->version, $update_data->new_version, '>=' ) ) {
			return false;
		}
		return (array) $update_data;
	}
Expand full source code Collapse full source code View on GitHub: admin/updater.php:477
  Add your comment