PluginProbe
Polylang / 2.1
Polylang v2.1
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 +39 -92 3.02.1 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,139 +7,89 @@
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
17 - *
18 - * @return bool
13 + * @since 0.1
19 14 */
20 - public function can_activate() {
15 + public function activate( $networkwide ) {
21 16 global $wp_version;
22 17
23 - if ( version_compare( PHP_VERSION, PLL_MIN_PHP_VERSION, '<' ) ) {
24 - add_action( 'admin_notices', array( $this, 'php_version_notice' ) );
25 - return false;
26 - }
18 + Polylang::define_constants();
27 19
28 - if ( version_compare( $wp_version, PLL_MIN_WP_VERSION, '<' ) ) {
29 - add_action( 'admin_notices', array( $this, 'wp_version_notice' ) );
30 - return false;
20 + load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ).'/languages' ); // plugin i18n
21 +
22 + if ( version_compare( $wp_version, PLL_MIN_WP_VERSION , '<' ) ) {
23 + die( sprintf( '<p style = "font-family: sans-serif; font-size: 12px; color: #333; margin: -5px">%s</p>',
24 + /* translators: %s are WordPress version numbers */
25 + sprintf( esc_html__( 'You are using WordPress %s. Polylang requires at least WordPress %s.', 'polylang' ),
26 + esc_html( $wp_version ),
27 + PLL_MIN_WP_VERSION
28 + )
29 + ) );
31 30 }
32 -
33 - return true;
31 + $this->do_for_all_blogs( 'activate', $networkwide );
34 32 }
35 33
36 34 /**
37 - * Displays a notice if PHP min version is not met.
35 + * get default Polylang options
38 36 *
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 - * Get default Polylang options
84 - *
85 37 * @since 1.8
86 38 *
87 - * @return array
39 + * return array
88 40 */
89 - public static function get_default_options() {
41 + static public function get_default_options() {
90 42 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(),
43 + 'browser' => 1, // default language for the front page is set by browser preference
44 + 'rewrite' => 1, // remove /language/ in permalinks ( was the opposite before 0.7.2 )
45 + 'hide_default' => 0, // do not remove URL language information for default language
46 + 'force_lang' => 1, // add URL language information ( was 0 before 1.7 )
47 + 'redirect_lang' => 0, // do not redirect the language page to the homepage
48 + 'media_support' => 1, // support languages and translation for media by default
49 + 'uninstall' => 0, // do not remove data when uninstalling Polylang
50 + 'sync' => array(), // synchronisation is disabled by default ( was the opposite before 1.2 )
51 + 'post_types' => array(),
52 + 'taxonomies' => array(),
53 + 'domains' => array(),
54 + 'version' => POLYLANG_VERSION,
104 55 );
105 56 }
106 57
107 58 /**
108 - * Plugin activation
59 + * plugin activation
109 60 *
110 61 * @since 0.5
111 - *
112 - * @return void
113 62 */
114 63 protected function _activate() {
115 64 if ( $options = get_option( 'polylang' ) ) {
116 - // Check if we will be able to upgrade
65 + // check if we will be able to upgrade
117 66 if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
118 67 $upgrade = new PLL_Upgrade( $options );
119 68 $upgrade->can_activate();
120 69 }
121 70 }
122 - // Defines default values for options in case this is the first installation
71 + // defines default values for options in case this is the first installation
123 72 else {
124 73 update_option( 'polylang', self::get_default_options() );
125 74 }
126 75
127 - // Avoid 1 query on every pages if no wpml strings is registered
76 + // avoid 1 query on every pages if no wpml strings is registered
128 77 if ( ! get_option( 'polylang_wpml_strings' ) ) {
129 78 update_option( 'polylang_wpml_strings', array() );
130 79 }
131 80
132 - // Don't use flush_rewrite_rules at network activation. See #32471
133 - // Thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/
134 - // Rewrite rules are created at next page load :)
81 + // don't use flush_rewrite_rules at network activation. See #32471
82 + // thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/
83 + // rewrite rules are created at next page load :)
135 84 delete_option( 'rewrite_rules' );
136 85 }
137 86
138 87 /**
139 - * Plugin deactivation
88 + * plugin deactivation
140 89 *
141 90 * @since 0.5
142 - *
143 - * @return void
144 91 */
145 92 protected function _deactivate() {
146 - delete_option( 'rewrite_rules' ); // Don't use flush_rewrite_rules at network activation. See #32471
93 + delete_option( 'rewrite_rules' ); // don't use flush_rewrite_rules at network activation. See #32471
147 94 }
148 95 }