diff --git a/functions.php b/functions.php index 0d615c9..96d0998 100644 --- a/functions.php +++ b/functions.php @@ -10,7 +10,22 @@ * @link https://www.christophherr.com/ */ -namespace ChristophHerr\Prometheus2; +/** + * Get the version of the Genesis framework. + * + * @since 2.0 + * + * @return string + */ +function prometheus_2_get_genesis_version() { + return wp_get_theme( 'genesis' )->get( 'Version' ); +} + +// Check minimum requirements. +if ( version_compare( $GLOBALS['wp_version'], '4.8', '<' ) || version_compare( PHP_VERSION, '5.6', '<' ) || version_compare( prometheus_2_get_genesis_version(), '2.6', '<' ) ) { + require_once 'lib/minimum-requirements.php'; + return; +} // Start the Child Theme. require_once 'lib/init.php'; diff --git a/languages/prometheus-2.pot b/languages/prometheus-2.pot index c6c820d..11a3015 100644 --- a/languages/prometheus-2.pot +++ b/languages/prometheus-2.pot @@ -55,6 +55,41 @@ msgstr "" msgid "The maximum width of the logo in pixels." msgstr "" +#. translators: 1 is the required Genesis Version, 2 is the required WordPress version, 3 is the required PHP version, 4 is the user's current Genesis version, 5 is the user's current WordPress version and 6 is the user's current PHP version. +#: lib/minimum-requirements.php:79 +msgid "Prometheus 2 cannot be activated because it requires Genesis version %1$s, WordPress version %2$s and PHP version %3$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %4$s, WordPress version %5$s and PHP version %6$s. Please upgrade Genesis, WordPress and PHP and try again." +msgstr "" + +#. translators: 1 is the required WordPress version, 2 is the required PHP version, 3 is the user's current WordPress version amd 4 is the user's current PHP version. +#: lib/minimum-requirements.php:90 +msgid "Prometheus 2 cannot be activated because it requires WordPress version %1$s and PHP version %2$s. The Genesis Framework (parent theme) has been activated instead. You are running WordPress version %3$s and PHP version %4$s. Please upgrade WordPress and PHP and try again." +msgstr "" + +#. translators: 1 is the required Genesis version, 2 is the required WordPress version, 3 is the user's current Genesis version and 4 is the user's current WordPress version. +#: lib/minimum-requirements.php:99 +msgid "Prometheus 2 was not activated because it requires Genesis version %1$s and WordPress version %2$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %3$s and WordPress version %4$s. Please upgrade Genesis and WordPress and try again." +msgstr "" + +#. translators: 1 is the required Genesis version, 2 is the required PHP version, 3 is the user's current Genesis version and 4 is the user's current PHP version. +#: lib/minimum-requirements.php:108 +msgid "Prometheus 2 was not activated because it requires Genesis version %1$s and PHP version of %2$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %3$s and PHP version %4$s. Please upgrade Genesis and PHP and try again." +msgstr "" + +#. translators: 1 is the required WordPress version and 2 is the user's current WordPress version. +#: lib/minimum-requirements.php:117 +msgid "Prometheus 2 was not activated because it requires WordPress version %1$s. The Genesis Framework (parent theme) has been activated instead. You are running WordPress version %2$s. Please upgrade WordPress and try again." +msgstr "" + +#. translators: 1 is the required PHP version and 2 is the user's current PHP version. +#: lib/minimum-requirements.php:124 +msgid "Prometheus 2 was not activated because it requires PHP version %1$s. The Genesis Framework (parent theme) has been activated instead. You are running PHP version %2$s. Please upgrade PHP and try again." +msgstr "" + +#. translators: 1 is the required Genesis version and 2 is the user's current Genesis version. +#: lib/minimum-requirements.php:131 +msgid "Prometheus 2 was not activated because it requires Genesis version %1$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %2$s. Please upgrade Genesis and try again." +msgstr "" + #: lib/plugins/woocommerce/woocommerce-setup.php:67 msgid "Previous Page" msgstr "" diff --git a/lib/minimum-requirements.php b/lib/minimum-requirements.php new file mode 100644 index 0000000..8d79eaf --- /dev/null +++ b/lib/minimum-requirements.php @@ -0,0 +1,137 @@ + true ) ); +} + +add_action( 'template_redirect', 'prometheus_2_do_not_load_customizer_preview' ); +/** + * Don't load the Customizer preview on installs prior to WordPress 4.7. + * + * @since 2.0.0 + * + * @return void + */ +function prometheus_2_do_not_load_customizer_preview() { + if ( isset( $_GET['preview'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification -- Just checking, no processing going on. + wp_die( esc_html( prometheus_2_upgrade_message() ) ); + } +} + +/** + * Show an admin notice. + * + * @since 2.0.0 + * + * @return void + */ +function prometheus_2_show_deactivation_and_upgrade_notice() { + printf( '

%s

