is_php_version_compatible example


function validate_plugin_requirements( $plugin ) {
    $plugin_headers = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );

    $requirements = array(
        'requires'     => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '',
        'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '',
    );

    $compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
    $compatible_php = is_php_version_compatible( $requirements['requires_php'] );

    $php_update_message = '</p><p>' . sprintf(
        /* translators: %s: URL to Update PHP page. */
        __( '<a href="%s">Learn more about updating PHP</a>.' ),
        esc_url( wp_get_update_php_url() )
    );

    $annotation = wp_get_update_php_annotation();

    if ( $annotation ) {
        $php_update_message .= '</p><p><em>' . $annotation . '</em>';
    }
</ul> <?php if ( ! empty( $api->donate_link ) ) { ?> <a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a> <?php } ?> <?php } ?> </div> <div id="section-holder"> <?php     $requires_php = isset( $api->requires_php ) ? $api->requires_php : null;
    $requires_wp  = isset( $api->requires ) ? $api->requires : null;

    $compatible_php = is_php_version_compatible( $requires_php );
    $compatible_wp  = is_wp_version_compatible( $requires_wp );
    $tested_wp      = ( empty( $api->tested ) || version_compare( get_bloginfo( 'version' )$api->tested, '<=' ) );

    if ( ! $compatible_php ) {
        echo '<div class="notice notice-error notice-alt"><p>';
        _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
        if ( current_user_can( 'update_php' ) ) {
            printf(
                /* translators: %s: URL to Update PHP page. */
                ' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
                esc_url( wp_get_update_php_url() )
            );
$name = strip_tags( $title . ' ' . $version );

            $author = wp_kses( $plugin['author']$plugins_allowedtags );
            if ( ! empty( $author ) ) {
                /* translators: %s: Plugin author. */
                $author = ' <cite>' . sprintf( __( 'By %s' )$author ) . '</cite>';
            }

            $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
            $requires_wp  = isset( $plugin['requires'] ) ? $plugin['requires'] : null;

            $compatible_php = is_php_version_compatible( $requires_php );
            $compatible_wp  = is_wp_version_compatible( $requires_wp );
            $tested_wp      = ( empty( $plugin['tested'] ) || version_compare( get_bloginfo( 'version' )$plugin['tested'], '<=' ) );

            $action_links = array();

            if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
                $status = install_plugin_install_status( $plugin );

                switch ( $status['status'] ) {
                    case 'install':
                        if ( $status['url'] ) {
                            
echo apply_filters( 'install_plugin_overwrite_comparison', $table$current_plugin_data$new_plugin_data );

        $install_actions = array();
        $can_update      = true;

        $blocked_message  = '<p>' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '</p>';
        $blocked_message .= '<ul class="ul-disc">';

        $requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null;
        $requires_wp  = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null;

        if ( ! is_php_version_compatible( $requires_php ) ) {
            $error = sprintf(
                /* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
                __( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
                PHP_VERSION,
                $requires_php
            );

            $blocked_message .= '<li>' . esc_html( $error ) . '</li>';
            $can_update       = false;
        }

        
        if ( $core_update_version ) {
            if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
                /* translators: %s: WordPress version. */
                $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' )$core_update_version );
            } else {
                /* translators: %s: WordPress version. */
                $compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' )$core_update_version );
            }
        }

        $requires_php   = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
        $compatible_php = is_php_version_compatible( $requires_php );

        if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
            $compat .= '<br />' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
            $compat .= sprintf(
                /* translators: %s: URL to Update PHP page. */
                __( '<a href="%s">Learn more about updating PHP</a>.' ),
                esc_url( wp_get_update_php_url() )
            );

            $annotation = wp_get_update_php_annotation();

            
'details'    => '',
            'delete'     => '',
        );

        // Do not restrict by default.         $restrict_network_active = false;
        $restrict_network_only   = false;

        $requires_php = isset( $plugin_data['RequiresPHP'] ) ? $plugin_data['RequiresPHP'] : null;
        $requires_wp  = isset( $plugin_data['RequiresWP'] ) ? $plugin_data['RequiresWP'] : null;

        $compatible_php = is_php_version_compatible( $requires_php );
        $compatible_wp  = is_wp_version_compatible( $requires_wp );

        if ( 'mustuse' === $context ) {
            $is_active = true;
        } elseif ( 'dropins' === $context ) {
            $dropins     = _get_dropins();
            $plugin_name = $plugin_file;

            if ( $plugin_file !== $plugin_data['Name'] ) {
                $plugin_name .= '<br />' . $plugin_data['Name'];
            }

            
'<code>index.php</code>',
                    __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ),
                    '<code>Template</code>',
                    '<code>style.css</code>'
                )
            );
        }

        $requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
        $requires_wp  = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null;

        if ( ! is_php_version_compatible( $requires_php ) ) {
            $error = sprintf(
                /* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */
                __( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ),
                PHP_VERSION,
                $requires_php
            );

            return new WP_Error( 'incompatible_php_required_version', $this->strings['incompatible_archive']$error );
        }
        if ( ! is_wp_version_compatible( $requires_wp ) ) {
            $error = sprintf(
                

function validate_theme_requirements( $stylesheet ) {
    $theme = wp_get_theme( $stylesheet );

    $requirements = array(
        'requires'     => ! empty( $theme->get( 'RequiresWP' ) ) ? $theme->get( 'RequiresWP' ) : '',
        'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '',
    );

    $compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
    $compatible_php = is_php_version_compatible( $requirements['requires_php'] );

    if ( ! $compatible_wp && ! $compatible_php ) {
        return new WP_Error(
            'theme_wp_php_incompatible',
            sprintf(
                /* translators: %s: Theme name. */
                _x( '<strong>Error:</strong> Current WordPress and PHP versions do not meet minimum requirements for %s.', 'theme' ),
                $theme->display( 'Name' )
            )
        );
    } elseif ( ! $compatible_php ) {
        

    );

    if ( is_network_admin() || ! is_multisite() ) {
        if ( is_network_admin() ) {
            $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
        } else {
            $active_class = is_plugin_active( $file ) ? ' active' : '';
        }

        $requires_php   = isset( $response->requires_php ) ? $response->requires_php : null;
        $compatible_php = is_php_version_compatible( $requires_php );
        $notice_type    = $compatible_php ? 'notice-warning' : 'notice-error';

        printf(
            '<tr class="plugin-update-tr%s" id="%s" data-slug="%s" data-plugin="%s">' .
            '<td colspan="%s" class="plugin-update colspanchange">' .
            '<div class="update-message notice inline %s notice-alt"><p>',
            $active_class,
            esc_attr( $plugin_slug . '-update' ),
            esc_attr( $plugin_slug ),
            esc_attr( $file ),
            esc_attr( $wp_list_table->get_column_count() ),
            
$theme->type = $theme_action;
                }

                // Set active based on customized theme.                 $theme->active = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme->slug );

                // Map available theme properties to installed theme properties.                 $theme->id            = $theme->slug;
                $theme->screenshot    = array( $theme->screenshot_url );
                $theme->authorAndUri  = wp_kses( $theme->author['display_name']$themes_allowedtags );
                $theme->compatibleWP  = is_wp_version_compatible( $theme->requires ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName                 $theme->compatiblePHP = is_php_version_compatible( $theme->requires_php ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
                if ( isset( $theme->parent ) ) {
                    $theme->parent = $theme->parent['slug'];
                } else {
                    $theme->parent = false;
                }
                unset( $theme->slug );
                unset( $theme->screenshot_url );
                unset( $theme->author );
            } // End foreach().         } // End if().
echo apply_filters( 'install_theme_overwrite_comparison', $table$current_theme_data$new_theme_data );

        $install_actions = array();
        $can_update      = true;

        $blocked_message  = '<p>' . esc_html__( 'The theme cannot be updated due to the following:' ) . '</p>';
        $blocked_message .= '<ul class="ul-disc">';

        $requires_php = isset( $new_theme_data['RequiresPHP'] ) ? $new_theme_data['RequiresPHP'] : null;
        $requires_wp  = isset( $new_theme_data['RequiresWP'] ) ? $new_theme_data['RequiresWP'] : null;

        if ( ! is_php_version_compatible( $requires_php ) ) {
            $error = sprintf(
                /* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */
                __( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ),
                PHP_VERSION,
                $requires_php
            );

            $blocked_message .= '<li>' . esc_html( $error ) . '</li>';
            $can_update       = false;
        }

        

do_action( 'customize_controls_head' );
?> </head> <body class="<?php echo esc_attr( $body_class ); ?>"> <div class="wp-full-overlay expanded"> <form id="customize-controls" class="wrap wp-full-overlay-sidebar"> <div id="customize-header-actions" class="wp-full-overlay-header"> <?php             $compatible_wp  = is_wp_version_compatible( $wp_customize->theme()->get( 'RequiresWP' ) );
            $compatible_php = is_php_version_compatible( $wp_customize->theme()->get( 'RequiresPHP' ) );
            ?> <?php if ( $compatible_wp && $compatible_php ) : ?> <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?> <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" > <?php submit_button( $save_text, 'primary save', 'save', false ); ?> <button id="publish-settings" class="publish-settings button-primary button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button> </div> <?php else : ?> <?php $save_text = _x( 'Cannot Activate', 'theme' ); ?> <div id="customize-save-button-wrapper" class="customize-save-button-wrapper disabled" > <button class="button button-primary disabled" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled><?php echo $save_text; ?></button> </div>

            }
        }

        if ( empty( $this->new_plugin_data ) ) {
            return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive']__( 'No valid plugins were found.' ) );
        }

        $requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
        $requires_wp  = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null;

        if ( ! is_php_version_compatible( $requires_php ) ) {
            $error = sprintf(
                /* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
                __( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
                PHP_VERSION,
                $requires_php
            );

            return new WP_Error( 'incompatible_php_required_version', $this->strings['incompatible_archive']$error );
        }

        if ( ! is_wp_version_compatible( $requires_wp ) ) {
            
$prepared_themes[ $slug ] = array(
            'id'             => $slug,
            'name'           => $theme->display( 'Name' ),
            'screenshot'     => array( $theme->get_screenshot() ), // @todo Multiple screenshots.             'description'    => $theme->display( 'Description' ),
            'author'         => $theme->display( 'Author', false, true ),
            'authorAndUri'   => $theme->display( 'Author' ),
            'tags'           => $theme->display( 'Tags' ),
            'version'        => $theme->get( 'Version' ),
            'compatibleWP'   => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
            'compatiblePHP'  => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ),
            'updateResponse' => array(
                'compatibleWP'  => is_wp_version_compatible( $update_requires_wp ),
                'compatiblePHP' => is_php_version_compatible( $update_requires_php ),
            ),
            'parent'         => $parent,
            'active'         => $slug === $current_theme,
            'hasUpdate'      => isset( $updates[ $slug ] ),
            'hasPackage'     => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
            'update'         => get_theme_update_available( $theme ),
            'autoupdate'     => array(
                'enabled'   => $auto_update || $auto_update_forced,
                
array(
                'rating' => $theme->rating,
                'type'   => 'percent',
                'number' => $theme->num_ratings,
                'echo'   => false,
            )
        );

        $theme->num_ratings    = number_format_i18n( $theme->num_ratings );
        $theme->preview_url    = set_url_scheme( $theme->preview_url );
        $theme->compatible_wp  = is_wp_version_compatible( $theme->requires );
        $theme->compatible_php = is_php_version_compatible( $theme->requires_php );
    }

    wp_send_json_success( $api );
}

/** * Applies [embed] Ajax handlers to a string. * * @since 4.0.0 * * @global WP_Post $post Global post object. * @global WP_Embed $wp_embed Embed API instance. * @global WP_Scripts $wp_scripts * @global int $content_width */
Home | Imprint | This part of the site doesn't use cookies.