Plugin Directory


Ignore:
Timestamp:
10/15/2026 07:29:29 PM (4 days ago)
Author:
roxyapi
Message:

Update to version 1.21.0 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roxyapi/trunk/src/Admin/SettingsPage.php

    r3667444 r3749195  
    2121        public const OPTION_NAME  = 'roxyapi_settings';
    2222        public const OPTION_GROUP = 'roxyapi';
     23        public const HELP_SLUG    = 'roxyapi-help';
    2324
    2425        public static function register(): void {
    … …  
    8687
    8788                // 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).
    9090                add_submenu_page(
    9191                        self::PAGE_SLUG,
    … …  
    104104                        ShortcodesPage::PAGE_SLUG,
    105105                        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' )
    106115                );
    107116
    … …  
    121130                        );
    122131                }
     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                );
    123141        }
    124142
    … …  
    147165        }
    148166
     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
    149183        public static function render(): void {
    150184                if ( ! current_user_can( 'manage_options' ) ) {
    … …  
    172206                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only tab selector on a manage_options page.
    173207                $active_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'connect';
    174                 if ( ! in_array( $active_tab, array( 'connect', 'branding', 'display', 'privacy', 'advanced' ), true ) ) {
     208                if ( ! isset( self::tabs()[ $active_tab ] ) ) {
    175209                        $active_tab = 'connect';
    176210                }
    … …  
    244278        }
    245279
     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
    246289        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                }
    247294                if ( $hook !== 'toplevel_page_' . self::PAGE_SLUG ) {
    248295                        return;
Note: See TracChangeset for help on using the changeset viewer.