close

Making WordPress.org

Changeset 14705


Ignore:
Timestamp:
03/13/2026 06:09:29 AM (14 hours ago)
Author:
dd32
Message:

Plugin Directory: Rest API: Expose the raw metadata behind public data on the plugin post type.

This allows for local development environment to import plugins without parsing APIs that generate content from it.
This results in a more complete import, and less parsing issues.

See https://github.com/WordPress/wordpress.org/pull/555

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
1 added
1 deleted
2 edited

Legend:

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

    r14258 r14705  
    33
    44use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    5 use WordPressdotorg\Plugin_Directory\Plugin_I18n;
    6 use WordPressdotorg\Plugin_Directory\Template;
    75
    86/**
     
    1513    public static function init() {
    1614        self::load_routes();
    17         self::load_fields();
    1815    }
    1916
     
    4037        new Routes\Plugin_Blueprint();
    4138        new Routes\Plugin_Review();
    42     }
    43 
    44     /**
    45      * Loads all API field for existing WordPress object types we offer.
    46      */
    47     public static function load_fields() {
    48         new Fields\Plugin\Banners();
    49         new Fields\Plugin\Icons();
    50         new Fields\Plugin\Rating();
    51         new Fields\Plugin\Ratings();
    52         new Fields\Plugin\Screenshots();
    5339    }
    5440
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r14704 r14705  
    220220            'public'            => true,
    221221            'show_ui'           => true,
     222            'show_in_rest'      => true,
    222223            'show_admin_column' => false,
    223224            'capabilities'      => array(
     
    253254            'public'            => true,
    254255            'show_ui'           => true,
     256            'show_in_rest'      => true,
    255257            'show_admin_column' => true,
    256258            'meta_box_cb'       => false,
     
    280282            'public'            => true,
    281283            'show_ui'           => true,
     284            'show_in_rest'      => true,
    282285            'show_admin_column' => false,
    283286            'capabilities'      => array(
     
    298301            'public'            => true,
    299302            'show_ui'           => true,
     303            'show_in_rest'      => true,
    300304            'show_admin_column' => true,
    301305            'capabilities'      => array(
     
    405409        ) );
    406410
    407         /**
    408          * TODO
    409          * Use register_rest_field() to add array and object meta data to the API:
    410          * ratings, upgrade_notice, contributors, screenshots, sections, assets_screenshots,
    411          * assets_icons, assets_banners,
    412          */
    413 
    414         register_meta( 'post', 'rating', array(
    415             'type'         => 'number',
    416             'description'  => __( 'Overall rating of the plugin.', 'wporg-plugins' ),
    417             'single'       => true,
    418             // todo 'sanitize_callback' => 'absint',
    419             'show_in_rest' => true,
    420         ) );
    421 
    422         register_meta( 'post', 'active_installs', array(
    423             'type'              => 'integer',
    424             'description'       => __( 'Number of installations.', 'wporg-plugins' ),
    425             'single'            => true,
    426             'sanitize_callback' => 'absint',
    427             'show_in_rest'      => true,
    428         ) );
    429 
    430         register_meta( 'post', 'downloads', array(
    431             'type'              => 'integer',
    432             'description'       => __( 'Number of downloads.', 'wporg-plugins' ),
    433             'single'            => true,
    434             'sanitize_callback' => 'absint',
    435             'show_in_rest'      => true,
    436         ) );
    437 
    438         register_meta( 'post', 'tested', array(
    439             'description'  => __( 'The version of WordPress the plugin was tested with.', 'wporg-plugins' ),
    440             'single'       => true,
    441             // TODO 'sanitize_callback' => 'absint',
    442             'show_in_rest' => true,
    443         ) );
    444 
    445         register_meta( 'post', 'requires', array(
    446             'description'  => __( 'The minimum version of WordPress the plugin needs to run.', 'wporg-plugins' ),
    447             'single'       => true,
    448             // TODO 'sanitize_callback' => 'absint',
    449             'show_in_rest' => true,
    450         ) );
    451 
    452         register_meta( 'post', 'requires_php', array(
    453             'description'  => __( 'The minimum version of PHP the plugin needs to run.', 'wporg-plugins' ),
    454             'single'       => true,
    455             // TODO 'sanitize_callback' => 'absint',
    456             'show_in_rest' => true,
    457         ) );
    458 
    459         register_meta( 'post', 'stable_tag', array(
    460             'description'  => __( 'Stable version of the plugin.', 'wporg-plugins' ),
    461             'single'       => true,
    462             // TODO 'sanitize_callback' => 'absint',
    463             'show_in_rest' => true,
    464         ) );
    465 
    466         register_meta( 'post', 'donate_link', array(
    467             'description'       => __( 'Link to donate to the plugin.', 'wporg-plugins' ),
    468             'single'            => true,
    469             'sanitize_callback' => 'esc_url_raw',
    470             'show_in_rest'      => true,
    471         ) );
    472 
    473         register_meta( 'post', 'version', array(
    474             'description'  => __( 'Current stable version.', 'wporg-plugins' ),
    475             'single'       => true,
    476             // TODO 'sanitize_callback' => 'esc_url_raw',
    477             'show_in_rest' => true,
    478         ) );
    479 
    480         register_meta( 'post', 'header_name', array(
    481             'description'  => __( 'Name of the plugin.', 'wporg-plugins' ),
    482             'single'       => true,
    483             // TODO 'sanitize_callback' => 'esc_url_raw',
    484             'show_in_rest' => true,
    485         ) );
    486 
    487         register_meta( 'post', 'header_plugin_uri', array(
    488             'description'       => __( 'URL to the homepage of the plugin.', 'wporg-plugins' ),
    489             'single'            => true,
    490             'sanitize_callback' => 'esc_url_raw',
    491             'show_in_rest'      => true,
    492         ) );
    493 
    494         register_meta( 'post', 'header_name', array(
    495             'description'  => __( 'Name of the plugin.', 'wporg-plugins' ),
    496             'single'       => true,
    497             // TODO 'sanitize_callback' => 'esc_url_raw',
    498             'show_in_rest' => true,
    499         ) );
    500 
    501         register_meta( 'post', 'header_author', array(
    502             'description'  => __( 'Name of the plugin author.', 'wporg-plugins' ),
    503             'single'       => true,
    504             // TODO 'sanitize_callback' => 'esc_url_raw',
    505             'show_in_rest' => true,
    506         ) );
    507 
    508         register_meta( 'post', 'header_author_uri', array(
    509             'description'       => __( 'URL to the homepage of the author.', 'wporg-plugins' ),
    510             'single'            => true,
    511             'sanitize_callback' => 'esc_url_raw',
    512             'show_in_rest'      => true,
    513         ) );
    514 
    515         register_meta( 'post', 'header_description', array(
    516             'description'  => __( 'Description of the plugin.', 'wporg-plugins' ),
    517             'single'       => true,
    518             // TODO 'sanitize_callback' => 'esc_url_raw',
    519             'show_in_rest' => true,
    520         ) );
    521 
    522         register_meta( 'post', 'assets_icons', array(
    523             'type'         => 'UserDefinedarray',
    524             'description'  => __( 'Icon images of the plugin.', 'wporg-plugins' ),
    525             'single'       => true,
    526             // TODO 'sanitize_callback' => 'esc_url_raw',
    527             'show_in_rest' => true,
    528         ) );
    529 
    530         register_meta( 'post', 'assets_banners_color', array(
    531             'description'  => __( 'Fallback color for the plugin.', 'wporg-plugins' ),
    532             'single'       => true,
    533             // TODO 'sanitize_callback' => 'esc_url_raw',
    534             'show_in_rest' => true,
    535         ) );
    536 
    537         register_meta( 'post', 'support_threads', array(
    538             'type'              => 'integer',
    539             'description'       => __( 'Amount of support threads for the plugin.', 'wporg-plugins' ),
    540             'single'            => true,
    541             'sanitize_callback' => 'absint',
    542             'show_in_rest'      => true,
    543         ) );
    544 
    545         register_meta( 'post', 'support_threads_resolved', array(
    546             'type'              => 'integer',
    547             'description'       => __( 'Amount of resolved support threads for the plugin.', 'wporg-plugins' ),
    548             'single'            => true,
    549             'sanitize_callback' => 'absint',
    550             'show_in_rest'      => true,
    551         ) );
     411        API\Plugin_Fields::register();
    552412
    553413        // Add the browse/* views.
Note: See TracChangeset for help on using the changeset viewer.