Making WordPress.org


Ignore:
Timestamp:
12/19/2017 04:22:37 PM (7 years ago)
Author:
obenland
Message:

PLugins: Clean up formatting with phpcbf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r6188 r6287  
    6262        $data = $this->export_and_parse_plugin( $plugin_slug );
    6363
    64         $readme = $data['readme'];
    65         $assets = $data['assets'];
    66         $headers = $data['plugin_headers'];
    67         $stable_tag = $data['stable_tag'];
     64        $readme          = $data['readme'];
     65        $assets          = $data['assets'];
     66        $headers         = $data['plugin_headers'];
     67        $stable_tag      = $data['stable_tag'];
    6868        $tagged_versions = $data['tagged_versions'];
    6969
     
    8989         */
    9090        if (
    91             ( !isset( $headers->Version ) || $headers->Version != get_post_meta( $plugin->ID, 'version', true ) ) ||
     91            ( ! isset( $headers->Version ) || $headers->Version != get_post_meta( $plugin->ID, 'version', true ) ) ||
    9292            $plugin->post_modified == '0000-00-00 00:00:00' ||
    9393            ( $svn_changed_tags && in_array( ( $stable_tag ?: 'trunk' ), $svn_changed_tags, true ) )
     
    150150        }
    151151
    152         update_post_meta( $plugin->ID, 'tagged_versions',    wp_slash( $tagged_versions ) );
    153         update_post_meta( $plugin->ID, 'sections',           wp_slash( array_keys( $readme->sections ) ) );
     152        update_post_meta( $plugin->ID, 'tagged_versions', wp_slash( $tagged_versions ) );
     153        update_post_meta( $plugin->ID, 'sections', wp_slash( array_keys( $readme->sections ) ) );
    154154        update_post_meta( $plugin->ID, 'assets_screenshots', wp_slash( $assets['screenshot'] ) );
    155         update_post_meta( $plugin->ID, 'assets_icons',       wp_slash( $assets['icon'] ) );
    156         update_post_meta( $plugin->ID, 'assets_banners',     wp_slash( $assets['banner'] ) );
    157         update_post_meta( $plugin->ID, 'last_updated',       wp_slash( $plugin->post_modified_gmt ) );
    158         update_post_meta( $plugin->ID, 'plugin_status',      wp_slash( $plugin->post_status ) );
     155        update_post_meta( $plugin->ID, 'assets_icons', wp_slash( $assets['icon'] ) );
     156        update_post_meta( $plugin->ID, 'assets_banners', wp_slash( $assets['banner'] ) );
     157        update_post_meta( $plugin->ID, 'last_updated', wp_slash( $plugin->post_modified_gmt ) );
     158        update_post_meta( $plugin->ID, 'plugin_status', wp_slash( $plugin->post_status ) );
    159159
    160160        // Calculate the 'plugin color' from the average color of the banner if provided. This is used for fallback icons.
     
    172172        // Finally, set the new version live.
    173173        update_post_meta( $plugin->ID, 'stable_tag', wp_slash( $stable_tag ) );
    174         update_post_meta( $plugin->ID, 'version',    wp_slash( $headers->Version ) );
     174        update_post_meta( $plugin->ID, 'version', wp_slash( $headers->Version ) );
    175175
    176176        // Ensure that the API gets the updated data
     
    208208                $svn_revision_triggered ?
    209209                    "{$plugin_slug}: ZIP build triggered by https://plugins.trac.wordpress.org/changeset/{$svn_revision_triggered}" :
    210                     "{$plugin_slug}: ZIP build triggered by " . php_uname('n'),
     210                    "{$plugin_slug}: ZIP build triggered by " . php_uname( 'n' ),
    211211                $stable_tag
    212212            );
    213         } catch( Exception $e ) {
     213        } catch ( Exception $e ) {
    214214            return false;
    215215        }
     
    247247        $tagged_versions = array_map( function( $item ) {
    248248            $trimmed_item = rtrim( $item, '/' );
     249
    249250            if ( $trimmed_item == $item ) {
    250251                // If attempting to trim `/` off didn't do anything, it was a file and we want to discard it.
     
    288289
    289290            $trunk_readme_file = self::PLUGIN_SVN_BASE . "/{$plugin_slug}/trunk/{$trunk_readme_file}";
    290             $trunk_readme = new Parser( $trunk_readme_file );
     291            $trunk_readme      = new Parser( $trunk_readme_file );
    291292
    292293            $stable_tag = $trunk_readme->stable_tag;
     
    300301                array(
    301302                    'ignore-externals',
    302                     'depth' => 'files'
     303                    'depth' => 'files',
    303304                )
    304305            );
     
    306307            if ( ! $svn_export['result'] && '0.' == substr( $stable_tag, 0, 2 ) ) {
    307308                $_stable_tag = substr( $stable_tag, 1 );
    308                 $svn_export = SVN::export(
     309                $svn_export  = SVN::export(
    309310                    self::PLUGIN_SVN_BASE . "/{$plugin_slug}/tags/{$_stable_tag}",
    310311                    $tmp_dir . '/export',
    311312                    array(
    312313                        'ignore-externals',
    313                         'depth' => 'files'
     314                        'depth' => 'files',
    314315                    )
    315316                );
     
    335336                array(
    336337                    'ignore-externals',
    337                     'depth' => 'files' // Only export the root files, we don't need the rest to read the plugin headers/screenshots
     338                    'depth' => 'files', // Only export the root files, we don't need the rest to read the plugin headers/screenshots
    338339                )
    339340            );
     
    354355
    355356        // Now we look in the /assets/ folder for banners, screenshots, and icons.
    356         $assets = array( 'screenshot' => array(), 'banner' => array(), 'icon' => array() );
     357        $assets            = array(
     358            'screenshot' => array(),
     359            'banner'     => array(),
     360            'icon'       => array(),
     361        );
    357362        $svn_assets_folder = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/assets/", true /* verbose */ );
    358363        if ( $svn_assets_folder ) { // /assets/ may not exist.
     
    362367                    continue;
    363368                }
    364                 $type = $m['type'];
    365                 $filename = $asset['filename'];
    366                 $revision = $asset['revision'];
    367                 $location = 'assets';
     369
     370                $type       = $m['type'];
     371                $filename   = $asset['filename'];
     372                $revision   = $asset['revision'];
     373                $location   = 'assets';
    368374                $resolution = isset( $m['resolution'] ) ? $m['resolution'] : false;
     375
    369376                $assets[ $type ][ $asset['filename'] ] = compact( 'filename', 'revision', 'resolution', 'location' );
    370377            }
     
    373380        // Find screenshots in the stable plugin folder (but don't overwrite /assets/)
    374381        foreach ( Filesystem::list_files( "$tmp_dir/export/", false /* non-recursive */, '!^screenshot-\d+\.(jpeg|jpg|png|gif)$!' ) as $plugin_screenshot ) {
    375             $filename = basename( $plugin_screenshot );
     382            $filename      = basename( $plugin_screenshot );
    376383            $screenshot_id = substr( $filename, strpos( $filename, '-' ) + 1 );
    377384            $screenshot_id = substr( $screenshot_id, 0, strpos( $screenshot_id, '.' ) );
    378385
    379             if ( isset( $assets['screenshot'][ $filename ]  ) ) {
     386            if ( isset( $assets['screenshot'][ $filename ] ) ) {
    380387                // Skip it, it exists within /assets/ already
    381388                continue;
     
    383390
    384391            $assets['screenshot'][ $filename ] = array(
    385                 'filename' => $filename,
    386                 'revision' => $svn_export['revision'],
     392                'filename'   => $filename,
     393                'revision'   => $svn_export['revision'],
    387394                'resolution' => $screenshot_id,
    388                 'location' => 'plugin',
     395                'location'   => 'plugin',
    389396            );
    390397        }
Note: See TracChangeset for help on using the changeset viewer.