Changeset 3749195 for roxyapi/trunk/src/Admin/SettingsPage.php
- Timestamp:
- 10/15/2026 07:29:29 PM (4 days ago)
- File:
-
- 1 edited
-
roxyapi/trunk/src/Admin/SettingsPage.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
roxyapi/trunk/src/Admin/SettingsPage.php
r3667444 r3749195 21 21 public const OPTION_NAME = 'roxyapi_settings'; 22 22 public const OPTION_GROUP = 'roxyapi'; 23 public const HELP_SLUG = 'roxyapi-help'; 23 24 24 25 public static function register(): void { … … 86 87 87 88 // Register the first submenu explicitly to rename the auto-generated 88 // duplicate to "Settings" (a tabbed screen) while keeping the default 89 // landing slug used by the post-activation redirect. 89 // duplicate to "Settings" (a tabbed screen). 90 90 add_submenu_page( 91 91 self::PAGE_SLUG, … … 104 104 ShortcodesPage::PAGE_SLUG, 105 105 array( ShortcodesPage::class, 'render' ) 106 ); 107 108 add_submenu_page( 109 self::PAGE_SLUG, 110 esc_html__( 'Create a reading', 'roxyapi' ), 111 esc_html__( 'Create a reading', 'roxyapi' ), 112 'manage_options', 113 BuilderPage::PAGE_SLUG, 114 array( BuilderPage::class, 'render' ) 106 115 ); 107 116 … … 121 130 ); 122 131 } 132 133 add_submenu_page( 134 self::PAGE_SLUG, 135 esc_html__( 'Help', 'roxyapi' ), 136 esc_html__( 'Help', 'roxyapi' ), 137 'manage_options', 138 self::HELP_SLUG, 139 array( self::class, 'render_help' ) 140 ); 123 141 } 124 142 … … 147 165 } 148 166 167 /** 168 * Settings tabs in display order, shared with the settings template. 169 * 170 * @return array<string, string> Tab labels keyed by slug. 171 */ 172 public static function tabs(): array { 173 return array( 174 'connect' => __( 'Connect', 'roxyapi' ), 175 'branding' => __( 'Branding', 'roxyapi' ), 176 'display' => __( 'Display', 'roxyapi' ), 177 'sell-readings' => __( 'Sell readings', 'roxyapi' ), 178 'privacy' => __( 'Privacy', 'roxyapi' ), 179 'advanced' => __( 'Advanced', 'roxyapi' ), 180 ); 181 } 182 149 183 public static function render(): void { 150 184 if ( ! current_user_can( 'manage_options' ) ) { … … 172 206 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only tab selector on a manage_options page. 173 207 $active_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'connect'; 174 if ( ! i n_array( $active_tab, array( 'connect', 'branding', 'display', 'privacy', 'advanced' ), true) ) {208 if ( ! isset( self::tabs()[ $active_tab ] ) ) { 175 209 $active_tab = 'connect'; 176 210 } … … 244 278 } 245 279 280 public static function render_help(): void { 281 if ( ! current_user_can( 'manage_options' ) ) { 282 return; 283 } 284 285 // The template escapes every label and URL at the source. 286 echo Templates::render( 'admin-help', array() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Template escape contract. 287 } 288 246 289 public static function enqueue( string $hook ): void { 290 if ( $hook === get_plugin_page_hookname( self::HELP_SLUG, self::PAGE_SLUG ) && current_user_can( 'manage_options' ) ) { 291 Assets::enqueue_admin_css(); 292 return; 293 } 247 294 if ( $hook !== 'toplevel_page_' . self::PAGE_SLUG ) { 248 295 return;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)