Changeset 15727
- Timestamp:
- 10/05/2010 01:24:41 PM (14 years ago)
- Location:
- trunk/wp-admin/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/theme-install.php
r15655 r15727 19 19 'tags' => true, 'num_ratings' => true 20 20 ); 21 22 23 /**24 * Retrieve theme installer pages from WordPress Themes API.25 *26 * It is possible for a theme to override the Themes API result with three27 * filters. Assume this is for themes, which can extend on the Theme Info to28 * offer more choices. This is very powerful and must be used with care, when29 * overridding the filters.30 *31 * The first filter, 'themes_api_args', is for the args and gives the action as32 * the second parameter. The hook for 'themes_api_args' must ensure that an33 * object is returned.34 *35 * The second filter, 'themes_api', is the result that would be returned.36 *37 * @since 2.8.038 *39 * @param string $action40 * @param array|object $args Optional. Arguments to serialize for the Theme Info API.41 * @return mixed42 */43 function themes_api($action, $args = null) {44 45 if ( is_array($args) )46 $args = (object)$args;47 48 if ( !isset($args->per_page) )49 $args->per_page = 24;50 51 $args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.52 $res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API.53 54 if ( ! $res ) {55 $request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );56 if ( is_wp_error($request) ) {57 $res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occured during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() );58 } else {59 $res = unserialize($request['body']);60 if ( ! $res )61 $res = new WP_Error('themes_api_failed', __('An unknown error occured'), $request['body']);62 }63 }64 //var_dump(array($args, $res));65 return apply_filters('themes_api_result', $res, $action, $args);66 }67 21 68 22 /** -
trunk/wp-admin/includes/theme.php
r15655 r15727 354 354 } 355 355 356 /** 357 * Retrieve theme installer pages from WordPress Themes API. 358 * 359 * It is possible for a theme to override the Themes API result with three 360 * filters. Assume this is for themes, which can extend on the Theme Info to 361 * offer more choices. This is very powerful and must be used with care, when 362 * overridding the filters. 363 * 364 * The first filter, 'themes_api_args', is for the args and gives the action as 365 * the second parameter. The hook for 'themes_api_args' must ensure that an 366 * object is returned. 367 * 368 * The second filter, 'themes_api', is the result that would be returned. 369 * 370 * @since 2.8.0 371 * 372 * @param string $action 373 * @param array|object $args Optional. Arguments to serialize for the Theme Info API. 374 * @return mixed 375 */ 376 function themes_api($action, $args = null) { 377 378 if ( is_array($args) ) 379 $args = (object)$args; 380 381 if ( !isset($args->per_page) ) 382 $args->per_page = 24; 383 384 $args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter. 385 $res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API. 386 387 if ( ! $res ) { 388 $request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) ); 389 if ( is_wp_error($request) ) { 390 $res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occured during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message() ); 391 } else { 392 $res = unserialize($request['body']); 393 if ( ! $res ) 394 $res = new WP_Error('themes_api_failed', __('An unknown error occured'), $request['body']); 395 } 396 } 397 //var_dump(array($args, $res)); 398 return apply_filters('themes_api_result', $res, $action, $args); 399 } 400 356 401 ?>
Note: See TracChangeset
for help on using the changeset viewer.