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

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

136 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Polylang activation / de-activation class
5 *
6 * @since 1.7
7 */
8 class PLL_Install extends PLL_Install_Base {
9
10 /**
11 * Checks min PHP and WP version, displays a notice if a requirement is not met.
12 *
13 * @since 2.6.7
14 */
15 public function can_activate() {
16 global $wp_version;
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 }
22
23 if ( version_compare( $wp_version, PLL_MIN_WP_VERSION, '<' ) ) {
24 add_action( 'admin_notices', array( $this, 'wp_version_notice' ) );
25 return false;
26 }
27
28 return true;
29 }
30
31 /**
32 * Displays a notice if PHP min version is not met.
33 *
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 * @since 1.8
77 *
78 * return array
79 */
80 public static function get_default_options() {
81 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(),
95 );
96 }
97
98 /**
99 * Plugin activation
100 *
101 * @since 0.5
102 */
103 protected function _activate() {
104 if ( $options = get_option( 'polylang' ) ) {
105 // Check if we will be able to upgrade
106 if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
107 $upgrade = new PLL_Upgrade( $options );
108 $upgrade->can_activate();
109 }
110 }
111 // Defines default values for options in case this is the first installation
112 else {
113 update_option( 'polylang', self::get_default_options() );
114 }
115
116 // Avoid 1 query on every pages if no wpml strings is registered
117 if ( ! get_option( 'polylang_wpml_strings' ) ) {
118 update_option( 'polylang_wpml_strings', array() );
119 }
120
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 :)
124 delete_option( 'rewrite_rules' );
125 }
126
127 /**
128 * Plugin deactivation
129 *
130 * @since 0.5
131 */
132 protected function _deactivate() {
133 delete_option( 'rewrite_rules' ); // Don't use flush_rewrite_rules at network activation. See #32471
134 }
135 }
136