/app/controller/class-ms-controller-help.php

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