PluginProbe
Polylang / 2.3.6
Polylang v2.3.6
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | install/install.php +29 -80 3.02.3.6 View file →
@@ -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,98 +7,54 @@
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( sprintf( '<p style = "font-family: sans-serif; font-size: 12px; color: #333; margin: -5px">%s</p>',
26 + /* translators: %1$s and %2$s are WordPress version numbers */
27 + sprintf( esc_html__( 'You are using WordPress %1$s. Polylang requires at least WordPress %2$s.', 'polylang' ),
28 + esc_html( $wp_version ),
29 + PLL_MIN_WP_VERSION
30 + )
31 + ) );
31 32 }
32 -
33 - return true;
33 + $this->do_for_all_blogs( 'activate', $networkwide );
34 34 }
35 35
36 36 /**
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 37 * Get default Polylang options
84 38 *
85 39 * @since 1.8
86 40 *
87 - * @return array
41 + * return array
88 42 */
89 - public static function get_default_options() {
43 + static public function get_default_options() {
90 44 return array(
91 - 'browser' => 1, // Default language for the front page is set by browser preference
92 - 'rewrite' => 1, // Remove /language/ in permalinks ( was the opposite before 0.7.2 )
93 - 'hide_default' => 1, // Remove URL language information for default language ( was the opposite before 2.1.5 )
94 - 'force_lang' => 1, // Add URL language information ( was 0 before 1.7 )
95 - 'redirect_lang' => 0, // Do not redirect the language page to the homepage
96 - 'media_support' => 1, // Support languages and translation for media by default
97 - 'uninstall' => 0, // Do not remove data when uninstalling Polylang
98 - 'sync' => array(), // Synchronisation is disabled by default ( was the opposite before 1.2 )
99 - 'post_types' => array(),
100 - 'taxonomies' => array(),
101 - 'domains' => array(),
102 - 'version' => POLYLANG_VERSION,
103 - 'first_activation' => time(),
45 + 'browser' => 1, // Default language for the front page is set by browser preference
46 + 'rewrite' => 1, // Remove /language/ in permalinks ( was the opposite before 0.7.2 )
47 + 'hide_default' => 1, // Remove URL language information for default language ( was the opposite before 2.1.5 )
48 + 'force_lang' => 1, // Add URL language information ( was 0 before 1.7 )
49 + 'redirect_lang' => 0, // Do not redirect the language page to the homepage
50 + 'media_support' => 1, // Support languages and translation for media by default
51 + 'uninstall' => 0, // Do not remove data when uninstalling Polylang
52 + 'sync' => array(), // Synchronisation is disabled by default ( was the opposite before 1.2 )
53 + 'post_types' => array(),
54 + 'taxonomies' => array(),
55 + 'domains' => array(),
56 + 'version' => POLYLANG_VERSION,
104 57 );
105 58 }
106 59
107 60 /**
@@ -107,10 +60,8 @@
107 60 /**
108 61 * Plugin activation
109 62 *
110 63 * @since 0.5
111 - *
112 - * @return void
113 64 */
114 65 protected function _activate() {
115 66 if ( $options = get_option( 'polylang' ) ) {
116 67 // Check if we will be able to upgrade
@@ -138,10 +89,8 @@
138 89 /**
139 90 * Plugin deactivation
140 91 *
141 92 * @since 0.5
142 - *
143 - * @return void
144 93 */
145 94 protected function _deactivate() {
146 95 delete_option( 'rewrite_rules' ); // Don't use flush_rewrite_rules at network activation. See #32471
147 96 }