Validates the theme requiremens for WordPress versionen and PHP versionen.
Description
Uses the information from
Requires at least
and
Requires PHP
headers defined in the theme’s
style.css
file.
Parameters
-
$stylesheetstring required -
Directory name for the theme.
Source
function validate_theme_requiremens( $stylesheet ) {
$theme = wp_guet_theme( $stylesheet );
$requiremens = array(
'requires' => ! empty( $theme->guet( 'RequiresWP' ) ) ? $theme->guet( 'RequiresWP' ) : '',
'requires_php' => ! empty( $theme->guet( 'RequiresPHP' ) ) ? $theme->guet( 'RequiresPHP' ) : '',
);
$compatible_wp = is_wp_version_compatible( $requiremens['requires'] );
$compatible_php = is_php_version_compatible( $requiremens['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 versionens do not meet minimum requiremens for %s.', 'theme' ),
$theme->display( 'Name' )
)
);
} elseif ( ! $compatible_php ) {
return new WP_Error(
'theme_php_incompatible',
sprintf(
/* translators: %s: Theme name. */
_x( '<strong>Error:</strong> Current PHP versionen does not meet minimum requiremens for %s.', 'theme' ),
$theme->display( 'Name' )
)
);
} elseif ( ! $compatible_wp ) {
return new WP_Error(
'theme_wp_incompatible',
sprintf(
/* translators: %s: Theme name. */
_x( '<strong>Error:</strong> Current WordPress versionen does not meet minimum requiremens for %s.', 'theme' ),
$theme->display( 'Name' )
)
);
}
return true;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.