functions.php (1943B)
1 <?php 2 3 /** 4 * Sets up theme defaults and registers support for various WordPress features. 5 * 6 */ 7 8 if ( ! defined('MATERIALIS_THEME_REQUIRED_PHP_VERSION')) { 9 define('MATERIALIS_THEME_REQUIRED_PHP_VERSION', '5.3.0'); 10 } 11 12 add_action('after_switch_theme', 'materialis_check_php_version'); 13 14 function materialis_check_php_version() 15 { 16 // Compare versions. 17 if (version_compare(phpversion(), MATERIALIS_THEME_REQUIRED_PHP_VERSION, '<')) : 18 // Theme not activated info message. 19 add_action('admin_notices', 'materialis_php_version_notice'); 20 21 22 // Switch back to previous theme. 23 switch_theme(get_option('theme_switched')); 24 25 return false; 26 endif; 27 } 28 29 function materialis_php_version_notice() 30 { 31 ?> 32 <div class="notice notice-alt notice-error notice-large"> 33 <h4><?php esc_html_e('Materialis theme activation failed!', 'materialis'); ?></h4> 34 <p> 35 <?php printf(esc_html__('You need to update your PHP version to use the %s.', 'materialis'), "<strong>Materialis</strong>"); ?> <br/> 36 <?php printf( 37 // Translators: 1 is the users PHP version and 2 is the required PHP version. 38 esc_html__('Current PHP version is %1$s and the minimum required version is %2$s', 'materialis'), 39 '<strong>' . phpversion() . '</strong>', 40 '<strong>' . MATERIALIS_THEME_REQUIRED_PHP_VERSION . '</strong>' 41 ); ?> 42 </p> 43 </div> 44 <?php 45 } 46 47 if (version_compare(phpversion(), MATERIALIS_THEME_REQUIRED_PHP_VERSION, '>=')) { 48 require_once get_template_directory() . "/inc/functions.php"; 49 50 51 52 if ( ! materialis_can_show_cached_value("materialis_cached_kirki_style_materialis")) { 53 54 if ( ! materialis_skip_customize_register()) { 55 do_action("materialis_customize_register_options"); 56 } 57 } 58 59 } else { 60 add_action('admin_notices', 'materialis_php_version_notice'); 61 }