Changeset 13610 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
- Timestamp:
- 04/29/2024 07:36:53 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
r13147 r13610 39 39 */ 40 40 function plugin_info( $request ) { 41 $plugin_slug = $request['plugin_slug']; 42 43 global $post; 44 $post = Plugin_Directory::get_plugin_post( $plugin_slug ); 45 46 if ( 'publish' != $post->post_status ) { 41 $post = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 42 43 if ( ! $post || 'publish' != $post->post_status ) { 47 44 // Copy what the REST API does if the param is incorrect 48 45 return new \WP_Error( … … 58 55 } 59 56 57 return $this->plugin_info_data( $request, $post ); 58 } 59 60 /** 61 * The underlying API for the plugin information. 62 * 63 * Expects that the input has been validated, and that the $post object is safe for display. 64 * This is shared with/called from Pending_Plugin too. 65 * 66 * @param \WP_REST_Request $request The request object. 67 * @param \WP_Post $post The post object for the plugin. 68 * @return array The formatted array of all the data for the plugin. 69 */ 70 public function plugin_info_data( $request, $post ) { 71 $GLOBALS['post'] = $post; 72 $plugin_slug = $post->post_name; 73 $post_id = $post->ID; 74 60 75 // Support returning API data in different locales, even on wordpress.org (for api.wordpress.org usage) 61 76 if ( ! empty( $request['locale'] ) && ! in_array( strtolower( $request['locale'] ), array( 'en_us', 'en' ) ) ) { 62 77 switch_to_locale( $request['locale'] ); 63 78 } 64 65 $post_id = $post->ID;66 79 67 80 $result = array();
Note: See TracChangeset
for help on using the changeset viewer.