WPSEO_Addon_Manager::check_for_updates
Checks if there are addon updates.
Метод класса: WPSEO_Addon_Manager{}
Хуков нет.
Возвращает
stdClass. Extended data for update_plugins.
Использование
$WPSEO_Addon_Manager = new WPSEO_Addon_Manager(); $WPSEO_Addon_Manager->check_for_updates( $data );
- $data(stdClass) (обязательный)
- The current data for update_plugins.
Код WPSEO_Addon_Manager::check_for_updates() WPSEO Addon Manager::check for updates Yoast 27.8
public function check_for_updates( $data ) {
global $wp_version;
if ( empty( $data ) ) {
return $data;
}
// We have to figure out if we're safe to upgrade the add-ons, based on what the latest Yoast Free requirements for the WP version is.
$yoast_free_data = $this->extract_yoast_data( $data );
foreach ( $this->get_installed_addons() as $plugin_file => $installed_plugin ) {
$subscription_slug = $this->get_slug_by_plugin_file( $plugin_file );
$subscription = $this->get_subscription( $subscription_slug );
if ( ! $subscription ) {
continue;
}
$plugin_data = $this->convert_subscription_to_plugin( $subscription, $yoast_free_data, false, $plugin_file );
// Let's assume for now that it will get added in the 'no_update' key that we'll return to the WP API.
$is_no_update = true;
// If the add-on's version is the latest, we have to do no further checks.
if ( version_compare( $installed_plugin['Version'], $plugin_data->new_version, '<' ) ) {
// If we haven't retrieved the Yoast Free requirements for the WP version yet, do nothing. The next run will probably get us that information.
if ( $plugin_data->requires === null ) {
continue;
}
if ( version_compare( $plugin_data->requires, $wp_version, '<=' ) ) {
// The add-on has an available update *and* the Yoast Free requirements for the WP version are also met, so go ahead and show the upgrade info to the user.
$is_no_update = false;
$data->response[ $plugin_file ] = $plugin_data;
if ( $this->has_subscription_expired( $subscription ) ) {
unset( $data->response[ $plugin_file ]->package, $data->response[ $plugin_file ]->download_link );
}
}
}
if ( $is_no_update ) {
// Still convert subscription when no updates is available.
$data->no_update[ $plugin_file ] = $plugin_data;
if ( $this->has_subscription_expired( $subscription ) ) {
unset( $data->no_update[ $plugin_file ]->package, $data->no_update[ $plugin_file ]->download_link );
}
}
}
return $data;
}