All_in_One_SEO_Pack_Module_Manager

Class All_in_One_SEO_Pack_Module_Manager.

Defined (1)

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

/admin/aioseop_module_manager.php  
  1. class All_in_One_SEO_Pack_Module_Manager { 
  2. protected $modules = array(); 
  3. protected $settings_update = false; 
  4. protected $settings_reset = false; 
  5. protected $settings_reset_all = false; 
  6. protected $module_settings_update = false; 
  7.  
  8. /** 
  9. * All_in_One_SEO_Pack_Module_Manager constructor. 
  10. * Initialize module list. 
  11. * @param $mod Modules. 
  12. */ 
  13. function __construct( $mod ) { 
  14.  
  15. $this->modules['feature_manager'] = null; 
  16. foreach ( $mod as $m ) { 
  17. $this->modules[ $m ] = null; 
  18. $reset = false; 
  19. $reset_all = ( isset( $_POST['Submit_All_Default'] ) && '' !== $_POST['Submit_All_Default'] ); 
  20. $reset = ( ( isset( $_POST['Submit_Default'] ) && '' !== $_POST['Submit_Default'] ) || $reset_all ); 
  21. $update = ( isset( $_POST['action'] ) && $_POST['action'] 
  22. && ( ( isset( $_POST['Submit'] ) && '' !== $_POST['Submit'] ) || $reset ) 
  23. ); 
  24. if ( $update ) { 
  25. if ( $reset ) { 
  26. $this->settings_reset = true; 
  27. if ( $reset_all ) { 
  28. $this->settings_reset_all = true; 
  29. if ( 'aiosp_update' === $_POST['action'] ) { 
  30. $this->settings_update = true; 
  31. if ( 'aiosp_update_module' === $_POST['action'] ) { 
  32. $this->module_settings_update = true; 
  33. $this->do_load_module( 'feature_manager', $mod ); 
  34.  
  35. /** 
  36. * Return module. 
  37. * @param $class 
  38. * @return $this|bool|mixed 
  39. */ 
  40. function return_module( $class ) { 
  41. global $aiosp; 
  42. if ( get_class( $aiosp ) === $class ) { 
  43. return $aiosp; 
  44. if ( get_class( $aiosp ) === $class ) { 
  45. return $this; 
  46. foreach ( $this->modules as $m ) { 
  47. if ( is_object( $m ) && ( get_class( $m ) === $class ) ) { 
  48. return $m; 
  49.  
  50. return false; 
  51.  
  52. /** 
  53. * @return array 
  54. */ 
  55. function get_loaded_module_list() { 
  56. $module_list = array(); 
  57. if ( ! empty( $this->modules ) ) { 
  58. foreach ( $this->modules as $k => $v ) { 
  59. if ( ! empty( $v ) ) { 
  60. $module_list[ $k ] = get_class( $v ); 
  61.  
  62. return $module_list; 
  63.  
  64. /** 
  65. * @param $mod Module. 
  66. * @param null $args 
  67. * @return bool 
  68. */ 
  69. function do_load_module( $mod, $args = null ) { 
  70. // Module name is used for these automatic settings: 
  71. // The aiosp_enable_$module settings - whether each plugin is active or not. 
  72. // The name of the .php file containing the module - aioseop_$module.php. 
  73. // The name of the class - All_in_One_SEO_Pack_$Module. 
  74. // The global $aioseop_$module. 
  75. // $this->modules[$module]. 
  76.  
  77. $mod_path = apply_filters( "aioseop_include_$mod", AIOSEOP_PLUGIN_DIR . "modules/aioseop_$mod.php" ); 
  78. if ( ! empty( $mod_path ) ) { 
  79. require_once( $mod_path ); 
  80. $ref = "aioseop_$mod"; 
  81. $classname = 'All_in_One_SEO_Pack_' . strtr( ucwords( strtr( $mod, '_', ' ' ) ), ' ', '_' ); 
  82. $classname = apply_filters( "aioseop_class_$mod", $classname ); 
  83. $module_class = new $classname( $args ); 
  84. $GLOBALS[ $ref ] = $module_class; 
  85. $this->modules[ $mod ] = $module_class; 
  86. if ( is_user_logged_in() && function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() && current_user_can( 'aiosp_manage_seo' ) ) { 
  87. add_action( 'admin_bar_menu', array( 
  88. $module_class,  
  89. 'add_admin_bar_submenu',  
  90. ), 1001 + $module_class->menu_order() ); 
  91. if ( is_admin() ) { 
  92. add_action( 'aioseop_modules_add_menus', array( 
  93. $module_class,  
  94. 'add_menu',  
  95. ), $module_class->menu_order() ); 
  96. add_action( 'aiosoep_options_reset', array( $module_class, 'reset_options' ) ); 
  97. add_filter( 'aioseop_export_settings', array( $module_class, 'settings_export' ) ); 
  98.  
  99. return true; 
  100.  
  101. /** 
  102. * @param $mod 
  103. * @return bool 
  104. */ 
  105. function load_module( $mod ) { 
  106. static $feature_options = null; 
  107. static $feature_prefix = null; 
  108. if ( ! is_array( $this->modules ) ) { 
  109. return false; 
  110. $v = $this->modules[ $mod ]; 
  111. if ( null !== $v ) { 
  112. return false; 
  113. } // Already loaded. 
  114. if ( 'performance' === $mod && ! is_super_admin() ) { 
  115. return false; 
  116. if ( ( 'file_editor' === $mod || 'robots' === $mod ) 
  117. && ( ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) 
  118. || ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) 
  119. || ! is_super_admin() ) 
  120. ) { 
  121. return false; 
  122. $mod_enable = false; 
  123. $fm_page = ( $this->module_settings_update && wp_verify_nonce( $_POST['nonce-aioseop'], 'aioseop-nonce' ) && 
  124. isset( $_REQUEST['page'] ) && trailingslashit( AIOSEOP_PLUGIN_DIRNAME ) . 'modules/aioseop_feature_manager.php' === $_REQUEST['page'] ); 
  125. if ( $fm_page && ! $this->settings_reset ) { 
  126. if ( isset( $_POST["aiosp_feature_manager_enable_$mod"] ) ) { 
  127. $mod_enable = $_POST["aiosp_feature_manager_enable_$mod"]; 
  128. } else { 
  129. $mod_enable = false; 
  130. } else { 
  131. if ( null === $feature_prefix ) { 
  132. $feature_prefix = $this->modules['feature_manager']->get_prefix(); 
  133. if ( $fm_page && $this->settings_reset ) { 
  134. $feature_options = $this->modules['feature_manager']->default_options(); 
  135. if ( null === $feature_options ) { 
  136. if ( $this->module_settings_update && $this->settings_reset_all && wp_verify_nonce( $_POST['nonce-aioseop'], 'aioseop-nonce' ) ) { 
  137. $feature_options = $this->modules['feature_manager']->default_options(); 
  138. } else { 
  139. $feature_options = $this->modules['feature_manager']->get_current_options(); 
  140. if ( isset( $feature_options["{$feature_prefix}enable_$mod"] ) ) { 
  141. $mod_enable = $feature_options["{$feature_prefix}enable_$mod"]; 
  142. if ( $mod_enable ) { 
  143. return $this->do_load_module( $mod ); 
  144.  
  145. return false; 
  146.  
  147. function load_modules() { 
  148. if ( is_array( $this->modules ) ) { 
  149. foreach ( $this->modules as $k => $v ) { 
  150. $this->load_module( $k );