Permalink
Browse files

Show an admin notice if WP is older than 3.5

  • Loading branch information...
1 parent 3ea7a2f commit a823f5d6472fd739d0fa1e3796bfddc98bea602d @nb nb committed Jan 22, 2013
Showing with 25 additions and 0 deletions.
  1. +20 −0 liveblog.php
  2. +5 −0 templates/old-wp-notice.php
View
@@ -36,6 +36,7 @@
const version = '1.3-alpha';
const rewrites_version = 1;
+ const min_wp_version = '3.5';
const key = 'liveblog';
const url_endpoint = 'liveblog';
const edit_cap = 'publish_posts';
@@ -64,13 +65,27 @@
public static function load() {
load_plugin_textdomain( 'liveblog', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
+ if ( self::is_wp_too_old() ) {
+ self::add_old_wp_notice();
+ return;
+ }
self::includes();
self::add_actions();
self::add_filters();
self::add_admin_actions();
self::register_embed_handlers();
}
+ private static function add_old_wp_notice() {
+ add_action( 'admin_notices', array( 'WPCOM_Liveblog', 'show_old_wp_notice' ) );
+ }
+
+ public static function show_old_wp_notice() {
+ global $wp_version;
+ $min_version = self::min_wp_version;
+ echo self::get_template_part( 'old-wp-notice.php', compact( 'wp_version', 'min_version' ) );
+ }
+
/**
* Include the necessary files
*/
@@ -853,6 +868,11 @@ private static function max_upload_size() {
return $bytes;
}
+
+ private static function is_wp_too_old() {
+ global $wp_version;
+ return version_compare( $wp_version, self::min_wp_version, '<' );
+ }
}
/**
@@ -0,0 +1,5 @@
+<div class="error">
+<p>
+<?php printf( __( 'Your current WordPress is version %1$s, which is too old to run the liveblog plugin. The minimum required version is %2$s. Please, either <a href="%3$s">update WordPress</a>, or <a href="%4$s">deactivate the liveblog plugin</a>.', 'liveblog' ), $wp_version, $min_version, admin_url( 'update-core.php' ), admin_url( 'plugins.php#liveblog' ) ); ?>
+</p>
+</div>

0 comments on commit a823f5d

Please sign in to comment.