WP_Site_Health::get_test_php_version()
Test if the supplied PHP version is supported.
{} Это метод класса: WP_Site_Health{}
Хуков нет.
Возвращает
Массив
. The test results.
Использование
$WP_Site_Health = new WP_Site_Health(); $WP_Site_Health->get_test_php_version();
Список изменений
С версии 5.2.0 | Введена. |
Код WP_Site_Health::get_test_php_version() WP Site Health::get test php version WP 6.0
public function get_test_php_version() { $response = wp_check_php_version(); $result = array( 'label' => sprintf( /* translators: %s: The current PHP version. */ __( 'Your site is running the current version of PHP (%s)' ), PHP_VERSION ), 'status' => 'good', 'badge' => array( 'label' => __( 'Performance' ), 'color' => 'blue', ), 'description' => sprintf( '<p>%s</p>', sprintf( /* translators: %s: The minimum recommended PHP version. */ __( 'PHP is the programming language used to build and maintain WordPress. Newer versions of PHP are created with increased performance in mind, so you may see a positive effect on your site’s performance. The minimum recommended version of PHP is %s.' ), $response ? $response['recommended_version'] : '' ) ), 'actions' => sprintf( '<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', esc_url( wp_get_update_php_url() ), __( 'Learn more about updating PHP' ), /* translators: Accessibility text. */ __( '(opens in a new tab)' ) ), 'test' => 'php_version', ); // PHP is up to date. if ( ! $response || version_compare( PHP_VERSION, $response['recommended_version'], '>=' ) ) { return $result; } // The PHP version is older than the recommended version, but still receiving active support. if ( $response['is_supported'] ) { $result['label'] = sprintf( /* translators: %s: The server PHP version. */ __( 'Your site is running an older version of PHP (%s)' ), PHP_VERSION ); $result['status'] = 'recommended'; return $result; } // The PHP version is only receiving security fixes. if ( $response['is_secure'] ) { $result['label'] = sprintf( /* translators: %s: The server PHP version. */ __( 'Your site is running an older version of PHP (%s), which should be updated' ), PHP_VERSION ); $result['status'] = 'recommended'; return $result; } // Anything no longer secure must be updated. $result['label'] = sprintf( /* translators: %s: The server PHP version. */ __( 'Your site is running an outdated version of PHP (%s), which requires an update' ), PHP_VERSION ); $result['status'] = 'critical'; $result['badge']['label'] = __( 'Security' ); return $result; }