Skip to content

Commit 4df7139

Browse files
Move PHP compatibility check.
1 parent 9b710a4 commit 4df7139

File tree

2 files changed

+61
-44
lines changed

2 files changed

+61
-44
lines changed

bootstrap/compatibility-check.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* PHP compatibility check.
4+
*
5+
* @since 1.15.0
6+
*
7+
* @package BigBox
8+
* @category Bootstrap
9+
* @author Spencer Finnell
10+
*/
11+
12+
if ( ! defined( 'ABSPATH' ) ) {
13+
exit; // Exit if accessed directly.
14+
}
15+
16+
// Minimum PHP version.
17+
define( 'BIGBOX_PHP_VERSION', '7.0.0' );
18+
19+
// Do not allow the theme to be active if the PHP version is not met.
20+
if ( version_compare( PHP_VERSION, BIGBOX_PHP_VERSION, '<' ) ) {
21+
add_action( 'admin_notices', 'bigbox_php_admin_notices' );
22+
23+
if ( is_admin() ) {
24+
return;
25+
}
26+
27+
wp_die( esc_html( bigbox_get_php_notice_text() ) ); // WPCS: XSS okay.
28+
}
29+
30+
/**
31+
* Output a notice that the minimum PHP version is not met.
32+
*
33+
* @since 1.10.0
34+
*/
35+
function bigbox_php_admin_notices() {
36+
echo '<div class="notice notice-error"><p>' . esc_html( bigbox_get_php_notice_text() ) . '</p></div>'; // WPCS: XSS okay.
37+
}
38+
39+
/**
40+
* PHP upgrade notice text.
41+
*
42+
* @since 1.10.0
43+
*
44+
* @return string
45+
*/
46+
function bigbox_get_php_notice_text() {
47+
/**
48+
* Filter text shown when current PHP version does not meet requirements.
49+
*
50+
* @since 1.10.0
51+
*
52+
* @param string $text Text to display.
53+
*/
54+
return apply_filters(
55+
'bigbox_php_notice_text',
56+
/* translators: %s Minimum PHP version required for theme to run. */
57+
sprintf( __( 'BigBox requires PHP version %s or above to be active. Please contact your web host to upgrade.', 'bigbox' ), esc_attr( BIGBOX_PHP_VERSION ) )
58+
);
59+
}

functions.php

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,8 @@
1616
// Current version -- automatically updated on release.
1717
define( 'BIGBOX_VERSION', '%BIGBOX_VERSION%' );
1818

19-
// Minimum PHP version.
20-
define( 'BIGBOX_PHP_VERSION', '7.0.0' );
21-
22-
// Do not allow the theme to be active if the PHP version is not met.
23-
if ( version_compare( PHP_VERSION, BIGBOX_PHP_VERSION, '<' ) ) {
24-
add_action( 'admin_notices', 'bigbox_php_admin_notices' );
25-
26-
if ( is_admin() ) {
27-
return;
28-
}
29-
30-
wp_die( esc_html( bigbox_get_php_notice_text() ) ); // WPCS: XSS okay.
31-
}
32-
33-
/**
34-
* Output a notice that the minimum PHP version is not met.
35-
*
36-
* @since 1.10.0
37-
*/
38-
function bigbox_php_admin_notices() {
39-
echo '<div class="notice notice-error"><p>' . esc_html( bigbox_get_php_notice_text() ) . '</p></div>'; // WPCS: XSS okay.
40-
}
41-
42-
/**
43-
* PHP upgrade notice text.
44-
*
45-
* @since 1.10.0
46-
*
47-
* @return string
48-
*/
49-
function bigbox_get_php_notice_text() {
50-
/**
51-
* Filter text shown when current PHP version does not meet requirements.
52-
*
53-
* @since 1.10.0
54-
*
55-
* @param string $text Text to display.
56-
*/
57-
return apply_filters(
58-
'bigbox_php_notice_text',
59-
/* translators: %s Minimum PHP version required for theme to run. */
60-
sprintf( __( 'BigBox requires PHP version %s or above to be active. Please contact your web host to upgrade.', 'bigbox' ), esc_attr( BIGBOX_PHP_VERSION ) )
61-
);
62-
}
19+
// Compatibility check.
20+
require_once __DIR__ . '/bootstrap/compatibility-check.php';
6321

6422
// Composer autoloader.
6523
require_once __DIR__ . '/bootstrap/autoload.php';

0 commit comments

Comments
 (0)