PluginProbe
Polylang / 3.7.7
Polylang v3.7.7
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 -32 2.9.23.7.7 View file →
@@ -2,8 +2,11 @@
2 2 /**
3 3 * @package Polylang
4 4 */
5 5
6 +use WP_Syntex\Polylang\Options\Options;
7 +use WP_Syntex\Polylang\Options\Registry as Options_Registry;
8 +
6 9 /**
7 10 * Polylang activation / de-activation class
8 11 *
9 12 * @since 1.7
@@ -13,8 +16,10 @@
13 16 /**
14 17 * Checks min PHP and WP version, displays a notice if a requirement is not met.
15 18 *
16 19 * @since 2.6.7
20 + *
21 + * @return bool
17 22 */
18 23 public function can_activate() {
19 24 global $wp_version;
20 25
@@ -34,8 +39,10 @@
34 39 /**
35 40 * Displays a notice if PHP min version is not met.
36 41 *
37 42 * @since 2.6.7
43 + *
44 + * @return void
38 45 */
39 46 public function php_version_notice() {
40 47 load_plugin_textdomain( 'polylang' ); // Plugin i18n.
41 48
@@ -54,8 +61,10 @@
54 61 /**
55 62 * Displays a notice if WP min version is not met.
56 63 *
57 64 * @since 2.6.7
65 + *
66 + * @return void
58 67 */
59 68 public function wp_version_notice() {
60 69 global $wp_version;
61 70
@@ -73,48 +82,34 @@
73 82 );
74 83 }
75 84
76 85 /**
77 - * Get default Polylang options
78 - *
79 - * @since 1.8
80 - *
81 - * return array
82 - */
83 - public static function get_default_options() {
84 - return array(
85 - 'browser' => 1, // Default language for the front page is set by browser preference
86 - 'rewrite' => 1, // Remove /language/ in permalinks ( was the opposite before 0.7.2 )
87 - 'hide_default' => 1, // Remove URL language information for default language ( was the opposite before 2.1.5 )
88 - 'force_lang' => 1, // Add URL language information ( was 0 before 1.7 )
89 - 'redirect_lang' => 0, // Do not redirect the language page to the homepage
90 - 'media_support' => 1, // Support languages and translation for media by default
91 - 'uninstall' => 0, // Do not remove data when uninstalling Polylang
92 - 'sync' => array(), // Synchronisation is disabled by default ( was the opposite before 1.2 )
93 - 'post_types' => array(),
94 - 'taxonomies' => array(),
95 - 'domains' => array(),
96 - 'version' => POLYLANG_VERSION,
97 - 'first_activation' => time(),
98 - );
99 - }
100 -
101 - /**
102 86 * Plugin activation
103 87 *
104 88 * @since 0.5
89 + *
90 + * @return void
105 91 */
106 92 protected function _activate() {
107 - if ( $options = get_option( 'polylang' ) ) {
108 - // Check if we will be able to upgrade
93 + add_action( 'pll_init_options_for_blog', array( Options_Registry::class, 'register' ) );
94 + $options = new Options();
95 +
96 + if ( ! empty( $options['version'] ) ) {
97 + // Check if we will be able to upgrade.
109 98 if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
110 - $upgrade = new PLL_Upgrade( $options );
111 - $upgrade->can_activate();
99 + ( new PLL_Upgrade( $options ) )->can_activate();
112 100 }
101 + } else {
102 + $options['version'] = POLYLANG_VERSION;
113 103 }
114 - // Defines default values for options in case this is the first installation
115 - else {
116 - update_option( 'polylang', self::get_default_options() );
104 +
105 + $options->save(); // Force save here to prevent any conflicts with another instance of `Options`.
106 +
107 + if ( false === get_option( 'pll_language_from_content_available' ) ) {
108 + update_option(
109 + 'pll_language_from_content_available',
110 + 0 === $options['force_lang'] ? 'yes' : 'no'
111 + );
117 112 }
118 113
119 114 // Avoid 1 query on every pages if no wpml strings is registered
120 115 if ( ! get_option( 'polylang_wpml_strings' ) ) {
@@ -130,8 +125,10 @@
130 125 /**
131 126 * Plugin deactivation
132 127 *
133 128 * @since 0.5
129 + *
130 + * @return void
134 131 */
135 132 protected function _deactivate() {
136 133 delete_option( 'rewrite_rules' ); // Don't use flush_rewrite_rules at network activation. See #32471
137 134 }