Making WordPress.org

Changeset 13147


Ignore:
Timestamp:
01/24/2024 06:33:47 AM (15 months ago)
Author:
dd32
Message:

Plugin Directory: API: Expose the Commercial / Community metadata through the API.

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

Legend:

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

    r13146 r13147  
    132132
    133133        $result['num_ratings']              = array_sum( $result['ratings'] );
     134        $result['support_url']              = 'https://wordpress.org/support/plugin/' . urlencode( $plugin_slug ) . '/';
    134135        $result['support_threads']          = intval( get_post_meta( $post_id, 'support_threads', true ) );
    135136        $result['support_threads_resolved'] = intval( get_post_meta( $post_id, 'support_threads_resolved', true ) );
     
    190191            foreach ( $versions as $version ) {
    191192                $result['versions'][ $version ] = Template::download_link( $post, $version );
     193            }
     194        }
     195
     196        // Add Commercial / Community metadata.
     197        $result['business_model']         = false;
     198        $result['repository_url']         = '';
     199        $result['commercial_support_url'] = '';
     200        if ( $terms = get_the_terms( $post_id, 'plugin_business_model' ) ) {
     201            $result['business_model'] = $terms[0]->slug; // commercial, community, canonical
     202
     203            if ( 'commercial' === $result['business_model'] ) {
     204                $result['commercial_support_url'] = get_post_meta( $post_id, 'external_support_url', true ) ?: '';
     205            } else {
     206                $result['repository_url']         = get_post_meta( $post_id, 'external_repository_url', true ) ?: '';
    192207            }
    193208        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php

    r13146 r13147  
    1111
    1212    static $fields = array(
    13         'active_installs'     => false,
    14         'added'               => false,
    15         'banners'             => false,
    16         'compatibility'       => false,
    17         'contributors'        => false,
    18         'description'         => false,
    19         'donate_link'         => false,
    20         'downloaded'          => false,
    21         'download_link'       => false,
    22         'homepage'            => false,
    23         'icons'               => false,
    24         'last_updated'        => false,
    25         'rating'              => false,
    26         'ratings'             => false,
    27         'reviews'             => false, // NOTE: sub-key of 'sections'.
    28         'requires'            => false,
    29         'requires_php'        => false,
    30         'sections'            => false,
    31         'short_description'   => false,
    32         'tags'                => false,
    33         'tested'              => false,
    34         'stable_tag'          => false,
    35         'blocks'              => false,
    36         'block_assets'        => false,
    37         'author_block_count'  => false,
    38         'author_block_rating' => false,
    39         'language_packs'      => false,
    40         'versions'            => false,
    41         'screenshots'         => false,
    42         'blueprints'          => false,
    43         'preview_link'        => false,
    44         'upgrade_notice'      => false,
     13        'active_installs'        => false,
     14        'added'                  => false,
     15        'banners'                => false,
     16        'compatibility'          => false,
     17        'contributors'           => false,
     18        'description'            => false,
     19        'donate_link'            => false,
     20        'downloaded'             => false,
     21        'download_link'          => false,
     22        'homepage'               => false,
     23        'icons'                  => false,
     24        'last_updated'           => false,
     25        'rating'                 => false,
     26        'ratings'                => false,
     27        'reviews'                => false, // NOTE: sub-key of 'sections'.
     28        'requires'               => false,
     29        'requires_php'           => false,
     30        'sections'               => false,
     31        'short_description'      => false,
     32        'tags'                   => false,
     33        'tested'                 => false,
     34        'stable_tag'             => false,
     35        'blocks'                 => false,
     36        'block_assets'           => false,
     37        'author_block_count'     => false,
     38        'author_block_rating'    => false,
     39        'language_packs'         => false,
     40        'versions'               => false,
     41        'screenshots'            => false,
     42        'blueprints'             => false,
     43        'preview_link'           => false,
     44        'upgrade_notice'         => false,
     45        'business_model'         => false,
     46        'repository_url'         => false,
     47        'support_url'            => false,
     48        'commercial_support_url' => false,
    4549    );
    4650
     
    6872    // Alterations made to default fields in the info/1.2 API.
    6973    static $plugins_info_fields_defaults_12 = array(
    70         'downloaded'        => false,
    71         'bare_contributors' => false,
    72         'compatibility'     => false,
    73         'description'       => false,
    74         'banners'           => true,
    75         'reviews'           => true,
    76         'active_installs'   => true,
    77         'contributors'      => true,
    78         'preview_link'      => true,
     74        'downloaded'             => false,
     75        'bare_contributors'      => false,
     76        'compatibility'          => false,
     77        'description'            => false,
     78        'banners'                => true,
     79        'reviews'                => true,
     80        'active_installs'        => true,
     81        'contributors'           => true,
     82        'preview_link'           => true,
     83        'upgrade_notice'         => true,
     84        'business_model'         => true,
     85        'repository_url'         => true,
     86        'support_url'            => true,
     87        'commercial_support_url' => true,
    7988    );
    8089
     
    130139    // If the key is disabled, disable all of the values here unless client turns them on.
    131140    static $field_interconnected = array(
    132         'sections' => [ 'reviews' ], // If sections is disabled, reviews should be disabled unless explicitly enabled.
     141        'sections'       => [ 'reviews' ], // If sections is disabled, reviews should be disabled unless explicitly enabled.
     142        'business_model' => [ 'repository_url', 'commercial_support_url' ]
    133143    );
    134144
Note: See TracChangeset for help on using the changeset viewer.