PluginProbe
Polylang / 2.1.6
Polylang v2.1.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.1.6, at install/install.php

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