Advertisement
Guest User

Untitled

a guest
Sep 30th, 2013
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2. class Shortcodes_Ultimate_Requirements {
  3.  
  4.     /**
  5.      * Constructor
  6.      */
  7.     function __construct() {
  8.         add_action( 'shutdown',      array( __CLASS__, 'wp_footer_check' ) );
  9.         add_action( 'admin_notices', array( __CLASS__, 'wp_footer_notice' ) );
  10.         add_action( 'su/activation', array( __CLASS__, 'php_wp' ) );
  11.     }
  12.  
  13.     public static function wp_footer_check() {
  14.         if ( is_admin() ) return;
  15.         if ( did_action( 'wp_footer' ) < 1 ) update_option( 'su_no_wp_footer', true );
  16.         else delete_option( 'su_no_wp_footer' );
  17.     }
  18.  
  19.     public static function wp_footer_notice() {
  20.         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>';
  21.     }
  22.  
  23.     /**
  24.      * Check PHP and WordPress versions
  25.      */
  26.     public static function php_wp() {
  27.         // Prepare versions
  28.         $min_wp = '3.5';
  29.         $min_php = '5.1';
  30.         $wp = get_bloginfo( 'version' );
  31.         $php = phpversion();
  32.         // Load textdomain
  33.         load_plugin_textdomain( 'shortcodes-ultimate', false, dirname( plugin_basename( SU_PLUGIN_FILE ) ), '/languages/' );
  34.         // Prepare messages
  35.         $message_wp = sprintf( __( '<h1>Oops! Plugin not activated&hellip;</h1> <p>Shortcodes Ultimate is not fully compatible with your version of WordPress (%s).<br />Reccomended WordPress version &ndash; %s (or higher).</p><a href="%s">&larr; Return to the plugins screen</a> <a href="%s"%s>Continue and activate anyway &rarr;</a>', 'su' ), $wp, $min_wp, network_admin_url( 'plugins.php?deactivate=true' ), $_SERVER['REQUEST_URI'] . '&continue=true', ' style="float:right;font-weight:bold"' );
  36.         $message_php = sprintf( __( '<h1>Oops! Plugin not activated&hellip;</h1> <p>Shortcodes Ultimate is not fully compatible with your PHP version (%s).<br />Reccomended PHP version &ndash; %s (or higher).</p><a href="%s">&larr; Return to the plugins screen</a> <a href="%s"%s>Continue and activate anyway &rarr;</a>', 'su' ), $php, $min_php, network_admin_url( 'plugins.php?deactivate=true' ), $_SERVER['REQUEST_URI'] . '&continue=true', ' style="float:right;font-weight:bold"' );
  37.         // Check Forced activation
  38.         if ( isset( $_GET['continue'] ) ) return;
  39.         // WP version is too low
  40.         if ( version_compare( $min_wp, $wp, '>' ) ) {
  41.             deactivate_plugins( plugin_basename( SU_PLUGIN_FILE ) );
  42.             wp_die( $message_wp );
  43.         }
  44.         // PHP version is too low
  45.         elseif ( version_compare( $min_php, $php, '>' ) ) {
  46.             deactivate_plugins( plugin_basename( SU_PLUGIN_FILE ) );
  47.             wp_die( $message_php );
  48.         }
  49.     }
  50.  
  51. }
  52.  
  53. new Shortcodes_Ultimate_Requirements;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement