Making WordPress.org

Changeset 14769


Ignore:
Timestamp:
03/27/2026 03:25:57 PM (21 hours ago)
Author:
obenland
Message:

WP.org Abilities: Fully load the plugin directory for MCP requests.

Previously, only the class autoloader was loaded when handling MCP
requests. This meant post types and custom statuses were not registered,
so queries for plugins in the review queue returned empty results.

Load the plugin bootstrap and run its initialization to ensure the
full runtime environment is available. Also use the plugin directory's
own slug lookup for consistency with the rest of the codebase.

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

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-abilities/plugins/plugin-directory/class-ability-base.php

    r14725 r14769  
    1212
    1313namespace WordPressdotorg\Abilities\Plugins\Plugin_Directory;
     14
     15use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    1416
    1517defined( 'ABSPATH' ) || exit;
     
    4749        }
    4850
    49         $autoloader = WP_PLUGIN_DIR . '/plugin-directory/class-autoloader.php';
     51        switch_to_blog( self::PLUGINS_BLOG_ID );
    5052
    51         if ( ! file_exists( $autoloader ) ) {
    52             return;
    53         }
     53        require_once WP_PLUGIN_DIR . '/plugin-directory/plugin-directory.php';
    5454
    55         require_once $autoloader;
    56         \WordPressdotorg\Plugin_Directory\Autoloader\register_class_path(
    57             'WordPressdotorg\\Plugin_Directory',
    58             WP_PLUGIN_DIR . '/plugin-directory'
    59         );
    60 
    61         switch_to_blog( self::PLUGINS_BLOG_ID );
     55        Plugin_Directory::instance()->init();
    6256
    6357        $loaded = true;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-abilities/plugins/plugin-directory/tools/class-get-plugin-status.php

    r14749 r14769  
    1212use WordPressdotorg\Abilities\Plugins\Plugin_Directory\Ability_Base;
    1313use WordPressdotorg\Plugin_Directory\Clients\HelpScout as HelpScout_Client;
     14use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    1415use WordPressdotorg\Plugin_Directory\Template;
    1516use WordPressdotorg\Plugin_Directory\Tools\Helpscout;
     
    143144        self::maybe_load_plugin_directory();
    144145
    145         $slug = sanitize_title( $input['plugin_slug'] );
    146         $post = self::get_plugin_post( $slug );
     146        $post = Plugin_Directory::get_plugin_post( $input['plugin_slug'] );
     147
     148        if ( $post && (int) $post->post_author !== get_current_user_id() ) {
     149            $post = false;
     150        }
    147151
    148152        if ( ! $post ) {
    149153            return array(
    150                 'error' => sprintf( 'No plugin with slug "%s" was found for your account.', $slug ),
     154                'error' => sprintf( 'No plugin with slug "%s" was found for your account.', sanitize_title( $input['plugin_slug'] ) ),
    151155            );
    152156        }
     
    158162            'feedback' => self::get_feedback( $post, $full_history ),
    159163        );
    160     }
    161 
    162     /**
    163      * Look up a plugin post owned by the current user.
    164      *
    165      * @param string $slug The plugin slug.
    166      * @return \WP_Post|null
    167      */
    168     private static function get_plugin_post( string $slug ): ?\WP_Post {
    169         $posts = get_posts(
    170             array(
    171                 'post_type'   => 'plugin',
    172                 'name'        => $slug,
    173                 'post_status' => 'any',
    174                 'author'      => get_current_user_id(),
    175                 'numberposts' => 1,
    176             )
    177         );
    178 
    179         return $posts[0] ?? null;
    180164    }
    181165
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-abilities/plugins/plugin-directory/tools/class-submit-plugin.php

    r14749 r14769  
    1111
    1212use WordPressdotorg\Abilities\Plugins\Plugin_Directory\Ability_Base;
     13use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    1314use WordPressdotorg\Plugin_Directory\Shortcodes\Upload_Handler;
    1415
     
    207208        $plugin_post_id = 0;
    208209        if ( $is_update ) {
    209             $slug = sanitize_title( $input['plugin_slug'] );
    210             $post = self::find_plugin_post( $slug );
     210            $post = Plugin_Directory::get_plugin_post( $input['plugin_slug'] );
    211211
    212212            if ( ! $post ) {
    213213                return self::error_response(
    214214                    'plugin_not_found',
    215                     sprintf( 'No plugin with slug "%s" was found for your account.', $slug ),
     215                    sprintf( 'No plugin with slug "%s" was found for your account.', sanitize_title( $input['plugin_slug'] ) ),
    216216                    'Use wporg://plugins/plugin-directory/get-plugin-status to check your plugin slugs.'
    217217                );
     
    474474
    475475        return $temp_path;
    476     }
    477 
    478     /**
    479      * Find a plugin post owned by the current user or accessible to a plugin reviewer.
    480      *
    481      * @param string $slug The plugin slug.
    482      * @return \WP_Post|null
    483      */
    484     private static function find_plugin_post( string $slug ): ?\WP_Post {
    485         $query_args = array(
    486             'post_type'   => 'plugin',
    487             'name'        => $slug,
    488             'post_status' => 'any',
    489             'numberposts' => 1,
    490         );
    491 
    492         // Scope to the current user unless they can review plugins.
    493         if ( ! current_user_can( 'plugin_approve' ) ) { // phpcs:ignore WordPress.WP.Capabilities.Unknown -- plugin_approve is registered by the plugin-directory plugin.
    494             $query_args['author'] = get_current_user_id();
    495         }
    496 
    497         $posts = get_posts( $query_args );
    498 
    499         return $posts[0] ?? null;
    500476    }
    501477
Note: See TracChangeset for help on using the changeset viewer.