| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Polylang activation / de-activation class |
| 8 | 5 | * |
| @@ -10,68 +7,35 @@ | ||
| 10 | 7 | */ |
| 11 | 8 | class PLL_Install extends PLL_Install_Base { |
| 12 | 9 | |
| 13 | 10 | /** |
| 14 | - * Checks min PHP and WP version, displays a notice if a requirement is not met. | |
| 11 | + * Plugin activation for multisite | |
| 15 | 12 | * |
| 16 | - * @since 2.6.7 | |
| 13 | + * @since 0.1 | |
| 14 | + * | |
| 15 | + * @param bool $networkwide | |
| 17 | 16 | */ |
| 18 | - public function can_activate() { | |
| 17 | + public function activate( $networkwide ) { | |
| 19 | 18 | global $wp_version; |
| 20 | 19 | |
| 21 | - if ( version_compare( PHP_VERSION, PLL_MIN_PHP_VERSION, '<' ) ) { | |
| 22 | - add_action( 'admin_notices', array( $this, 'php_version_notice' ) ); | |
| 23 | - return false; | |
| 24 | - } | |
| 20 | + Polylang::define_constants(); | |
| 25 | 21 | |
| 22 | + load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); // plugin i18n | |
| 23 | + | |
| 26 | 24 | if ( version_compare( $wp_version, PLL_MIN_WP_VERSION, '<' ) ) { |
| 27 | - add_action( 'admin_notices', array( $this, 'wp_version_notice' ) ); | |
| 28 | - return false; | |
| 25 | + die( | |
| 26 | + sprintf( | |
| 27 | + '<p style = "font-family: sans-serif; font-size: 12px; color: #333; margin: -5px">%s</p>', | |
| 28 | + sprintf( | |
| 29 | + /* translators: %1$s and %2$s are WordPress version numbers */ | |
| 30 | + esc_html__( 'You are using WordPress %1$s. Polylang requires at least WordPress %2$s.', 'polylang' ), | |
| 31 | + esc_html( $wp_version ), | |
| 32 | + PLL_MIN_WP_VERSION | |
| 33 | + ) | |
| 34 | + ) | |
| 35 | + ); | |
| 29 | 36 | } |
| 30 | - | |
| 31 | - return true; | |
| 32 | - } | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * Displays a notice if PHP min version is not met. | |
| 36 | - * | |
| 37 | - * @since 2.6.7 | |
| 38 | - */ | |
| 39 | - public function php_version_notice() { | |
| 40 | - load_plugin_textdomain( 'polylang' ); // Plugin i18n. | |
| 41 | - | |
| 42 | - printf( | |
| 43 | - '<div class="error"><p>%s</p></div>', | |
| 44 | - sprintf( | |
| 45 | - /* translators: 1: Plugin name 2: Current PHP version 3: Required PHP version */ | |
| 46 | - esc_html__( '%1$s has deactivated itself because you are using an old version of PHP. You are using using PHP %2$s. %1$s requires PHP %3$s.', 'polylang' ), | |
| 47 | - esc_html( POLYLANG ), | |
| 48 | - PHP_VERSION, | |
| 49 | - esc_html( PLL_MIN_PHP_VERSION ) | |
| 50 | - ) | |
| 51 | - ); | |
| 52 | - } | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * Displays a notice if WP min version is not met. | |
| 56 | - * | |
| 57 | - * @since 2.6.7 | |
| 58 | - */ | |
| 59 | - public function wp_version_notice() { | |
| 60 | - global $wp_version; | |
| 61 | - | |
| 62 | - load_plugin_textdomain( 'polylang' ); // Plugin i18n. | |
| 63 | - | |
| 64 | - printf( | |
| 65 | - '<div class="error"><p>%s</p></div>', | |
| 66 | - sprintf( | |
| 67 | - /* translators: 1: Plugin name 2: Current WordPress version 3: Required WordPress version */ | |
| 68 | - esc_html__( '%1$s has deactivated itself because you are using an old version of WordPress. You are using using WordPress %2$s. %1$s requires at least WordPress %3$s.', 'polylang' ), | |
| 69 | - esc_html( POLYLANG ), | |
| 70 | - esc_html( $wp_version ), | |
| 71 | - esc_html( PLL_MIN_WP_VERSION ) | |
| 72 | - ) | |
| 73 | - ); | |
| 37 | + $this->do_for_all_blogs( 'activate', $networkwide ); | |
| 74 | 38 | } |
| 75 | 39 | |
| 76 | 40 | /** |
| 77 | 41 | * Get default Polylang options |