protected function _activate() { if ($options = get_option('polylang')) { // check if we will be able to upgrade if (version_compare($options['version'], POLYLANG_VERSION, '<')) { $upgrade = new PLL_Upgrade($options); $upgrade->can_activate(); } } else { update_option('polylang', self::get_default_options()); } // avoid 1 query on every pages if no wpml strings is registered if (!get_option('polylang_wpml_strings')) { update_option('polylang_wpml_strings', array()); } // don't use flush_rewrite_rules at network activation. See #32471 // thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/ // rewrite rules are created at next page load :) delete_option('rewrite_rules'); }
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(); } } else { $options = array('browser' => 1, 'rewrite' => 1, 'hide_default' => 0, 'force_lang' => 1, 'redirect_lang' => 0, 'media_support' => 1, 'sync' => array(), '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(); do_action('pll_init'); flush_rewrite_rules(); }
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(); } } else { $options = array('browser' => 1, 'rewrite' => 1, 'hide_default' => 0, 'force_lang' => 1, 'redirect_lang' => 0, 'media_support' => 1, 'sync' => array(), '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(); do_action('pll_init'); // don't use flush_rewrite_rules at network activation. See #32471 // thanks to RavanH for the trick. See https://polylang.wordpress.com/2015/06/10/polylang-1-7-6-and-multisite/ delete_option('rewrite_rules'); }
public function init() { global $polylang; self::define_constants(); $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(); } elseif ($model->get_languages_list()) { $polylang = new PLL_Frontend($links_model); $polylang->init(); } if (!$model->get_languages_list()) { do_action('pll_no_language_defined'); } // to load overriden textdomains // load wpml-config.xml if (!defined('PLL_WPML_COMPAT') || PLL_WPML_COMPAT) { PLL_WPML_Config::instance(); } do_action('pll_init'); }
/** * Polylang initialization * setups models and separate admin and frontend * * @since 1.2 */ public function init() { global $polylang; self::define_constants(); $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; } } // Make sure that this filter is *always* added before PLL_Model::get_languages_list() is called for the first time add_filter('pll_languages_list', array('PLL_Static_Pages', 'pll_languages_list'), 2, 2); // before PLL_Links_Model /** * Filter the model class to use * /!\ this filter is fired *before* the $polylang object is available * * @since 1.5 * * @param string $class either PLL_Model or PLL_Admin_Model */ $class = apply_filters('pll_model', PLL_SETTINGS ? 'PLL_Admin_Model' : 'PLL_Model'); $model = new $class($options); $links_model = $model->get_links_model(); if (PLL_SETTINGS) { $polylang = new PLL_Settings($links_model); } elseif (PLL_ADMIN) { $polylang = new PLL_Admin($links_model); } elseif ($model->get_languages_list() && empty($_GET['deactivate-polylang'])) { $polylang = new PLL_Frontend($links_model); } if (!$model->get_languages_list()) { /** * Fires when no language has been defined yet * Used to load overriden textdomains * * @since 1.2 */ do_action('pll_no_language_defined'); } if (!empty($polylang)) { /** * Fires after the $polylang object is created and before the API is loaded * * @since 2.0 * * @param object $polylang */ do_action_ref_array('pll_pre_init', array(&$polylang)); require_once PLL_INC . '/api.php'; // loads the API if (!defined('PLL_WPML_COMPAT') || PLL_WPML_COMPAT) { PLL_WPML_Compat::instance(); // WPML API PLL_WPML_Config::instance(); // wpml-config.xml } $polylang->init(); /** * Fires after the $polylang object and the API is loaded * * @since 1.7 * * @param object $polylang */ do_action_ref_array('pll_init', array(&$polylang)); } }
public function upgrade_languages($version) { // $GLOBALS['wp_version'] is the old WP version if (version_compare($version, '4.0', '>=') && version_compare($GLOBALS['wp_version'], '4.0', '<')) { apply_filters('update_feedback', __('Upgrading language files…', 'polylang')); PLL_Upgrade::download_language_packs(); } }
/** * ugprades languages files after a core upgrade * only for backward compatibility WP < 4.0 *AND* Polylang < 1.6 * * @since 0.6 * * @param string $version new WP version */ public function upgrade_languages($version) { // $GLOBALS['wp_version'] is the old WP version if (version_compare($version, '4.0', '>=') && version_compare($GLOBALS['wp_version'], '4.0', '<')) { /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters('update_feedback', __('Upgrading language files…', 'polylang')); PLL_Upgrade::download_language_packs(); } }
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; } } $model = PLL_SETTINGS ? new PLL_Admin_Model($options) : new PLL_Model($options); $links_model = $this->get_links_model($model); if (PLL_ADMIN) { $polylang = new PLL_Admin($links_model); $polylang->init(); } 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(); } }
public function upgrade_languages($version) { // backward compatibility WP < 4.0 if (version_compare($version, '4.0', '<')) { apply_filters('update_feedback', __('Upgrading language files…', 'polylang')); foreach ($this->model->get_languages_list() as $language) { if (!empty($_POST['locale']) && $language->locale != $_POST['locale']) { // do not (re)update the language files of a localized WordPress PLL_Admin::download_mo($language->locale, $version); } } } elseif (version_compare($GLOBALS['wp_version'], '4.0', '<')) { apply_filters('update_feedback', __('Upgrading language files…', 'polylang')); PLL_Upgrade::download_language_packs(); } }
public function init() { global $polylang; self::define_constants(); $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; } } // /!\ this filter is fired *before* the $polylang object is available $class = apply_filters('pll_model', PLL_SETTINGS ? 'PLL_Admin_Model' : 'PLL_Model'); $model = new $class($options); $links_model = $model->get_links_model(); add_filter('pll_languages_list', array('PLL_Static_Pages', 'pll_languages_list'), 2, 2); // before PLL_Links_Model if (PLL_SETTINGS) { $polylang = new PLL_Settings($links_model); } elseif (PLL_ADMIN) { $polylang = new PLL_Admin($links_model); } elseif ($model->get_languages_list() && empty($_GET['deactivate-polylang'])) { $polylang = new PLL_Frontend($links_model); } if (!$model->get_languages_list()) { do_action('pll_no_language_defined'); // to load overriden textdomains } if (!empty($polylang)) { require_once PLL_INC . '/api.php'; // loads the API if (!defined('PLL_WPML_COMPAT') || PLL_WPML_COMPAT) { PLL_WPML_Compat::instance(); // WPML API PLL_WPML_Config::instance(); // wpml-config.xml } $polylang->init(); do_action('pll_init', $polylang); } }