Making WordPress.org

Changeset 12507


Ignore:
Timestamp:
03/29/2023 08:31:18 AM (4 years ago)
Author:
dd32
Message:

Plugin Directory: Move the plugin tools from the Tools menu to it's own dedicated menu.

See #6864.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php

    r12492 r12507  
    3838                add_action( 'all_admin_notices', array( $this, 'admin_notices' ) );
    3939                add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
     40                add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
    4041
    4142                add_filter( 'wp_insert_post_data', array( $this, 'check_existing_plugin_slug_on_post_update' ), 10, 2 );
    … …  
    141142                        }
    142143                }
     144        }
     145
     146        /**
     147         * Add the Repo Tools menu item to the admin menu.
     148         */
     149        public function admin_menu() {
     150                add_menu_page(
     151                        __( 'Plugin Tools', 'wporg-plugins' ),
     152                        __( 'Plugin Tools', 'wporg-plugins' ),
     153                        'plugin_review',
     154                        'plugin-tools',
     155                        array( $this, 'plugin_tools_page' ),
     156                        'dashicons-admin-tools',
     157                        30
     158                );
     159        }
     160
     161        /**
     162         * Render the Repo Tools dashboard page, just a basic list of the menu items.
     163         */
     164        public function plugin_tools_page() {
     165                global $submenu;
     166                ?>
     167                <div class="wrap">
     168                        <h1><?php _e( 'Plugin Tools', 'wporg-plugins' ); ?></h1>
     169                        <ul>
     170                                <?php
     171                                foreach ( $submenu['plugin-tools'] ?? [] as $page ) {
     172                                        if ( 'plugin-tools' === $page[2] ) {
     173                                                continue;
     174                                        }
     175
     176                                        printf(
     177                                                '<li><a href="%s">%s</a></li>',
     178                                                esc_url( admin_url( 'admin.php?page=' . $page[2] ) ),
     179                                                esc_html( $page[0] )
     180                                        );
     181                                }
     182                                ?>
     183                        </ul>
     184                </div>
     185                <?php
    143186        }
    144187
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-author-cards.php

    r7310 r12507  
    44use WordPressdotorg\Plugin_Directory;
    55use WordPressdotorg\Plugin_Directory\Admin\Metabox\Author_Card;
     6use const WordPressdotorg\Plugin_Directory\PLUGIN_FILE;
    67
    78/**
    … …  
    2627        private function __construct() {
    2728                add_action( 'admin_menu', array( $this, 'add_to_menu' ) );
    28                 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
    2929        }
    3030
    3131        /**
    32          * Enqueue JS and CSS assets needed for any wp-admin screens.
    33          *
    34          * @param string $hook_suffix The hook suffix of the current screen.
     32         * Add the Author Cards tool to the Tools menu.
    3533         */
    36         public function enqueue_assets( $hook_suffix ) {
    37                 switch ( $hook_suffix ) {
    38                         case 'tools_page_authorcards':
    39                                 wp_enqueue_style( 'plugin-admin-post-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 5 );
    40                                 break;
    41                 }
    42         }
    43 
    4434        public function add_to_menu() {
    45                 add_submenu_page(
    46                         'tools.php',
     35                $hook = add_submenu_page(
     36                        'plugin-tools',
    4737                        __( 'Author Cards', 'wporg-plugins' ),
    4838                        __( 'Author Cards', 'wporg-plugins' ),
    … …  
    5141                        array( $this, 'show_form' )
    5242                );
     43
     44                add_action( "admin_print_styles-{$hook}", array( $this, 'enqueue_assets' ) );
    5345        }
    5446
     47        /**
     48         * Enqueue JS and CSS assets needed for any wp-admin screens.
     49         */
     50        public function enqueue_assets() {
     51                wp_enqueue_style( 'plugin-admin-post-css', plugins_url( 'css/edit-form.css', PLUGIN_FILE ), array( 'edit' ), 5 );
     52        }
     53
     54        /**
     55         * Display the Author Cards tool.
     56         */
    5557        public function show_form() {
    5658                if ( ! current_user_can( 'plugin_review' ) ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php

    r11742 r12507  
    3232        public function add_to_menu() {
    3333                add_submenu_page(
    34                         'tools.php',
     34                        'plugin-tools',
    3535                        __( 'Stats Report', 'wporg-plugins' ),
    3636                        __( 'Stats Report', 'wporg-plugins' ),
Note: See TracChangeset for help on using the changeset viewer.