Making WordPress.org

Changeset 10741


Ignore:
Timestamp:
03/04/2021 06:12:12 AM (4 years ago)
Author:
dd32
Message:

Theme Directory: Add a set of REST API Endpoints that currently just wrap wporg_themes_query_api().

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
Files:
7 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-internal-stats.php

    r10740 r10741  
    11<?php
     2namespace WordPressdotorg\Theme_Directory\Rest_API;
     3use WP_REST_Server;
     4use WP_Error;
     5use WP_Http;
    26
    3 class WPorg_Themes_Rest_API_Internal_Stats {
     7class Internal_Stats {
    48
    59    function __construct() {
    6         register_rest_route( 'themes/v1', '/update-stats', array(
    7             'methods'  => \WP_REST_Server::CREATABLE,
    8             'callback' => array( $this, 'bulk_update_stats' ),
     10        register_rest_route( 'themes/v1', 'update-stats', array(
     11            'methods'             => \WP_REST_Server::CREATABLE,
     12            'callback'            => array( $this, 'bulk_update_stats' ),
    913            'permission_callback' => array( $this, 'permission_check_internal_api_bearer' ),
    1014        ) );
     
    2630            ! hash_equals( THEME_API_INTERNAL_BEARER_TOKEN, $authorization_header )
    2731        ) {
    28             return new \WP_Error(
     32            return new WP_Error(
    2933                'not_authorized',
    3034                __( 'Sorry! You cannot do that.', 'wporg-themes' ),
     
    114118
    115119}
    116 new WPorg_Themes_Rest_API_Internal_Stats();
     120new Internal_Stats();
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r10740 r10741  
    3434// Load the GitHub API client.
    3535include __DIR__ . '/lib/class-github.php';
     36
     37// Load the Rest API Endpoints.
     38include __DIR__ . '/rest-api.php';
    3639
    3740define( 'WPORG_THEMES_DEFAULT_BROWSE', 'popular' );
     
    171174}
    172175add_action( 'init', 'wporg_themes_init' );
    173 
    174 /**
    175  * Loads the Rest API Endpoints.
    176  */
    177 function wporg_themes_rest_apis() {
    178     include __DIR__ . '/class-wporg-themes-rest-api-internal-stats.php';
    179 }
    180 add_action( 'rest_api_init', 'wporg_themes_rest_apis' );
    181176
    182177/**
Note: See TracChangeset for help on using the changeset viewer.