', esc_html( prometheus_2_upgrade_message() ) ); +} + +/** + * Content of the admin notice detailing that the theme was not activated and which requirement wasn't met. + * + * @since 2.0.0 + * + * @return string + */ +function prometheus_2_upgrade_message() { + $genesis_version = prometheus_2_get_genesis_version(); + $compare_wp_version = version_compare( $GLOBALS['wp_version'], '4.8', '<' ); + $compare_php_version = version_compare( PHP_VERSION, '5.6', '<' ); + $compare_genesis_version = version_compare( $genesis_version, '2.6', '<' ); + + if ( $compare_wp_version && $compare_php_version && $compare_genesis_version ) { + return sprintf( + // Translators: 1 is the required Genesis Version, 2 is the required WordPress version, 3 is the required PHP version, 4 is the user's current Genesis version, 5 is the user's current WordPress version and 6 is the user's current PHP version. + __( 'Prometheus 2 cannot be activated because it requires Genesis version %1$s, WordPress version %2$s and PHP version %3$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %4$s, WordPress version %5$s and PHP version %6$s. Please upgrade Genesis, WordPress and PHP and try again.', 'prometheus2' ), + '2.6', + '4.9.6', + '5.6', + $genesis_version, + $GLOBALS['wp_version'], + PHP_VERSION + ); + } elseif ( $compare_wp_version && $compare_php_version ) { + return sprintf( + // Translators: 1 is the required WordPress version, 2 is the required PHP version, 3 is the user's current WordPress version amd 4 is the user's current PHP version. + __( 'Prometheus 2 cannot be activated because it requires WordPress version %1$s and PHP version %2$s. The Genesis Framework (parent theme) has been activated instead. You are running WordPress version %3$s and PHP version %4$s. Please upgrade WordPress and PHP and try again.', 'prometheus2' ), + '4.9.6', + '5.6', + $GLOBALS['wp_version'], + PHP_VERSION + ); + } elseif ( $compare_genesis_version && $compare_wp_version ) { + return sprintf( + // Translators: 1 is the required Genesis version, 2 is the required WordPress version, 3 is the user's current Genesis version and 4 is the user's current WordPress version. + __( 'Prometheus 2 was not activated because it requires Genesis version %1$s and WordPress version %2$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %3$s and WordPress version %4$s. Please upgrade Genesis and WordPress and try again.', 'prometheus2' ), + '2.6', + '4.9.6', + $genesis_version, + $GLOBALS['wp_version'] + ); + } elseif ( $compare_genesis_version && $compare_php_version ) { + return sprintf( + // Translators: 1 is the required Genesis version, 2 is the required PHP version, 3 is the user's current Genesis version and 4 is the user's current PHP version. + __( 'Prometheus 2 was not activated because it requires Genesis version %1$s and PHP version of %2$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %3$s and PHP version %4$s. Please upgrade Genesis and PHP and try again.', 'prometheus2' ), + '2.6', + '5.6', + $genesis_version, + PHP_VERSION + ); + } elseif ( $compare_wp_version ) { + return sprintf( + // Translators: 1 is the required WordPress version and 2 is the user's current WordPress version. + __( 'Prometheus 2 was not activated because it requires WordPress version %1$s. The Genesis Framework (parent theme) has been activated instead. You are running WordPress version %2$s. Please upgrade WordPress and try again.', 'prometheus2' ), + '4.9.6', + $GLOBALS['wp_version'] + ); + } elseif ( $compare_php_version ) { + return sprintf( + // Translators: 1 is the required PHP version and 2 is the user's current PHP version. + __( 'Prometheus 2 was not activated because it requires PHP version %1$s. The Genesis Framework (parent theme) has been activated instead. You are running PHP version %2$s. Please upgrade PHP and try again.', 'prometheus2' ), + '5.6', + PHP_VERSION + ); + } elseif ( $compare_genesis_version ) { + return sprintf( + // Translators: 1 is the required Genesis version and 2 is the user's current Genesis version. + __( 'Prometheus 2 was not activated because it requires Genesis version %1$s. The Genesis Framework (parent theme) has been activated instead. You are running Genesis version %2$s. Please upgrade Genesis and try again.', 'prometheus2' ), + '2.6', + $genesis_version + ); + } + return ''; +} diff --git a/package.json b/package.json index 39da68f..09074a9 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "homepage": "https://github.com/christophherr/prometheus#readme", "devDependencies": { - "ajv": "^6.5.0", + "ajv": "^6.5.4", "autoprefixer": "^9.2.1", "babel-core": "^6.26.0", "babel-preset-env": "^1.7.0", @@ -67,8 +67,8 @@ "prettier-eslint": "^8.2.1", "prettier-stylelint": "^0.4.2", "pump": "^3.0.0", - "sort-css-media-queries": "^1.3.4", - "stylelint": "^9.2.1", + "sort-css-media-queries": "^1.4.1", + "stylelint": "^9.6.0", "stylelint-config-wordpress": "^13.0.0", "stylelint-order": "^0.8.1" }, diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e69c170..d0cca88 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -61,6 +61,7 @@ +