PLL_Install

Polylang activation / de-activation class.

Defined (1)

The class is defined in the following location(s).

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