Making WordPress.org


Ignore:
Timestamp:
02/04/2018 03:01:50 PM (9 years ago)
Author:
ocean90
Message:

Translate, Plugin Directory: Improve fallback data for missing plugin details.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-plugin-directory/inc/cli/class-set-plugin-project.php

    r6533 r6535  
    4949                // Get plugin details from the API.
    5050                $plugin_details = $this->get_plugin_details( $plugin_slug );
     51
    5152                if ( ! $plugin_details ) {
    5253                        WP_CLI::warning( "The plugin API couldn't be reached." );
    … …  
    6465                                // Fill details with old data in case the API is down.
    6566                                $plugin_details = new stdClass();
    66                                 $plugin_details->name = $plugin_project->name;
    67                                 $plugin_details->short_description = $plugin_project->description;
     67                                $plugin_details->name = $plugin_project->name ?: $plugin_slug;
     68                                $plugin_details->short_description = str_replace( "<br><br><a href='https://wordpress.org/plugins/{$plugin_slug}'>WordPress.org Plugin Page</a>", '', $plugin_project->description );
    6869                                $plugin_details->stable_tag = 'trunk';
    6970                        }
    … …  
    283284                $details = $json && '{' == $json[0] ? json_decode( $json ) : null;
    284285
     286                if ( isset( $details->error ) ) {
     287                        return null;
     288                }
     289
    285290                return $details;
    286291        }
Note: See TracChangeset for help on using the changeset viewer.