Changeset 13620 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
- Timestamp:
- 04/30/2024 05:26:07 AM (5 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
r13610 r13620 7 7 use WordPressdotorg\Plugin_Directory\Tools; 8 8 use WordPressdotorg\Plugin_Directory\API\Base; 9 use function WordPressdotorg\Plugin_Directory\Theme\get_plugin_status_notice; 9 10 use WP_REST_Server; 10 11 … … 39 40 */ 40 41 function plugin_info( $request ) { 42 global $post; 41 43 $post = Plugin_Directory::get_plugin_post( $request['plugin_slug'] ); 42 44 43 if ( ! $post || 'publish' != $post->post_status ) { 45 // Support returning API data in different locales, even on wordpress.org (for api.wordpress.org usage) 46 if ( ! empty( $request['locale'] ) && ! in_array( strtolower( $request['locale'] ), array( 'en_us', 'en' ) ) ) { 47 switch_to_locale( $request['locale'] ); 48 } 49 50 if ( $post && in_array( $post->post_status, [ 'closed', 'disabled' ] ) ) { 51 $close_data = Template::get_close_data( $post ); 52 53 $close_text = ''; 54 if ( is_callable( '\WordPressdotorg\Plugin_Directory\Theme\get_plugin_status_notice' ) ) { 55 $close_text = strip_tags( get_plugin_status_notice( $post ) ); 56 } 57 58 return [ 59 'error' => 'closed', 60 'name' => get_the_title(), 61 'slug' => $post->post_name, 62 'description' => $close_text, 63 'closed' => true, 64 'closed_date' => $close_data['date'] ?: false, 65 'reason' => $close_data['public'] ? $close_data['reason'] : false, 66 'reason_text' => $close_data['public'] ? $close_data['label'] : false, 67 ]; 68 69 } elseif ( ! $post || 'publish' != $post->post_status ) { 44 70 // Copy what the REST API does if the param is incorrect 45 71 return new \WP_Error( … … 69 95 */ 70 96 public function plugin_info_data( $request, $post ) { 71 $GLOBALS['post'] = $post; 72 $plugin_slug = $post->post_name; 73 $post_id = $post->ID; 74 75 // Support returning API data in different locales, even on wordpress.org (for api.wordpress.org usage) 76 if ( ! empty( $request['locale'] ) && ! in_array( strtolower( $request['locale'] ), array( 'en_us', 'en' ) ) ) { 77 switch_to_locale( $request['locale'] ); 78 } 97 global $post; 98 99 $plugin_slug = $post->post_name; 100 $post_id = $post->ID; 79 101 80 102 $result = array();
Note: See TracChangeset
for help on using the changeset viewer.