PluginProbe
WP Discourse / trunk
WP Discourse vtrunk
2.6.4 2.6.3 1.2.1 1.2.2 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.85 1.4.0 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 All 150 releases
wp-discourse / admin / admin-menu.php

admin-menu.php in WP Discourse trunk, at admin/admin-menu.php

201 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Adds the admin menu page and sub-menu pages.
4 *
5 * @package WPDiscourse
6 */
7
8 namespace WPDiscourse\Admin;
9
10 /**
11 * Class AdminMenu
12 */
13 class AdminMenu {
14
15 /**
16 * An instance of the OptionsPage class.
17 *
18 * @access protected
19 * @var \WPDiscourse\Admin\OptionsPage
20 */
21 protected $options_page;
22
23 /**
24 * An instance of the FormHelper class.
25 *
26 * @access protected
27 * @var \WPDiscourse\Admin\FormHelper
28 */
29 protected $form_helper;
30
31 /**
32 * AdminMenu constructor.
33 *
34 * @param \WPDiscourse\Admin\OptionsPage $options_page An instance of the OptionsPage class.
35 * @param \WPDiscourse\Admin\FormHelper $form_helper An instance of the FormHelper class.
36 */
37 public function __construct( $options_page, $form_helper ) {
38 $this->options_page = $options_page;
39 $this->form_helper = $form_helper;
40
41 add_action( 'admin_menu', array( $this, 'add_menu_pages' ) );
42 }
43
44 /**
45 * Add menu and sub-menu pages.
46 */
47 public function add_menu_pages() {
48 $settings = add_menu_page(
49 __( 'Discourse', 'wp-discourse' ),
50 __( 'Discourse', 'wp-discourse' ),
51 'manage_options',
52 'wp_discourse_options',
53 array( $this->options_page, 'display' ),
54 WPDISCOURSE_LOGO
55 );
56 add_action( 'load-' . $settings, array( $this->form_helper, 'connection_status_notice' ) );
57
58 $all_settings = add_submenu_page(
59 'wp_discourse_options',
60 __( 'All Options', 'wp-discourse' ),
61 __( 'All Options', 'wp-discourse' ),
62 'manage_options',
63 'wp_discourse_options'
64 );
65 add_action( 'load-' . $all_settings, array( $this->form_helper, 'connection_status_notice' ) );
66
67 $connection_settings = add_submenu_page(
68 'wp_discourse_options',
69 __( 'Connection', 'wp-discourse' ),
70 __( 'Connection', 'wp-discourse' ),
71 'manage_options',
72 'connection_options',
73 array( $this, 'connection_options_tab' )
74 );
75 add_action( 'load-' . $connection_settings, array( $this->form_helper, 'connection_status_notice' ) );
76
77 $publishing_settings = add_submenu_page(
78 'wp_discourse_options',
79 __( 'Publishing', 'wp-discourse' ),
80 __( 'Publishing', 'wp-discourse' ),
81 'manage_options',
82 'publishing_options',
83 array( $this, 'publishing_options_tab' )
84 );
85 add_action( 'load-' . $publishing_settings, array( $this->form_helper, 'connection_status_notice' ) );
86
87 $commenting_settings = add_submenu_page(
88 'wp_discourse_options',
89 __( 'Commenting', 'wp-discourse' ),
90 __( 'Commenting', 'wp-discourse' ),
91 'manage_options',
92 'commenting_options',
93 array( $this, 'commenting_options_tab' )
94 );
95 add_action( 'load-' . $commenting_settings, array( $this->form_helper, 'connection_status_notice' ) );
96
97 $configurable_text_settings = add_submenu_page(
98 'wp_discourse_options',
99 __( 'Text Content', 'wp-discourse' ),
100 __( 'Text Content', 'wp-discourse' ),
101 'manage_options',
102 'text_content_options',
103 array( $this, 'text_content_options_tab' )
104 );
105 add_action( 'load-' . $configurable_text_settings, array( $this->form_helper, 'connection_status_notice' ) );
106
107 $webhook_settings = add_submenu_page(
108 'wp_discourse_options',
109 __( 'Webhooks', 'wp-discourse' ),
110 __( 'Webhooks', 'wp-discourse' ),
111 'manage_options',
112 'webhook_options',
113 array( $this, 'webhook_options_tab' )
114 );
115 add_action( 'load-' . $webhook_settings, array( $this->form_helper, 'connection_status_notice' ) );
116
117 $sso_settings = add_submenu_page(
118 'wp_discourse_options',
119 __( 'DiscourseConnect', 'wp-discourse' ),
120 __( 'DiscourseConnect', 'wp-discourse' ),
121 'manage_options',
122 'sso_options',
123 array( $this, 'sso_options_tab' )
124 );
125 add_action( 'load-' . $sso_settings, array( $this->form_helper, 'connection_status_notice' ) );
126
127 $log_viewer = add_submenu_page(
128 'wp_discourse_options',
129 __( 'Logs', 'wp-discourse' ),
130 __( 'Logs', 'wp-discourse' ),
131 'manage_options',
132 'log_viewer',
133 array( $this, 'log_viewer_tab' )
134 );
135 add_action( 'load-' . $log_viewer, array( $this->form_helper, 'connection_status_notice' ) );
136 }
137
138 /**
139 * Called to display the 'connection_options' tab.
140 */
141 public function connection_options_tab() {
142 if ( current_user_can( 'manage_options' ) ) {
143 $this->options_page->display( 'connection_options' );
144 }
145 }
146
147 /**
148 * Called to display the 'publishing_options' tab.
149 */
150 public function publishing_options_tab() {
151 if ( current_user_can( 'manage_options' ) ) {
152 $this->options_page->display( 'publishing_options' );
153 }
154 }
155
156 /**
157 * Called to display the 'commenting_options' tab.
158 */
159 public function commenting_options_tab() {
160 if ( current_user_can( 'manage_options' ) ) {
161 $this->options_page->display( 'commenting_options' );
162 }
163 }
164
165 /**
166 * Called to display the 'text_content_options' tab.
167 */
168 public function text_content_options_tab() {
169 if ( current_user_can( 'manage_options' ) ) {
170 $this->options_page->display( 'text_content_options' );
171 }
172 }
173
174 /**
175 * Called to display the 'webhook_options' tab.
176 */
177 public function webhook_options_tab() {
178 if ( current_user_can( 'manage_options' ) ) {
179 $this->options_page->display( 'webhook_options' );
180 }
181 }
182
183 /**
184 * Called to display the 'sso_options' tab.
185 */
186 public function sso_options_tab() {
187 if ( current_user_can( 'manage_options' ) ) {
188 $this->options_page->display( 'sso_options' );
189 }
190 }
191
192 /**
193 * Called to display the 'log_viewer' tab.
194 */
195 public function log_viewer_tab() {
196 if ( current_user_can( 'manage_options' ) ) {
197 $this->options_page->display( 'log_viewer' );
198 }
199 }
200 }
201