ACF_Updates::get_plugin_updates()
get_plugin_updates
Checks for plugin updates.
Метод класса: ACF_Updates{}
Хуков нет.
Возвращает
Массив|WP_Error.
.
Использование
$ACF_Updates = new ACF_Updates(); $ACF_Updates->get_plugin_updates( $force_check );
- $force_check(true|false)
- Bypasses cached result.
По умолчанию: false
Список изменений
С версии 5.6.9 | Введена. |
С версии 5.7.2 | Added 'checked' comparison |
Код ACF_Updates::get_plugin_updates() ACF Updates::get plugin updates ACF 6.0.4
function get_plugin_updates( $force_check = false ) { // var $transient_name = 'acf_plugin_updates'; // construct array of 'checked' plugins // sort by key to avoid detecting change due to "include order" $checked = array(); foreach ( $this->plugins as $basename => $plugin ) { $checked[ $basename ] = $plugin['version']; } ksort( $checked ); // $force_check prevents transient lookup if ( ! $force_check ) { $transient = get_transient( $transient_name ); // if cached response was found, compare $transient['checked'] against $checked and ignore if they don't match (plugins/versions have changed) if ( is_array( $transient ) ) { $transient_checked = isset( $transient['checked'] ) ? $transient['checked'] : array(); if ( wp_json_encode( $checked ) !== wp_json_encode( $transient_checked ) ) { $transient = false; } } if ( $transient !== false ) { return $transient; } } // vars $post = array( 'plugins' => wp_json_encode( $this->plugins ), 'wp' => wp_json_encode( array( 'wp_name' => get_bloginfo( 'name' ), 'wp_url' => home_url(), 'wp_version' => get_bloginfo( 'version' ), 'wp_language' => get_bloginfo( 'language' ), 'wp_timezone' => get_option( 'timezone_string' ), 'php_version' => PHP_VERSION, ) ), 'acf' => wp_json_encode( array( 'acf_version' => get_option( 'acf_version' ), 'acf_pro' => ( defined( 'ACF_PRO' ) && ACF_PRO ), 'block_count' => acf_pro_get_registered_block_count(), ) ), ); // request $response = $this->request( 'v2/plugins/update-check', $post ); // append checked reference if ( is_array( $response ) ) { $response['checked'] = $checked; } // allow json to include expiration but force minimum and max for safety $expiration = $this->get_expiration( $response, DAY_IN_SECONDS, MONTH_IN_SECONDS ); // update transient set_transient( $transient_name, $response, $expiration ); // return return $response; }