Changeset 6462
- Timestamp:
- 01/30/2018 03:18:52 AM (7 years ago)
- Location:
- sites/trunk
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/themes/info/1.0/index.php
r6418 r6462 9 9 if ( defined( 'JSON_RESPONSE' ) && JSON_RESPONSE ) { 10 10 $request = isset( $_REQUEST['request'] ) ? (object) wp_unslash( $_REQUEST['request'] ) : ''; 11 $format = 'json'; 11 12 } else { 12 13 $post_request = isset( $_POST['request'] ) ? urldecode( wp_unslash( $_POST['request'] ) ) : ''; … … 16 17 17 18 $request = unserialize( $post_request ); 19 20 $format = 'php'; 18 21 } 22 19 23 $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : ''; 20 24 21 // Load the Themes API. 22 if ( ! class_exists( 'Themes_API' ) ) { 23 require_once __DIR__ . '/class-themes-api.php'; 24 } 25 26 // Instantiate the API and serve the result. 27 $api = new Themes_API( $action, $request ); 28 echo $api->get_result(); 25 // Serve an API request. 26 echo wporg_themes_query_api( $action, $request, $format ); -
sites/trunk/api.wordpress.org/public_html/themes/theme-directory/1.0/index.php
r6418 r6462 55 55 } 56 56 57 $theme_slug = $_REQUEST['theme'];57 $theme_slug = wp_unslash( $_REQUEST['theme'] ); 58 58 59 59 if ( 'add-favorite' == $_REQUEST['action'] ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php
r6419 r6462 118 118 * @return string|void 119 119 */ 120 public function get_result( ) {121 if ( defined( 'JSON_RESPONSE' ) && JSON_RESPONSE) {120 public function get_result( $format = 'raw' ) { 121 if ( 'json' === $format ) { 122 122 return wp_json_encode( $this->response ); 123 } else {123 } elseif ( 'php' === $format ) { 124 124 return serialize( $this->response ); 125 } else { // 'raw' === $format, or anything else. 126 return $this->response; 125 127 } 126 128 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r6419 r6462 788 788 789 789 /** 790 * Makes a query against api.wordpress.org/themes/info/1.0/ without making a HTTP call 791 * Switches to the appropriate blog for the query. 792 */ 793 function wporg_themes_query_api( $method, $args = array() ) { 790 * Make a query against the api.wordpress.org/themes/info/ API 791 * This function can be used to access the API without making an external HTTP call. 792 * 793 * NOTE: The API also calls this function. 794 * 795 * @param $method string The Method being called. Valid values: 'query_themes', 'theme_information', 'hot_tags', 'feature_list', and 'get_commercial_shops' 796 * @param $args array The arguements for the call. 797 * @param $format string The format to return the data in. Valid values: 'json', 'php', 'raw' (default) 798 */ 799 function wporg_themes_query_api( $method, $args = array(), $format = 'raw' ) { 794 800 if ( ! class_exists( 'Themes_API' ) ) { 795 if ( file_exists( __DIR__ . '/class-themes-api.php' ) ) { 796 include_once __DIR__ . '/class-themes-api.php'; 797 } else { 798 include_once API_WPORGPATH . 'themes/info/1.0/class-themes-api.php'; 799 } 801 include_once __DIR__ . '/class-themes-api.php'; 800 802 } 801 803 802 804 $api = new Themes_API( $method, $args ); 803 805 804 return $api-> response;806 return $api->get_result( $format ); 805 807 } 806 808
Note: See TracChangeset
for help on using the changeset viewer.