Making WordPress.org


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

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

File:
1 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                }
Note: See TracChangeset for help on using the changeset viewer.