PluginProbe
Polylang / 2.6
Polylang v2.6
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.6, at install/install.php

103 lines 3.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 * Plugin activation for multisite
12 *
13 * @since 0.1
14 *
15 * @param bool $networkwide
16 */
17 public function activate( $networkwide ) {
18 global $wp_version;
19
20 Polylang::define_constants();
21
22 load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' ); // plugin i18n
23
24 if ( version_compare( $wp_version, PLL_MIN_WP_VERSION, '<' ) ) {
25 die(
26 sprintf(
27 '<p style = "font-family: sans-serif; font-size: 12px; color: #333; margin: -5px">%s</p>',
28 sprintf(
29 /* translators: %1$s and %2$s are WordPress version numbers */
30 esc_html__( 'You are using WordPress %1$s. Polylang requires at least WordPress %2$s.', 'polylang' ),
31 esc_html( $wp_version ),
32 PLL_MIN_WP_VERSION // phpcs:ignore WordPress.Security.EscapeOutput
33 )
34 )
35 );
36 }
37 $this->do_for_all_blogs( 'activate', $networkwide );
38 }
39
40 /**
41 * Get default Polylang options
42 *
43 * @since 1.8
44 *
45 * return array
46 */
47 public static function get_default_options() {
48 return array(
49 'browser' => 1, // Default language for the front page is set by browser preference
50 'rewrite' => 1, // Remove /language/ in permalinks ( was the opposite before 0.7.2 )
51 'hide_default' => 1, // Remove URL language information for default language ( was the opposite before 2.1.5 )
52 'force_lang' => 1, // Add URL language information ( was 0 before 1.7 )
53 'redirect_lang' => 0, // Do not redirect the language page to the homepage
54 'media_support' => 1, // Support languages and translation for media by default
55 'uninstall' => 0, // Do not remove data when uninstalling Polylang
56 'sync' => array(), // Synchronisation is disabled by default ( was the opposite before 1.2 )
57 'post_types' => array(),
58 'taxonomies' => array(),
59 'domains' => array(),
60 'version' => POLYLANG_VERSION,
61 'first_activation' => time(),
62 );
63 }
64
65 /**
66 * Plugin activation
67 *
68 * @since 0.5
69 */
70 protected function _activate() {
71 if ( $options = get_option( 'polylang' ) ) {
72 // Check if we will be able to upgrade
73 if ( version_compare( $options['version'], POLYLANG_VERSION, '<' ) ) {
74 $upgrade = new PLL_Upgrade( $options );
75 $upgrade->can_activate();
76 }
77 }
78 // Defines default values for options in case this is the first installation
79 else {
80 update_option( 'polylang', self::get_default_options() );
81 }
82
83 // Avoid 1 query on every pages if no wpml strings is registered
84 if ( ! get_option( 'polylang_wpml_strings' ) ) {
85 update_option( 'polylang_wpml_strings', array() );
86 }
87
88 // Don't use flush_rewrite_rules at network activation. See #32471
89 // Thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/
90 // Rewrite rules are created at next page load :)
91 delete_option( 'rewrite_rules' );
92 }
93
94 /**
95 * Plugin deactivation
96 *
97 * @since 0.5
98 */
99 protected function _deactivate() {
100 delete_option( 'rewrite_rules' ); // Don't use flush_rewrite_rules at network activation. See #32471
101 }
102 }
103