PluginProbe
Polylang / 2.0.3
Polylang v2.0.3
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 +38 -78 2.72.0.3 View file →
@@ -7,129 +7,89 @@
7 7 */
8 8 class PLL_Install extends PLL_Install_Base {
9 9
10 10 /**
11 - * Checks min PHP and WP version, displays a notice if a requirement is not met.
11 + * plugin activation for multisite
12 12 *
13 - * @since 2.6.7
13 + * @since 0.1
14 14 */
15 - public function can_activate() {
15 + public function activate( $networkwide ) {
16 16 global $wp_version;
17 17
18 - if ( version_compare( PHP_VERSION, PLL_MIN_PHP_VERSION, '<' ) ) {
19 - add_action( 'admin_notices', array( $this, 'php_version_notice' ) );
20 - return false;
21 - }
18 + Polylang::define_constants();
22 19
23 - if ( version_compare( $wp_version, PLL_MIN_WP_VERSION, '<' ) ) {
24 - add_action( 'admin_notices', array( $this, 'wp_version_notice' ) );
25 - 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 + ) );
26 30 }
27 -
28 - return true;
31 + $this->do_for_all_blogs( 'activate', $networkwide );
29 32 }
30 33
31 34 /**
32 - * Displays a notice if PHP min version is not met.
35 + * get default Polylang options
33 36 *
34 - * @since 2.6.7
35 - */
36 - public function php_version_notice() {
37 - load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); // Plugin i18n.
38 -
39 - printf(
40 - '<div class="error"><p>%s</p></div>',
41 - sprintf(
42 - /* translators: 1: Plugin name 2: Current PHP version 3: Required PHP version */
43 - 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' ),
44 - esc_html( POLYLANG ),
45 - PHP_VERSION,
46 - esc_html( PLL_MIN_PHP_VERSION )
47 - )
48 - );
49 - }
50 -
51 - /**
52 - * Displays a notice if WP min version is not met.
53 - *
54 - * @since 2.6.7
55 - */
56 - public function wp_version_notice() {
57 - global $wp_version;
58 -
59 - load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); // Plugin i18n.
60 -
61 - printf(
62 - '<div class="error"><p>%s</p></div>',
63 - sprintf(
64 - /* translators: 1: Plugin name 2: Current WordPress version 3: Required WordPress version */
65 - 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' ),
66 - esc_html( POLYLANG ),
67 - esc_html( $wp_version ),
68 - esc_html( PLL_MIN_WP_VERSION )
69 - )
70 - );
71 - }
72 -
73 - /**
74 - * Get default Polylang options
75 - *
76 37 * @since 1.8
77 38 *
78 39 * return array
79 40 */
80 - public static function get_default_options() {
41 + static public function get_default_options() {
81 42 return array(
82 - 'browser' => 1, // Default language for the front page is set by browser preference
83 - 'rewrite' => 1, // Remove /language/ in permalinks ( was the opposite before 0.7.2 )
84 - 'hide_default' => 1, // Remove URL language information for default language ( was the opposite before 2.1.5 )
85 - 'force_lang' => 1, // Add URL language information ( was 0 before 1.7 )
86 - 'redirect_lang' => 0, // Do not redirect the language page to the homepage
87 - 'media_support' => 1, // Support languages and translation for media by default
88 - 'uninstall' => 0, // Do not remove data when uninstalling Polylang
89 - 'sync' => array(), // Synchronisation is disabled by default ( was the opposite before 1.2 )
90 - 'post_types' => array(),
91 - 'taxonomies' => array(),
92 - 'domains' => array(),
93 - 'version' => POLYLANG_VERSION,
94 - '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_values( get_post_types( array( '_builtin' => false, 'show_ui' => true ) ) ),
52 + 'taxonomies' => array_values( get_taxonomies( array( '_builtin' => false, 'show_ui' => true ) ) ),
53 + 'domains' => array(),
54 + 'version' => POLYLANG_VERSION,
95 55 );
96 56 }
97 57
98 58 /**
99 - * Plugin activation
59 + * plugin activation
100 60 *
101 61 * @since 0.5
102 62 */
103 63 protected function _activate() {
104 64 if ( $options = get_option( 'polylang' ) ) {
105 - // Check if we will be able to upgrade
65 + // check if we will be able to upgrade
106 66 if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
107 67 $upgrade = new PLL_Upgrade( $options );
108 68 $upgrade->can_activate();
109 69 }
110 70 }
111 - // 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
112 72 else {
113 73 update_option( 'polylang', self::get_default_options() );
114 74 }
115 75
116 - // 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
117 77 if ( ! get_option( 'polylang_wpml_strings' ) ) {
118 78 update_option( 'polylang_wpml_strings', array() );
119 79 }
120 80
121 - // Don't use flush_rewrite_rules at network activation. See #32471
122 - // Thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/
123 - // 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 :)
124 84 delete_option( 'rewrite_rules' );
125 85 }
126 86
127 87 /**
128 - * Plugin deactivation
88 + * plugin deactivation
129 89 *
130 90 * @since 0.5
131 91 */
132 92 protected function _deactivate() {
133 - 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
134 94 }
135 95 }