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();
 }
Beispiel #2
0
 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');
 }