PluginProbe
Polylang / 3.7.1
Polylang v3.7.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 +19 -32 3.03.7.1 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
@@ -79,33 +82,8 @@
79 82 );
80 83 }
81 84
82 85 /**
83 - * Get default Polylang options
84 - *
85 - * @since 1.8
86 - *
87 - * @return array
88 - */
89 - public static function get_default_options() {
90 - 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(),
104 - );
105 - }
106 -
107 - /**
108 86 * Plugin activation
109 87 *
110 88 * @since 0.5
111 89 *
@@ -111,18 +89,27 @@
111 89 *
112 90 * @return void
113 91 */
114 92 protected function _activate() {
115 - if ( $options = get_option( 'polylang' ) ) {
116 - // 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.
117 98 if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
118 - $upgrade = new PLL_Upgrade( $options );
119 - $upgrade->can_activate();
99 + ( new PLL_Upgrade( $options ) )->can_activate();
120 100 }
101 + } else {
102 + $options['version'] = POLYLANG_VERSION;
121 103 }
122 - // Defines default values for options in case this is the first installation
123 - else {
124 - 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 + );
125 112 }
126 113
127 114 // Avoid 1 query on every pages if no wpml strings is registered
128 115 if ( ! get_option( 'polylang_wpml_strings' ) ) {