PluginProbe
Polylang / 2.8
Polylang v2.8
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
polylang / install / install.php

install.php in Polylang 2.8, at install/install.php

139 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Polylang
4 */
5
6 /**
7 * Polylang activation / de-activation class
8 *
9 * @since 1.7
10 */
11 class PLL_Install extends PLL_Install_Base {
12
13 /**
14 * Checks min PHP and WP version, displays a notice if a requirement is not met.
15 *
16 * @since 2.6.7
17 */
18 public function can_activate() {
19 global $wp_version;
20
21 if ( version_compare( PHP_VERSION, PLL_MIN_PHP_VERSION, '<' ) ) {
22 add_action( 'admin_notices', array( $this, 'php_version_notice' ) );
23 return false;
24 }
25
26 if ( version_compare( $wp_version, PLL_MIN_WP_VERSION, '<' ) ) {
27 add_action( 'admin_notices', array( $this, 'wp_version_notice' ) );
28 return false;
29 }
30
31 return true;
32 }
33
34 /**
35 * Displays a notice if PHP min version is not met.
36 *
37 * @since 2.6.7
38 */
39 public function php_version_notice() {
40 load_plugin_textdomain( 'polylang' ); // Plugin i18n.
41
42 printf(
43 '<div class="error"><p>%s</p></div>',
44 sprintf(
45 /* translators: 1: Plugin name 2: Current PHP version 3: Required PHP version */
46 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' ),
47 esc_html( POLYLANG ),
48 PHP_VERSION,
49 esc_html( PLL_MIN_PHP_VERSION )
50 )
51 );
52 }
53
54 /**
55 * Displays a notice if WP min version is not met.
56 *
57 * @since 2.6.7
58 */
59 public function wp_version_notice() {
60 global $wp_version;
61
62 load_plugin_textdomain( 'polylang' ); // Plugin i18n.
63
64 printf(
65 '<div class="error"><p>%s</p></div>',
66 sprintf(
67 /* translators: 1: Plugin name 2: Current WordPress version 3: Required WordPress version */
68 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' ),
69 esc_html( POLYLANG ),
70 esc_html( $wp_version ),
71 esc_html( PLL_MIN_WP_VERSION )
72 )
73 );
74 }
75
76 /**
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 * Plugin activation
103 *
104 * @since 0.5
105 */
106 protected function _activate() {
107 if ( $options = get_option( 'polylang' ) ) {
108 // Check if we will be able to upgrade
109 if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
110 $upgrade = new PLL_Upgrade( $options );
111 $upgrade->can_activate();
112 }
113 }
114 // Defines default values for options in case this is the first installation
115 else {
116 update_option( 'polylang', self::get_default_options() );
117 }
118
119 // Avoid 1 query on every pages if no wpml strings is registered
120 if ( ! get_option( 'polylang_wpml_strings' ) ) {
121 update_option( 'polylang_wpml_strings', array() );
122 }
123
124 // Don't use flush_rewrite_rules at network activation. See #32471
125 // Thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/
126 // Rewrite rules are created at next page load :)
127 delete_option( 'rewrite_rules' );
128 }
129
130 /**
131 * Plugin deactivation
132 *
133 * @since 0.5
134 */
135 protected function _deactivate() {
136 delete_option( 'rewrite_rules' ); // Don't use flush_rewrite_rules at network activation. See #32471
137 }
138 }
139