Making WordPress.org


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

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

See #6864.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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' ) ) {
Note: See TracChangeset for help on using the changeset viewer.