| @@ -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,82 +7,43 @@ | ||
| 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 | |
| 17 | 14 | * |
| 18 | - * @return bool | |
| 15 | + * @param bool $networkwide | |
| 19 | 16 | */ |
| 20 | - public function can_activate() { | |
| 17 | + public function activate( $networkwide ) { | |
| 21 | 18 | global $wp_version; |
| 22 | 19 | |
| 23 | - if ( version_compare( PHP_VERSION, PLL_MIN_PHP_VERSION, '<' ) ) { | |
| 24 | - add_action( 'admin_notices', array( $this, 'php_version_notice' ) ); | |
| 25 | - return false; | |
| 26 | - } | |
| 20 | + Polylang::define_constants(); | |
| 27 | 21 | |
| 22 | + load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); // plugin i18n | |
| 23 | + | |
| 28 | 24 | if ( version_compare( $wp_version, PLL_MIN_WP_VERSION, '<' ) ) { |
| 29 | - add_action( 'admin_notices', array( $this, 'wp_version_notice' ) ); | |
| 30 | - 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 // phpcs:ignore WordPress.Security.EscapeOutput | |
| 33 | + ) | |
| 34 | + ) | |
| 35 | + ); | |
| 31 | 36 | } |
| 32 | - | |
| 33 | - return true; | |
| 37 | + $this->do_for_all_blogs( 'activate', $networkwide ); | |
| 34 | 38 | } |
| 35 | 39 | |
| 36 | 40 | /** |
| 37 | - * Displays a notice if PHP min version is not met. | |
| 38 | - * | |
| 39 | - * @since 2.6.7 | |
| 40 | - * | |
| 41 | - * @return void | |
| 42 | - */ | |
| 43 | - public function php_version_notice() { | |
| 44 | - load_plugin_textdomain( 'polylang' ); // Plugin i18n. | |
| 45 | - | |
| 46 | - printf( | |
| 47 | - '<div class="error"><p>%s</p></div>', | |
| 48 | - sprintf( | |
| 49 | - /* translators: 1: Plugin name 2: Current PHP version 3: Required PHP version */ | |
| 50 | - 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' ), | |
| 51 | - esc_html( POLYLANG ), | |
| 52 | - PHP_VERSION, | |
| 53 | - esc_html( PLL_MIN_PHP_VERSION ) | |
| 54 | - ) | |
| 55 | - ); | |
| 56 | - } | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * Displays a notice if WP min version is not met. | |
| 60 | - * | |
| 61 | - * @since 2.6.7 | |
| 62 | - * | |
| 63 | - * @return void | |
| 64 | - */ | |
| 65 | - public function wp_version_notice() { | |
| 66 | - global $wp_version; | |
| 67 | - | |
| 68 | - load_plugin_textdomain( 'polylang' ); // Plugin i18n. | |
| 69 | - | |
| 70 | - printf( | |
| 71 | - '<div class="error"><p>%s</p></div>', | |
| 72 | - sprintf( | |
| 73 | - /* translators: 1: Plugin name 2: Current WordPress version 3: Required WordPress version */ | |
| 74 | - 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' ), | |
| 75 | - esc_html( POLYLANG ), | |
| 76 | - esc_html( $wp_version ), | |
| 77 | - esc_html( PLL_MIN_WP_VERSION ) | |
| 78 | - ) | |
| 79 | - ); | |
| 80 | - } | |
| 81 | - | |
| 82 | - /** | |
| 83 | 41 | * Get default Polylang options |
| 84 | 42 | * |
| 85 | 43 | * @since 1.8 |
| 86 | 44 | * |
| 87 | - * @return array | |
| 45 | + * return array | |
| 88 | 46 | */ |
| 89 | 47 | public static function get_default_options() { |
| 90 | 48 | return array( |
| 91 | 49 | 'browser' => 1, // Default language for the front page is set by browser preference |
| @@ -107,10 +65,8 @@ | ||
| 107 | 65 | /** |
| 108 | 66 | * Plugin activation |
| 109 | 67 | * |
| 110 | 68 | * @since 0.5 |
| 111 | - * | |
| 112 | - * @return void | |
| 113 | 69 | */ |
| 114 | 70 | protected function _activate() { |
| 115 | 71 | if ( $options = get_option( 'polylang' ) ) { |
| 116 | 72 | // Check if we will be able to upgrade |
| @@ -138,10 +94,8 @@ | ||
| 138 | 94 | /** |
| 139 | 95 | * Plugin deactivation |
| 140 | 96 | * |
| 141 | 97 | * @since 0.5 |
| 142 | - * | |
| 143 | - * @return void | |
| 144 | 98 | */ |
| 145 | 99 | protected function _deactivate() { |
| 146 | 100 | delete_option( 'rewrite_rules' ); // Don't use flush_rewrite_rules at network activation. See #32471 |
| 147 | 101 | } |