get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) { switch_to_blog($blog_id); $what == 'activate' ? $this->_activate() : $this->_deactivate(); } restore_current_blog(); } // single blog else $what == 'activate' ? $this->_activate() : $this->_deactivate(); } /* * plugin activation for multisite * * @since 0.1 */ public function activate() { global $wp_version; load_plugin_textdomain('polylang', false, basename(POLYLANG_DIR).'/languages'); // plugin i18n if (version_compare($wp_version, PLL_MIN_WP_VERSION , '<')) die (sprintf('
%s
', sprintf(__('You are using WordPress %s. Polylang requires at least WordPress %s.', 'polylang'), esc_html($wp_version), PLL_MIN_WP_VERSION ) )); $this->do_for_all_blogs('activate'); } /* * plugin activation * * @since 0.5 */ protected function _activate() { global $polylang; if ($options = get_option('polylang')) { // plugin upgrade if (version_compare($options['version'], POLYLANG_VERSION, '<')) { $upgrade = new PLL_Upgrade($options); $upgrade->upgrade_at_activation(); } } // defines default values for options in case this is the first installation else { $options = array( 'browser' => 1, // default language for the front page is set by browser preference 'rewrite' => 1, // remove /language/ in permalinks (was the opposite before 0.7.2) 'hide_default' => 0, // do not remove URL language information for default language 'force_lang' => 0, // do not add URL language information when useless 'redirect_lang' => 0, // do not redirect the language page to the homepage 'media_support' => 1, // support languages and translation for media by default 'sync' => array(), // synchronisation is disabled by default (was the opposite before 1.2) 'post_types' => array_values(get_post_types(array('_builtin' => false, 'show_ui => true'))), 'taxonomies' => array_values(get_taxonomies(array('_builtin' => false, 'show_ui => true'))), 'domains' => array(), 'version' => POLYLANG_VERSION, ); update_option('polylang', $options); } // always provide a global $polylang object and add our rewrite rules if needed $polylang = new StdClass(); $polylang->options = &$options; $polylang->model = new PLL_Admin_Model($options); $polylang->links_model = $polylang->model->get_links_model(); flush_rewrite_rules(); } /* * plugin deactivation for multisite * * @since 0.1 */ public function deactivate() { $this->do_for_all_blogs('deactivate'); } /* * plugin deactivation * * @since 0.5 */ protected function _deactivate() { flush_rewrite_rules(); } /* * blog creation on multisite (to set default options) * * @since 0.9.4 * * @param int $blog_id */ public function wpmu_new_blog($blog_id) { switch_to_blog($blog_id); $this->_activate(); restore_current_blog(); } /* * autoload classes * * @since 1.2 * * @param string $class */ public function autoload($class) { $class = str_replace('_', '-', strtolower(substr($class, 4))); foreach (array(PLL_INC, PLL_FRONT_INC, PLL_ADMIN_INC) as $path) { if (file_exists($file = "$path/$class.php")) { require_once($file); break; } } } /* * Polylang initialization * setups models and separate admin and frontend * * @since 1.2 */ public function init() { global $polylang; $options = get_option('polylang'); // plugin upgrade if ($options && version_compare($options['version'], POLYLANG_VERSION, '<')) { $upgrade = new PLL_Upgrade($options); if (!$upgrade->upgrade()) // if the version is too old return; } $class = apply_filters('pll_model', PLL_SETTINGS ? 'PLL_Admin_Model' : 'PLL_Model'); $model = new $class($options); $links_model = $model->get_links_model(); if (PLL_ADMIN) { $polylang = new PLL_Admin($links_model); $polylang->init(); } // do nothing on frontend if no language is defined elseif ($model->get_languages_list()) { $polylang = new PLL_Frontend($links_model); $polylang->init(); } else do_action('pll_no_language_defined'); // to load overriden textdomains // load wpml-config.xml if (!defined('PLL_WPML_COMPAT') || PLL_WPML_COMPAT) new PLL_WPML_Config; } } new Polylang();