Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Shortcodes_Ultimate_Requirements {
- /**
- * Constructor
- */
- function __construct() {
- add_action( 'shutdown', array( __CLASS__, 'wp_footer_check' ) );
- add_action( 'admin_notices', array( __CLASS__, 'wp_footer_notice' ) );
- add_action( 'su/activation', array( __CLASS__, 'php_wp' ) );
- }
- public static function wp_footer_check() {
- if ( is_admin() ) return;
- if ( did_action( 'wp_footer' ) < 1 ) update_option( 'su_no_wp_footer', true );
- else delete_option( 'su_no_wp_footer' );
- }
- public static function wp_footer_notice() {
- if ( get_option( 'su_no_wp_footer' ) ) echo '<div class="error"><p>' . __( '<b>Shortcodes Ultimate:</b> Your current theme does not use wp_footer tag. Shortcodes will not work properly. Please add the wp_footer in the footer of your theme.', 'su' ) . ' <a href="http://codex.wordpress.org/Function_Reference/wp_footer" target="_blank">' . __( 'Learn more', 'su' ) . '</a>.' . '</p></div>';
- }
- /**
- * Check PHP and WordPress versions
- */
- public static function php_wp() {
- // Prepare versions
- $min_wp = '3.5';
- $min_php = '5.1';
- $wp = get_bloginfo( 'version' );
- $php = phpversion();
- // Load textdomain
- load_plugin_textdomain( 'shortcodes-ultimate', false, dirname( plugin_basename( SU_PLUGIN_FILE ) ), '/languages/' );
- // Prepare messages
- $message_wp = sprintf( __( '<h1>Oops! Plugin not activated…</h1> <p>Shortcodes Ultimate is not fully compatible with your version of WordPress (%s).<br />Reccomended WordPress version – %s (or higher).</p><a href="%s">← Return to the plugins screen</a> <a href="%s"%s>Continue and activate anyway →</a>', 'su' ), $wp, $min_wp, network_admin_url( 'plugins.php?deactivate=true' ), $_SERVER['REQUEST_URI'] . '&continue=true', ' style="float:right;font-weight:bold"' );
- $message_php = sprintf( __( '<h1>Oops! Plugin not activated…</h1> <p>Shortcodes Ultimate is not fully compatible with your PHP version (%s).<br />Reccomended PHP version – %s (or higher).</p><a href="%s">← Return to the plugins screen</a> <a href="%s"%s>Continue and activate anyway →</a>', 'su' ), $php, $min_php, network_admin_url( 'plugins.php?deactivate=true' ), $_SERVER['REQUEST_URI'] . '&continue=true', ' style="float:right;font-weight:bold"' );
- // Check Forced activation
- if ( isset( $_GET['continue'] ) ) return;
- // WP version is too low
- if ( version_compare( $min_wp, $wp, '>' ) ) {
- deactivate_plugins( plugin_basename( SU_PLUGIN_FILE ) );
- wp_die( $message_wp );
- }
- // PHP version is too low
- elseif ( version_compare( $min_php, $php, '>' ) ) {
- deactivate_plugins( plugin_basename( SU_PLUGIN_FILE ) );
- wp_die( $message_php );
- }
- }
- }
- new Shortcodes_Ultimate_Requirements;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement