MS_Controller_Help

Controller for Plugin documentation and help.

Defined (1)

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

/app/controller/class-ms-controller-help.php  
  1. class MS_Controller_Help extends MS_Controller { 
  2.  
  3. /** 
  4. * Prepare the component. 
  5. * @since 1.0.0 
  6. */ 
  7. public function __construct() { 
  8. parent::__construct(); 
  9.  
  10. /** 
  11. * Initialize the admin-side functions. 
  12. * @since 1.0.0 
  13. */ 
  14. public function admin_init() { 
  15. $hook = MS_Controller_Plugin::admin_page_hook( 'help' ); 
  16.  
  17. $this->run_action( 'admin_print_scripts-' . $hook, 'enqueue_scripts' ); 
  18.  
  19. /** 
  20. * Load and render the Documentation view. 
  21. * @since 1.0.0 
  22. */ 
  23. public function admin_page() { 
  24. /** 
  25. * Create / Filter the view. 
  26. * @since 1.0.0 
  27. * @param object $this The MS_Controller_Help object. 
  28. */ 
  29. $view = MS_Factory::create( 'MS_View_Help' ); 
  30. $data = array(); 
  31. $data['tabs'] = $this->get_tabs(); 
  32.  
  33. $view->data = apply_filters( 'ms_view_help_data', $data ); 
  34. $view->render(); 
  35.  
  36. /** 
  37. * Get available tabs. 
  38. * @since 1.0.0 
  39. * @return array The tabs configuration. 
  40. */ 
  41. public function get_tabs() { 
  42. $tabs = array( 
  43. 'general' => array( 
  44. 'title' => __( 'General', 'membership2' ),  
  45. ),  
  46. 'shortcodes' => array( 
  47. 'title' => __( 'Shortcodes', 'membership2' ),  
  48. ),  
  49. 'network' => array( 
  50. 'title' => __( 'Network-Wide Protection', 'membership2' ),  
  51. ),  
  52. 'advanced' => array( 
  53. 'title' => __( 'Advanced Settings', 'membership2' ),  
  54. ),  
  55. 'branding' => array( 
  56. 'title' => __( 'Customize Membership 2', 'membership2' ),  
  57. ),  
  58. 'emails' => array( 
  59. 'title' => __( 'Email history', 'membership2' ),  
  60. ),  
  61. 'api' => array( 
  62. 'title' => __( 'API Docs', 'membership2' ),  
  63. 'url' => MS_Plugin::instance()->url . 'docs/namespaces/default.html',  
  64. 'target' => '_blank',  
  65. ),  
  66. ); 
  67.  
  68. if ( ! is_multisite() ) { 
  69. unset( $tabs['network'] ); 
  70. if ( ! defined( 'MS_LOG_EMAILS' ) || ! MS_LOG_EMAILS ) { 
  71. unset( $tabs['emails'] ); 
  72.  
  73. lib3()->array->equip_get( 'page' ); 
  74. $def_key = MS_Controller_Plugin::MENU_SLUG . '-help'; 
  75. $page = sanitize_html_class( $_GET['page'], $def_key ); 
  76.  
  77. foreach ( $tabs as $key => $tab ) { 
  78. if ( empty( $tabs[ $key ]['url'] ) ) { 
  79. $tabs[ $key ]['url'] = sprintf( 
  80. 'admin.php?page=%1$s&tab=%2$s',  
  81. esc_attr( $page ),  
  82. esc_attr( $key ) 
  83. ); 
  84.  
  85. return apply_filters( 
  86. 'ms_controller_help_get_tabs',  
  87. $tabs,  
  88. $this 
  89. ); 
  90.  
  91. /** 
  92. * Load specific scripts. 
  93. * @since 1.0.0 
  94. */ 
  95. public function enqueue_scripts() { 
  96. $data = array( 
  97. 'ms_init' => array( 'view_help' ),  
  98. ); 
  99.  
  100. lib3()->ui->data( 'ms_data', $data ); 
  101. wp_enqueue_script( 'ms-admin' ); 
  102.