Making WordPress.org

Changeset 6287


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

PLugins: Clean up formatting with phpcbf

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
8 added
81 edited

Legend:

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

    r6217 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin;
     3
    34use \WordPressdotorg\Plugin_Directory;
    45use \WordPressdotorg\Plugin_Directory\Tools;
     
    4950                add_action( 'do_meta_boxes', array( $this, 'replace_title_global' ) );
    5051
    51                 add_filter( 'postbox_classes_plugin_internal-notes',      array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'postbox_classes' ) );
    52                 add_filter( 'postbox_classes_plugin_plugin-committers',   array( __NAMESPACE__ . '\Metabox\Committers',    'postbox_classes' ) );
    53                 add_filter( 'postbox_classes_plugin_plugin-support-reps', array( __NAMESPACE__ . '\Metabox\Support_Reps',   'postbox_classes' ) );
    54                 add_filter( 'wp_ajax_add-committer',        array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' ) );
    55                 add_filter( 'wp_ajax_delete-committer',     array( __NAMESPACE__ . '\Metabox\Committers', 'remove_committer' ) );
    56                 add_filter( 'wp_ajax_add-support-rep',      array( __NAMESPACE__ . '\Metabox\Support_Reps', 'add_support_rep' ) );
    57                 add_filter( 'wp_ajax_delete-support-rep',   array( __NAMESPACE__ . '\Metabox\Support_Reps', 'remove_support_rep' ) );
     52                add_filter( 'postbox_classes_plugin_internal-notes', array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'postbox_classes' ) );
     53                add_filter( 'postbox_classes_plugin_plugin-committers', array( __NAMESPACE__ . '\Metabox\Committers', 'postbox_classes' ) );
     54                add_filter( 'postbox_classes_plugin_plugin-support-reps', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'postbox_classes' ) );
     55                add_filter( 'wp_ajax_add-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' ) );
     56                add_filter( 'wp_ajax_delete-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'remove_committer' ) );
     57                add_filter( 'wp_ajax_add-support-rep', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'add_support_rep' ) );
     58                add_filter( 'wp_ajax_delete-support-rep', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'remove_support_rep' ) );
    5859                add_action( 'wp_ajax_plugin-author-lookup', array( __NAMESPACE__ . '\Metabox\Author', 'lookup_author' ) );
    5960        }
     
    204205
    205206                if ( $rejected ) {
    206                         set_transient( 'settings_errors', array( array(
    207                                 'setting' => 'wporg-plugins',
    208                                 'code'    => 'plugins-bulk-rejected',
    209                                 'message' => sprintf( _n( '%d plugin rejected.', '%d plugins rejected.', $rejected, 'wporg-plugins' ), $rejected ),
    210                                 'type'    => 'updated',
    211                         ) ) );
     207                        set_transient( 'settings_errors', array(
     208                                array(
     209                                        'setting' => 'wporg-plugins',
     210                                        'code'    => 'plugins-bulk-rejected',
     211                                        'message' => sprintf( _n( '%d plugin rejected.', '%d plugins rejected.', $rejected, 'wporg-plugins' ), $rejected ),
     212                                        'type'    => 'updated',
     213                                ),
     214                        ) );
    212215                }
    213216
     
    277280
    278281                if ( $message ) {
    279                         printf( '<div class="notice %1$s"><p>%2$s</p></div>', esc_attr( $type ), esc_html( $message ) ); 
     282                        printf( '<div class="notice %1$s"><p>%2$s</p></div>', esc_attr( $type ), esc_html( $message ) );
    280283                }
    281284        }
     
    331334                        return $data;
    332335                }
    333                
     336
    334337                $existing_plugin = Plugin_Directory\Plugin_Directory::get_plugin_post( $data['post_name'] );
    335338
     
    416419                );
    417420
    418 
    419421                add_meta_box(
    420422                        'plugin-fields',
     
    449451
    450452                // Remove unnecessary metaboxes.
    451                 remove_meta_box( 'commentsdiv',      'plugin', 'normal' );
     453                remove_meta_box( 'commentsdiv', 'plugin', 'normal' );
    452454                remove_meta_box( 'commentstatusdiv', 'plugin', 'normal' );
    453455
     
    489491         * Changes the permalink for internal notes to link to the edit post screen.
    490492         *
    491          * @param string $link The comment permalink with '#comment-$id' appended.
     493         * @param string      $link The comment permalink with '#comment-$id' appended.
    492494         * @param \WP_Comment $comment The current comment object.
    493495         * @return string The permalink to the given comment.
     
    602604                ob_start();
    603605                if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) {
    604                         require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
     606                        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
    605607                        _wp_dashboard_recent_comments_row( $comment );
    606608                } else {
     
    618620                        'id'       => $comment->comment_ID,
    619621                        'data'     => $comment_list_item,
    620                         'position' => $position
     622                        'position' => $position,
    621623                );
    622624
     
    631633                                _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments', 'wporg-plugins' ),
    632634                                number_format_i18n( $counts->moderated )
    633                         )
     635                        ),
    634636                );
    635637
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php

    r6229 r6287  
    9696
    9797                // ...or it's a white-listed status for plugin reviewers.
    98                 if ( current_user_can( 'plugin_review', $postarr['ID'] ) && in_array( $postarr['post_status'], array(
     98                if ( current_user_can( 'plugin_review', $postarr['ID'] ) && in_array(
     99                        $postarr['post_status'], array(
    99100                                'new',
    100101                                'pending',
    101                         ) ) ) {
     102                        )
     103                ) ) {
    102104                        return $data;
    103105                }
     
    131133                                $this->approved( $post->ID, $post );
    132134                                break;
     135
    133136                        case 'rejected':
    134137                                $this->rejected( $post->ID, $post );
    135138                                break;
     139
    136140                        case 'publish':
    137141                                $this->clean_closed_date( $post->ID );
    138142                                break;
     143
    139144                        case 'disabled':
    140145                        case 'closed':
     
    163168                }
    164169
    165                 /* Temporarily disable SVN prefill from ZIP files
     170                /*
     171                 Temporarily disable SVN prefill from ZIP files
    166172                if ( $attachments ) {
    167173                        $attachment = end( $attachments );
     
    191197
    192198                /* translators: 1: plugin name, 2: plugin slug */
    193                 $content = sprintf( __( 'Congratulations, your plugin hosting request for %1$s has been approved.
     199                $content = sprintf(
     200                        __(
     201                                'Congratulations, your plugin hosting request for %1$s has been approved.
    194202
    195203Within one hour you will have access to your SVN repository with the WordPress.org username and password you used to log in and submit your request. Your username is case sensitive.
     
    223231--
    224232The WordPress Plugin Directory Team
    225 https://make.wordpress.org/plugins', 'wporg-plugins' ),
     233https://make.wordpress.org/plugins', 'wporg-plugins'
     234                        ),
    226235                        $post->post_title,
    227236                        $post->post_name
     
    256265
    257266                /* translators: 1: plugin name, 2: plugins@wordpress.org */
    258                 $content = sprintf( __( 'Unfortunately your plugin submission for %1$s has been rejected from the WordPress Plugin Directory.
     267                $content = sprintf(
     268                        __(
     269                                'Unfortunately your plugin submission for %1$s has been rejected from the WordPress Plugin Directory.
    259270
    260271If you believe this to be in error, please email %2$s with your plugin attached as a zip and explain why you feel your plugin should be an exception.
     
    262273--
    263274The WordPress Plugin Directory Team
    264 https://make.wordpress.org/plugins', 'wporg-plugins' ),
     275https://make.wordpress.org/plugins', 'wporg-plugins'
     276                        ),
    265277                        $post->post_title,
    266278                        'plugins@wordpress.org'
     
    340352                        'comment_author'       => $user->display_name,
    341353                        'comment_author_email' => $user->user_email,
    342                         'comment_author_url'   => $user->user_url,     
     354                        'comment_author_url'   => $user->user_url,
    343355                        'comment_type'         => 'internal-note',
    344356                        'comment_post_ID'      => $post_id,
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-committers.php

    r5867 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\List_Table;
     3
    34use WordPressdotorg\Plugin_Directory\Tools;
    45
     
    4546         */
    4647        public function prepare_items() {
    47                 $plugin_slug         = get_post()->post_name;
     48                $plugin_slug = get_post()->post_name;
    4849                if ( ! $plugin_slug ) {
    4950                        return;
    5051                }
    51                 $existing_committers = Tools::get_plugin_committers( $plugin_slug );
    52                 $this->items         = array_map( function ( $user ) {
     52
     53                $this->items = array_map( function ( $user ) {
    5354                        return new \WP_User( $user );
    54                 }, $existing_committers );
     55                }, Tools::get_plugin_committers( $plugin_slug ) );
    5556        }
    5657
     
    148149                        $user_object = get_userdata( (int) $user_object );
    149150                }
    150                 $user_object->filter = 'display';
     151                $user_object->filter                = 'display';
    151152                list( $columns, $hidden, $primary ) = $this->get_column_info();
    152153
     
    157158                $post_id = get_post()->ID;
    158159                if ( current_user_can( 'plugin_remove_committer', $post_id ) && $user_object->ID != get_current_user_id() ) {
    159                         $actions['delete'] = "<a class='submitremove' data-wp-lists='delete:the-committer-list:committer-{$user_object->ID}:faafaa:post_id={$post_id}' href='" . wp_nonce_url( 'users.php?action=remove&amp;committer=' . $user_object->ID, "remove-committer-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . "</a>";
     160                        $actions['delete'] = "<a class='submitremove' data-wp-lists='delete:the-committer-list:committer-{$user_object->ID}:faafaa:post_id={$post_id}' href='" . wp_nonce_url( 'users.php?action=remove&amp;committer=' . $user_object->ID, "remove-committer-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . '</a>';
    160161                }
    161162
     
    188189
    189190                                case 'username':
    190                                         $row .= sprintf( '<strong><a href="%s">%s</a></strong><br />&lt;%s&gt;',
     191                                        $row .= sprintf(
     192                                                '<strong><a href="%s">%s</a></strong><br />&lt;%s&gt;',
    191193                                                esc_url( '//profiles.wordpress.org/' . $user_object->user_nicename ),
    192194                                                $user_object->user_login,
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-comments.php

    r2764 r6287  
    3838                $singular = $this->_args['singular'];
    3939
    40                 wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
     40                wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
    4141                ?>
    4242                <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" data-comment-type="<?php echo esc_attr( $this->comment_type ); ?>" style="display:none;">
     
    4747                        <tbody id="the-comment-list"<?php if ( $singular ) { echo " data-wp-lists='list:$singular'"; } ?>>
    4848                        <?php
    49                                 if ( ! $output_empty ) {
    50                                         $this->display_rows_or_placeholder();
    51                                 }
     49                        if ( ! $output_empty ) {
     50                                $this->display_rows_or_placeholder();
     51                        }
    5252                        ?>
    5353                        </tbody>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php

    r5797 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\List_Table;
     3
    34use \WordPressdotorg\Plugin_Directory\Tools;
    45use \WordPressdotorg\Plugin_Directory\Template;
     
    2122
    2223                $post_type = $this->screen->post_type;
    23                 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
     24                $per_page  = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
    2425
    2526                /** This filter is documented in wp-admin/includes/post.php */
     
    3334                        $post_counts = (array) wp_count_posts( $post_type, 'readable' );
    3435
    35                         if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) {
     36                        if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati ) ) {
    3637                                $total_items = $post_counts[ $_REQUEST['post_status'] ];
    3738                        } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
     
    6061                $this->set_pagination_args( array(
    6162                        'total_items' => $total_items,
    62                         'per_page' => $per_page
     63                        'per_page'    => $per_page,
    6364                ) );
    6465        }
     
    6970         */
    7071        protected function get_bulk_actions() {
    71                 $actions = array();
     72                $actions       = array();
    7273                $post_type_obj = get_post_type_object( $this->screen->post_type );
    7374
     
    9293                $post_type     = $this->screen->post_type;
    9394                $posts_columns = array(
    94                         'cb'        => '<input type="checkbox" />',
     95                        'cb'     => '<input type="checkbox" />',
    9596                        /* translators: manage posts column name */
    96                         'title'     => _x( 'Title', 'column name', 'wporg-plugins' ),
    97                         'author'    => __( 'Submitter', 'wporg-plugins' ),
     97                        'title'  => _x( 'Title', 'column name', 'wporg-plugins' ),
     98                        'author' => __( 'Submitter', 'wporg-plugins' ),
    9899                );
    99100
     
    104105
    105106                foreach ( $taxonomies as $taxonomy ) {
    106                         $column_key = 'taxonomy-' . $taxonomy;
     107                        $column_key                   = 'taxonomy-' . $taxonomy;
    107108                        $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
    108109                }
    109110
    110111                $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Internal Notes', 'wporg-plugins' ) . '"><span class="screen-reader-text">' . __( 'Internal Notes', 'wporg-plugins' ) . '</span></span>';
    111                 $posts_columns['date'] = __( 'Date', 'wporg-plugins' );
     112                $posts_columns['date']     = __( 'Date', 'wporg-plugins' );
    112113
    113114                /**
     
    133134         *
    134135         * @param int|\WP_Post $post
    135          * @param int         $level
     136         * @param int          $level
    136137         */
    137138        public function single_row( $post, $level = 0 ) {
    138139                $global_post = get_post();
    139140
    140                 $post = get_post( $post );
     141                $post                = get_post( $post );
    141142                $this->current_level = $level;
    142143
     
    155156
    156157                if ( $post->post_parent ) {
    157                         $count = count( get_post_ancestors( $post->ID ) );
     158                        $count     = count( get_post_ancestors( $post->ID ) );
    158159                        $classes[] = 'level-' . $count;
    159160                } else {
     
    184185
    185186                $post_type_object = get_post_type_object( $post->post_type );
    186                 $can_edit_post = current_user_can( 'edit_post', $post->ID );
    187                 $actions = array();
    188                 $title = _draft_or_post_title();
     187                $can_edit_post    = current_user_can( 'edit_post', $post->ID );
     188                $actions          = array();
     189                $title            = _draft_or_post_title();
    189190
    190191                if ( $can_edit_post && 'trash' != $post->post_status ) {
     
    260261                $screen = $this->screen;
    261262
    262                 $taxonomy_names = get_object_taxonomies( $screen->post_type );
     263                $taxonomy_names          = get_object_taxonomies( $screen->post_type );
    263264                $hierarchical_taxonomies = array();
    264265
    265266                foreach ( $taxonomy_names as $taxonomy_name ) {
    266 
    267267                        $taxonomy = get_taxonomy( $taxonomy_name );
    268268
     
    302302        <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
    303303
    304                         <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
     304                        <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
    305305                        <input type="hidden" name="tax_input[<?php echo esc_attr( $taxonomy->name ); ?>][]" value="0" />
    306                         <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
    307                                 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
     306                        <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist">
     307                                <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?>
    308308                        </ul>
    309309
     
    355355                $mine            = '';
    356356
    357                 $plugins = Tools::get_users_write_access_plugins( $current_user_id );
    358                 $plugins = array_map( 'sanitize_title_for_query', $plugins );
    359                 $exclude_states   = get_post_stati( array(
     357                $plugins        = Tools::get_users_write_access_plugins( $current_user_id );
     358                $plugins        = array_map( 'sanitize_title_for_query', $plugins );
     359                $exclude_states = get_post_stati( array(
    360360                        'show_in_admin_all_list' => false,
    361361                ) );
     
    378378
    379379                if ( ! empty( $plugins ) ) {
    380                         $user_post_count_query = str_replace('AND post_author = %d', "AND ( post_author = %d OR post_name IN ( '" . implode( "','", $plugins ) . "' ) )", $user_post_count_query );
     380                        $user_post_count_query = str_replace( 'AND post_author = %d', "AND ( post_author = %d OR post_name IN ( '" . implode( "','", $plugins ) . "' ) )", $user_post_count_query );
    381381                }
    382382
     
    395395                        $mine_args = array(
    396396                                'post_type' => $post_type,
    397                                 'author'    => $current_user_id
     397                                'author'    => $current_user_id,
    398398                        );
    399399
     
    410410
    411411                        if ( ! current_user_can( 'plugin_review' ) ) {
    412                                 $status_links['mine'] = $this->get_edit_link( $mine_args, $mine_inner_html, 'current' );;
     412                                $status_links['mine'] = $this->get_edit_link( $mine_args, $mine_inner_html, 'current' );
     413
    413414                                return $status_links;
    414415                        } else {
     
    417418
    418419                        $all_args['all_posts'] = 1;
    419                         $class = '';
     420                        $class                 = '';
    420421                }
    421422
     
    440441                }
    441442
    442                 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
     443                foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) {
    443444                        $class = '';
    444445
     
    453454                        }
    454455
    455                         if ( isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) {
     456                        if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) {
    456457                                $class = 'current';
    457458                        }
     
    459460                        $status_args = array(
    460461                                'post_status' => $status_name,
    461                                 'post_type' => $post_type,
     462                                'post_type'   => $post_type,
    462463                        );
    463464
     
    474475
    475476                        $sticky_args = array(
    476                                 'post_type'     => $post_type,
    477                                 'show_sticky' => 1
     477                                'post_type'   => $post_type,
     478                                'show_sticky' => 1,
    478479                        );
    479480
     
    490491
    491492                        $sticky_link = array(
    492                                 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class )
     493                                'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ),
    493494                        );
    494495
    495496                        // Sticky comes after Publish, or if not listed, after All.
    496                         $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
     497                        $split        = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
    497498                        $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
    498499                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-support-reps.php

    r5867 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\List_Table;
     3
    34use WordPressdotorg\Plugin_Directory\Tools;
    45
     
    4546         */
    4647        public function prepare_items() {
    47                 $plugin_slug         = get_post()->post_name;
     48                $plugin_slug = get_post()->post_name;
    4849                if ( ! $plugin_slug ) {
    4950                        return;
    5051                }
    51                 $existing_support_reps = Tools::get_plugin_support_reps( $plugin_slug );
    52                 $this->items           = array_map( function ( $user ) {
     52
     53                $this->items = array_map( function ( $user ) {
    5354                        return new \WP_User( $user );
    54                 }, $existing_support_reps );
     55                }, Tools::get_plugin_support_reps( $plugin_slug ) );
    5556        }
    5657
     
    148149                        $user_object = get_userdata( (int) $user_object );
    149150                }
    150                 $user_object->filter = 'display';
     151                $user_object->filter                = 'display';
    151152                list( $columns, $hidden, $primary ) = $this->get_column_info();
    152153
     
    157158                $post_id = get_post()->ID;
    158159                if ( current_user_can( 'plugin_remove_support_rep', $post_id ) && $user_object->ID != get_current_user_id() ) {
    159                         $actions['delete'] = "<a class='submitremove' data-wp-lists='delete:the-support-rep-list:support-rep-{$user_object->ID}:faafaa:post_id={$post_id}' href='" . wp_nonce_url( 'users.php?action=remove&amp;support-rep=' . $user_object->ID, "remove-support-rep-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . "</a>";
     160                        $actions['delete'] = "<a class='submitremove' data-wp-lists='delete:the-support-rep-list:support-rep-{$user_object->ID}:faafaa:post_id={$post_id}' href='" . wp_nonce_url( 'users.php?action=remove&amp;support-rep=' . $user_object->ID, "remove-support-rep-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . '</a>';
    160161                }
    161162
     
    188189
    189190                                case 'username':
    190                                         $row .= sprintf( '<strong><a href="%s">%s</a></strong><br />&lt;%s&gt;',
     191                                        $row .= sprintf(
     192                                                '<strong><a href="%s">%s</a></strong><br />&lt;%s&gt;',
    191193                                                esc_url( '//profiles.wordpress.org/' . $user_object->user_nicename ),
    192194                                                $user_object->user_login,
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-card.php

    r6170 r6287  
    2424                add_action( 'wporg_usercards_after_content', array(
    2525                        __NAMESPACE__ . '\Author_Card',
    26                         'show_warning_flags'
     26                        'show_warning_flags',
    2727                ), 10, 6 );
    2828
     
    3939                }
    4040
    41                 $author_commit  = Tools::get_users_write_access_plugins( $author );
     41                $author_commit    = Tools::get_users_write_access_plugins( $author );
    4242                $author_plugins_q = array(
    4343                        'author'         => $author->ID,
     
    5050                }
    5151                $author_plugins = get_posts( $author_plugins_q );
    52                 $all_plugins = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} WHERE post_name IN ('" . implode( "', '", array_merge( $author_commit, wp_list_pluck( $author_plugins, 'post_name' ) ) ) . "')" );
     52                $all_plugins    = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} WHERE post_name IN ('" . implode( "', '", array_merge( $author_commit, wp_list_pluck( $author_plugins, 'post_name' ) ) ) . "')" );
    5353                ?>
    5454                <div class="profile">
     
    5959                                <?php
    6060                                        $author_links = array(
    61                                                 sprintf( '<a href="//make.wordpress.org/pluginrepo/?s=%s" title="%s">P2</a>',
     61                                                sprintf(
     62                                                        '<a href="//make.wordpress.org/pluginrepo/?s=%s" title="%s">P2</a>',
    6263                                                        urlencode( esc_attr( $author->user_nicename ) ),
    6364                                                        esc_attr__( 'Click to search Pluginrepo P2 for mentions of this author', 'wporg-plugins' )
    6465                                                ),
    65                                                 sprintf( '<a href="https://supportpress.wordpress.org/plugins/?q=%s&status=&todo=Search+%%C2%%BB" title="%s">SP</a>',
     66                                                sprintf(
     67                                                        '<a href="https://supportpress.wordpress.org/plugins/?q=%s&status=&todo=Search+%%C2%%BB" title="%s">SP</a>',
    6668                                                        urlencode( esc_attr( $author->user_nicename ) ),
    6769                                                        esc_attr__( 'Click to search Pluginrepo SupportPress for mentions of this author', 'wporg-plugins' )
     
    7779                                <div class="profile-email">
    7880                                        &lt;<?php echo $author->user_email; ?>&gt;
    79                                         <span class="profile-sp-link"><?php
    80                                                 printf( '[ <a href="https://supportpress.wordpress.org/plugins/?sender=%s&status=&todo=Search" title="%s">SP</a> ]',
     81                                        <span class="profile-sp-link">
     82                                        <?php
     83                                                printf(
     84                                                        '[ <a href="https://supportpress.wordpress.org/plugins/?sender=%s&status=&todo=Search" title="%s">SP</a> ]',
    8185                                                        esc_attr( $author->user_email ),
    8286                                                        esc_attr__( 'Click to search Pluginrepo SupportPress for emails sent to/from this email address', 'wporg-plugins' )
    8387                                                );
    84                                         ?></span>
     88                                        ?>
     89                                        </span>
    8590                                </div>
    86                                 <div class="profile-join"><?php
     91                                <div class="profile-join">
     92                                <?php
    8793                                        /* translators: 1: time ago, 2: registration date */
    88                                         printf( __( 'Joined %1$s ago (%2$s)', 'wporg-plugins' ),
     94                                        printf(
     95                                                __( 'Joined %1$s ago (%2$s)', 'wporg-plugins' ),
    8996                                                human_time_diff( strtotime( $author->user_registered ) ),
    9097                                                date( 'Y-M-d', strtotime( $author->user_registered ) )
    9198                                        );
    92                                 ?></div>
     99                                ?>
     100                                </div>
    93101                        </div>
    94102                </div>
     
    103111                <?php
    104112                if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {
    105                         $user = new \WP_User( $author, '', WPORG_SUPPORT_FORUMS_BLOGID );
     113                        $user     = new \WP_User( $author, '', WPORG_SUPPORT_FORUMS_BLOGID );
    106114                        $statuses = array();
    107115
     
    123131                                $labels = array();
    124132                                foreach ( $statuses as $status ) {
    125                                         $labels[] = sprintf( '<strong><span title="%s">%s</span></strong>',
     133                                        $labels[] = sprintf(
     134                                                '<strong><span title="%s">%s</span></strong>',
    126135                                                esc_attr( $status['desc'] ),
    127136                                                $status['text']
     
    150159
    151160                        /* translators: %s: comma-separated list of plugin author's IP addresses */
    152                         printf( '<p>' . __( 'IPs : %s', 'wporg-plugins' ) . '</p>',
     161                        printf(
     162                                '<p>' . __( 'IPs : %s', 'wporg-plugins' ) . '</p>',
    153163                                implode( ', ', array_map( array( __NAMESPACE__ . '\Author_Card', 'link_ip' ), $user_ips ) )
    154164                        );
     
    170180                                foreach ( $all_plugins as $plugin ) {
    171181                                        echo '<li>';
    172                                         $note    = false;
    173                                         $extra   = '';
    174                                         $classes = $tooltips = array();
     182                                        $note         = false;
     183                                        $extra        = '';
     184                                        $classes      = $tooltips = array();
    175185                                        $last_updated = get_post_meta( $plugin->ID, 'last_updated', true );
    176186
     
    187197                                        if ( in_array( $plugin->post_status, array( 'new', 'pending' ) ) ) {
    188198                                                /* translators: %s: time ago */
    189                                                 $extra .= sprintf( __( '(requested %s ago)', 'wporg-plugins' ),
     199                                                $extra     .= sprintf(
     200                                                        __( '(requested %s ago)', 'wporg-plugins' ),
    190201                                                        human_time_diff( strtotime( $last_updated ) )
    191202                                                );
     
    200211                                        } elseif ( 'closed' === $plugin->post_status ) {
    201212                                                /* translators: %s: close/disable reason */
    202                                                 $extra .= sprintf( __( '(closed: %s)', 'wporg-plugins' ),
     213                                                $extra     .= sprintf(
     214                                                        __( '(closed: %s)', 'wporg-plugins' ),
    203215                                                        Template::get_close_reason( $plugin )
    204216                                                );
     
    208220                                        } elseif ( 'disabled' === $plugin->post_status ) {
    209221                                                /* translators: %s: close/disable reason */
    210                                                 $extra .= sprintf( __( '(disabled: %s)', 'wporg-plugins' ),
     222                                                $extra     .= sprintf(
     223                                                        __( '(disabled: %s)', 'wporg-plugins' ),
    211224                                                        Template::get_close_reason( $plugin )
    212225                                                );
    213226                                                $tooltips[] = __( 'Plugin is disabled (updates are active).', 'wporg-plugins' );
    214227                                                $classes[]  = 'profile-plugin-closed';
    215                                                 $note = true;
     228                                                $note       = true;
    216229
    217230                                        } else {
     
    226239                                                        $tooltips[] = __( 'Plugin is open.', 'wporg-plugins' );
    227240                                                }
    228                                                 $classes[]      = 'profile-plugin-open';
     241                                                $classes[] = 'profile-plugin-open';
    229242                                        }
    230243
    231244                                        echo '<span>';
    232245
    233                                         printf( '<a class="%1$s" title="%2$s" href="%3$s">%4$s</a>',
     246                                        printf(
     247                                                '<a class="%1$s" title="%2$s" href="%3$s">%4$s</a>',
    234248                                                esc_attr( implode( ' ', $classes ) ),
    235249                                                esc_attr( implode( ' ', $tooltips ) ),
     
    243257
    244258                                        $plugin_links = array(
    245                                                 sprintf( '<a href="%s" title="%s">%s</a>',
     259                                                sprintf(
     260                                                        '<a href="%s" title="%s">%s</a>',
    246261                                                        esc_url( get_edit_post_link( $plugin->ID, '' ) ),
    247262                                                        esc_attr__( 'Edit this plugin', 'wporg-plugins' ),
    248263                                                        __( 'Edit', 'wporg-plugins' )
    249264                                                ),
    250                                                 sprintf( '<a href="//make.wordpress.org/pluginrepo/?s=%s" title="%s">P2</a>',
     265                                                sprintf(
     266                                                        '<a href="//make.wordpress.org/pluginrepo/?s=%s" title="%s">P2</a>',
    251267                                                        urlencode( esc_attr( $plugin_slug ) ),
    252268                                                        esc_attr__( 'Click to search Pluginrepo P2 for mentions of this plugin', 'wporg-plugins' )
    253269                                                ),
    254                                                 sprintf( '<a href="https://supportpress.wordpress.org/plugins/?q=%s&status=&todo=Search+%%C2%%BB" title="%s">SP</a>',
     270                                                sprintf(
     271                                                        '<a href="https://supportpress.wordpress.org/plugins/?q=%s&status=&todo=Search+%%C2%%BB" title="%s">SP</a>',
    255272                                                        urlencode( esc_attr( $plugin_slug ) ),
    256273                                                        esc_attr__( 'Click to search Pluginrepo SupportPress for mentions of this plugin', 'wporg-plugins' )
     
    290307         */
    291308        protected static function link_ip( $ip ) {
    292                 return sprintf( '<a href="%1$s">%2$s</a>', esc_url( add_query_arg( array(
    293                         'post_type' => 'plugin',
    294                         's'         => $ip,
    295                 ), admin_url( 'edit.php' ) ) ), $ip );
     309                return sprintf(
     310                        '<a href="%1$s">%2$s</a>',
     311                        esc_url( add_query_arg( array(
     312                                'post_type' => 'plugin',
     313                                's'         => $ip,
     314                        ), admin_url( 'edit.php' ) ) ),
     315                        $ip
     316                );
    296317        }
    297318}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author.php

    r3506 r6287  
    1515         */
    1616        public static function display() {
    17                 $post  = get_post();
    18                 $value = empty( $post->ID ) ? get_current_user_id() : $post->post_author;
    19                 $user  = new \WP_User( $value );
     17                $post   = get_post();
     18                $value  = empty( $post->ID ) ? get_current_user_id() : $post->post_author;
     19                $user   = new \WP_User( $value );
     20                $source = add_query_arg( array(
     21                        'action'      => 'plugin-author-lookup',
     22                        '_ajax_nonce' => wp_create_nonce( 'wporg_plugins_author_lookup' ),
     23                ), admin_url( 'admin-ajax.php' ) );
    2024
    2125                ?>
     
    2731                        jQuery( function( $ ) {
    2832                                $( '#post_author_username' ).autocomplete( {
    29                                         source: '<?php echo add_query_arg( array( 'action' => 'plugin-author-lookup', '_ajax_nonce' => wp_create_nonce( 'wporg_plugins_author_lookup' ) ), admin_url( 'admin-ajax.php' ) ); ?>',
     33                                        source: '<?php echo esc_js( $source ); ?>',
    3034                                        minLength: 2,
    3135                                        delay: 700,
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php

    r2994 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
     3
    34use WordPressdotorg\Plugin_Directory\Admin\List_Table;
    45use WordPressdotorg\Plugin_Directory\Tools;
     
    3637         */
    3738        public static function add_committer() {
    38                 $login    = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : '';
    39                 $post_id  = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
     39                $login   = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : '';
     40                $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
    4041
    4142                check_ajax_referer( 'add-committer' );
     
    8586         */
    8687        public static function remove_committer() {
    87                 $id      = isset( $_POST['id'] )      ? (int) $_POST['id']      : 0;
     88                $id      = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
    8889                $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
    8990
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php

    r6162 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
     3
    34use WordPressdotorg\Plugin_Directory\Admin\Status_Transitions;
    45use WordPressdotorg\Plugin_Directory\Template;
     
    9091                }
    9192
    92                 $close_reasons  = Template::get_close_reasons();
    93                 $close_reason   = (string) get_post_meta( $post->ID, '_close_reason', true );
     93                $close_reasons = Template::get_close_reasons();
     94                $close_reason  = (string) get_post_meta( $post->ID, '_close_reason', true );
    9495
    9596                $reason_label   = Template::get_close_reason();
     
    110111                        <?php endif; ?>
    111112
    112                         <?php if (
     113                        <?php
     114                        if (
    113115                                        ( in_array( 'closed', $statuses, true ) || in_array( 'disabled', $statuses, true ) )
    114116                                &&
    115117                                        ( ! in_array( $post->post_status, array( 'closed', 'disabled' ) ) || $reason_unknown )
    116                                 ) : ?>
     118                                ) :
     119                                ?>
    117120
    118121                                <p>
     
    134137
    135138                        <?php endforeach; ?>
    136                 </div><!-- .misc-pub-section --><?php
     139                </div><!-- .misc-pub-section -->
     140                <?php
    137141        }
    138142
     
    148152                        <label for="tested_with"><?php _e( 'Tested With:', 'wporg-plugins' ); ?></label>
    149153                        <strong id="tested-with-display"><?php echo ( $tested_up_to ? sprintf( 'WordPress %s', $tested_up_to ) : $unknown_string ); ?></strong>
    150 
    151                 </div><!-- .misc-pub-section --><?php
     154                </div><!-- .misc-pub-section -->
     155                <?php
    152156        }
    153157
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-custom-fields.php

    r5841 r6287  
    1111                $post   = get_post();
    1212                $fields = array(
    13                         'version' => 'Latest Plugin Version',
    14                         'stable_tag' => 'Stable Tag',
    15                         'tested' => 'Tested With',
    16                         'requires' => 'Requires',
    17                         'requires_php' => 'Requires PHP',
    18                         'donate_link' => 'Donate URL',
    19                         'header_plugin_uri' => 'Plugin URI',
    20                         'header_author' => 'Plugin Author',
    21                         'header_author_uri' => 'Plugin Author URI',
    22                         'header_textdomain' => 'Plugin TextDomain',
     13                        'version'            => 'Latest Plugin Version',
     14                        'stable_tag'         => 'Stable Tag',
     15                        'tested'             => 'Tested With',
     16                        'requires'           => 'Requires',
     17                        'requires_php'       => 'Requires PHP',
     18                        'donate_link'        => 'Donate URL',
     19                        'header_plugin_uri'  => 'Plugin URI',
     20                        'header_author'      => 'Plugin Author',
     21                        'header_author_uri'  => 'Plugin Author URI',
     22                        'header_textdomain'  => 'Plugin TextDomain',
    2323                        'header_description' => 'Plugin Description',
    2424                );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-internal-notes.php

    r2763 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
     3
    34use WordPressdotorg\Plugin_Directory\Admin\List_Table\Plugin_Comments;
    45
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php

    r6028 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
     3
    34use WordPressdotorg\Plugin_Directory\Tools;
    45
     
    1415                $zip_files = array();
    1516                foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) {
    16                         $zip_files[ $zip_file->post_date ] = array(     wp_get_attachment_url( $zip_file->ID ), $zip_file );
     17                        $zip_files[ $zip_file->post_date ] = array( wp_get_attachment_url( $zip_file->ID ), $zip_file );
    1718                }
    1819                uksort( $zip_files, function( $a, $b ) {
     
    2223                if ( $zip_url = get_post_meta( $post->ID, '_submitted_zip', true ) ) {
    2324                        // Back-compat only.
    24                         $zip_files[ 'User provided URL' ] = array( $zip_url, null );
     25                        $zip_files['User provided URL'] = array( $zip_url, null );
    2526                }
    2627
    2728                foreach ( $zip_files as $zip_date => $zip ) {
    2829                        list( $zip_url, $zip_file ) = $zip;
    29                         $zip_size = ( is_object( $zip_file ) ? size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ) : __( 'unknown size', 'wporg-plugins' ) );
    30                         printf( '<p>' . __( '<strong>Zip file:</strong> %s', 'wporg-plugins' ) . '</p>',
     30                        $zip_size                   = ( is_object( $zip_file ) ? size_format( filesize( get_attached_file( $zip_file->ID ) ), 1 ) : __( 'unknown size', 'wporg-plugins' ) );
     31                        printf(
     32                                '<p>' . __( '<strong>Zip file:</strong> %s', 'wporg-plugins' ) . '</p>',
    3133                                sprintf( '%s <a href="%s">%s</a> (%s)', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ), esc_html( $zip_size ) )
    3234                        );
     
    6567                                $subject = sprintf( __( '[WordPress Plugin Directory] Notice: %s', 'wporg-plugins' ), $post->post_title );
    6668                        }
    67                        
     69
    6870                        ?>
    6971                        <form id="contact-author" class="contact-author" method="POST" action="https://supportpress.wordpress.org/plugins/thread-new.php">
     
    7577                        </form>
    7678                        <?php
     79
    7780                        return $string;
    7881                } );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-support-reps.php

    r5867 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
     3
    34use WordPressdotorg\Plugin_Directory\Admin\List_Table;
    45use WordPressdotorg\Plugin_Directory\Tools;
     
    3637         */
    3738        public static function add_support_rep() {
    38                 $login    = isset( $_POST['add_support_rep'] ) ? sanitize_user( $_POST['add_support_rep'] ) : '';
    39                 $post_id  = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
     39                $login   = isset( $_POST['add_support_rep'] ) ? sanitize_user( $_POST['add_support_rep'] ) : '';
     40                $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
    4041
    4142                check_ajax_referer( 'add-support-rep' );
     
    8586         */
    8687        public static function remove_support_rep() {
    87                 $id      = isset( $_POST['id'] )      ? (int) $_POST['id']      : 0;
     88                $id      = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
    8889                $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
    8990
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-author-cards.php

    r5314 r6287  
    2525         */
    2626        private function __construct() {
    27                 add_action( 'admin_menu',            array( $this, 'add_to_menu' ) );
     27                add_action( 'admin_menu', array( $this, 'add_to_menu' ) );
    2828                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
    2929        }
     
    3838                        case 'tools_page_authorcards':
    3939                                wp_enqueue_style( 'plugin-admin-post-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 4 );
    40                         break;
     40                                break;
    4141                }
    4242        }
    43        
     43
    4444        public function add_to_menu() {
    4545                add_submenu_page(
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php

    r5919 r6287  
    4242         * Returns the stats.
    4343         *
    44          * @param array  $args {
    45          *     Optional. Array of override arguments
     44         * @param array $args {
     45         *    Optional. Array of override arguments
    4646         *
    4747         *     @type string $date       The date (in Y-m-d format) for the end of the stats time interval (non-inclusive). Default today.
     
    8888                // Plugin Status Changes
    8989                // --------------
    90 
    9190                $states = array( 'plugin_approve', 'plugin_delist', 'plugin_new', 'plugin_reject' );
    9291                foreach ( $states as $state ) {
    9392                        // The stats table used by bbPress1 (and could still be used, but isn't yet).
    9493                        // Won't provide meaningful results for time intervals that include days after the switch to WP.
    95                         $stats[ $state ] = $wpdb->get_var( $wpdb->prepare (
     94                        $stats[ $state ] = $wpdb->get_var( $wpdb->prepare(
    9695                                "SELECT SUM(views) FROM stats_extras WHERE name = 'plugin' AND date < %s AND date > DATE_SUB( %s, INTERVAL %d DAY ) AND value = %s",
    9796                                $args['date'],
     
    104103                // Temporary until the above is updated to work with the new directory:
    105104                foreach ( array( 'plugin_approve', 'plugin_delist', 'plugin_reject' ) as $unused_stat ) {
    106                         if ( ! $stats[ $unused_stat ] ) $stats[ $unused_stat ] = __( 'N/A', 'wporg-plugins' );
     105                        if ( ! $stats[ $unused_stat ] ) {
     106                                $stats[ $unused_stat ] = __( 'N/A', 'wporg-plugins' );
     107                        }
    107108                }
    108109
     
    110111                // Plugin Queue
    111112                // --------------
    112 
    113113                // # of plugins currently in the queue that are new (have not been processed/replied to yet)
    114114                $stats['in_queue_new'] = $wpdb->get_var(
     
    142142                // SupportPress Queue
    143143                // --------------
    144 
    145144                // # of currently open threads
    146145                $stats['supportpress_queue_total_open'] = $wpdb->get_var(
     
    194193                }
    195194
    196                 $args['num_days'] = empty( $_POST['days'] ) ? '' : absint( $_POST['days'] );
     195                $args['num_days']   = empty( $_POST['days'] ) ? '' : absint( $_POST['days'] );
    197196                $args['recentdays'] = empty( $_POST['recentdays'] ) ? '' : absint( $_POST['recentdays'] );
    198197
     
    212211                <tr><th scope="row"><label for="date"><?php _e( 'Date', 'wporg-plugins' ); ?></label></th><td>
    213212                <input name="date" type="text" id="date" value="<?php echo esc_attr( $args['date'] ); ?>" class="text">
    214                 <p><?php
     213                <p>
     214                <?php
    215215                        /* translators: %s: today's date */
    216                         printf( __( 'The day up to which stats are to be gathered. In YYYY-MM-DD format. Defaults to today (%s).', 'wporg-plugins' ),
     216                        printf(
     217                                __( 'The day up to which stats are to be gathered. In YYYY-MM-DD format. Defaults to today (%s).', 'wporg-plugins' ),
    217218                                $date
    218219                        );
    219                 ?></p>
     220                ?>
     221                </p>
    220222                </td></tr>
    221223
    222224                <tr><th scope="row"><label for="days"><?php _e( 'Number of days', 'wporg-plugins' ); ?></label></th><td>
    223225                <input name="days" type="text" id="days" value="<?php echo esc_attr( $args['num_days'] ); ?>" class="small-text">
    224                 <p><?php
     226                <p>
     227                <?php
    225228                        /* translators: %d: 7 */
    226                         printf( __( 'The number of days before "Date" to include in stats. Default is %d.', 'wporg-plugins' ),
     229                        printf(
     230                                __( 'The number of days before "Date" to include in stats. Default is %d.', 'wporg-plugins' ),
    227231                                7
    228232                        );
    229                 ?></p>
     233                ?>
     234                </p>
    230235                </td></tr>
    231236
    232237                <tr><th scope="row"><label for="recentdays"><?php _e( '"Recent" number of days', 'wporg-plugins' ); ?></label></th><td>
    233238                <input name="recentdays" type="text" id="recentdays" value="<?php echo esc_attr( $args['recentdays'] ); ?>" class="small-text">
    234                 <p><?php
     239                <p>
     240                <?php
    235241                        /* translators: %d: 7 */
    236                         printf( __( 'The number of days before today to consider as being "recent" (stats marked with **). Default is %d.', 'wporg-plugins' ),
     242                        printf(
     243                                __( 'The number of days before today to consider as being "recent" (stats marked with **). Default is %d.', 'wporg-plugins' ),
    237244                                7
    238245                        );
    239                 ?></p>
     246                ?>
     247                </p>
    240248                </td></tr>
    241249
     
    246254                <h2><?php _e( 'Stats', 'wporg-plugins' ); ?></h2>
    247255
    248                 <p><?php
     256                <p>
     257                <?php
    249258                        /* translators: 1: number of days, 2: selected date, 3: number of most recent days */
    250                         printf( __( 'Displaying stats for the %1$d days preceding %2$s (and other stats for the %3$d most recent days).', 'wporg-plugins' ),
     259                        printf(
     260                                __( 'Displaying stats for the %1$d days preceding %2$s (and other stats for the %3$d most recent days).', 'wporg-plugins' ),
    251261                                $stats['num_days'],
    252262                                $stats['date'],
    253263                                $stats['recentdays']
    254264                        );
    255                 ?></p>
     265                ?>
     266                </p>
    256267
    257268                <h3><?php _e( 'Plugin Status Change Stats', 'wporg-plugins' ); ?></h3>
    258269
    259270                <ul style="font-family:Courier New;">
    260                         <li><?php
     271                        <li>
     272                        <?php
    261273                                /* translators: %d: number of requested plugins */
    262                                 printf( __( 'Plugins requested : %d', 'wporg-plugins' ),
     274                                printf(
     275                                        __( 'Plugins requested : %d', 'wporg-plugins' ),
    263276                                        $stats['plugin_new']
    264277                                );
    265                         ?></li>
    266                         <li><?php
     278                        ?>
     279                        </li>
     280                        <li>
     281                        <?php
    267282                                /* translators: %s: number of rejected plugins */
    268                                 printf( __( 'Plugins rejected : %s', 'wporg-plugins' ),
     283                                printf(
     284                                        __( 'Plugins rejected : %s', 'wporg-plugins' ),
    269285                                        $stats['plugin_reject']
    270286                                );
    271                         ?></li>
    272                         <li><?php
     287                        ?>
     288                        </li>
     289                        <li>
     290                        <?php
    273291                                /* translators: %s: number of closed plugins */
    274                                 printf( __( 'Plugins closed : %s', 'wporg-plugins' ),
     292                                printf(
     293                                        __( 'Plugins closed : %s', 'wporg-plugins' ),
    275294                                        $stats['plugin_delist']
    276295                                );
    277                         ?></li>
    278                         <li><?php
     296                        ?>
     297                        </li>
     298                        <li>
     299                        <?php
    279300                                /* translators: %s: number of approved plugins */
    280                                 printf( __( 'Plugins approved : %s', 'wporg-plugins' ),
     301                                printf(
     302                                        __( 'Plugins approved : %s', 'wporg-plugins' ),
    281303                                        $stats['plugin_approve']
    282304                                );
    283                         ?></li>
     305                        ?>
     306                        </li>
    284307                </ul>
    285308
     
    287310
    288311                <ul style="font-family:Courier New;">
    289                         <li><?php
     312                        <li>
     313                        <?php
    290314                                /* translators: %d: number of plugins in the queue */
    291                                 printf( __( 'Plugins in the queue (new and pending)* : %d', 'wporg-plugins' ),
     315                                printf(
     316                                        __( 'Plugins in the queue (new and pending)* : %d', 'wporg-plugins' ),
    292317                                        $stats['in_queue']
    293318                                );
    294                         ?></li>
    295                         <li><?php
     319                        ?>
     320                        </li>
     321                        <li>
     322                        <?php
    296323                                /* translators: 1: number of most recent days, 2: number of older plugins in the queue */
    297                                 printf( __( '&rarr; (older than %1$d days ago)** : %2$d', 'wporg-plugins' ),
     324                                printf(
     325                                        __( '&rarr; (older than %1$d days ago)** : %2$d', 'wporg-plugins' ),
    298326                                        $stats['recentdays'],
    299327                                        $stats['in_queue_old']
    300328                                );
    301                         ?></li>
    302                         <li><?php
     329                        ?>
     330                        </li>
     331                        <li>
     332                        <?php
    303333                                /* translators: 1: start date, 2: end date, 3: number of plugins in the queue within defined time window */
    304                                 printf( __( '&rarr; (%1$s - %2$s) : %3$d', 'wporg-plugins' ),
     334                                printf(
     335                                        __( '&rarr; (%1$s - %2$s) : %3$d', 'wporg-plugins' ),
    305336                                        $start_date,
    306337                                        $stats['date'],
    307338                                        $stats['in_queue_from_time_window']
    308339                                );
    309                         ?></li>
    310                         <li><?php
     340                        ?>
     341                        </li>
     342                        <li>
     343                        <?php
    311344                                /* translators: %d: number of new plugins */
    312                                 printf( __( '&rarr; (new; not processed or replied to yet)* : %d', 'wporg-plugins' ),
     345                                printf(
     346                                        __( '&rarr; (new; not processed or replied to yet)* : %d', 'wporg-plugins' ),
    313347                                        $stats['in_queue_new']
    314348                                );
    315                         ?></li>
    316                         <li><?php
     349                        ?>
     350                        </li>
     351                        <li>
     352                        <?php
    317353                                /* translators: %d: number of pending plugins */
    318                                 printf( __( '&rarr; (pending; replied to)* : %d', 'wporg-plugins' ),
     354                                printf(
     355                                        __( '&rarr; (pending; replied to)* : %d', 'wporg-plugins' ),
    319356                                        $stats['in_queue_pending']
    320357                                );
    321                         ?></li>
     358                        ?>
     359                        </li>
    322360                </ul>
    323361
     
    325363
    326364                <ul style="font-family:Courier New;">
    327                         <li><?php
     365                        <li>
     366                        <?php
    328367                                /* translators: %d: number of open tickets */
    329                                 printf( __( 'Total open tickets* : %d', 'wporg-plugins' ),
     368                                printf(
     369                                        __( 'Total open tickets* : %d', 'wporg-plugins' ),
    330370                                        $stats['supportpress_queue_total_open']
    331371                                );
    332                         ?></li>
    333                         <li><?php
     372                        ?>
     373                        </li>
     374                        <li>
     375                        <?php
    334376                                /* translators: 1: number of most recent days, 2: number of plugins with no activity */
    335                                 printf( __( ' &rarr; (with no activity in last %1$d days)** : %2$d', 'wporg-plugins' ),
     377                                printf(
     378                                        __( ' &rarr; (with no activity in last %1$d days)** : %2$d', 'wporg-plugins' ),
    336379                                        $stats['recentdays'],
    337380                                        $stats['supportpress_queue_total_open_old']
    338381                                );
    339                         ?></li>
    340                         <li><?php
     382                        ?>
     383                        </li>
     384                        <li>
     385                        <?php
    341386                                /* translators: %d: number of most recent days */
    342                                 printf( __( 'Within defined %d day time window:', 'wporg-plugins' ),
     387                                printf(
     388                                        __( 'Within defined %d day time window:', 'wporg-plugins' ),
    343389                                        $stats['num_days']
    344390                                );
    345                                 ?><ul style="margin-left:20px;margin-top:0.5em;">
    346                                         <li><?php
     391                                ?>
     392                                <ul style="margin-left:20px;margin-top:0.5em;">
     393                                        <li>
     394                                        <?php
    347395                                                /* translators: %d: total number of plugins within defined time window */
    348                                                 printf( __( 'Total : %d', 'wporg-plugins' ),
     396                                                printf(
     397                                                        __( 'Total : %d', 'wporg-plugins' ),
    349398                                                        $stats['supportpress_queue_interval_all']
    350399                                                );
    351                                         ?></li>
    352                                         <li><?php
     400                                        ?>
     401                                        </li>
     402                                        <li>
     403                                        <?php
    353404                                                /* translators: %d: number of closed plugins within defined time window */
    354                                                 printf( __( 'Closed : %d', 'wporg-plugins' ),
     405                                                printf(
     406                                                        __( 'Closed : %d', 'wporg-plugins' ),
    355407                                                        $stats['supportpress_queue_interval_closed']
    356408                                                );
    357                                         ?></li>
    358                                         <li><?php
     409                                        ?>
     410                                        </li>
     411                                        <li>
     412                                        <?php
    359413                                                /* translators: %d: number of open plugins within defined time window */
    360                                                 printf( __( 'Open : %d', 'wporg-plugins' ),
     414                                                printf(
     415                                                        __( 'Open : %d', 'wporg-plugins' ),
    361416                                                        $stats['supportpress_queue_interval_open']
    362417                                                );
    363                                         ?></li>
     418                                        ?>
     419                                        </li>
    364420                                </ul>
    365421                        </li>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-base.php

    r5867 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
     5use WordPressdotorg\Plugin_Directory\Plugin_I18n;
     6use WordPressdotorg\Plugin_Directory\Template;
    47
    58/**
    69 * @package WordPressdotorg_Plugin_Directory
    710 */
    8 
    911class Base {
    1012        /**
    11          * Initialises each API route we offer.
     13         * Initializes REST API customizations.
    1214         */
    13         static function load_routes() {
     15        public static function init() {
     16                self::load_routes();
     17                self::load_fields();
     18        }
     19
     20        /**
     21         * Loads all API route we offer.
     22         */
     23        public static function load_routes() {
    1424                new Routes\Internal_Stats();
    1525                new Routes\Plugin();
     
    2232                new Routes\Plugin_Committers();
    2333                new Routes\Plugin_Support_Reps();
     34        }
     35
     36        /**
     37         * Loads all API field for existing WordPress object types we offer.
     38         */
     39        public static function load_fields() {
     40                new Fields\Plugin\Banners();
     41                new Fields\Plugin\Icons();
     42                new Fields\Plugin\Rating();
     43                new Fields\Plugin\Ratings();
     44                new Fields\Plugin\Screenshots();
    2445        }
    2546
     
    5879                return true;
    5980        }
    60 
    6181}
    62 
    63 
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-commit-subscriptions.php

    r3510 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\API\Base;
     
    1415        public function __construct() {
    1516                register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/commit-subscription', array(
    16                         'methods'  => \WP_REST_Server::READABLE,
    17                         'callback' => array( $this, 'subscribe' ),
    18                         'args' => array(
     17                        'methods'             => \WP_REST_Server::READABLE,
     18                        'callback'            => array( $this, 'subscribe' ),
     19                        'args'                => array(
    1920                                'plugin_slug' => array(
    2021                                        'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    2122                                ),
    22                                 'subscribe' => array(
    23                                         'validate_callback' => function( $bool ) { return is_numeric( $bool ); },
     23                                'subscribe'   => array(
     24                                        'validate_callback' => function( $bool ) {
     25                                                return is_numeric( $bool );
     26                                        },
    2427                                ),
    2528                                'unsubscribe' => array(
    26                                         'validate_callback' => function( $bool ) { return is_numeric( $bool ); },
     29                                        'validate_callback' => function( $bool ) {
     30                                                return is_numeric( $bool );
     31                                        },
    2732                                ),
    2833                        ),
    29                         'permission_callback' => 'is_user_logged_in'
     34                        'permission_callback' => 'is_user_logged_in',
    3035                ) );
    3136        }
     
    4247
    4348                $result = array(
    44                         "location" => $location,
     49                        'location' => $location,
    4550                );
    4651
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-internal-stats.php

    r5839 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\API\Base;
     
    1920        function __construct() {
    2021                register_rest_route( 'plugins/v1', '/update-stats', array(
    21                         'methods'  => \WP_REST_Server::CREATABLE,
    22                         'callback' => array( $this, 'bulk_update_stats' ),
     22                        'methods'             => \WP_REST_Server::CREATABLE,
     23                        'callback'            => array( $this, 'bulk_update_stats' ),
    2324                        'permission_callback' => array( $this, 'permission_check_internal_api_bearer' ),
    2425                ) );
     
    112113        protected function sanitize_usage_numbers( $usage, $plugin ) {
    113114                $latest_version = get_post_meta( $plugin->ID, 'version', true ) ?: '0.0';
    114                 $latest_branch = implode( '.', array_slice( explode('.', $latest_version ), 0, 2 ) );
     115                $latest_branch  = implode( '.', array_slice( explode( '.', $latest_version ), 0, 2 ) );
    115116
    116117                // Exclude any version strings higher than the latest plugin version (ie. 99.9)
     
    126127
    127128                // Calculate the percentage of each version branch
    128                 $total = array_sum( $usage );
     129                $total  = array_sum( $usage );
    129130                $others = array();
    130131                foreach ( $usage as $version => $count ) {
     
    141142                // If there was only one version < $percent_cut_off then display it as-is
    142143                if ( count( $others ) == 1 ) {
    143                         $version = array_keys( $others );
    144                         $version = array_shift( $version );
     144                        $version           = array_keys( $others );
     145                        $version           = array_shift( $version );
    145146                        $usage[ $version ] = round( $others[ $version ] / $total * 100, 2 );
    146                 // Else we'll add an 'others' version.
     147                        // Else we'll add an 'others' version.
    147148                } elseif ( count( $others ) > 1 ) {
    148149                        $usage['other'] = round( array_sum( $others ) / $total * 100, 2 );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-locale-banner.php

    r6196 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\API\Base;
    45use WP_REST_Server;
     
    1516                        'methods'  => WP_REST_Server::EDITABLE,
    1617                        'callback' => array( $this, 'locale_banner' ),
    17                         'args' => array(
     18                        'args'     => array(
    1819                                'plugin_slug' => array(
    1920                                        'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
     
    6970
    7071                // Build a list of WordPress locales which we'll suggest to the user.
    71                 $suggest_locales = array_values( array_intersect( $locales_from_header, $translated_locales ) );
    72                 $current_locale_is_suggested = in_array( $current_locale, $suggest_locales );
     72                $suggest_locales              = array_values( array_intersect( $locales_from_header, $translated_locales ) );
     73                $current_locale_is_suggested  = in_array( $current_locale, $suggest_locales );
    7374                $current_locale_is_translated = in_array( $current_locale, $translated_locales );
    7475
     
    116117                                }
    117118
    118                         // Multiple locale suggestions.
     119                                // Multiple locale suggestions.
    119120                        } elseif ( ! empty( $suggest_named_locales ) ) {
    120                                 $primary_locale = key( $suggest_named_locales );
     121                                $primary_locale   = key( $suggest_named_locales );
    121122                                $primary_language = current( $suggest_named_locales );
    122123                                array_shift( $suggest_named_locales );
     
    169170                                }
    170171
    171                         // Non-English locale in header, no translations.
     172                                // Non-English locale in header, no translations.
    172173                        } elseif ( $locales_from_header ) {
    173174                                $locale = reset( $locales_from_header );
     
    180181                        }
    181182
    182                 // Localized directory.
     183                        // Localized directory.
    183184                } elseif ( ! $current_locale_is_suggested && ! $current_locale_is_translated && $is_plugin_request ) {
    184185                        $suggest_string = sprintf(
     
    254255        protected function get_http_locales( $header ) {
    255256                $locale_part_re = '[a-z]{2,}';
    256                 $locale_re = "($locale_part_re(\-$locale_part_re)?)";
     257                $locale_re      = "($locale_part_re(\-$locale_part_re)?)";
     258
    257259                if ( preg_match_all( "/$locale_re/i", $header, $matches ) ) {
    258260                        return $matches[0];
     
    271273         */
    272274        protected function map_locale( $lang, $region, $available_locales ) {
    273                 $uregion = strtoupper( $region );
    274                 $ulang   = strtoupper( $lang );
     275                $uregion  = strtoupper( $region );
     276                $ulang    = strtoupper( $lang );
    275277                $variants = array(
    276278                        "$lang-$region",
     
    353355
    354356// Strings for the POT file.
    355 
    356357/* translators: %s: native language name. */
    357358__( 'This plugin is also available in %1$s. <a href="%2$s">Help improve the translation!</a>', 'wporg-plugins' );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-committers.php

    r5930 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\Template;
     
    2021                register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/committers/?', array(
    2122                        array(
    22                                 'methods'  => WP_REST_Server::READABLE,
    23                                 'callback' => array( $this, 'list_committers' ),
     23                                'methods'             => WP_REST_Server::READABLE,
     24                                'callback'            => array( $this, 'list_committers' ),
    2425                                'permission_callback' => function( $request ) {
    2526                                        return current_user_can(
     
    2829                                        );
    2930                                },
    30                                 'args' => array(
     31                                'args'                => array(
    3132                                        'plugin_slug' => array(
    3233                                                'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    33                                                 'required' => true,
     34                                                'required'          => true,
    3435                                        ),
    35                                 )
     36                                ),
    3637                        ),
    3738                        array(
    38                                 'methods'  => WP_REST_Server::CREATABLE,
    39                                 'callback' => array( $this, 'add_committer' ),
     39                                'methods'             => WP_REST_Server::CREATABLE,
     40                                'callback'            => array( $this, 'add_committer' ),
    4041                                'permission_callback' => function( $request ) {
    4142                                        return current_user_can(
     
    4445                                        );
    4546                                },
    46                                 'args' => array(
     47                                'args'                => array(
    4748                                        'plugin_slug' => array(
    4849                                                'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    49                                                 'required' => true,
     50                                                'required'          => true,
    5051                                        ),
    51                                 )
    52                         )
     52                                ),
     53                        ),
    5354                ) );
    5455
    5556                register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/committers/(?P<committer>[^/]+)/?', array(
    56                         'methods'  => WP_REST_Server::DELETABLE,
    57                         'callback' => array( $this, 'revoke_committer' ),
     57                        'methods'             => WP_REST_Server::DELETABLE,
     58                        'callback'            => array( $this, 'revoke_committer' ),
    5859                        'permission_callback' => function( $request ) {
    5960                                return current_user_can(
     
    6263                                );
    6364                        },
    64                         'args' => array(
     65                        'args'                => array(
    6566                                'plugin_slug' => array(
    6667                                        'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    67                                         'required' => true,
     68                                        'required'          => true,
    6869                                ),
    69                                 'committer' => array(
     70                                'committer'   => array(
    7071                                        'validate_callback' => array( $this, 'validate_user_slug_callback' ),
    71                                         'required' => true,
    72                                 )
    73                         )
     72                                        'required'          => true,
     73                                ),
     74                        ),
    7475                ) );
    7576        }
     
    8384                $committers = array();
    8485                foreach ( (array) Tools::get_plugin_committers( $plugin_slug ) as $user_login ) {
    85                         $user = get_user_by( 'login', $user_login );
     86                        $user         = get_user_by( 'login', $user_login );
    8687                        $committers[] = $this->user_committer_details( $user );
    8788                }
     
    158159                        'profile'  => esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename ),
    159160                        'avatar'   => get_avatar_url( $user->ID, 32 ),
    160                         'name'     => Template::encode( $user->display_name )
     161                        'name'     => Template::encode( $user->display_name ),
    161162                );
    162163
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-favorites.php

    r3545 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\API\Base;
     
    1415        public function __construct() {
    1516                register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/favorite', array(
    16                         'methods'  => array( \WP_REST_Server::READABLE, \WP_REST_Server::CREATABLE ),
    17                         'callback' => array( $this, 'favorite' ),
    18                         'args' => array(
     17                        'methods'             => array( \WP_REST_Server::READABLE, \WP_REST_Server::CREATABLE ),
     18                        'callback'            => array( $this, 'favorite' ),
     19                        'args'                => array(
    1920                                'plugin_slug' => array(
    2021                                        'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    2122                                ),
    22                                 'favorite' => array(
    23                                         'validate_callback' => function( $bool ) { return is_numeric( $bool ); },
     23                                'favorite'    => array(
     24                                        'validate_callback' => function( $bool ) {
     25                                                return is_numeric( $bool );
     26                                        },
    2427                                ),
    25                                 'unfavorite' => array(
    26                                         'validate_callback' => function( $bool ) { return is_numeric( $bool ); },
     28                                'unfavorite'  => array(
     29                                        'validate_callback' => function( $bool ) {
     30                                                return is_numeric( $bool );
     31                                        },
    2732                                ),
    2833                        ),
    29                         'permission_callback' => 'is_user_logged_in'
     34                        'permission_callback' => 'is_user_logged_in',
    3035                ) );
    3136        }
     
    4247
    4348                $result = array(
    44                         "location" => $location,
     49                        'location' => $location,
    4550                );
    4651
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-support-reps.php

    r5930 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\Template;
     
    2021                register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/support-reps/?', array(
    2122                        array(
    22                                 'methods'  => WP_REST_Server::READABLE,
    23                                 'callback' => array( $this, 'list_support_reps' ),
     23                                'methods'             => WP_REST_Server::READABLE,
     24                                'callback'            => array( $this, 'list_support_reps' ),
    2425                                'permission_callback' => function( $request ) {
    2526                                        return current_user_can(
     
    2829                                        );
    2930                                },
    30                                 'args' => array(
     31                                'args'                => array(
    3132                                        'plugin_slug' => array(
    3233                                                'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    33                                                 'required' => true,
     34                                                'required'          => true,
    3435                                        ),
    35                                 )
     36                                ),
    3637                        ),
    3738                        array(
    38                                 'methods'  => WP_REST_Server::CREATABLE,
    39                                 'callback' => array( $this, 'add_support_rep' ),
     39                                'methods'             => WP_REST_Server::CREATABLE,
     40                                'callback'            => array( $this, 'add_support_rep' ),
    4041                                'permission_callback' => function( $request ) {
    4142                                        return current_user_can(
     
    4445                                        );
    4546                                },
    46                                 'args' => array(
     47                                'args'                => array(
    4748                                        'plugin_slug' => array(
    4849                                                'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    49                                                 'required' => true,
     50                                                'required'          => true,
    5051                                        ),
    51                                 )
    52                         )
     52                                ),
     53                        ),
    5354                ) );
    5455
    5556                register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/support-reps/(?P<support_rep>[^/]+)/?', array(
    56                         'methods'  => WP_REST_Server::DELETABLE,
    57                         'callback' => array( $this, 'remove_support_rep' ),
     57                        'methods'             => WP_REST_Server::DELETABLE,
     58                        'callback'            => array( $this, 'remove_support_rep' ),
    5859                        'permission_callback' => function( $request ) {
    5960                                return current_user_can(
     
    6263                                );
    6364                        },
    64                         'args' => array(
     65                        'args'                => array(
    6566                                'plugin_slug' => array(
    6667                                        'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    67                                         'required' => true,
     68                                        'required'          => true,
    6869                                ),
    6970                                'support_rep' => array(
    7071                                        'validate_callback' => array( $this, 'validate_user_slug_callback' ),
    71                                         'required' => true,
    72                                 )
    73                         )
     72                                        'required'          => true,
     73                                ),
     74                        ),
    7475                ) );
    7576        }
     
    8384                $support_reps = array();
    8485                foreach ( (array) Tools::get_plugin_support_reps( $plugin_slug ) as $user_nicename ) {
    85                         $user = get_user_by( 'slug', $user_nicename );
     86                        $user           = get_user_by( 'slug', $user_nicename );
    8687                        $support_reps[] = $this->user_support_rep_details( $user );
    8788                }
     
    158159                        'profile'  => esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename ),
    159160                        'avatar'   => get_avatar_url( $user->ID, 32 ),
    160                         'name'     => Template::encode( $user->display_name )
     161                        'name'     => Template::encode( $user->display_name ),
    161162                );
    162163
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php

    r5924 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\Plugin_i18n;
     
    2223                        'methods'  => WP_REST_Server::READABLE,
    2324                        'callback' => array( $this, 'plugin_info' ),
    24                         'args' => array(
     25                        'args'     => array(
    2526                                'plugin_slug' => array(
    2627                                        'validate_callback' => array( $this, 'validate_plugin_slug_callback' ),
    27                                 )
    28                         )
     28                                ),
     29                        ),
    2930                ) );
    3031        }
     
    5051                                        'status' => \WP_HTTP::BAD_REQUEST,
    5152                                        'params' => array(
    52                                                 'plugin_slug' => 'Invalid parameter.'
    53                                         )
     53                                                'plugin_slug' => 'Invalid parameter.',
     54                                        ),
    5455                                )
    5556                        );
     
    5758
    5859                // Support returning API data in different locales, even on wordpress.org (for api.wordpress.org usage)
    59                 if ( ! empty( $request['locale'] ) && !in_array( strtolower( $request['locale'] ), array( 'en_us', 'en' ) ) ) {
     60                if ( ! empty( $request['locale'] ) && ! in_array( strtolower( $request['locale'] ), array( 'en_us', 'en' ) ) ) {
    6061                        switch_to_locale( $request['locale'] );
    6162                }
     
    6364                $post_id = $post->ID;
    6465
    65                 $result = array();
    66                 $result['name'] = get_the_title();
    67                 $result['slug'] = $post->post_name;
     66                $result            = array();
     67                $result['name']    = get_the_title();
     68                $result['slug']    = $post->post_name;
    6869                $result['version'] = get_post_meta( $post_id, 'version', true ) ?: '0.0';
    6970
     
    7576                // Profile of the original plugin submitter
    7677                $result['author_profile'] = $this->get_user_profile_link( $post->post_author );
    77                 $result['contributors'] = array();
     78                $result['contributors']   = array();
    7879
    7980                $contributors = get_terms( array(
    80                         'taxonomy' => 'plugin_contributors',
     81                        'taxonomy'   => 'plugin_contributors',
    8182                        'object_ids' => array( $post->ID ),
    82                         'orderby' => 'term_order',
    83                         'fields' => 'names',
     83                        'orderby'    => 'term_order',
     84                        'fields'     => 'names',
    8485                ) );
    8586
     
    9495                        }
    9596                }
     97
    9698                foreach ( $contributors as $contributor ) {
    9799                        $user = get_user_by( 'slug', $contributor );
     
    101103
    102104                        $result['contributors'][ $user->user_nicename ] = array(
    103                                 'profile' => $this->get_user_profile_link( $user ),
    104                                 'avatar' => get_avatar_url( $user, array( 'default' => 'monsterid', 'rating' => 'g' ) ),
    105                                 'display_name' => $user->display_name
     105                                'profile'      => $this->get_user_profile_link( $user ),
     106                                'avatar'       => get_avatar_url( $user, array(
     107                                        'default' => 'monsterid',
     108                                        'rating'  => 'g',
     109                                ) ),
     110                                'display_name' => $user->display_name,
    106111                        );
    107112                }
    108113
    109                 $result['requires'] = get_post_meta( $post_id, 'requires', true ) ?: false;
    110                 $result['tested'] = get_post_meta( $post_id, 'tested', true ) ?: false;
    111                 $result['requires_php'] = get_post_meta( $post_id, 'requires_php', true ) ?: false;
     114                $result['requires']      = get_post_meta( $post_id, 'requires', true ) ?: false;
     115                $result['tested']        = get_post_meta( $post_id, 'tested', true ) ?: false;
     116                $result['requires_php']  = get_post_meta( $post_id, 'requires_php', true ) ?: false;
    112117                $result['compatibility'] = array();
    113                 $result['rating'] = ( get_post_meta( $post_id, 'rating', true ) ?: 0 ) * 20; // Stored as 0.0 ~ 5.0, API outputs as 0..100
    114                 $result['ratings'] = array_map( 'intval', (array) get_post_meta( $post_id, 'ratings', true ) );
     118                $result['rating']        = ( get_post_meta( $post_id, 'rating', true ) ?: 0 ) * 20; // Stored as 0.0 ~ 5.0, API outputs as 0..100
     119                $result['ratings']       = array_map( 'intval', (array) get_post_meta( $post_id, 'ratings', true ) );
    115120                krsort( $result['ratings'] );
    116121
    117                 $result['num_ratings'] = array_sum( $result['ratings'] );
    118                 $result['support_threads'] = intval( get_post_meta( $post_id, 'support_threads', true ) );
     122                $result['num_ratings']              = array_sum( $result['ratings'] );
     123                $result['support_threads']          = intval( get_post_meta( $post_id, 'support_threads', true ) );
    119124                $result['support_threads_resolved'] = intval( get_post_meta( $post_id, 'support_threads_resolved', true ) );
    120                 $result['active_installs'] = intval( get_post_meta( $post_id, 'active_installs', true ) );
    121                 $result['downloaded'] = intval( get_post_meta( $post_id, 'downloads', true ) );
    122                 $result['last_updated'] = gmdate( 'Y-m-d g:ia \G\M\T', strtotime( $post->post_modified_gmt ) );
    123                 $result['added'] = gmdate( 'Y-m-d', strtotime( $post->post_date_gmt ) );
    124                 $result['homepage'] = get_post_meta( $post_id, 'header_plugin_uri', true );
    125                 $result['sections'] = array();
    126 
    127                 $_pages = preg_split( "#<!--section=(.+?)-->#", $post->post_content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     125                $result['active_installs']          = intval( get_post_meta( $post_id, 'active_installs', true ) );
     126                $result['downloaded']               = intval( get_post_meta( $post_id, 'downloads', true ) );
     127                $result['last_updated']             = gmdate( 'Y-m-d g:ia \G\M\T', strtotime( $post->post_modified_gmt ) );
     128                $result['added']                    = gmdate( 'Y-m-d', strtotime( $post->post_date_gmt ) );
     129                $result['homepage']                 = get_post_meta( $post_id, 'header_plugin_uri', true );
     130                $result['sections']                 = array();
     131
     132                $_pages = preg_split( '#<!--section=(.+?)-->#', $post->post_content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
    128133                for ( $i = 0; $i < count( $_pages ); $i += 2 ) {
    129134                        $result['sections'][ $_pages[ $i ] ] = apply_filters( 'the_content', $_pages[ $i + 1 ], $_pages[ $i ] );
    130135                }
    131136                $result['sections']['screenshots'] = ''; // placeholder to put screenshots prior to reviews at the end.
    132                 $result['sections']['reviews'] = $this->get_plugin_reviews_markup( $post->post_name );
    133 
    134                 if ( !empty( $result['sections']['faq'] ) ) {
     137                $result['sections']['reviews']     = $this->get_plugin_reviews_markup( $post->post_name );
     138
     139                if ( ! empty( $result['sections']['faq'] ) ) {
    135140                        $result['sections']['faq'] = $this->get_simplified_faq_markup( $result['sections']['faq'] );
    136141                }
    137                
     142
    138143                $result['description'] = $result['sections']['description'];
    139144
    140145                $result['short_description'] = get_the_excerpt();
    141                 $result['download_link'] = Template::download_link( $post );
     146                $result['download_link']     = Template::download_link( $post );
    142147
    143148                $result['screenshots'] = array();
    144                 $descriptions = get_post_meta( $post->ID, 'screenshots', true ) ?: array();
    145                 $screen_shots = get_post_meta( $post->ID, 'assets_screenshots', true ) ?: array();
     149                $descriptions          = get_post_meta( $post->ID, 'screenshots', true ) ?: array();
     150                $screen_shots          = get_post_meta( $post->ID, 'assets_screenshots', true ) ?: array();
    146151
    147152                /*
     
    150155                 */
    151156                foreach ( $screen_shots as $image ) {
    152                         $src = Template::get_asset_url( $post, $image );
     157                        $src     = Template::get_asset_url( $post, $image );
    153158                        $caption = '';
    154                         if ( $descriptions && !empty( $descriptions[ (int)$image['resolution'] ] ) ) {
    155                                 $caption = $descriptions[ (int)$image['resolution'] ];
     159                        if ( $descriptions && ! empty( $descriptions[ (int) $image['resolution'] ] ) ) {
     160                                $caption = $descriptions[ (int) $image['resolution'] ];
    156161                                $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $post->ID ] );
    157162                        }
     
    199204                $result['icons'] = array();
    200205                if ( $icons = Template::get_plugin_icon( $post ) ) {
    201                         if ( !empty( $icons['icon'] ) && empty( $icons['generated'] ) ) {
     206                        if ( ! empty( $icons['icon'] ) && empty( $icons['generated'] ) ) {
    202207                                $result['icons']['1x'] = $icons['icon'];
    203                         } elseif ( !empty( $icons['icon'] ) && ! empty( $icons['generated'] ) ) {
     208                        } elseif ( ! empty( $icons['icon'] ) && ! empty( $icons['generated'] ) ) {
    204209                                $result['icons']['default'] = $icons['icon'];
    205210                        }
    206                         if ( !empty( $icons['icon_2x'] ) ) {
     211                        if ( ! empty( $icons['icon_2x'] ) ) {
    207212                                $result['icons']['2x'] = $icons['icon_2x'];
    208213                        }
    209                         if ( !empty( $icons['svg'] ) ) {
     214                        if ( ! empty( $icons['svg'] ) ) {
    210215                                $result['icons']['svg'] = $icons['svg'];
    211216                        }
     
    213218
    214219                // That's all folks!
    215 
    216220                return $result;
    217221        }
     
    225229        protected function get_user_profile_link( $user ) {
    226230                $u = false;
    227                 if ( $user instanceOf \WP_User ) {
     231                if ( $user instanceof \WP_User ) {
    228232                        $u = $user;
    229233                } else {
     
    274278                        <div class="review-title-section">
    275279                                <h4 class="review-title"><?php echo esc_html( $review->post_title ); ?></h4>
    276                                 <div class="star-rating"><?php
     280                                <div class="star-rating">
     281                                <?php
    277282                                        /* Core has .star-rating .star colour styling, which is why we use a custom wrapper and template */
    278283                                        echo Template::dashicons_stars( array(
    279                                                 'rating' => $review->post_rating,
     284                                                'rating'   => $review->post_rating,
    280285                                                'template' => '<span class="star %1$s"></span>',
    281286                                        ) );
    282                                 ?></div>
     287                                ?>
     288                                </div>
    283289                        </div>
    284290                        <p class="reviewer">
    285291                                <?php
    286                                         $review_author_markup_profile = esc_url( 'https://profiles.wordpress.org/' . $reviewer->user_nicename );
    287                                         $review_author_markup  = '<a href="' . $review_author_markup_profile . '">';
    288                                         $review_author_markup .= get_avatar( $reviewer->ID, 16, 'monsterid' ) . '</a>';
    289                                         $review_author_markup .= '<a href="' . $review_author_markup_profile . '" class="reviewer-name">';
    290                                         $review_author_markup .= $reviewer->display_name;
    291                                         if ( $reviewer->display_name != $reviewer->user_login ) {
    292                                                 $review_author_markup .= " <small>({$reviewer->user_login})</small>";
    293                                         }
    294                                         $review_author_markup .= '</a>';
    295 
    296                                         printf( __( 'By %1$s on %2$s', 'wporg-plugins' ),
    297                                                 $review_author_markup,
    298                                                 '<span class="review-date">' . gmdate( 'F j, Y', strtotime( $review->post_modified ) ) . '</span>'
    299                                         );
     292                                $review_author_markup_profile = esc_url( 'https://profiles.wordpress.org/' . $reviewer->user_nicename );
     293                                $review_author_markup         = '<a href="' . $review_author_markup_profile . '">';
     294                                $review_author_markup        .= get_avatar( $reviewer->ID, 16, 'monsterid' ) . '</a>';
     295                                $review_author_markup        .= '<a href="' . $review_author_markup_profile . '" class="reviewer-name">';
     296                                $review_author_markup        .= $reviewer->display_name;
     297                                if ( $reviewer->display_name != $reviewer->user_login ) {
     298                                        $review_author_markup .= " <small>({$reviewer->user_login})</small>";
     299                                }
     300                                $review_author_markup .= '</a>';
     301
     302                                printf(
     303                                        __( 'By %1$s on %2$s', 'wporg-plugins' ),
     304                                        $review_author_markup,
     305                                        '<span class="review-date">' . gmdate( 'F j, Y', strtotime( $review->post_modified ) ) . '</span>'
     306                                );
    300307                                ?>
    301308                        </p>
     
    306313<?php
    307314                return ob_get_clean();
    308 
    309315        }
    310316
     
    320326                $markup = str_replace(
    321327                        array( '<dl>', '</dl>', '<dt>', '</dt>', '<dd>', '</dd>' ),
    322                         array( '',      '',     '<h4>', '</h4>', '<p>',  '</p>'  ),
     328                        array( '',     '',      '<h4>', '</h4>', '<p>',  '</p>'  ),
    323329                        $markup
    324330                );
     
    349355                return $markup;
    350356        }
    351 
    352357}
    353 
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-popular-tags.php

    r4559 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\API\Base;
    45use WP_REST_Server;
     
    2728                $terms = get_terms( 'plugin_tags', array(
    2829                        'hide_empty' => true,
    29                         'orderby' => 'count',
    30                         'order' => 'DESC',
    31                         'number' => 1000
     30                        'orderby'    => 'count',
     31                        'order'      => 'DESC',
     32                        'number'     => 1000,
    3233                ) );
    3334
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-query-plugins.php

    r5484 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\API\Base;
    45use WP_REST_Server;
     
    2122                'author_name',
    2223                'installed_plugins',
    23                 'plugin_tags'
     24                'plugin_tags',
    2425        );
    2526
     
    4142
    4243                $response = array(
    43                         'info' => array(
     44                        'info'    => array(
    4445                                'page'    => 0,
    4546                                'pages'   => 0,
     
    6970
    7071                $response['info']['page']    = (int) $wp_query->get( 'paged' ) ?: 1;
    71                 $response['info']['pages']   = (int) $wp_query->max_num_pages  ?: 0;
    72                 $response['info']['results'] = (int) $wp_query->found_posts    ?: 0;
     72                $response['info']['pages']   = (int) $wp_query->max_num_pages ?: 0;
     73                $response['info']['results'] = (int) $wp_query->found_posts ?: 0;
    7374
    7475                foreach ( $wp_query->posts as $post ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-svn-access.php

    r3301 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\API\Routes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\API\Base;
     
    2122
    2223                register_rest_route( 'plugins/v1', '/svn-access', array(
    23                         'methods'  => \WP_REST_Server::READABLE,
    24                         'callback' => array( $this, 'generate_svn_access' ),
     24                        'methods'             => \WP_REST_Server::READABLE,
     25                        'callback'            => array( $this, 'generate_svn_access' ),
    2526                        'permission_callback' => array( $this, 'permission_check_internal_api_bearer' ),
    2627                ) );
     
    4243                if ( empty( $svn_access ) ) {
    4344                        return false;
    44                         }
     45                }
    4546
    4647                foreach ( $svn_access as $slug => $users ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/import-plugin-to-glotpress.php

    r5446 r6287  
    1515if ( empty( $opts ) && $argc == 2 ) {
    1616        $opts['plugin'] = $argv[1];
    17         $argv[1] = '--plugin ' . $argv[1];
     17        $argv[1]        = '--plugin ' . $argv[1];
    1818}
    1919if ( empty( $opts['url'] ) ) {
     
    4242$_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH );
    4343
    44 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
     44require rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
    4545
    4646if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) {
     
    4848        if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
    4949                fwrite( STDERR, "Run the following command instead:\n" );
    50                 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . " --url " . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
     50                fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
    5151        }
    5252        die();
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/import-plugin.php

    r4563 r6287  
    1414if ( empty( $opts ) && $argc == 2 ) {
    1515        $opts['plugin'] = $argv[1];
    16         $argv[1] = '--plugin ' . $argv[1];
     16        $argv[1]        = '--plugin ' . $argv[1];
    1717}
    1818if ( empty( $opts['url'] ) ) {
     
    4444$_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH );
    4545
    46 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
     46require rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
    4747
    4848if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) {
     
    5050        if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
    5151                fwrite( STDERR, "Run the following command instead:\n" );
    52                 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . " --url " . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
     52                fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
    5353        }
    5454        die();
     
    5757$plugin_slug  = $opts['plugin'];
    5858$changed_tags = $opts['changed-tags'];
    59 $start_time   = microtime(1);
     59$start_time   = microtime( 1 );
    6060
    6161// If async, queue it to be parsed instead.
     
    6868echo "Processing Import for $plugin_slug... ";
    6969try {
    70         $importer = new CLI\Import;
     70        $importer = new CLI\Import();
    7171        $importer->import_from_svn( $plugin_slug, $changed_tags );
    72         echo "OK. Took " . round( microtime(1) - $start_time, 2 ) . "s\n";
    73 } catch( \Exception $e ) {
    74         echo "Failed. Took " . round( microtime(1) - $start_time, 2 ) . "s\n";
     72        echo 'OK. Took ' . round( microtime( 1 ) - $start_time, 2 ) . "s\n";
     73} catch ( \Exception $e ) {
     74        echo 'Failed. Took ' . round( microtime( 1 ) - $start_time, 2 ) . "s\n";
    7575
    7676        fwrite( STDERR, "[{$plugin_slug}] Plugin Import Failed: " . $e->getMessage() . "\n" );
    77         exit(1);
     77        exit( 1 );
    7878}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/quick-stats.php

    r6261 r6287  
    2020$_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH );
    2121
    22 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
     22require rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
    2323
    2424if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) {
     
    2626        if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
    2727                fwrite( STDERR, "Run the following command instead:\n" );
    28                 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . " --url " . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
     28                fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
    2929        }
    3030        die();
     
    3838function display_top_table( $stats, $n = 20 ) {
    3939
    40         $top = array_slice( $stats, 0, $n );
     40        $top  = array_slice( $stats, 0, $n );
    4141        $tail = array_slice( $stats, $n );
    4242
    4343        foreach ( $top as $row ) {
    44                 #$vals = array_values( (array) $row );
     44                // $vals = array_values( (array) $row );
    4545                echo $row[0] . "\t\t\t" . number_format( $row[1] ) . "\n";
    4646        }
    4747
    48         echo "Top $n Total: " . number_format( array_reduce( $top, __NAMESPACE__.'\callback_sum' ) ) . "\n";
     48        echo "Top $n Total: " . number_format( array_reduce( $top, __NAMESPACE__ . '\callback_sum' ) ) . "\n";
    4949
    5050        $tail_n = count( $tail );
    51         echo "Other $tail_n: " . number_format( array_reduce( $tail, __NAMESPACE__.'\callback_sum' ) ) . "\n";
     51        echo "Other $tail_n: " . number_format( array_reduce( $tail, __NAMESPACE__ . '\callback_sum' ) ) . "\n";
    5252
    5353}
    5454
    55 function tested_to_summary($pfx_where = '1=1') {
     55function tested_to_summary( $pfx_where = '1=1' ) {
    5656        global $wpdb;
    5757
     
    6161}
    6262
    63 $where = $wpdb->prepare( "post_status = %s", 'publish' );
     63$where = $wpdb->prepare( 'post_status = %s', 'publish' );
    6464
    65 if ( !empty( $opts['age'] ) && strtotime( $opts['age'] ) > 0 )
    66         $where .= $wpdb->prepare( " AND post_modified >= %s", strftime( '%Y-%m-%d',     strtotime( $opts['age'] ) ) );
     65if ( ! empty( $opts['age'] ) && strtotime( $opts['age'] ) > 0 ) {
     66        $where .= $wpdb->prepare( ' AND post_modified >= %s', strftime( '%Y-%m-%d', strtotime( $opts['age'] ) ) );
     67}
    6768
    68 //TODO: add some more reports, and a CLI argument for choosing them
     69// TODO: add some more reports, and a CLI argument for choosing them
    6970display_top_table( tested_to_summary( $where ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/rebuild-zip.php

    r6235 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_Directory;
    45use WordPressdotorg\Plugin_Directory\Tools\SVN;
     
    1718if ( empty( $opts ) && $argc == 2 ) {
    1819        $opts['plugin'] = $argv[1];
    19         $argv[1] = '--plugin ' . $argv[1];
     20        $argv[1]        = '--plugin ' . $argv[1];
    2021}
    2122if ( empty( $opts ) && $argc == 3 ) {
    2223        $opts['plugin'] = $argv[1];
    23         $argv[1] = '--plugin ' . $argv[1];
     24        $argv[1]        = '--plugin ' . $argv[1];
    2425
    2526        $opts['versions'] = $argv[2];
    26         $argv[2] = '--versions ' . $argv[2];
     27        $argv[2]          = '--versions ' . $argv[2];
    2728}
    2829if ( empty( $opts['url'] ) ) {
     
    4142                fwrite( STDERR, "Usage: php {$argv[0]} --plugin hello-dolly --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" );
    4243                fwrite( STDERR, "--url and --abspath will be guessed if possible.\n" );
    43                 exit(1);
     44                exit( 1 );
    4445        }
    4546}
     
    4950$_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH );
    5051
    51 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
     52require rtrim( $opts['abspath'], '/' ) . '/wp-load.php';
    5253
    5354if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) {
     
    5556        if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
    5657                fwrite( STDERR, "Run the following command instead:\n" );
    57                 fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . " --url " . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
     58                fwrite( STDERR, "\tphp " . implode( ' ', $argv ) . ' --url ' . get_site_url( WPORG_PLUGIN_DIRECTORY_BLOGID, '/' ) . "\n" );
    5859        }
    59         exit(1);
     60        exit( 1 );
    6061}
    6162
    6263$plugin_slug = $opts['plugin'];
    6364$versions    = array_filter( array_unique( array_map( 'trim', (array) explode( ',', $opts['versions'] ) ) ), 'strlen' );
    64 $start_time  = microtime(1);
     65$start_time  = microtime( 1 );
    6566
    6667if ( empty( $versions ) ) {
     
    7273        }
    7374
    74         $versions = array_map(
    75                 function( $dir ) { return trim( $dir, '/' ); },
    76                 $svn_tags
    77         );
     75        $versions = array_map( function( $dir ) {
     76                return trim( $dir, '/' );
     77        }, $svn_tags );
    7878        $versions[] = 'trunk';
    7979}
     
    8181if ( ! $versions ) {
    8282        fwrite( STDERR, "{$plugin_slug}: Error! No versions specified.\n" );
    83         exit(1);
     83        exit( 1 );
    8484}
    8585
     
    9090        $plugin_post = Plugin_Directory::get_plugin_post( $plugin_slug );
    9191        if ( ! $plugin_post ) {
    92                 throw new Exception( "Could not locate plugin post" );
     92                throw new Exception( 'Could not locate plugin post' );
    9393        }
    9494        $stable_tag = get_post_meta( $plugin_post->ID, 'stable_tag', true ) ?? 'trunk';
     
    9999                        $plugin_slug,
    100100                        $versions_to_build,
    101                         "{$plugin_slug}: Rebuild triggered by " . php_uname('n' ),
     101                        "{$plugin_slug}: Rebuild triggered by " . php_uname( 'n' ),
    102102                        $stable_tag
    103103                );
    104104        }
    105105
    106         echo "OK. Took " . round( microtime(1) - $start_time, 2 ) . "s\n";
    107 } catch( Exception $e ) {
     106        echo 'OK. Took ' . round( microtime( 1 ) - $start_time, 2 ) . "s\n";
     107} catch ( Exception $e ) {
    108108        fwrite( STDERR, "{$plugin_slug}: Zip Rebuild failed: " . $e->getMessage() . "\n" );
    109         echo "Failed. Took " . round( microtime(1) - $start_time, 2 ) . "s\n";
    110         exit(1);
     109        echo 'Failed. Took ' . round( microtime( 1 ) - $start_time, 2 ) . "s\n";
     110        exit( 1 );
    111111}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php

    r5867 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34use WordPressdotorg\Plugin_Directory\Tools;
    45
     
    2324        public static function map_meta_cap( $required_caps, $cap, $user_id, $context ) {
    2425                $plugin_edit_cap = false;
    25                 switch( $cap ) {
     26                switch ( $cap ) {
    2627                        case 'plugin_admin_edit':
    2728                        case 'plugin_add_committer':
     
    3031                        case 'plugin_remove_support_rep':
    3132                                $plugin_edit_cap = true;
     33
    3234                                // Fall through
    33 
    34                         // Although we no longer have a admin view, this capability is still used to determine if the current user is a committer/contributor.
     35                                // Although we no longer have a admin view, this capability is still used to determine if the current user is a committer/contributor.
    3536                        case 'plugin_admin_view':
    3637                                // Committers + Contributors.
    3738                                // If no committers, post_author.
    3839                                $required_caps = array();
    39                                 $post = get_post( $context[0] );
     40                                $post          = get_post( $context[0] );
    4041
    4142                                if ( ! $post ) {
     
    9899         */
    99100        public static function add_roles() {
    100 
    101101                $reviewer = array(
    102102                        'read'                    => true,
     
    121121                // Remove the roles first, incase we've changed the permission set.
    122122                remove_role( 'plugin_reviewer' );
    123                 remove_role( 'plugin_admin'    );
    124                 add_role( 'plugin_reviewer',  'Plugin Reviewer', $reviewer );
    125                 add_role( 'plugin_admin',     'Plugin Admin',    $admin    );
     123                remove_role( 'plugin_admin' );
     124                add_role( 'plugin_reviewer', 'Plugin Reviewer', $reviewer );
     125                add_role( 'plugin_admin', 'Plugin Admin', $admin );
    126126
    127127                $wp_admin_role = get_role( 'administrator' );
     
    135135        }
    136136}
    137 
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-i18n.php

    r5450 r6287  
    3838         *
    3939         * This function is never called, and only exists so that out pot tools can detect the strings.
     40         *
    4041         * @ignore
    4142         */
     
    4344
    4445                // Category terms.
    45                 _x( 'Accessibility',              'Plugin Category Name', 'wporg-plugins' );
    46                 _x( 'Advertising',                'Plugin Category Name', 'wporg-plugins' );
    47                 _x( 'Analytics',                  'Plugin Category Name', 'wporg-plugins' );
    48                 _x( 'Arts & Entertainment',       'Plugin Category Name', 'wporg-plugins' );
    49                 _x( 'Authentication',             'Plugin Category Name', 'wporg-plugins' );
    50                 _x( 'Business',                   'Plugin Category Name', 'wporg-plugins' );
    51                 _x( 'Calendar & Events',          'Plugin Category Name', 'wporg-plugins' );
    52                 _x( 'Communication',              'Plugin Category Name', 'wporg-plugins' );
    53                 _x( 'Contact Forms',              'Plugin Category Name', 'wporg-plugins' );
    54                 _x( 'Customization',              'Plugin Category Name', 'wporg-plugins' );
    55                 _x( 'Discussion & Community',     'Plugin Category Name', 'wporg-plugins' );
    56                 _x( 'eCommerce',                  'Plugin Category Name', 'wporg-plugins' );
    57                 _x( 'Editor & Writing',           'Plugin Category Name', 'wporg-plugins' );
    58                 _x( 'Education & Support',        'Plugin Category Name', 'wporg-plugins' );
    59                 _x( 'Language Tools',             'Plugin Category Name', 'wporg-plugins' );
    60                 _x( 'Maps & Location',            'Plugin Category Name', 'wporg-plugins' );
    61                 _x( 'Media',                      'Plugin Category Name', 'wporg-plugins' );
    62                 _x( 'Multisite',                  'Plugin Category Name', 'wporg-plugins' );
    63                 _x( 'Performance',                'Plugin Category Name', 'wporg-plugins' );
    64                 _x( 'Ratings & Reviews',          'Plugin Category Name', 'wporg-plugins' );
     46                _x( 'Accessibility', 'Plugin Category Name', 'wporg-plugins' );
     47                _x( 'Advertising', 'Plugin Category Name', 'wporg-plugins' );
     48                _x( 'Analytics', 'Plugin Category Name', 'wporg-plugins' );
     49                _x( 'Arts & Entertainment', 'Plugin Category Name', 'wporg-plugins' );
     50                _x( 'Authentication', 'Plugin Category Name', 'wporg-plugins' );
     51                _x( 'Business', 'Plugin Category Name', 'wporg-plugins' );
     52                _x( 'Calendar & Events', 'Plugin Category Name', 'wporg-plugins' );
     53                _x( 'Communication', 'Plugin Category Name', 'wporg-plugins' );
     54                _x( 'Contact Forms', 'Plugin Category Name', 'wporg-plugins' );
     55                _x( 'Customization', 'Plugin Category Name', 'wporg-plugins' );
     56                _x( 'Discussion & Community', 'Plugin Category Name', 'wporg-plugins' );
     57                _x( 'eCommerce', 'Plugin Category Name', 'wporg-plugins' );
     58                _x( 'Editor & Writing', 'Plugin Category Name', 'wporg-plugins' );
     59                _x( 'Education & Support', 'Plugin Category Name', 'wporg-plugins' );
     60                _x( 'Language Tools', 'Plugin Category Name', 'wporg-plugins' );
     61                _x( 'Maps & Location', 'Plugin Category Name', 'wporg-plugins' );
     62                _x( 'Media', 'Plugin Category Name', 'wporg-plugins' );
     63                _x( 'Multisite', 'Plugin Category Name', 'wporg-plugins' );
     64                _x( 'Performance', 'Plugin Category Name', 'wporg-plugins' );
     65                _x( 'Ratings & Reviews', 'Plugin Category Name', 'wporg-plugins' );
    6566                _x( 'Security & Spam Protection', 'Plugin Category Name', 'wporg-plugins' );
    66                 _x( 'SEO & Marketing',            'Plugin Category Name', 'wporg-plugins' );
    67                 _x( 'Social & Sharing',           'Plugin Category Name', 'wporg-plugins' );
    68                 _x( 'Taxonomy',                   'Plugin Category Name', 'wporg-plugins' );
    69                 _x( 'User Management',            'Plugin Category Name', 'wporg-plugins' );
    70                 _x( 'Utilities & Tools',          'Plugin Category Name', 'wporg-plugins' );
     67                _x( 'SEO & Marketing', 'Plugin Category Name', 'wporg-plugins' );
     68                _x( 'Social & Sharing', 'Plugin Category Name', 'wporg-plugins' );
     69                _x( 'Taxonomy', 'Plugin Category Name', 'wporg-plugins' );
     70                _x( 'User Management', 'Plugin Category Name', 'wporg-plugins' );
     71                _x( 'Utilities & Tools', 'Plugin Category Name', 'wporg-plugins' );
    7172
    7273                // Section terms.
    73                 _x( 'Adopt Me',     'Plugin Section Name', 'wporg-plugins' );
    74                 _x( 'Beta',         'Plugin Section Name', 'wporg-plugins' );
     74                _x( 'Adopt Me', 'Plugin Section Name', 'wporg-plugins' );
     75                _x( 'Beta', 'Plugin Section Name', 'wporg-plugins' );
    7576                _x( 'My Favorites', 'Plugin Section Name', 'wporg-plugins' );
    76                 _x( 'Featured',     'Plugin Section Name', 'wporg-plugins' );
    77                 _x( 'Popular',      'Plugin Section Name', 'wporg-plugins' );
     77                _x( 'Featured', 'Plugin Section Name', 'wporg-plugins' );
     78                _x( 'Popular', 'Plugin Section Name', 'wporg-plugins' );
    7879
    7980                // Section descriptions.
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-markdown.php

    r3511 r6287  
    4242                 * markdown will preserve things like underscores in code blocks.
    4343                 */
    44                 $text = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( $this, 'code_trick_decodeit_cb' ), $text );
     44                $text = preg_replace_callback( '!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s', array( $this, 'code_trick_decodeit_cb' ), $text );
    4545                $text = str_replace( array( "\r\n", "\r" ), "\n", $text );
    4646
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r6217 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34use WordPressdotorg\Plugin_Directory\Admin\Customizations;
    45use WordPressdotorg\Plugin_Directory\Admin\Tools\Author_Cards;
     
    5960
    6061                // Load the API routes.
    61                 add_action( 'rest_api_init', array( __NAMESPACE__ . '\API\Base', 'load_routes' ) );
     62                add_action( 'rest_api_init', array( __NAMESPACE__ . '\API\Base', 'init' ) );
    6263
    6364                // Allow post_modified not to be modified when we don't specifically bump it.
     
    6566
    6667                // Work around caching issues
    67                 add_filter( 'pre_option_jetpack_sync_full__started' , array( $this, 'bypass_options_cache' ), 10, 2 );
     68                add_filter( 'pre_option_jetpack_sync_full__started', array( $this, 'bypass_options_cache' ), 10, 2 );
    6869                add_filter( 'default_option_jetpack_sync_full__started', '__return_null' );
    69                 add_filter( 'pre_option_jetpack_sync_full__params' , array( $this, 'bypass_options_cache' ), 10, 2 );
     70                add_filter( 'pre_option_jetpack_sync_full__params', array( $this, 'bypass_options_cache' ), 10, 2 );
    7071                add_filter( 'default_option_jetpack_sync_full__params', '__return_null' );
    71                 add_filter( 'pre_option_jetpack_sync_full__queue_finished' , array( $this, 'bypass_options_cache' ), 10, 2 );
     72                add_filter( 'pre_option_jetpack_sync_full__queue_finished', array( $this, 'bypass_options_cache' ), 10, 2 );
    7273                add_filter( 'default_option_jetpack_sync_full__queue_finished', '__return_null' );
    73                 add_filter( 'pre_option_jetpack_sync_full__send_started' , array( $this, 'bypass_options_cache' ), 10, 2 );
     74                add_filter( 'pre_option_jetpack_sync_full__send_started', array( $this, 'bypass_options_cache' ), 10, 2 );
    7475                add_filter( 'default_option_jetpack_sync_full__send_started', '__return_null' );
    75                 add_filter( 'pre_option_jetpack_sync_full__finished' , array( $this, 'bypass_options_cache' ), 10, 2 );
     76                add_filter( 'pre_option_jetpack_sync_full__finished', array( $this, 'bypass_options_cache' ), 10, 2 );
    7677                add_filter( 'default_option_jetpack_sync_full__finished', '__return_null' );
    7778
     
    8889                        Stats_Report::instance();
    8990
    90                         add_action( 'wp_insert_post_data',    array( __NAMESPACE__ . '\Admin\Status_Transitions', 'can_change_post_status' ), 10, 2 );
     91                        add_action( 'wp_insert_post_data', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'can_change_post_status' ), 10, 2 );
    9192                        add_action( 'transition_post_status', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'instance' ) );
    9293                }
     
    124125                register_post_type( 'plugin', array(
    125126                        'labels'       => array(
    126                                 'name'               => __( 'Repo Plugins',              'wporg-plugins' ),
    127                                 'singular_name'      => __( 'Repo Plugin',               'wporg-plugins' ),
    128                                 'menu_name'          => __( 'Repo Plugins',              'wporg-plugins' ),
    129                                 'add_new'            => __( 'Add New',                   'wporg-plugins' ),
    130                                 'add_new_item'       => __( 'Add New Plugin',            'wporg-plugins' ),
    131                                 'new_item'           => __( 'New Plugin',                'wporg-plugins' ),
    132                                 'view_item'          => __( 'View Plugin',               'wporg-plugins' ),
    133                                 'search_items'       => __( 'Search Plugins',            'wporg-plugins' ),
    134                                 'not_found'          => __( 'No plugins found',          'wporg-plugins' ),
     127                                'name'               => __( 'Repo Plugins', 'wporg-plugins' ),
     128                                'singular_name'      => __( 'Repo Plugin', 'wporg-plugins' ),
     129                                'menu_name'          => __( 'Repo Plugins', 'wporg-plugins' ),
     130                                'add_new'            => __( 'Add New', 'wporg-plugins' ),
     131                                'add_new_item'       => __( 'Add New Plugin', 'wporg-plugins' ),
     132                                'new_item'           => __( 'New Plugin', 'wporg-plugins' ),
     133                                'view_item'          => __( 'View Plugin', 'wporg-plugins' ),
     134                                'search_items'       => __( 'Search Plugins', 'wporg-plugins' ),
     135                                'not_found'          => __( 'No plugins found', 'wporg-plugins' ),
    135136                                'not_found_in_trash' => __( 'No plugins found in Trash', 'wporg-plugins' ),
    136137
     
    138139                                'edit_item'          => is_admin() ? __( 'Editing Plugin: %s', 'wporg-plugins' ) : __( 'Edit Plugin', 'wporg-plugins' ),
    139140                        ),
    140                         'description'     => __( 'A Repo Plugin', 'wporg-plugins' ),
    141                         'supports'        => array( 'comments', 'author', 'custom-fields' ),
    142                         'public'          => true,
    143                         'show_ui'         => true,
    144                         'show_in_rest'    => true,
    145                         'has_archive'     => true,
    146                         'rewrite'         => false,
    147                         'menu_icon'       => 'dashicons-admin-plugins',
    148                         'capabilities'    => array(
     141                        'description'  => __( 'A Repo Plugin', 'wporg-plugins' ),
     142                        'supports'     => array( 'comments', 'author', 'custom-fields' ),
     143                        'public'       => true,
     144                        'show_ui'      => true,
     145                        'show_in_rest' => true,
     146                        'has_archive'  => true,
     147                        'rewrite'      => false,
     148                        'menu_icon'    => 'dashicons-admin-plugins',
     149                        'capabilities' => array(
    149150                                'edit_post'          => 'plugin_edit',
    150151                                'read_post'          => 'read',
     
    184185                        'labels'            => array(
    185186                                'name'          => __( 'Plugin Categories', 'wporg-plugins' ),
    186                                 'singular_name' => __( 'Plugin Category',   'wporg-plugins' ),
    187                                 'edit_item'     => __( 'Edit Category',     'wporg-plugins' ),
    188                                 'update_item'   => __( 'Update Category',   'wporg-plugins' ),
    189                                 'add_new_item'  => __( 'Add New Category',  'wporg-plugins' ),
     187                                'singular_name' => __( 'Plugin Category', 'wporg-plugins' ),
     188                                'edit_item'     => __( 'Edit Category', 'wporg-plugins' ),
     189                                'update_item'   => __( 'Update Category', 'wporg-plugins' ),
     190                                'add_new_item'  => __( 'Add New Category', 'wporg-plugins' ),
    190191                                'new_item_name' => __( 'New Category Name', 'wporg-plugins' ),
    191192                                'search_items'  => __( 'Search Categories', 'wporg-plugins' ),
     
    237238                        'rewrite'           => false,
    238239                        'labels'            => array(
    239                                 'name' => __( 'Contributors', 'wporg-plugins' ),
     240                                'name'          => __( 'Contributors', 'wporg-plugins' ),
    240241                                'singular_name' => __( 'Contributor', 'wporg-plugins' ),
    241242                        ),
     
    253254                        'rewrite'           => false,
    254255                        'labels'            => array(
    255                                 'name' => __( 'Committers', 'wporg-plugins' ),
     256                                'name'          => __( 'Committers', 'wporg-plugins' ),
    256257                                'singular_name' => __( 'Committer', 'wporg-plugins' ),
    257258                        ),
     
    269270                        'rewrite'           => false,
    270271                        'labels'            => array(
    271                                 'name' => __( 'Support Reps', 'wporg-plugins' ),
     272                                'name'          => __( 'Support Reps', 'wporg-plugins' ),
    272273                                'singular_name' => __( 'Support Rep', 'wporg-plugins' ),
    273274                        ),
     
    291292                        'labels'            => array(
    292293                                'name'          => __( 'Plugin Tags', 'wporg-plugins' ),
    293                                 'singular_name' => __( 'Plugin Tag',   'wporg-plugins' ),
    294                                 'edit_item'     => __( 'Edit Tag',     'wporg-plugins' ),
    295                                 'update_item'   => __( 'Update Tag',   'wporg-plugins' ),
    296                                 'add_new_item'  => __( 'Add New Tag',  'wporg-plugins' ),
     294                                'singular_name' => __( 'Plugin Tag', 'wporg-plugins' ),
     295                                'edit_item'     => __( 'Edit Tag', 'wporg-plugins' ),
     296                                'update_item'   => __( 'Update Tag', 'wporg-plugins' ),
     297                                'add_new_item'  => __( 'Add New Tag', 'wporg-plugins' ),
    297298                                'new_item_name' => __( 'New Tag Name', 'wporg-plugins' ),
    298299                                'search_items'  => __( 'Search Tags', 'wporg-plugins' ),
     
    352353
    353354                register_meta( 'post', 'rating', array(
    354                         'type'              => 'number',
    355                         'description'       => __( 'Overall rating of the plugin.', 'wporg-plugins' ),
    356                         'single'            => true,
     355                        'type'         => 'number',
     356                        'description'  => __( 'Overall rating of the plugin.', 'wporg-plugins' ),
     357                        'single'       => true,
    357358                        // todo 'sanitize_callback' => 'absint',
    358                         'show_in_rest'      => true,
     359                        'show_in_rest' => true,
    359360                ) );
    360361
     
    376377
    377378                register_meta( 'post', 'tested', array(
    378                         'description'       => __( 'The version of WordPress the plugin was tested with.', 'wporg-plugins' ),
    379                         'single'            => true,
     379                        'description'  => __( 'The version of WordPress the plugin was tested with.', 'wporg-plugins' ),
     380                        'single'       => true,
    380381                        // TODO 'sanitize_callback' => 'absint',
    381                         'show_in_rest'      => true,
     382                        'show_in_rest' => true,
    382383                ) );
    383384
    384385                register_meta( 'post', 'requires', array(
    385                         'description'       => __( 'The minimum version of WordPress the plugin needs to run.', 'wporg-plugins' ),
    386                         'single'            => true,
     386                        'description'  => __( 'The minimum version of WordPress the plugin needs to run.', 'wporg-plugins' ),
     387                        'single'       => true,
    387388                        // TODO 'sanitize_callback' => 'absint',
    388                         'show_in_rest'      => true,
     389                        'show_in_rest' => true,
    389390                ) );
    390391
    391392                register_meta( 'post', 'requires_php', array(
    392                         'description'       => __( 'The minimum version of PHP the plugin needs to run.', 'wporg-plugins' ),
    393                         'single'            => true,
     393                        'description'  => __( 'The minimum version of PHP the plugin needs to run.', 'wporg-plugins' ),
     394                        'single'       => true,
    394395                        // TODO 'sanitize_callback' => 'absint',
    395                         'show_in_rest'      => true,
     396                        'show_in_rest' => true,
    396397                ) );
    397398
    398399                register_meta( 'post', 'stable_tag', array(
    399                         'description'       => __( 'Stable version of the plugin.', 'wporg-plugins' ),
    400                         'single'            => true,
     400                        'description'  => __( 'Stable version of the plugin.', 'wporg-plugins' ),
     401                        'single'       => true,
    401402                        // TODO 'sanitize_callback' => 'absint',
    402                         'show_in_rest'      => true,
     403                        'show_in_rest' => true,
    403404                ) );
    404405
     
    411412
    412413                register_meta( 'post', 'version', array(
    413                         'description'       => __( 'Current stable version.', 'wporg-plugins' ),
    414                         'single'            => true,
     414                        'description'  => __( 'Current stable version.', 'wporg-plugins' ),
     415                        'single'       => true,
    415416                        // TODO 'sanitize_callback' => 'esc_url_raw',
    416                         'show_in_rest'      => true,
     417                        'show_in_rest' => true,
    417418                ) );
    418419
    419420                register_meta( 'post', 'header_name', array(
    420                         'description'       => __( 'Name of the plugin.', 'wporg-plugins' ),
    421                         'single'            => true,
     421                        'description'  => __( 'Name of the plugin.', 'wporg-plugins' ),
     422                        'single'       => true,
    422423                        // TODO 'sanitize_callback' => 'esc_url_raw',
    423                         'show_in_rest'      => true,
     424                        'show_in_rest' => true,
    424425                ) );
    425426
     
    432433
    433434                register_meta( 'post', 'header_name', array(
    434                         'description'       => __( 'Name of the plugin.', 'wporg-plugins' ),
    435                         'single'            => true,
     435                        'description'  => __( 'Name of the plugin.', 'wporg-plugins' ),
     436                        'single'       => true,
    436437                        // TODO 'sanitize_callback' => 'esc_url_raw',
    437                         'show_in_rest'      => true,
     438                        'show_in_rest' => true,
    438439                ) );
    439440
    440441                register_meta( 'post', 'header_author', array(
    441                         'description'       => __( 'Name of the plugin author.', 'wporg-plugins' ),
    442                         'single'            => true,
     442                        'description'  => __( 'Name of the plugin author.', 'wporg-plugins' ),
     443                        'single'       => true,
    443444                        // TODO 'sanitize_callback' => 'esc_url_raw',
    444                         'show_in_rest'      => true,
     445                        'show_in_rest' => true,
    445446                ) );
    446447
     
    453454
    454455                register_meta( 'post', 'header_description', array(
    455                         'description'       => __( 'Description of the plugin.', 'wporg-plugins' ),
    456                         'single'            => true,
     456                        'description'  => __( 'Description of the plugin.', 'wporg-plugins' ),
     457                        'single'       => true,
    457458                        // TODO 'sanitize_callback' => 'esc_url_raw',
    458                         'show_in_rest'      => true,
     459                        'show_in_rest' => true,
    459460                ) );
    460461
    461462                register_meta( 'post', 'assets_icons', array(
    462                         'type'              => 'array',
    463                         'description'       => __( 'Icon images of the plugin.', 'wporg-plugins' ),
    464                         'single'            => true,
     463                        'type'         => 'array',
     464                        'description'  => __( 'Icon images of the plugin.', 'wporg-plugins' ),
     465                        'single'       => true,
    465466                        // TODO 'sanitize_callback' => 'esc_url_raw',
    466                         'show_in_rest'      => true,
     467                        'show_in_rest' => true,
    467468                ) );
    468469
    469470                register_meta( 'post', 'assets_banners_color', array(
    470                         'description'       => __( 'Fallback color for the plugin.', 'wporg-plugins' ),
    471                         'single'            => true,
     471                        'description'  => __( 'Fallback color for the plugin.', 'wporg-plugins' ),
     472                        'single'       => true,
    472473                        // TODO 'sanitize_callback' => 'esc_url_raw',
    473                         'show_in_rest'      => true,
     474                        'show_in_rest' => true,
    474475                ) );
    475476
     
    510511
    511512                // If changing capabilities around, uncomment this.
    512                 //Capabilities::add_roles();
     513                // Capabilities::add_roles();
    513514
    514515                // Remove the /admin$ redirect to wp-admin
     
    523524                if ( class_exists( 'Jetpack' ) && \Jetpack::get_option( 'id' ) && ! class_exists( 'Jetpack_Search' )
    524525                        && ! isset( $_GET['s'] ) ) { // Don't run the ES query if we're going to redirect to the pretty search URL
    525                                 require_once( __DIR__ . '/libs/site-search/jetpack-search.php' );
     526                                require_once __DIR__ . '/libs/site-search/jetpack-search.php';
    526527                                \Jetpack_Search::instance();
    527528                }
     
    532533         */
    533534        public function register_shortcodes() {
    534                 add_shortcode( 'wporg-plugins-developers',  array( __NAMESPACE__ . '\Shortcodes\Developers', 'display' ) );
    535                 add_shortcode( 'wporg-plugin-upload',       array( __NAMESPACE__ . '\Shortcodes\Upload',      'display' ) );
     535                add_shortcode( 'wporg-plugins-developers', array( __NAMESPACE__ . '\Shortcodes\Developers', 'display' ) );
     536                add_shortcode( 'wporg-plugin-upload', array( __NAMESPACE__ . '\Shortcodes\Upload', 'display' ) );
    536537                add_shortcode( 'wporg-plugins-screenshots', array( __NAMESPACE__ . '\Shortcodes\Screenshots', 'display' ) );
    537                 add_shortcode( 'wporg-plugins-reviews',     array( __NAMESPACE__ . '\Shortcodes\Reviews',    'display' ) );
    538                 add_shortcode( 'readme-validator',          array( __NAMESPACE__ . '\Shortcodes\Readme_Validator',    'display' ) );
     538                add_shortcode( 'wporg-plugins-reviews', array( __NAMESPACE__ . '\Shortcodes\Reviews', 'display' ) );
     539                add_shortcode( 'readme-validator', array( __NAMESPACE__ . '\Shortcodes\Readme_Validator', 'display' ) );
    539540        }
    540541
     
    552553                        'wporg-plugins-screenshots',
    553554                        'wporg-plugins-reviews',
    554                         'readme-validator'
     555                        'readme-validator',
    555556                );
    556557
     
    568569         */
    569570        public function register_widgets() {
    570                 register_widget( __NAMESPACE__ . '\Widgets\Donate'        );
    571                 register_widget( __NAMESPACE__ . '\Widgets\Meta'          );
    572                 register_widget( __NAMESPACE__ . '\Widgets\Ratings'       );
    573                 register_widget( __NAMESPACE__ . '\Widgets\Support'       );
    574                 register_widget( __NAMESPACE__ . '\Widgets\Committers'    );
    575                 register_widget( __NAMESPACE__ . '\Widgets\Contributors'  );
    576                 register_widget( __NAMESPACE__ . '\Widgets\Support_Reps'  );
     571                register_widget( __NAMESPACE__ . '\Widgets\Donate' );
     572                register_widget( __NAMESPACE__ . '\Widgets\Meta' );
     573                register_widget( __NAMESPACE__ . '\Widgets\Ratings' );
     574                register_widget( __NAMESPACE__ . '\Widgets\Support' );
     575                register_widget( __NAMESPACE__ . '\Widgets\Committers' );
     576                register_widget( __NAMESPACE__ . '\Widgets\Contributors' );
     577                register_widget( __NAMESPACE__ . '\Widgets\Support_Reps' );
    577578        }
    578579
     
    669670        /**
    670671         * Filter content to make links rel=nofollow on plugin pages only
    671          * @param string        $content        The content.
     672         *
     673         * @param string $content    The content.
    672674         * @return string
    673675         */
     
    675677                if ( get_post_type() == 'plugin' ) {
    676678                        // regex copied from wp_rel_nofollow(). Not calling that function because it messes with slashes.
    677                         $content = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $content);
     679                        $content = preg_replace_callback( '|<a (.+?)>|i', 'wp_rel_nofollow_callback', $content );
    678680                }
    679681                return $content;
     
    706708                                $wp_query->query_vars['order']    = 'DESC';
    707709                                break;
     710
    708711                        case 'favorites':
    709712                                $favorites_user = wp_get_current_user();
     
    723726
    724727                                        $wp_query->query_vars['orderby'] = 'post_title';
    725                                         $wp_query->query_vars['order'] = 'ASC';
     728                                        $wp_query->query_vars['order']   = 'ASC';
    726729                                }
    727730
     
    766769                                array(
    767770                                        'taxonomy' => 'plugin_contributors',
    768                                         'field' => 'slug',
    769                                         'terms' => $user
    770                                 )
     771                                        'field'    => 'slug',
     772                                        'terms'    => $user,
     773                                ),
    771774                        );
    772775
     
    776779                                $wp_query->query_vars['tax_query'][] = array(
    777780                                        'taxonomy' => 'plugin_committers',
    778                                         'field' => 'slug',
    779                                         'terms' => $user
     781                                        'field'    => 'slug',
     782                                        'terms'    => $user,
    780783                                );
    781784                        }
    782785
    783786                        $wp_query->query_vars['orderby'] = 'post_title';
    784                         $wp_query->query_vars['order'] = 'ASC';
     787                        $wp_query->query_vars['order']   = 'ASC';
    785788
    786789                        // Treat it as a taxonomy query now, not the author archive.
    787790                        $wp_query->is_author = false;
    788                         $wp_query->is_tax = true;
     791                        $wp_query->is_tax    = true;
    789792
    790793                        unset( $wp_query->query_vars['author_name'], $wp_query->query_vars['author'] );
     
    796799                        $wp_query->query_vars['post_status'] = array( 'approved', 'publish', 'closed', 'disabled' );
    797800
    798                         add_filter( 'posts_results', function( $posts, $this_wp_query ) use( $wp_query ) {
     801                        add_filter( 'posts_results', function( $posts, $this_wp_query ) use ( $wp_query ) {
    799802                                if ( $this_wp_query != $wp_query ) {
    800803                                        return $posts;
     
    825828                // Allow anyone to view a closed plugin directly from its page. It won't show in search results or lists.
    826829                if ( $wp_query->is_main_query() && ! empty( $wp_query->query_vars['name'] ) ) {
    827                         $wp_query->query_vars['post_status'] = (array) $wp_query->query_vars['post_status'];
     830                        $wp_query->query_vars['post_status']   = (array) $wp_query->query_vars['post_status'];
    828831                        $wp_query->query_vars['post_status'][] = 'closed';
    829832                        $wp_query->query_vars['post_status'][] = 'disabled';
    830                         $wp_query->query_vars['post_status'] = array_unique( $wp_query->query_vars['post_status'] );
     833                        $wp_query->query_vars['post_status']   = array_unique( $wp_query->query_vars['post_status'] );
    831834                }
    832835
     
    856859        public function bypass_options_cache( $value, $option ) {
    857860                global $wpdb;
    858                 $value = $wpdb->get_var(
    859                         $wpdb->prepare(
    860                                 "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1",
    861                                 $option
    862                         )
    863                 );
     861                $value = $wpdb->get_var( $wpdb->prepare(
     862                        "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1",
     863                        $option
     864                ) );
    864865                $value = maybe_unserialize( $value );
    865866
     
    874875        public function fix_login_url( $login_url, $redirect, $force_reauth ) {
    875876                // modify the redirect_to for the support forums to point to the current page
    876                 if ( 0 === strpos($_SERVER['REQUEST_URI'], '/plugins' ) ) {
     877                if ( 0 === strpos( $_SERVER['REQUEST_URI'], '/plugins' ) ) {
    877878                        // Note that this is not normal because of the code in /mu-plugins/wporg-sso/class-wporg-sso.php.
    878879                        // The login_url function there expects the redirect_to as the first parameter passed into it instead of the second
     
    884885                        // parse_url is used here to remove any additional query args from the REQUEST_URI before redirection
    885886                        // The SSO code handles the urlencoding of the redirect_to parameter
    886                         $url_parts = parse_url('https://wordpress.org'.$_SERVER['REQUEST_URI']);
    887                         $constructed_url = $url_parts['scheme'] . '://' . $url_parts['host'] . (isset($url_parts['path'])?$url_parts['path']:'');
    888                         $login_url = $constructed_url;
     887                        $url_parts       = parse_url( 'https://wordpress.org' . $_SERVER['REQUEST_URI'] );
     888                        $constructed_url = $url_parts['scheme'] . '://' . $url_parts['host'] . ( isset( $url_parts['path'] ) ? $url_parts['path'] : '' );
     889                        $login_url       = $constructed_url;
    889890                }
    890891                return $login_url;
     
    940941         * @global string $locale Current locale.
    941942         *
    942          * @param int   $post_id        Post ID to update.
    943          * @param int   $min_translated Translations below this % threshold will not be synced to meta, to save space.
     943         * @param int $post_id    Post ID to update.
     944         * @param int $min_translated Translations below this % threshold will not be synced to meta, to save space.
    944945         * @return array
    945946         */
    946         public function sync_all_translations_to_meta( $post_id, $min_translated = 40, $skip_pfx = array('en_') ) {
     947        public function sync_all_translations_to_meta( $post_id, $min_translated = 40, $skip_pfx = array( 'en_' ) ) {
    947948
    948949                $locales_to_sync = array();
    949                 $post = get_post( $post_id );
     950                $post            = get_post( $post_id );
    950951                if ( $post ) {
    951952                        $translations = Plugin_I18n::instance()->find_all_translations_for_plugin( $post->post_name, 'stable-readme', $min_translated ); // at least $min_translated % translated
     
    953954                                // Eliminate translations that start with unwanted prefixes, so we don't waste space on near-duplicates like en_AU, en_CA etc.
    954955                                foreach ( $translations as $i => $_locale ) {
    955                                         foreach ( $skip_pfx as $pfx )
    956                                                 if ( substr( $_locale, 0, strlen( $pfx ) ) === $pfx )
     956                                        foreach ( $skip_pfx as $pfx ) {
     957                                                if ( substr( $_locale, 0, strlen( $pfx ) ) === $pfx ) {
    957958                                                        unset( $translations[ $i ] );
     959                                                }
     960                                        }
    958961                                }
    959962                                $locales_to_sync = array_unique( $translations );
     
    961964                }
    962965
    963                 if ( count($locales_to_sync) > 0 ) {
     966                if ( count( $locales_to_sync ) > 0 ) {
    964967                        foreach ( $locales_to_sync as $locale ) {
    965968                                $this->sync_translation_to_meta( $post_id, $locale );
     
    975978         * @global string $locale Current locale.
    976979         *
    977          * @param int   $post_id        Post ID to update.
    978          * @param string   $locale      Locale to translate.
     980         * @param int    $post_id    Post ID to update.
     981         * @param string $locale  Locale to translate.
    979982         */
    980983        public function sync_translation_to_meta( $post_id, $_locale ) {
     
    983986                $old_locale = $locale;
    984987                // Keep track of the original untranslated strings
    985                 $orig_title = get_the_title( $post_id );
     988                $orig_title   = get_the_title( $post_id );
    986989                $orig_excerpt = get_the_excerpt( $post_id );
    987990                $orig_content = get_post_field( 'post_content', $post_id );
    988                 $locale = $_locale;
     991                $locale       = $_locale;
    989992
    990993                // Update postmeta values for the translated title, excerpt, and content, if they are available and different from the originals.
    991994                // There is a bug here, in that no attempt is made to remove old meta values for translations that do not have new translations.
    992 
    993995                $the_title = Plugin_I18n::instance()->translate( 'title', $orig_title, [ 'post_id' => $post_id ] );
    994996                if ( $the_title && $the_title != $orig_title ) {
     
    10031005                // Split up the content to translate it in sections.
    10041006                $the_content = array();
    1005                 $sections = $this->split_post_content_into_pages( $orig_content );
     1007                $sections    = $this->split_post_content_into_pages( $orig_content );
    10061008                foreach ( $sections as $section => $section_content ) {
    10071009                        $translated_section = $this->translate_post_content( $section_content, $section, $post_id );
     
    10121014                }
    10131015
    1014                 if ( !empty( $the_content ) ) {
     1016                if ( ! empty( $the_content ) ) {
    10151017                        update_post_meta( $post_id, 'content_' . $locale, implode( $the_content ) );
    10161018                }
     
    11091111
    11101112                        if ( 'tags' === $path[2] ) {
    1111                                 if ( isset( $path[3] ) && !empty( $path[3] ) ) {
     1113                                if ( isset( $path[3] ) && ! empty( $path[3] ) ) {
    11121114                                        wp_safe_redirect( home_url( '/search/' . urlencode( $path[3] ) . '/' ) );
    11131115                                        die();
     
    11451147                        }
    11461148
    1147                         //Otherwise, let's redirect to the search page
    1148                         if ( isset( $path[2] ) && !empty( $path[2] ) ) {
     1149                        // Otherwise, let's redirect to the search page
     1150                        if ( isset( $path[2] ) && ! empty( $path[2] ) ) {
    11491151                                wp_safe_redirect( home_url( '/search/' . urlencode( $path[2] ) . '/' ) );
    11501152                                die();
     
    12051207         */
    12061208        public function split_post_content_into_pages( $content ) {
    1207                 $_pages        = preg_split( "#<!--section=(.+?)-->#", $content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     1209                $_pages        = preg_split( '#<!--section=(.+?)-->#', $content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
    12081210                $content_pages = array(
    12091211                        'screenshots' => '[wporg-plugins-screenshots]',
     
    13181320        public static function create_plugin_post( array $args ) {
    13191321                $title = $args['post_title'] ?: $args['post_name'];
    1320                 $slug  = $args['post_name']  ?: sanitize_title( $title );
     1322                $slug  = $args['post_name'] ?: sanitize_title( $title );
    13211323
    13221324                $args = wp_parse_args( $args, array(
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-geopattern-svg.php

    r2994 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34use RedeyeVentures\GeoPattern\SVG;
    45
     
    4142
    4243        /**
    43          * @param       $text
    44          * @param       $x
    45          * @param       $y
    46          * @param       $text_anchor
    47          * @param       $style
    48          * @param array $args
     44         * @param string $text
     45         * @param string $x
     46         * @param string $y
     47         * @param string $text_anchor
     48         * @param string $style
     49         * @param array  $args
    4950         *
    5051         * @return $this
    5152         */
    5253        public function addText( $text, $x, $y, $text_anchor, $style, $args = array() ) {
    53                 $element = new Plugin_Geopattern_SVGText( $text, $x, $y, $text_anchor, $style, $args );
     54                $element          = new Plugin_Geopattern_SVGText( $text, $x, $y, $text_anchor, $style, $args );
    5455                $this->svgString .= $element;
    5556
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-geopattern-svgtext.php

    r2994 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34use RedeyeVentures\GeoPattern\SVGElements\Base;
    45
     
    2122
    2223        /**
    23          * @param       $text
    24          * @param       $x
    25          * @param       $y
    26          * @param       $text_anchor
    27          * @param       $style
    28          * @param array $args
     24         * @param string $text
     25         * @param string $x
     26         * @param string $y
     27         * @param string $text_anchor
     28         * @param string $style
     29         * @param array  $args
    2930         */
    3031        function __construct( $text, $x, $y, $text_anchor, $style, $args = array() ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-geopattern.php

    r2994 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34use RedeyeVentures\GeoPattern\GeoPattern;
    45
     
    9192                $this->generatePattern();
    9293
    93                 #if ( $this->svg->getWidth() < $width || $this->svg->getHeight() < $height ) {
     94                // if ( $this->svg->getWidth() < $width || $this->svg->getHeight() < $height ) {
    9495                        $this->svg->setViewBox( 0, 0, $this->svg->getWidth(), $this->svg->getHeight() );
    95                 #}
    96 
     96                // }
    9797                if ( $this->text ) {
    9898                        $inner = $this->svg;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php

    r5982 r6287  
    6464         *
    6565         * @access private
    66          *
    6766         */
    6867        private function __construct() {
     
    237236                $translation_set_id = $wpdb->get_var( $wpdb->prepare(
    238237                        'SELECT id FROM ' . GLOTPRESS_TABLE_PREFIX . 'translation_sets WHERE project_id = %d AND locale = %s',
    239                         $branch_id, $locale ) );
     238                        $branch_id, $locale
     239                ) );
    240240
    241241                if ( empty( $translation_set_id ) ) {
     
    456456                $translation_sets = $this->cache_get( $post->post_name, $branch, $cache_suffix );
    457457                if ( false === $translation_sets ) {
    458                         $api_url = esc_url_raw( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $post->post_name . '/' . $branch, [ 'https' ] );
     458                        $api_url  = esc_url_raw( 'https://translate.wordpress.org/api/projects/wp-plugins/' . $post->post_name . '/' . $branch, [ 'https' ] );
    459459                        $response = wp_remote_get( $api_url );
    460460
     
    462462                                $translation_sets = [];
    463463                        } else {
    464                                 $result = json_decode( wp_remote_retrieve_body( $response ) );
     464                                $result           = json_decode( wp_remote_retrieve_body( $response ) );
    465465                                $translation_sets = isset( $result->translation_sets ) ? $result->translation_sets : [];
    466466                        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r6250 r6287  
    33
    44// Explicitly require dependencies so this file can be sourced outside the Plugin Directory.
    5 require_once( __DIR__ . '/class-plugin-geopattern.php' );
    6 require_once( __DIR__ . '/class-plugin-geopattern-svg.php' );
    7 require_once( __DIR__ . '/class-plugin-geopattern-svgtext.php' );
     5require_once __DIR__ . '/class-plugin-geopattern.php';
     6require_once __DIR__ . '/class-plugin-geopattern-svg.php';
     7require_once __DIR__ . '/class-plugin-geopattern-svgtext.php';
    88
    99/**
     
    137137
    138138                if ( is_singular( 'plugin' ) ) {
    139                         $metas[] = sprintf( '<meta name="description" value="%s" />',
     139                        $metas[] = sprintf(
     140                                '<meta name="description" value="%s" />',
    140141                                esc_attr( get_the_excerpt() )
    141142                        );
     
    192193
    193194                        // TODO: While the plugin ZIPs are still being served by bbPress, the download stats are stored there.
    194                         $count = $wpdb->get_var( $wpdb->prepare( "SELECT downloads FROM `" . PLUGINS_TABLE_PREFIX . "download_counts` WHERE topic_id = (SELECT topic_id FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE topic_slug = %s )", $post->post_name ) );
     195                        $count = $wpdb->get_var( $wpdb->prepare( 'SELECT downloads FROM `' . PLUGINS_TABLE_PREFIX . 'download_counts` WHERE topic_id = (SELECT topic_id FROM `' . PLUGINS_TABLE_PREFIX . 'topics` WHERE topic_slug = %s )', $post->post_name ) );
    195196
    196197                        wp_cache_set( $post->ID, $count, 'plugin_download_count', HOUR_IN_SECONDS );
     
    212213                        global $wpdb;
    213214
    214                         $count = $wpdb->get_var( "SELECT SUM(downloads) FROM `" . PLUGINS_TABLE_PREFIX . "stats`" );
     215                        $count = $wpdb->get_var( 'SELECT SUM(downloads) FROM `' . PLUGINS_TABLE_PREFIX . 'stats`' );
    215216                        wp_cache_set( 'plugin_download_count', $count, 'plugin_download_count', DAY_IN_SECONDS );
    216217                }
     
    234235                $num_ratings = array_sum( $ratings );
    235236
    236                 return
    237                         '<div class="plugin-rating">' .
     237                return '<div class="plugin-rating">' .
    238238                                Template::dashicons_stars( $rating ) .
    239239                                '<span class="rating-count">(' .
     
    356356         */
    357357        public static function get_plugin_icon( $post = null, $output = 'raw' ) {
    358                 $plugin    = get_post( $post );
     358                $plugin = get_post( $post );
     359
     360                if ( in_array( $plugin->post_status, [ 'disabled', 'closed' ], true ) ) {
     361                        return false;
     362                }
     363
    359364                $raw_icons = get_post_meta( $plugin->ID, 'assets_icons', true ) ?: array();
    360 
    361                 $icon = $icon_2x = $svg = $generated = false;
     365                $icon      = $icon_2x = $svg = $generated = false;
    362366
    363367                foreach ( $raw_icons as $file => $info ) {
     
    391395                        $generated = true;
    392396
    393                         $icon = new Plugin_Geopattern;
     397                        $icon = new Plugin_Geopattern();
    394398                        $icon->setString( $plugin->post_name );
    395399
     
    412416                                        $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$icon_2x}'); } }";
    413417                                }
    414                                 $html .= "</style>";
     418                                $html .= '</style>';
    415419                                $html .= "<div class='plugin-icon' id='{$id}'></div>";
    416420
     
    425429
    426430        /**
    427          * Retrieve the Plugin Icon details for a plugin.
     431         * Retrieve the Plugin banner details for a plugin.
    428432         *
    429433         * @static
     
    436440                $plugin = get_post( $post );
    437441
    438                 if ( in_array( $plugin->post_status, ['disabled', 'closed'], true ) ) {
     442                if ( in_array( $plugin->post_status, [ 'disabled', 'closed' ], true ) ) {
    439443                        return false;
    440444                }
     
    488492                                        $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$banner_2x}'); } }";
    489493                                }
    490                                 $html .= "</style>";
     494                                $html .= '</style>';
    491495                                $html .= "<div class='plugin-banner' id='{$id}'></div>";
    492496
     
    580584         */
    581585        public static function dashicons_stars( $args = array() ) {
    582                 $args = wp_parse_args( ( is_numeric( $args ) ? array( 'rating' => $args ) : $args ), array(
     586                $args = is_numeric( $args ) ? array( 'rating' => $args ) : $args;
     587                $args = wp_parse_args( $args, array(
    583588                        'rating'   => 0,
    584589                        'template' => '<span class="%1$s"></span>',
     
    629634
    630635                if ( 'trunk' != $version ) {
    631                         return sprintf( "https://downloads.wordpress.org/plugin/%s.%s.zip", $post->post_name, $version );
     636                        return sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $post->post_name, $version );
    632637                } else {
    633                         return sprintf( "https://downloads.wordpress.org/plugin/%s.zip", $post->post_name );
     638                        return sprintf( 'https://downloads.wordpress.org/plugin/%s.zip', $post->post_name );
    634639                }
    635640        }
     
    662667
    663668                return add_query_arg( array(
    664                         '_wpnonce' => wp_create_nonce( 'wp_rest' ),
    665                         ( $favorited ? 'unfavorite' : 'favorite' ) => '1'
     669                        '_wpnonce'                                 => wp_create_nonce( 'wp_rest' ),
     670                        ( $favorited ? 'unfavorite' : 'favorite' ) => '1',
    666671                ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' ) );
    667672        }
     
    759764                                'locale'    => 'en_US',
    760765                                'hreflang'  => 'en',
    761                                 'subdomain' => ''
     766                                'subdomain' => '',
    762767                        );
    763768
     
    766771                        } );
    767772
    768                         wp_cache_set( 'local-sites-'.get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS );
     773                        wp_cache_set( 'local-sites-' . get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS );
    769774                }
    770775
     
    773778                                'https://%swordpress.org%s',
    774779                                $site->subdomain ? "{$site->subdomain}." : '',
    775                                 $_SERVER[ 'REQUEST_URI' ]
     780                                $_SERVER['REQUEST_URI']
    776781                        );
    777782
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php

    r5910 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34use WP_User;
    45
     
    5455
    5556                        $reviews = $wpdb->get_results( $wpdb->prepare(
    56                         "SELECT
     57                                "SELECT
    5758                                        ID, post_content, post_title, post_author, post_modified,
    5859                                        r.rating as post_rating
    59                         FROM ratings r
    60                                 LEFT JOIN wporg_419_posts p ON r.post_id = p.ID
    61                         WHERE r.object_type = 'plugin' AND r.object_slug = %s AND p.post_status = 'publish'
    62                         ORDER BY r.review_id DESC
    63                         LIMIT %d", $plugin_slug, $number ) );
     60                                FROM ratings r
     61                                        LEFT JOIN wporg_419_posts p ON r.post_id = p.ID
     62                                WHERE r.object_type = 'plugin' AND r.object_slug = %s AND p.post_status = 'publish'
     63                                ORDER BY r.review_id DESC
     64                                LIMIT %d",
     65                                $plugin_slug,
     66                                $number
     67                        ) );
    6468
    6569                        wp_cache_set( "{$plugin_slug}_last{$number}", $reviews, 'plugin-reviews', HOUR_IN_SECONDS );
     
    241245
    242246                if ( false === ( $support_reps = wp_cache_get( $plugin_slug, 'plugin-support-reps' ) ) ) {
    243                         $post = Plugin_Directory::get_plugin_post( $plugin_slug );
     247                        $post         = Plugin_Directory::get_plugin_post( $plugin_slug );
    244248                        $support_reps = wp_get_object_terms( $post->ID, 'plugin_support_reps', array( 'fields' => 'names' ) );
    245249
     
    341345                if ( $subscribe ) {
    342346                        $users[] = $user->ID;
    343                         $users = array_unique( $users );
     347                        $users   = array_unique( $users );
    344348                } else {
    345349                        if ( false !== ( $pos = array_search( $user->ID, $users, true ) ) ) {
     
    423427                }
    424428
    425                 $users_favorites = get_user_meta( $user->ID, 'plugin_favorites', true ) ?: array();
    426 
     429                $users_favorites   = get_user_meta( $user->ID, 'plugin_favorites', true ) ?: array();
    427430                $already_favorited = in_array( $post->post_name, $users_favorites, true );
    428431
     
    447450         *
    448451         * @param string $plugin_slug       The plugin to retrieve subscribers for.
    449          * @param bool   $include_committers Whether to include Plugin Committers in the list. Default false. 
     452         * @param bool   $include_committers Whether to include Plugin Committers in the list. Default false.
    450453         * @return array Array of \WP_User's who are subscribed.
    451454         */
     
    468471
    469472                // Plugin Committers are always subscrived to plugin commits.
    470                 $committers  = self::get_plugin_committers( $plugin_slug );
     473                $committers = self::get_plugin_committers( $plugin_slug );
    471474                foreach ( $committers as $committer ) {
    472475                        if ( $committer && $user = get_user_by( 'login', $committer ) ) {
  • 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                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-svn-watcher.php

    r5449 r6287  
    1313class SVN_Watcher {
    1414
    15         const SVN_URL      = 'https://plugins.svn.wordpress.org/';
    16         const PHP          = '/usr/local/bin/php';
     15        const SVN_URL = 'https://plugins.svn.wordpress.org/';
     16        const PHP     = '/usr/local/bin/php';
    1717
    1818        /**
     
    7777                                wp_schedule_single_event( time() + 30, 'plugin_directory_check_cronjobs' );
    7878
    79                                 throw new Exception( "Could not fetch plugins.svn logs: " . implode( ', ', $logs['errors'] ) );
     79                                throw new Exception( 'Could not fetch plugins.svn logs: ' . implode( ', ', $logs['errors'] ) );
    8080                        } else {
    8181                                // If the job fails again within the next minute, throw an exception (as above)
     
    104104                        if ( ! isset( $plugins[ $plugin_slug ] ) ) {
    105105                                $plugins[ $plugin_slug ] = array(
    106                                         'tags_touched' => array(), // trunk is a tag too!
     106                                        'tags_touched'   => array(), // trunk is a tag too!
    107107                                        'readme_touched' => false, // minor optimization, only parse readme i18n on readme-related commits
    108                                         'code_touched' => false,
     108                                        'code_touched'   => false,
    109109                                        'assets_touched' => false,
    110                                         'revisions' => array(),
     110                                        'revisions'      => array(),
    111111                                );
    112112                        }
     
    116116                        $plugin['revisions'][] = $log['revision'];
    117117                        foreach ( $log['paths'] as $path ) {
    118                                 $path_parts = explode('/', trim( $path, '/' ) );
     118                                $path_parts = explode( '/', trim( $path, '/' ) );
    119119
    120120                                if ( ! isset( $path_parts[1] ) ) {
     
    140140                                        $plugin['code_touched'] = true;
    141141                                }
    142 
    143142                        }
    144143                        $plugin['tags_touched'] = array_unique( $plugin['tags_touched'] );
     
    168167                        wp_schedule_single_event( time() + 30, 'plugin_directory_check_cronjobs' );
    169168
    170                         throw new Exception( "Unable to determine HEAD revision" );
     169                        throw new Exception( 'Unable to determine HEAD revision' );
    171170                }
    172171                return array_keys( $log['log'] )[0];
     
    182181        protected function get_option( $option_name ) {
    183182                global $wpdb;
     183
    184184                return maybe_unserialize( $wpdb->get_var( $wpdb->prepare(
    185185                        "SELECT option_value FROM $wpdb->options WHERE option_name = %s",
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-code-import.php

    r5446 r6287  
    3030                }
    3131
    32                 $tmp_directory = Filesystem::temp_directory( $this->plugin . '-code-' . $tag );
     32                $tmp_directory    = Filesystem::temp_directory( $this->plugin . '-code-' . $tag );
    3333                $export_directory = $tmp_directory . '/export';
    3434
     
    4848
    4949                $pot_file = "{$tmp_directory}/{$this->plugin}-code.pot";
    50                 $makepot  = new \MakePOT;
     50                $makepot  = new \MakePOT();
    5151
    5252                if ( ! $makepot->wp_plugin( $export_directory, $pot_file, $this->plugin ) || ! file_exists( $pot_file ) ) {
     
    8181                // Whether plugin files should be checked for valid text domains.
    8282                if ( empty( $readme->requires ) || version_compare( $readme->requires, '4.6', '<' ) ) {
    83                         $error  = new WP_Error();
     83                        $error                = new WP_Error();
    8484                        $esc_export_directory = escapeshellarg( $export_directory );
    8585
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-i18n-import.php

    r5488 r6287  
    7676
    7777                $return_code = 0;
    78                 $output = [];
     78                $output      = [];
    7979                exec( $cmd, $output, $return_code );
    8080                $last_line = array_pop( $output );
     
    104104                                        $return = new WP_Error( 'create-failure', 'An undefined error occurred while creating the main GlotPress project.' );
    105105                                        break;
    106                                 default :
     106                                default:
    107107                                        $return = new WP_Error( 'undefined', 'An undefined error occurred while setting the GlotPress projects.' );
    108108                        }
     
    118118         * @param string $branch        GP project branch to import to (dev|stable)
    119119         * @param string $file          Path to POT file
    120          * @param array $str_priorities GP string priorities
     120         * @param array  $str_priorities GP string priorities
    121121         */
    122122        public function import_pot_to_glotpress_project( $project, $branch, $file, $str_priorities = array() ) {
     
    172172                        // Fix some locales.
    173173                        switch ( $language ) {
    174                                 case 'ga_IR' :
     174                                case 'ga_IR':
    175175                                        $language = 'ga';
    176176                                        break;
    177                                 case 'ca_ES' :
     177                                case 'ca_ES':
    178178                                        $language = 'ca';
    179179                                        break;
    180                                 case 'el_GR' :
     180                                case 'el_GR':
    181181                                        $language = 'el';
    182182                                        break;
    183                                 case 'af_ZA' :
     183                                case 'af_ZA':
    184184                                        $language = 'af';
    185185                                        break;
    186                                 case 'zh_cn' :
    187                                 case 'zh_ZH' :
     186                                case 'zh_cn':
     187                                case 'zh_ZH':
    188188                                        $language = 'zh_CN';
    189189                                        break;
    190                                 case 'uk_UA' :
     190                                case 'uk_UA':
    191191                                        $language = 'uk';
    192192                                        break;
    193                                 case 'sq_AL' :
     193                                case 'sq_AL':
    194194                                        $language = 'sq';
    195195                                        break;
    196                                 case 'ga_IE' :
     196                                case 'ga_IE':
    197197                                        $language = 'ga';
    198198                                        break;
    199                                 case 'gu_IN' :
     199                                case 'gu_IN':
    200200                                        $language = 'gu';
    201201                                        break;
    202                                 case 'hy_AM' :
     202                                case 'hy_AM':
    203203                                        $language = 'hy';
    204204                                        break;
    205                                 case 'eo_EO' :
     205                                case 'eo_EO':
    206206                                        $language = 'eo';
    207207                                        break;
    208                                 case 'ar_AR' :
     208                                case 'ar_AR':
    209209                                        $language = 'ar';
    210210                                        break;
    211                                 case 'hr_HR' :
     211                                case 'hr_HR':
    212212                                        $language = 'hr';
    213213                                        break;
    214                                 case 'cs_CS' :
     214                                case 'cs_CS':
    215215                                        $language = 'cs_CZ';
    216216                                        break;
    217                                 case 'vi_VN' :
     217                                case 'vi_VN':
    218218                                        $language = 'vi';
    219219                                        break;
    220                                 case 'ja_JP' :
     220                                case 'ja_JP':
    221221                                        $language = 'ja';
    222222                                        break;
    223                                 case 'tr' :
     223                                case 'tr':
    224224                                        $language = 'tr_TR';
    225225                                        break;
    226                                 case 'be_BY' :
    227                                 case 'be' :
     226                                case 'be_BY':
     227                                case 'be':
    228228                                        $language = 'bel';
    229229                                        break;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-readme-import.php

    r5485 r6287  
    4545
    4646                $readme_file = "{$svn_url}{$readme_file}";
    47                 $readme = new Parser( $readme_file );
     47                $readme      = new Parser( $readme_file );
    4848
    4949                if ( ! class_exists( '\PO' ) ) {
     
    5151                }
    5252
    53                 $pot = new PO;
     53                $pot = new PO();
    5454                $pot->set_header( 'MIME-Version', '1.0' );
    5555                $pot->set_header( 'Content-Type', 'text/plain; charset=UTF-8' );
     
    129129
    130130                $tmp_directory = Filesystem::temp_directory( $this->plugin . '-readme-' . $tag );
    131                 $pot_file = "{$tmp_directory}/{$this->plugin}-readme.pot";
     131                $pot_file      = "{$tmp_directory}/{$this->plugin}-readme.pot";
    132132
    133133                $exported = $pot->export_to_file( $pot_file );
     
    148148         * Handles GlotPress "extracted comments" for translators to get context for each string translations.
    149149         *
    150          * @param array $array Empty or existing arrays of string and comments
     150         * @param array  $array Empty or existing arrays of string and comments
    151151         * @param string $key Unique key
    152152         * @param string $val Comment value
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/clients/class-slack.php

    r5446 r6287  
    3636         */
    3737        private $success_emoji = [
    38                 ':green_heart:', ':white_check_mark:', ':smiley:', ':ok: ',
     38                ':green_heart:',
     39                ':white_check_mark:',
     40                ':smiley:',
     41                ':ok: ',
    3942        ];
    4043
     
    4548         */
    4649        private $failure_emoji = [
    47                 ':broken_heart:', ':umbrella_with_rain_drops:', ':cry:', ':sos:',
     50                ':broken_heart:',
     51                ':umbrella_with_rain_drops:',
     52                ':cry:',
     53                ':sos:',
    4854        ];
    4955
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-api-update-updater.php

    r6195 r6287  
    5858
    5959                if ( ! $post || ! in_array( $post->post_status, array( 'publish', 'disabled', 'closed' ) ) ) {
    60                         $wpdb->delete(  $wpdb->prefix . 'update_source', compact( 'plugin_slug' ) );
     60                        $wpdb->delete( $wpdb->prefix . 'update_source', compact( 'plugin_slug' ) );
    6161                        return true;
    6262                }
    6363
    64                 $data = array(
     64                $data           = array(
    6565                        'plugin_id'       => $post->ID,
    6666                        'plugin_slug'     => $post->post_name,
     
    102102
    103103                        foreach ( $locales as $locale ) {
    104                                 $cache_key = "plugin_information:"
     104                                $cache_key = 'plugin_information:'
    105105                                        . ( strlen( $plugin_slug ) > 200 ? 'md5:' . md5( $plugin_slug ) : $plugin_slug )
    106106                                        . ":{$locale}";
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php

    r5453 r6287  
    1818
    1919                // The actual cron hooks.
    20                 add_action( 'plugin_directory_meta_sync',        array( __NAMESPACE__ . '\Meta_Sync', 'cron_trigger' ) );
    21                 add_action( 'plugin_directory_svn_sync',         array( __NAMESPACE__ . '\SVN_Watcher', 'cron_trigger' ) );
     20                add_action( 'plugin_directory_meta_sync', array( __NAMESPACE__ . '\Meta_Sync', 'cron_trigger' ) );
     21                add_action( 'plugin_directory_svn_sync', array( __NAMESPACE__ . '\SVN_Watcher', 'cron_trigger' ) );
    2222                add_action( 'plugin_directory_update_api_check', array( __NAMESPACE__ . '\API_Update_Updater', 'cron_trigger' ) );
    2323
    2424                // A cronjob to check cronjobs
    25                 add_action( 'plugin_directory_check_cronjobs',   array( $this, 'register_cron_tasks' ) );
     25                add_action( 'plugin_directory_check_cronjobs', array( $this, 'register_cron_tasks' ) );
    2626
    2727                // Register the wildcard cron hook tasks.
     
    3636         */
    3737        public function register_schedules( $schedules ) {
    38                 $schedules['every_30s'] = array( 'interval' => 30, 'display' => 'Every 30 seconds' );
    39                 $schedules['every_120s'] = array( 'interval' => 120, 'display' => 'Every 120 seconds' );
     38                $schedules['every_30s']  = array(
     39                        'interval' => 30,
     40                        'display'  => 'Every 30 seconds',
     41                );
     42                $schedules['every_120s'] = array(
     43                        'interval' => 120,
     44                        'display'  => 'Every 120 seconds',
     45                );
    4046
    4147                return $schedules;
     
    121127                                        if ( ! $next_timestamp || $next_timestamp === $timestamp ) {
    122128                                                $events[] = [
    123                                                         'hook'      => $cron_item['_job']->hook,
    124                                                         'args'      => $cron_item['_job']->args,
    125                                                         'nextrun'   => $timestamp,
     129                                                        'hook'    => $cron_item['_job']->hook,
     130                                                        'args'    => $cron_item['_job']->args,
     131                                                        'nextrun' => $timestamp,
    126132                                                ];
    127133                                        }
     
    164170                                        }
    165171
    166                                         $event['_job']->args = $data['args'];
     172                                        $event['_job']->args    = $data['args'];
    167173                                        $event['_job']->nextrun = $data['nextrun'];
    168174                                        $event['_job']->save();
     
    227233         */
    228234        public function register_cron_tasks() {
    229                 if ( ! wp_next_scheduled ( 'plugin_directory_meta_sync' ) ) {
     235                if ( ! wp_next_scheduled( 'plugin_directory_meta_sync' ) ) {
    230236                        wp_schedule_event( time() + 60, 'hourly', 'plugin_directory_meta_sync' );
    231237                }
    232                 if ( ! wp_next_scheduled ( 'plugin_directory_svn_sync' ) ) {
     238                if ( ! wp_next_scheduled( 'plugin_directory_svn_sync' ) ) {
    233239                        wp_schedule_event( time() + 60, 'every_30s', 'plugin_directory_svn_sync' );
    234240                }
    235                 if ( ! wp_next_scheduled ( 'plugin_directory_update_api_check' ) ) {
     241                if ( ! wp_next_scheduled( 'plugin_directory_update_api_check' ) ) {
    236242                        wp_schedule_event( time() + 60, 'hourly', 'plugin_directory_update_api_check' );
    237243                }
    238                 if ( ! wp_next_scheduled ( 'plugin_directory_check_cronjobs' ) ) {
     244                if ( ! wp_next_scheduled( 'plugin_directory_check_cronjobs' ) ) {
    239245                        wp_schedule_event( time() + 60, 'every_120s', 'plugin_directory_check_cronjobs' );
    240246                }
     
    257263                );
    258264
    259                 foreach ( $cron_array as $timestamp => $handlers ) {
    260                         if ( ! is_numeric( $timestamp ) ) {
    261                                 continue;
    262                         }
    263                         foreach ( $handlers as $hook => $jobs ) {
    264                                 $pos = strpos( $hook, ':' );
    265                                 if ( ! $pos ) {
     265                if ( is_array( $cron_array ) ) {
     266                        foreach ( $cron_array as $timestamp => $handlers ) {
     267                                if ( ! is_numeric( $timestamp ) ) {
    266268                                        continue;
    267269                                }
    268270
    269                                 $partial_hook = substr( $hook, 0, $pos );
    270 
    271                                 if ( isset( $wildcard_cron_tasks[ $partial_hook ] ) ) {
    272                                         add_action( $hook, $wildcard_cron_tasks[ $partial_hook ], 10, PHP_INT_MAX );
     271                                foreach ( $handlers as $hook => $jobs ) {
     272                                        $pos = strpos( $hook, ':' );
     273                                        if ( ! $pos ) {
     274                                                continue;
     275                                        }
     276
     277                                        $partial_hook = substr( $hook, 0, $pos );
     278
     279                                        if ( isset( $wildcard_cron_tasks[ $partial_hook ] ) ) {
     280                                                add_action( $hook, $wildcard_cron_tasks[ $partial_hook ], 10, PHP_INT_MAX );
     281                                        }
    273282                                }
    274283                        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-meta-sync.php

    r5449 r6287  
    1515         */
    1616        public static function cron_trigger() {
    17                 $class = new Meta_Sync;
     17                $class = new Meta_Sync();
    1818                $class->sync();
    1919        }
     
    6262
    6363                // Sync new (and updated) ratings to postmeta
    64                 $last_review_time = get_option( 'plugin_last_review_sync' );
    65                 $current_review_time = $wpdb->get_var( "SELECT MAX(`date`) FROM `ratings`" );
     64                $last_review_time    = get_option( 'plugin_last_review_sync' );
     65                $current_review_time = $wpdb->get_var( 'SELECT MAX(`date`) FROM `ratings`' );
    6666
    6767                if ( strtotime( $last_review_time ) >= strtotime( $current_review_time ) ) {
     
    7070
    7171                // Get the plugin slugs for whom extra reviews have been made, or ratings changed.
    72                 $slugs = $wpdb->get_col( $sql = $wpdb->prepare(
     72                $slugs = $wpdb->get_col( $wpdb->prepare(
    7373                        "SELECT distinct object_slug FROM `ratings` WHERE object_type = 'plugin' AND `date` >= %s AND `date` < %s",
    7474                        $last_review_time,
     
    107107                }
    108108
    109                 $equivs = wporg_get_version_equivalents();
     109                $equivs     = wporg_get_version_equivalents();
    110110                $equivs_key = md5( serialize( $equivs ) );
    111111                if ( $equivs_key === get_option( 'plugin_last_tested_sync' ) ) {
     
    121121
    122122                $tested_meta_value_esc_sql = '"' . implode( '", "', array_map( 'esc_sql', array_keys( $latest_equiv ) ) ) . '"';
    123                 $tested_values = $wpdb->get_results( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'tested' AND meta_value IN( {$tested_meta_value_esc_sql} )" );
     123                $tested_values             = $wpdb->get_results( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'tested' AND meta_value IN( {$tested_meta_value_esc_sql} )" );
    124124
    125125                foreach ( $tested_values as $row ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-plugin-i18n-import.php

    r5488 r6287  
    1717         */
    1818        public static function queue( $plugin_slug, $plugin_data ) {
    19                 $when_to_run = time() + 15 * MINUTE_IN_SECONDS;
     19                $when_to_run    = time() + 15 * MINUTE_IN_SECONDS;
    2020                $next_scheduled = Manager::get_scheduled_time( "import_plugin_i18n:{$plugin_slug}", 'last' );
    2121
    2222                // Update a scheduled event if it doesn't run in the next minute.
    2323                if ( $next_scheduled && $next_scheduled > time() + 1 * MINUTE_IN_SECONDS ) {
    24                         $next_scheduled_events = Manager::get_scheduled_events( "import_plugin_i18n:{$plugin_slug}",$next_scheduled );
     24                        $next_scheduled_events = Manager::get_scheduled_events( "import_plugin_i18n:{$plugin_slug}", $next_scheduled );
    2525                        if ( $next_scheduled_events ) {
    2626                                $next_scheduled_event = array_shift( $next_scheduled_events );
     
    5959                        "import_plugin_i18n:{$plugin_slug}",
    6060                        array(
    61                                 array_merge( array( 'plugin' => $plugin_slug ), $plugin_data )
     61                                array_merge( array( 'plugin' => $plugin_slug ), $plugin_data ),
    6262                        )
    6363                );
     
    9999         *
    100100         * @param string $plugin_slug
    101          * @param array $i18n_processes
     101         * @param array  $i18n_processes
    102102         */
    103103        public static function process_i18n_for_plugin( $plugin_slug, $i18n_processes ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-plugin-import.php

    r5453 r6287  
    2323                        "import_plugin:{$plugin_slug}",
    2424                        array(
    25                                 array_merge( array( 'plugin' => $plugin_slug ), $plugin_data )
     25                                array_merge( array( 'plugin' => $plugin_slug ), $plugin_data ),
    2626                        )
    2727                );
     
    3535                $changed_tags = isset( $plugin_data['tags_touched'] ) ? $plugin_data['tags_touched'] : array( 'trunk' );
    3636
    37                 $revision = isset( $plugin_data['revisions'] ) ? max( (array)$plugin_data['revisions'] ) : false;
     37                $revision = isset( $plugin_data['revisions'] ) ? max( (array) $plugin_data['revisions'] ) : false;
    3838
    3939                try {
    40                         $importer = new CLI\Import;
     40                        $importer = new CLI\Import();
    4141                        $importer->import_from_svn( $plugin_slug, $changed_tags, $revision );
    42                 } catch( Exception $e ) {
     42                } catch ( Exception $e ) {
    4343                        fwrite( STDERR, "[{$plugin_slug}] Plugin Import Failed: " . $e->getMessage() . "\n" );
    4444                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/class.jetpack-searchresult-posts-iterator.php

    r2934 r6287  
    88
    99/**
    10  * Provide a custom Iterator for seamlessly switching to the appropriate blog and inflating posts for 
     10 * Provide a custom Iterator for seamlessly switching to the appropriate blog and inflating posts for
    1111 * search results that may or many not live on other sites.
    1212 *
     
    1919        /**
    2020         * The ES search result to retrieve posts for
    21          * 
     21         *
    2222         * @var array
    2323         */
     
    2626        /**
    2727         * An array of inflated posts represented in the $search_result
    28          * 
     28         *
    2929         * @var array
    3030         */
     
    3333        /**
    3434         * The current offset
    35          * 
     35         *
    3636         * @var int
    3737         */
     
    4040        /**
    4141         * Retrieve the ES search result
    42          * 
     42         *
    4343         * @return array The ES search result
    4444         */
     
    4949        /**
    5050         * Set the ES search result
    51          * 
     51         *
    5252         * @param array $search_result The ES search result to associate with this iterator
    5353         */
     
    6060        /**
    6161         * Retrieve a post from the database by id, and conditionally switch to the appropriate blog, if needed
    62          * 
    63          * @param  array        $es_result The individual hit in an ES search result to inflate a post for
    64          * @return WP_Post      The inflated WP_Post object, or null if not found
     62         *
     63         * @param  array $es_result The individual hit in an ES search result to inflate a post for
     64         * @return WP_Post  The inflated WP_Post object, or null if not found
    6565         */
    6666        protected function inflate_post( $es_result ) {
    6767
    68                 #$post = get_blog_post( $es_result['fields']['blog_id'], $es_result['fields']['post_id'] );
    69 
    70                 //TODO: is this a good thing to kill?
    71                 //if ( isset( $es_result['fields']['blog_id'] ) && get_current_blog_id() !== $es_result['fields']['blog_id'] )
    72                 //      switch_to_blog( $es_result['fields']['blog_id'] );
    73 
     68                // $post = get_blog_post( $es_result['fields']['blog_id'], $es_result['fields']['post_id'] );
     69                // TODO: is this a good thing to kill?
     70                // if ( isset( $es_result['fields']['blog_id'] ) && get_current_blog_id() !== $es_result['fields']['blog_id'] )
     71                // switch_to_blog( $es_result['fields']['blog_id'] );
    7472                $post = get_post( $es_result['fields']['post_id'] );
    7573
     
    7876
    7977        // Implement SeekableIterator
    80        
    8178        public function seek( $position ) {
    8279                $this->pointer = $position;
    8380        }
    8481
    85         public function current () {
     82        public function current() {
    8683                return $this->pointer;
    8784        }
    8885
    89         public function key () {
     86        public function key() {
    9087                return $this->pointer;
    9188        }
     
    104101
    105102        // Implement Countable
    106        
    107103        public function count() {
    108104                return count( $this->search_result['results']['hits'] );
     
    110106
    111107        // Implement ArrayAccess
    112        
    113108        public function offsetExists( $index ) {
    114109                return isset( $this->search_result['results']['hits'][ $index ] );
     
    116111
    117112        public function offsetGet( $index ) {
    118                 if ( ! $this->offsetExists( $index ) )
     113                if ( ! $this->offsetExists( $index ) ) {
    119114                        return null;
     115                }
    120116
    121117                // Lazy load the post
    122                 if ( ! isset( $this->posts[ $index ] ) )
     118                if ( ! isset( $this->posts[ $index ] ) ) {
    123119                        $this->posts[ $index ] = $this->inflate_post( $this->search_result['results']['hits'][ $index ] );
     120                }
    124121
    125122                return $this->posts[ $index ];
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search-debug.php

    r4456 r6287  
    11<?php
    22
    3 add_filter('debug_bar_panels', function($panels) {
     3add_filter( 'debug_bar_panels', function( $panels ) {
    44        class Debug_Bar_Search extends Debug_Bar_Panel {
    55                function init() {
    6                         $this->title( __('Search', 'debug-bar') );
     6                        $this->title( __( 'Search', 'debug-bar' ) );
    77                }
    88
     
    1212
    1313                function render() {
    14 
    1514                        $search = Jetpack_Search::instance();
    1615
    1716                        echo "<div id='debug-bar-jetpack-search'>";
    18 
    1917
    2018                        echo '<h3>', __( 'Elasticsearch Query:', 'debug-bar' ), '</h3>';
     
    3028        $panels[] = new Debug_Bar_Search();
    3129        return $panels;
    32 });
     30} );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php

    r6197 r6287  
    5050 */
    5151
    52 require_once( __DIR__ . '/class.jetpack-searchresult-posts-iterator.php' );
     52require_once __DIR__ . '/class.jetpack-searchresult-posts-iterator.php';
    5353
    5454class Jetpack_Search {
     
    6767        protected static $instance;
    6868
    69         //Languages with custom analyzers, other languages are supported,
     69        // Languages with custom analyzers, other languages are supported,
    7070        // but are analyzed with the default analyzer.
    7171        public static $analyzed_langs = array( 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'eu', 'fa', 'fi', 'fr', 'he', 'hi', 'hu', 'hy', 'id', 'it', 'ja', 'ko', 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' );
    7272
    73         const CACHE_GROUP = 'jetpack-search';
    74         const CACHE_EXPIRY = 300;
    75         const ERROR_COUNT_KEY = 'error-count-';
     73        const CACHE_GROUP        = 'jetpack-search';
     74        const CACHE_EXPIRY       = 300;
     75        const ERROR_COUNT_KEY    = 'error-count-';
    7676        const ERROR_COUNT_WINDOW = 60; // seconds
    7777
     
    8080        }
    8181
    82         public function __clone() { wp_die( "Please don't __clone WPCOM_elasticsearch" ); }
    83 
    84         public function __wakeup() { wp_die( "Please don't __wakeup WPCOM_elasticsearch" ); }
     82        public function __clone() {
     83                wp_die( "Please don't __clone WPCOM_elasticsearch" ); }
     84
     85        public function __wakeup() {
     86                wp_die( "Please don't __wakeup WPCOM_elasticsearch" ); }
    8587
    8688        public static function instance() {
    8789                if ( ! isset( self::$instance ) ) {
    88                         self::$instance = new Jetpack_Search;
     90                        self::$instance = new Jetpack_Search();
    8991                        self::$instance->setup();
    9092                }
     
    9395
    9496        public function setup() {
    95                 //TODO: only enable if this site is public (otherwise we don't have content)
    96                 //TODO: check that the module is activated
    97 
     97                // TODO: only enable if this site is public (otherwise we don't have content)
     98                // TODO: check that the module is activated
    9899                $this->jetpack_blog_id = Jetpack::get_option( 'id' );
    99100
     
    105106        public function set_lang( $lang = false ) {
    106107                if ( ! $lang ) {
    107                         //TODO: don't think this works for Jetpack
     108                        // TODO: don't think this works for Jetpack
    108109                        $blog = get_blog_details( $blog_id );
    109110                        $lang = get_lang_code_by_id( $blog->lang_id );
     
    112113        }
    113114
    114         /////////////////////////////////////////////////////
     115        //
    115116        // Lots of hooks
    116 
    117117        public function init_hooks() {
    118118                // Checks to see if we need to worry about found_posts
    119119                add_filter( 'post_limits_request', array( $this, 'filter__post_limits_request' ), 999, 2 );
    120120
    121                 # Note: Advanced Post Cache hooks in at 10 so it's important to hook in before that
    122 
     121                // Note: Advanced Post Cache hooks in at 10 so it's important to hook in before that
    123122                // Force $q['cache_results'] = false; this prevents the un-inflated WP_Post objects from being stored in cache
    124123                add_action( 'pre_get_posts', array( $this, 'action__pre_get_posts' ), 5 );
     
    142141
    143142                // Debug
    144                 if ( file_exists( __DIR__ . '/jetpack-search-debug.php' ) )
    145                         include_once( __DIR__ . '/jetpack-search-debug.php' );
     143                if ( file_exists( __DIR__ . '/jetpack-search-debug.php' ) ) {
     144                        include_once __DIR__ . '/jetpack-search-debug.php';
     145                }
    146146        }
    147147
     
    152152         */
    153153        public function register_loop_hooks() {
    154                 add_action( 'loop_start',       array( $this, 'action__loop_start' ) );
    155                 add_action( 'loop_end',         array( $this, 'action__loop_end' ) );
     154                add_action( 'loop_start', array( $this, 'action__loop_start' ) );
     155                add_action( 'loop_end', array( $this, 'action__loop_end' ) );
    156156        }
    157157
     
    162162         */
    163163        public function unregister_loop_hooks() {
    164                 remove_action( 'the_post',              array( $this, 'action__the_post' ) );
    165                 remove_action( 'loop_end',              array( $this, 'action__loop_end' ) );
    166         }
    167 
    168 
    169         /////////////////////////////////////////////////////////
     164                remove_action( 'the_post', array( $this, 'action__the_post' ) );
     165                remove_action( 'loop_end', array( $this, 'action__loop_end' ) );
     166        }
     167
     168
     169        //
    170170        // Raw Search Query
    171 
    172         /*
     171        /*
    173172         * Return a count of the number of search API errors within the last ERROR_COUNT_WINDOW seconds
    174173         */
    175174        protected function get_error_volume() {
    176175                // Use a dual-tick window like nonces
    177                 $tick = ceil( time() / (self::ERROR_COUNT_WINDOW/2) );
    178 
    179                 return intval( wp_cache_get( self::ERROR_COUNT_KEY . $tick, self::CACHE_GROUP ) ) 
    180                          + intval( wp_cache_get( self::ERROR_COUNT_KEY . ($tick -1), self::CACHE_GROUP ) );
    181         }
    182 
    183         /* 
     176                $tick = ceil( time() / ( self::ERROR_COUNT_WINDOW / 2 ) );
     177
     178                return intval( wp_cache_get( self::ERROR_COUNT_KEY . $tick, self::CACHE_GROUP ) )
     179                         + intval( wp_cache_get( self::ERROR_COUNT_KEY . ( $tick - 1 ), self::CACHE_GROUP ) );
     180        }
     181
     182        /*
    184183         *      Increment the recent error volume by $count.
    185184         */
    186185        protected function increment_error_volume( $count = 1 ) {
    187186                // wp_cache_incr() bails if the key does not exist
    188                 $tick = ceil( time() / (self::ERROR_COUNT_WINDOW/2) );
     187                $tick = ceil( time() / ( self::ERROR_COUNT_WINDOW / 2 ) );
    189188                wp_cache_add( self::ERROR_COUNT_KEY . $tick, 0, self::CACHE_GROUP, self::ERROR_COUNT_WINDOW );
    190189                return wp_cache_incr( self::ERROR_COUNT_KEY . $tick, $count, self::CACHE_GROUP );
     
    204203                // For 20 errors, a 50% chance
    205204                // For 40+ errors, a 0% chance
    206 
    207205                $threshold = ceil( 10 / ( 1 + pow( $error_volume / 20, 4 ) ) );
    208206                return mt_rand( 1, 10 ) <= $threshold;
     
    213211         */
    214212        protected function search_error( $reason ) {
    215                 trigger_error( 'Plugin directory search: '.$reason, E_USER_WARNING );
     213                trigger_error( 'Plugin directory search: ' . $reason, E_USER_WARNING );
    216214                return $this->increment_error_volume();
    217215        }
     
    224222         */
    225223        public function search( $es_args ) {
    226                 $service_url = 'https://public-api.wordpress.com/rest/v1/sites/' . $this->jetpack_blog_id . '/search';
     224                $service_url  = 'https://public-api.wordpress.com/rest/v1/sites/' . $this->jetpack_blog_id . '/search';
    227225                $json_es_args = json_encode( $es_args );
    228                 $cache_key = md5( $json_es_args );
    229                 $lock_key = 'lock-'.$cache_key;
    230                
     226                $cache_key    = md5( $json_es_args );
     227                $lock_key     = 'lock-' . $cache_key;
     228
    231229                $response = wp_cache_get( $cache_key, self::CACHE_GROUP );
    232230
     
    238236                        if ( $this->error_volume_is_low() ) {
    239237                                $request = wp_remote_post( $service_url, array(
    240                                         'headers' => array(
     238                                        'headers'    => array(
    241239                                                'Content-Type' => 'application/json',
    242240                                        ),
    243                                         'timeout' => 10,
     241                                        'timeout'    => 10,
    244242                                        'user-agent' => 'WordPress.org/jetpack_search',
    245                                         'body' => $json_es_args,
     243                                        'body'       => $json_es_args,
    246244                                ) );
    247245                        } else {
     
    258256                                wp_cache_set( $lock_key, 1, self::CACHE_GROUP, mt_rand( 3, 7 ) );
    259257
    260                                 if ( is_wp_error( $request ) )
    261                                         $this->search_error( 'http error '.$request->get_error_message(), E_USER_WARNING );
    262                                 else
    263                                         $this->search_error( 'http status '.wp_remote_retrieve_response_code( $request ), E_USER_WARNING );
     258                                if ( is_wp_error( $request ) ) {
     259                                        $this->search_error( 'http error ' . $request->get_error_message(), E_USER_WARNING );
     260                                } else {
     261                                        $this->search_error( 'http status ' . wp_remote_retrieve_response_code( $request ), E_USER_WARNING );
     262                                }
    264263
    265264                                // If we have a stale cached response, return that. Otherwise, return the error object.
    266                                 if ( $response )
     265                                if ( $response ) {
    267266                                        return $response; // Stale cached response.
     267                                }
    268268                                return $request; // Fresh error object.
    269269                        }
     
    271271                        $fresh_response = json_decode( wp_remote_retrieve_body( $request ), true );
    272272
    273                         if ( !$fresh_response || isset( $fresh_response['error'] ) ) {
     273                        if ( ! $fresh_response || isset( $fresh_response['error'] ) ) {
    274274                                // As above, lock further requests for the same search for a few seconds
    275275                                wp_cache_set( $lock_key, 1, self::CACHE_GROUP, mt_rand( 3, 7 ) );
    276276
    277                                 if ( isset( $fresh_response['error'] ) )
    278                                         $this->search_error( 'remote error '.$fresh_response['error'], E_USER_WARNING );
    279                                 else
     277                                if ( isset( $fresh_response['error'] ) ) {
     278                                        $this->search_error( 'remote error ' . $fresh_response['error'], E_USER_WARNING );
     279                                } else {
    280280                                        $this->search_error( 'invalid json response', E_USER_WARNING );
     281                                }
    281282
    282283                                // Return a stale response if we have one
    283                                 if ( $response )
     284                                if ( $response ) {
    284285                                        return $response;
     286                                }
    285287                                return $fresh_response; // Fresh error object as a last resort
    286288
     
    294296                } else {
    295297                        // Stampede protection has kicked in, AND we have no stale cached value to display. That's bad - possibly indicates cache exhaustion
    296                         if ( false === $response )
     298                        if ( false === $response ) {
    297299                                trigger_error( 'Plugin directory search: no cached results available during stampede.', E_USER_WARNING );
     300                        }
    298301                }
    299302
     
    301304        }
    302305
    303         //TODO: add secured search for posts/comments
    304 
    305         /////////////////////////////////////////////////////////
     306        // TODO: add secured search for posts/comments
     307        //
    306308        // Insert the ES results into the Loop when searching
    307309        //
    308 
    309310        public function filter__post_limits_request( $limits, $query ) {
    310                 if ( ! $query->is_search() )
     311                if ( ! $query->is_search() ) {
    311312                        return $limits;
     313                }
    312314
    313315                if ( empty( $limits ) || $query->get( 'no_found_rows' ) ) {
     
    321323
    322324        public function filter__the_posts( $posts, $query ) {
    323                 if ( ! $query->is_main_query() || ! $query->is_search() )
     325                if ( ! $query->is_main_query() || ! $query->is_search() ) {
    324326                        return $posts;
     327                }
    325328
    326329                if ( ! is_array( $this->search_result ) || ! isset( $this->search_result['results'] ) ) {
     
    340343                        $post = new stdClass();
    341344
    342                         $post->ID               = $result['fields']['post_id'];
    343                         $post->blog_id  = $result['fields']['blog_id'];
     345                        $post->ID      = $result['fields']['post_id'];
     346                        $post->blog_id = $result['fields']['blog_id'];
    344347
    345348                        // Run through get_post() to add all expected properties (even if they're empty)
    346349                        $post = get_post( $post );
    347350
    348                         if ( $post )
     351                        if ( $post ) {
    349352                                $posts[] = $post;
     353                        }
    350354                }
    351355
     
    359363                global $wpdb;
    360364
    361                 if ( ! $query->is_main_query() || ! $query->is_search() )
     365                if ( ! $query->is_main_query() || ! $query->is_search() ) {
    362366                        return $sql;
    363 
    364                 $page = ( $query->get( 'paged' ) ) ? absint( $query->get( 'paged' ) ) : 1;
     367                }
     368
     369                $page           = ( $query->get( 'paged' ) ) ? absint( $query->get( 'paged' ) ) : 1;
    365370                $posts_per_page = $query->get( 'posts_per_page' );
    366371
    367372                // ES API does not allow more than 15 results at a time
    368                 if ( $posts_per_page > 200 )
     373                if ( $posts_per_page > 200 ) {
    369374                        $posts_per_page = 200;
     375                }
    370376
    371377                // ES API does not allow fetching past the 10,000th post
    372378                $page = min( $page, floor( 9999 / $posts_per_page ) );
    373379
    374                 $date_cutoff = strftime( '%Y-%m-%d', strtotime( '-8 years' ) );
    375                 $date_today = strftime( '%Y-%m-%d' );
    376                 $version_cutoff = ( defined('WP_CORE_STABLE_BRANCH') ? sprintf( '%0.1f', WP_CORE_STABLE_BRANCH - 0.5) : '4.0' );
     380                $date_cutoff    = strftime( '%Y-%m-%d', strtotime( '-8 years' ) );
     381                $date_today     = strftime( '%Y-%m-%d' );
     382                $version_cutoff = ( defined( 'WP_CORE_STABLE_BRANCH' ) ? sprintf( '%0.1f', WP_CORE_STABLE_BRANCH - 0.5 ) : '4.0' );
    377383
    378384                // Start building the WP-style search query args
     
    385391                        'order'          => $query->get( 'order' ),
    386392                        // plugin directory specific:
    387                         #'date_range'    =>  array( 'field' => 'modified', 'gte' => $date_cutoff ),
    388                         #'tested_range' =>  array( 'field' => 'tested', 'gte' => $version_cutoff ),
    389                         'filters'                => array(
     393                        // 'date_range'    =>  array( 'field' => 'modified', 'gte' => $date_cutoff ),
     394                        // 'tested_range' =>  array( 'field' => 'tested', 'gte' => $version_cutoff ),
     395                        'filters'        => array(
    390396                                array( 'term' => array( 'disabled' => array( 'value' => false ) ) ),
    391397                        ),
     
    400406
    401407                $es_wp_query_args['locale'] = get_locale();
    402                
     408
    403409                // You can use this filter to modify the search query parameters, such as controlling the post_type.
    404410                // These arguments are in the format for convert_wp_es_to_es_args(), i.e. WP-style.
     
    408414                $es_query_args = $this->convert_wp_es_to_es_args( $es_wp_query_args );
    409415
    410                 //Only trust ES to give us IDs, not the content since it is a mirror
     416                // Only trust ES to give us IDs, not the content since it is a mirror
    411417                $es_query_args['fields'] = array(
    412418                        'slug',
     
    422428                        'plugin_modified',
    423429                        'post_id',
    424                         'blog_id'
     430                        'blog_id',
    425431                );
    426432
    427433                // This filter is harder to use if you're unfamiliar with ES but it allows complete control over the query
    428                 $es_query_args = apply_filters( 'jetpack_search_es_query_args', $es_query_args, $query );
     434                $es_query_args      = apply_filters( 'jetpack_search_es_query_args', $es_query_args, $query );
    429435                $this->search_query = $es_query_args;
    430436
     
    447453
    448454        public function filter__found_posts_query( $sql, $query ) {
    449                 if ( ! $query->is_main_query() || ! $query->is_search() )
     455                if ( ! $query->is_main_query() || ! $query->is_search() ) {
    450456                        return $sql;
     457                }
    451458
    452459                return '';
     
    454461
    455462        public function filter__found_posts( $found_posts, $query ) {
    456                 if ( ! $query->is_main_query() || ! $query->is_search() )
     463                if ( ! $query->is_main_query() || ! $query->is_search() ) {
    457464                        return $found_posts;
     465                }
    458466
    459467                return $this->found_posts;
     
    462470        public function action__pre_get_posts( $query ) {
    463471                // Treat an API request for the recommended tab as a search, even though there is no search string in the query
    464                 if ( defined( 'WPORG_IS_API' ) && WPORG_IS_API && isset( $query->query['browse'] ) && $query->query['browse'] === 'recommended' )
     472                if ( defined( 'WPORG_IS_API' ) && WPORG_IS_API && isset( $query->query['browse'] ) && $query->query['browse'] === 'recommended' ) {
    465473                        $query->is_search = true;
    466 
    467                 if ( ! $query->is_main_query() || ! $query->is_search() )
     474                }
     475
     476                if ( ! $query->is_main_query() || ! $query->is_search() ) {
    468477                        return;
     478                }
    469479
    470480                $query->set( 'cache_results', false );
     
    490500
    491501                // Restore the original blog, if we're not on it
    492                 if ( get_current_blog_id() !== $this->original_blog_id )
     502                if ( get_current_blog_id() !== $this->original_blog_id ) {
    493503                        switch_to_blog( $this->original_blog_id );
     504                }
    494505        }
    495506
     
    499510                $post = $this->get_post_by_index( $wp_query->current_post );
    500511
    501                 if ( ! $post )
     512                if ( ! $post ) {
    502513                        return;
     514                }
    503515
    504516                // Do some additional setup that normally happens in setup_postdata(), but gets skipped
    505517                // in this plugin because the posts hadn't yet been inflated.
    506                 $authordata     = get_userdata( $post->post_author );
    507 
    508                 $currentday     = mysql2date('d.m.y', $post->post_date, false);
    509                 $currentmonth   = mysql2date('m', $post->post_date, false);
    510 
    511                 $numpages = 1;
     518                $authordata = get_userdata( $post->post_author );
     519
     520                $currentday   = mysql2date( 'd.m.y', $post->post_date, false );
     521                $currentmonth = mysql2date( 'm', $post->post_date, false );
     522
     523                $numpages  = 1;
    512524                $multipage = 0;
    513                 $page = get_query_var('page');
    514                 if ( ! $page )
     525                $page      = get_query_var( 'page' );
     526                if ( ! $page ) {
    515527                        $page = 1;
    516                 if ( is_single() || is_page() || is_feed() )
     528                }
     529                if ( is_single() || is_page() || is_feed() ) {
    517530                        $more = 1;
     531                }
    518532                $content = $post->post_content;
    519533                if ( false !== strpos( $content, '<!--nextpage-->' ) ) {
    520                         if ( $page > 1 )
     534                        if ( $page > 1 ) {
    521535                                $more = 1;
     536                        }
    522537                        $content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
    523538                        $content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
    524539                        $content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );
    525540                        // Ignore nextpage at the beginning of the content.
    526                         if ( 0 === strpos( $content, '<!--nextpage-->' ) )
     541                        if ( 0 === strpos( $content, '<!--nextpage-->' ) ) {
    527542                                $content = substr( $content, 15 );
    528                         $pages = explode('<!--nextpage-->', $content);
    529                         $numpages = count($pages);
    530                         if ( $numpages > 1 )
     543                        }
     544                        $pages    = explode( '<!--nextpage-->', $content );
     545                        $numpages = count( $pages );
     546                        if ( $numpages > 1 ) {
    531547                                $multipage = 1;
     548                        }
    532549                } else {
    533550                        $pages = array( $post->post_content );
     
    543560
    544561        public function get_search_result( $raw = false ) {
    545                 if ( $raw )
     562                if ( $raw ) {
    546563                        return $this->search_result;
     564                }
    547565
    548566                return ( ! empty( $this->search_result ) && ! is_wp_error( $this->search_result ) && is_array( $this->search_result ) && ! empty( $this->search_result['results'] ) ) ? $this->search_result['results'] : false;
     
    553571        }
    554572
    555         /////////////////////////////////////////////////
     573        //
    556574        // Standard Filters Applied to the search query
    557575        //
    558 
    559576        public function filter__add_date_filter_to_query( $es_wp_query_args, $query ) {
    560577                if ( $query->get( 'year' ) ) {
     
    580597                        }
    581598
    582                         $es_wp_query_args['date_range'] = array( 'field' => 'date', 'gte' => $date_start, 'lte' => $date_end );
     599                        $es_wp_query_args['date_range'] = array(
     600                                'field' => 'date',
     601                                'gte'   => $date_start,
     602                                'lte'   => $date_end,
     603                        );
    583604                }
    584605
     
    586607        }
    587608
    588         /////////////////////////////////////////////////
     609        //
    589610        // Helpers for manipulating queries
    590611        //
    591 
    592612        // Someday: Should we just use ES_WP_Query???
    593 
    594613        // Converts WP-style args to ES args
    595614        function convert_wp_es_to_es_args( $args ) {
     
    608627
    609628                        'date_range'     => null,    // array( 'field' => 'date', 'gt' => 'YYYY-MM-dd', 'lte' => 'YYYY-MM-dd' ); date formats: 'YYYY-MM-dd' or 'YYYY-MM-dd HH:MM:SS'
    610                         'tested_range'  => null,
    611                         'filters'                => array(),
     629                        'tested_range'  => null,
     630                        'filters'        => array(),
    612631
    613632                        'orderby'        => null,    // Defaults to 'relevance' if query is set, otherwise 'date'. Pass an array for multiple orders.
     
    637656                );
    638657
    639                 //TODO: limit size to 15
    640 
     658                // TODO: limit size to 15
    641659                // ES "from" arg (offset)
    642660                if ( $args['offset'] ) {
     
    646664                }
    647665
    648                 if ( !is_array( $args['author_name'] ) ) {
     666                if ( ! is_array( $args['author_name'] ) ) {
    649667                        $args['author_name'] = array( $args['author_name'] );
    650668                }
     
    652670                // ES stores usernames, not IDs, so transform
    653671                if ( ! empty( $args['author'] ) ) {
    654                         if ( !is_array( $args['author'] ) )
     672                        if ( ! is_array( $args['author'] ) ) {
    655673                                $args['author'] = array( $args['author'] );
     674                        }
    656675                        foreach ( $args['author'] as $author ) {
    657676                                $user = get_user_by( 'id', $author );
     
    663682                }
    664683
    665                 //////////////////////////////////////////////////
     684                //
    666685                // Build the filters from the query elements.
    667686                // Filters rock because they are cached from one query to the next
     
    671690
    672691                if ( $args['post_type'] ) {
    673                         if ( !is_array( $args['post_type'] ) )
     692                        if ( ! is_array( $args['post_type'] ) ) {
    674693                                $args['post_type'] = array( $args['post_type'] );
     694                        }
    675695                        $filters[] = array( 'terms' => array( 'post_type' => $args['post_type'] ) );
    676696                }
     
    680700                }
    681701
    682                 if ( !empty( $args['date_range'] ) && isset( $args['date_range']['field'] ) ) {
     702                if ( ! empty( $args['date_range'] ) && isset( $args['date_range']['field'] ) ) {
    683703                        $field = $args['date_range']['field'];
    684704                        unset( $args['date_range']['field'] );
     
    686706                }
    687707
    688                 if ( !empty( $args['tested_range'] ) && isset( $args['tested_range']['field'] ) ) {
     708                if ( ! empty( $args['tested_range'] ) && isset( $args['tested_range']['field'] ) ) {
    689709                        $field = $args['tested_range']['field'];
    690710                        unset( $args['tested_range']['field'] );
     
    721741                        $locale = $args['locale'];
    722742
    723                         //Because most plugins don't have any translations we need to
     743                        // Because most plugins don't have any translations we need to
    724744                        // correct for the very low scores that locale-specific fields.
    725745                        // end up getting. This is caused by the average field length being
     
    729749                        // As of 2017-01-23 it looked like we were off by about 10,000x,
    730750                        // so rather than 0.1 we use a much smaller multiplier of en content
    731                         $en_boost = 0.00001;
    732                         $matching_fields = array(
     751                        $en_boost             = 0.00001;
     752                        $matching_fields      = array(
    733753                                'all_content_' . $locale,
    734                                 'all_content_en^' . $en_boost
    735                         );
    736                         $boost_phrase_fields = array(
     754                                'all_content_en^' . $en_boost,
     755                        );
     756                        $boost_phrase_fields  = array(
    737757                                'title_' . $locale,
    738758                                'excerpt_' . $locale,
     
    743763                                'taxonomy.plugin_tags.name',
    744764                        );
    745                         $boost_ngram_fields = array(
     765                        $boost_ngram_fields   = array(
    746766                                'title_' . $locale . '.ngram',
    747                                 'title_en.ngram^' . $en_boost
    748                         );
    749                         $boost_title_fields = array(
     767                                'title_en.ngram^' . $en_boost,
     768                        );
     769                        $boost_title_fields   = array(
    750770                                'title_' . $locale,
    751771                                'title_en^' . $en_boost,
     
    760780                        );
    761781                } else {
    762                         $matching_fields = array(
    763                                 'all_content_en'
    764                         );
    765                         $boost_phrase_fields = array(
     782                        $matching_fields      = array(
     783                                'all_content_en',
     784                        );
     785                        $boost_phrase_fields  = array(
    766786                                'title_en',
    767787                                'excerpt_en',
     
    769789                                'taxonomy.plugin_tags.name',
    770790                        );
    771                         $boost_ngram_fields = array(
    772                                 'title_en.ngram'
    773                         );
    774                         $boost_title_fields = array(
     791                        $boost_ngram_fields   = array(
     792                                'title_en.ngram',
     793                        );
     794                        $boost_title_fields   = array(
    775795                                'title_en',
    776796                                'slug_text',
     
    782802                        );
    783803                }
    784                
    785                 ///////////////////////////////////////////////////////////
     804
     805                //
    786806                // Build the query - potentially extracting more filters
    787                 //  TODO: add auto phrase searching
    788                 //  TODO: add fuzzy searching to correct for spelling mistakes
    789                 //  TODO: boost title, tag, and category matches
     807                // TODO: add auto phrase searching
     808                // TODO: add fuzzy searching to correct for spelling mistakes
     809                // TODO: boost title, tag, and category matches
    790810                if ( $args['query'] ) {
    791811                        $analyzer = Jetpack_Search::get_analyzer_name( $this->blog_lang );
    792                         $query = array(
     812                        $query    = array(
    793813                                'bool' => array(
    794                                         'must' => array(
     814                                        'must'   => array(
    795815                                                'multi_match' => array(
    796                                                         'query'  => $args['query'],
    797                                                         'fields' => $matching_fields,
    798                                                         'boost'  => 0.1,
     816                                                        'query'    => $args['query'],
     817                                                        'fields'   => $matching_fields,
     818                                                        'boost'    => 0.1,
    799819                                                        'operator' => 'and',
    800820                                                ),
     
    805825                                                                'query'  => $args['query'],
    806826                                                                'fields' => $boost_phrase_fields,
    807                                                                 'type'  => 'phrase',
    808                                                                 'boost' => 2
     827                                                                'type'   => 'phrase',
     828                                                                'boost'  => 2,
    809829                                                        ),
    810830                                                ),
     
    813833                                                                'query'  => $args['query'],
    814834                                                                'fields' => $boost_ngram_fields,
    815                                                                 'type'  => 'phrase',
    816                                                                 'boost' => 0.2
     835                                                                'type'   => 'phrase',
     836                                                                'boost'  => 0.2,
    817837                                                        ),
    818838                                                ),
     
    821841                                                                'query'  => $args['query'],
    822842                                                                'fields' => $boost_title_fields,
    823                                                                 'type'  => 'best_fields',
    824                                                                 'boost' => 2
     843                                                                'type'   => 'best_fields',
     844                                                                'boost'  => 2,
    825845                                                        ),
    826846                                                ),
     
    829849                                                                'query'  => $args['query'],
    830850                                                                'fields' => $boost_content_fields,
    831                                                                 'type'  => 'best_fields',
    832                                                                 'boost' => 2
     851                                                                'type'   => 'best_fields',
     852                                                                'boost'  => 2,
    833853                                                        ),
    834854                                                ),
     
    840860                                                                        'contributors',
    841861                                                                ),
    842                                                                 'type'  => 'best_fields',
    843                                                                 'boost' => 2
     862                                                                'type'   => 'best_fields',
     863                                                                'boost'  => 2,
    844864                                                        ),
    845865                                                ),
     
    854874                        }
    855875                } else {
    856                         $query = array( 'match_all' => array() );
     876                        $query                  = array( 'match_all' => array() );
    857877                        $es_query_args['query'] = Jetpack_Search::score_query_by_recency( $query );
    858878                        if ( ! $args['orderby'] ) {
     
    877897                        // todo: add support for sorting by title, num likes, num comments, num views, etc
    878898                        switch ( $orderby ) {
    879                                 case 'relevance' :
    880                                         //never order by score ascending
     899                                case 'relevance':
     900                                        // never order by score ascending
    881901                                        $es_query_args['sort'][] = array( '_score' => array( 'order' => 'desc' ) );
    882902                                        break;
    883                                 case 'date' :
     903                                case 'date':
    884904                                        $es_query_args['sort'][] = array( 'date' => array( 'order' => $args['order'] ) );
    885905                                        break;
    886                                 case 'ID' :
     906                                case 'ID':
    887907                                        $es_query_args['sort'][] = array( 'id' => array( 'order' => $args['order'] ) );
    888908                                        break;
    889                                 case 'author' :
     909                                case 'author':
    890910                                        $es_query_args['sort'][] = array( 'author.raw' => array( 'order' => $args['order'] ) );
    891911                                        break;
    892912                        }
    893913                }
    894                 if ( empty( $es_query_args['sort'] ) )
     914                if ( empty( $es_query_args['sort'] ) ) {
    895915                        unset( $es_query_args['sort'] );
    896 
     916                }
    897917
    898918                if ( ! empty( $filters ) ) {
     
    911931                } else {
    912932                        $split_lang = explode( '-', $lang_code );
    913                         if ( in_array( $split_lang[0], Jetpack_Search::$analyzed_langs ) )
     933                        if ( in_array( $split_lang[0], Jetpack_Search::$analyzed_langs ) ) {
    914934                                $analyzer = $split_lang[0] . '_analyzer';
     935                        }
    915936                }
    916937                return $analyzer;
    917938        }
    918939
    919         ////////////////////////////////////////////
     940        //
    920941        // ES Filter Manipulation
    921 
    922942        /*
    923943         * And an existing filter object with a list of additional filters.
     
    925945         */
    926946        public static function and_es_filters( $curr_filter, $filters ) {
    927                 if ( !is_array( $curr_filter ) || isset( $curr_filter['match_all'] ) ) {
    928                         if ( 1 == count( $filters ) )
     947                if ( ! is_array( $curr_filter ) || isset( $curr_filter['match_all'] ) ) {
     948                        if ( 1 == count( $filters ) ) {
    929949                                return $filters[0];
     950                        }
    930951
    931952                        return array( 'and' => $filters );
     
    935956        }
    936957
    937         ////////////////////////////////////////////
     958        //
    938959        // ES Query Manipulation
    939 
    940960        public static function score_query_by_recency( $query ) {
    941                 //Newer content gets weighted slightly higher
    942                 $date_scale = '360d';
     961                // Newer content gets weighted slightly higher
     962                $date_scale  = '360d';
    943963                $date_offset = '180d';
    944                 $date_decay = 0.5;
     964                $date_decay  = 0.5;
    945965                $date_origin = date( 'Y-m-d' );
    946966
     
    949969                                'query' => array(
    950970                                        'function_score' => array(
    951                                                 'query' => $query,
    952                                                 'functions' => array(
     971                                                'query'      => $query,
     972                                                'functions'  => array(
    953973                                                        array(
    954                                                                 'exp'=> array(
     974                                                                'exp' => array(
    955975                                                                        'plugin_modified' => array(
    956976                                                                                'origin' => $date_origin,
    957977                                                                                'offset' => $date_offset,
    958                                                                                 'scale' => $date_scale,
    959                                                                                 'decay' => $date_decay,
     978                                                                                'scale'  => $date_scale,
     979                                                                                'decay'  => $date_decay,
    960980                                                                        ),
    961981                                                                ),
    962982                                                        ),
    963                                                         array( 
     983                                                        array(
    964984                                                                'exp' => array(
    965985                                                                        'tested' => array(
    966986                                                                                'origin' => sprintf( '%0.1f', WP_CORE_STABLE_BRANCH ),
    967987                                                                                'offset' => 0.1,
    968                                                                                 'scale' => 0.4,
    969                                                                                 'decay' => 0.6,
     988                                                                                'scale'  => 0.4,
     989                                                                                'decay'  => 0.6,
    970990                                                                        ),
    971991                                                                ),
     
    973993                                                        array(
    974994                                                                'field_value_factor' => array(
    975                                                                         'field' => 'active_installs',
    976                                                                         'factor' => 0.375,
     995                                                                        'field'    => 'active_installs',
     996                                                                        'factor'   => 0.375,
    977997                                                                        'modifier' => 'log2p',
    978                                                                         'missing' => 1,
     998                                                                        'missing'  => 1,
    979999                                                                ),
    9801000                                                        ),
    9811001                                                        array(
    982                                                                 //there aren't that many plugins with more than 1 million (6 total)
     1002                                                                // there aren't that many plugins with more than 1 million (6 total)
    9831003                                                                // we don't need to differentiate them as much
    9841004                                                                'filter' => array(
    985                                                                         'range' => array( 'active_installs' => array(
    986                                                                                 'lte' => 1000000
    987                                                                         ) )
     1005                                                                        'range' => array(
     1006                                                                                'active_installs' => array(
     1007                                                                                        'lte' => 1000000,
     1008                                                                                ),
     1009                                                                        ),
    9881010                                                                ),
    989                                                                 'exp' => array(
     1011                                                                'exp'    => array(
    9901012                                                                        'active_installs' => array(
    9911013                                                                                'origin' => 1000000,
    9921014                                                                                'offset' => 0,
    993                                                                                 'scale' => 900000,
    994                                                                                 'decay' => 0.75,
     1015                                                                                'scale'  => 900000,
     1016                                                                                'decay'  => 0.75,
    9951017                                                                        ),
    9961018                                                                ),
     
    9981020                                                        array(
    9991021                                                                'field_value_factor' => array(
    1000                                                                         'field' => 'support_threads_resolved',
    1001                                                                         'factor' => 0.25,
     1022                                                                        'field'    => 'support_threads_resolved',
     1023                                                                        'factor'   => 0.25,
    10021024                                                                        'modifier' => 'log2p',
    1003                                                                         'missing' => 0.5,
     1025                                                                        'missing'  => 0.5,
    10041026                                                                ),
    10051027                                                        ),
    10061028                                                        array(
    10071029                                                                'field_value_factor' => array(
    1008                                                                         'field' => 'rating',
    1009                                                                         'factor' => 0.25,
     1030                                                                        'field'    => 'rating',
     1031                                                                        'factor'   => 0.25,
    10101032                                                                        'modifier' => 'sqrt',
    1011                                                                         'missing' => 2.5,
     1033                                                                        'missing'  => 2.5,
    10121034                                                                ),
    10131035                                                        ),
    10141036                                                ),
    10151037                                                'boost_mode' => 'multiply',
    1016                                         )
     1038                                        ),
    10171039                                ),
    1018                         )
     1040                        ),
    10191041                );
    10201042        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/plugin-directory.php

    r3369 r6287  
    2222
    2323// Register an Autoloader for all files
    24 include __DIR__ . '/class-autoloader.php';
     24require __DIR__ . '/class-autoloader.php';
    2525Autoloader\register_class_path( __NAMESPACE__, __DIR__ );
    2626
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r6285 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Readme;
     3
    34use WordPressdotorg\Plugin_Directory\Markdown;
    45
     
    159160        protected function parse_readme( $file ) {
    160161                $contents = file_get_contents( $file );
    161                 if ( preg_match( '!!u', $contents ) )
     162                if ( preg_match( '!!u', $contents ) ) {
    162163                        $contents = preg_split( '!\R!u', $contents );
    163                 else
     164                } else {
    164165                        $contents = preg_split( '!\R!', $contents ); // regex failed due to invalid UTF8 in $contents, see #2298
     166                }
    165167                $contents = array_map( array( $this, 'strip_newlines' ), $contents );
    166168
     
    212214                        }
    213215
    214                         $bits = explode( ':', trim( $line ), 2 );
     216                        $bits                = explode( ':', trim( $line ), 2 );
    215217                        list( $key, $value ) = $bits;
    216                         $key = strtolower( trim( $key, " \t*-\r\n" ) );
     218                        $key                 = strtolower( trim( $key, " \t*-\r\n" ) );
    217219                        if ( isset( $this->valid_headers[ $key ] ) ) {
    218220                                $headers[ $this->valid_headers[ $key ] ] = trim( $value );
     
    252254                        if ( empty( $headers['license_uri'] ) && preg_match( '!(https?://\S+)!i', $headers['license'], $url ) ) {
    253255                                $headers['license_uri'] = $url[1];
    254                                 $headers['license'] = trim( str_replace( $url[1], '', $headers['license'] ), " -*\t\n\r\n" );
     256                                $headers['license']     = trim( str_replace( $url[1], '', $headers['license'] ), " -*\t\n\r\n" );
    255257                        }
    256258                        $this->license = $headers['license'];
     
    268270                        }
    269271                        if ( ( '=' === $trimmed[0] && isset( $trimmed[1] ) && '=' === $trimmed[1] ) ||
    270                             ( '#' === $trimmed[0] && isset( $trimmed[1] ) && '#' === $trimmed[1] )
     272                                ( '#' === $trimmed[0] && isset( $trimmed[1] ) && '#' === $trimmed[1] )
    271273                        ) {
    272274
     
    295297                        // Stop only after a ## Markdown header, not a ###.
    296298                        if ( ( '=' === $trimmed[0] && isset( $trimmed[1] ) && '=' === $trimmed[1] ) ||
    297                             ( '#' === $trimmed[0] && isset( $trimmed[1] ) && '#' === $trimmed[1] && isset( $trimmed[2] ) && '#' !== $trimmed[2] )
     299                                ( '#' === $trimmed[0] && isset( $trimmed[1] ) && '#' === $trimmed[1] && isset( $trimmed[2] ) && '#' !== $trimmed[2] )
    298300                        ) {
    299301
     
    312314                                // If we encounter an unknown section header, include the provided Title, we'll filter it to other_notes later.
    313315                                if ( ! in_array( $section_name, $this->expected_sections ) ) {
    314                                         $current .= '<h3>' . $section_title . '</h3>';
     316                                        $current     .= '<h3>' . $section_title . '</h3>';
    315317                                        $section_name = 'other_notes';
    316318                                }
     
    334336
    335337                // Suffix the Other Notes section to the description.
    336                 if ( !empty( $this->sections['other_notes'] ) ) {
     338                if ( ! empty( $this->sections['other_notes'] ) ) {
    337339                        $this->sections['description'] .= "\n" . $this->sections['other_notes'];
    338340                        unset( $this->sections['other_notes'] );
     
    348350                // Display FAQs as a definition list.
    349351                if ( isset( $this->sections['faq'] ) ) {
    350                         $this->faq = $this->parse_section( $this->sections['faq'] );
     352                        $this->faq             = $this->parse_section( $this->sections['faq'] );
    351353                        $this->sections['faq'] = '';
    352354                }
     
    356358                        $this->faq = array_merge(
    357359                                array(
    358                                         __( 'Installation Instructions', 'wporg-plugins' ) => $this->sections['installation']
     360                                        __( 'Installation Instructions', 'wporg-plugins' ) => $this->sections['installation'],
    359361                                ),
    360362                                $this->faq
    361363                        );
    362                         //unset( $this->sections['installation'] );
     364                        // unset( $this->sections['installation'] );
    363365                        $this->sections['faq'] = ''; // Ensure it's set as per faq section above.
    364366                }
     
    401403                                $this->sections['faq'] .= "\n<dl>\n";
    402404                                foreach ( $this->faq as $question => $answer ) {
    403                                         $question_slug = sanitize_title_with_dashes( $question );
     405                                        $question_slug          = sanitize_title_with_dashes( $question );
    404406                                        $this->sections['faq'] .= "<dt id='{$question_slug}'>{$question}</dt>\n<dd>{$answer}</dd>\n";
    405407                                }
     
    497499                $text = force_balance_tags( $text );
    498500                // TODO: make_clickable() will act inside shortcodes.
    499                 //$text = make_clickable( $text );
    500 
     501                // $text = make_clickable( $text );
    501502                $text = wp_kses( $text, $allowed );
    502503
    503504                // wpautop() will eventually replace all \n's with <br>s, and that isn't what we want (The text may be line-wrapped in the readme, we don't want that, we want paragraph-wrapped text)
    504505                // TODO: This incorrectly also applies within `<code>` tags which we don't want either.
    505                 //$text = preg_replace( "/(?<![> ])\n/", ' ', $text );
    506 
     506                // $text = preg_replace( "/(?<![> ])\n/", ' ', $text );
    507507                $text = trim( $text );
    508508
     
    516516         * @return string
    517517         */
    518         protected function sanitize_text( $text ) { // not fancy
     518        protected function sanitize_text( $text ) {
     519                // not fancy
    519520                $text = strip_tags( $text );
    520521                $text = esc_html( $text );
     
    583584         */
    584585        protected function parse_section( $lines ) {
    585                 $key = $value = '';
     586                $key    = $value = '';
    586587                $return = array();
    587588
     
    606607                $line_count = count( $lines );
    607608                for ( $i = 0; $i < $line_count; $i++ ) {
    608                         $line = &$lines[ $i ];
     609                        $line    = &$lines[ $i ];
    609610                        $trimmed = &$trimmed_lines[ $i ];
    610611                        if ( ! $trimmed ) {
     
    627628                                $value = '';
    628629                                // Trim off the first character of the line, as we know that's the heading style we're expecting to remove.
    629                                 $key   = trim( $line, $trimmed[0] . " \t" );
     630                                $key = trim( $line, $trimmed[0] . " \t" );
    630631                                continue;
    631632                        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php

    r5841 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Readme;
     3
    34use WordPressdotorg\Plugin_Directory\Tools\Filesystem;
    45
     
    3435                        $error = sprintf( __( 'URL must end in %s!', 'wporg-plugins' ), '<code>readme.txt</code>' );
    3536                        return array(
    36                                 'errors' => array( $error )
     37                                'errors' => array( $error ),
    3738                        );
    3839                }
     
    4243                        $error = __( 'Invalid readme.txt URL.', 'wporg-plugins' );
    4344                        return array(
    44                                 'errors' => array( $error )
     45                                'errors' => array( $error ),
    4546                        );
    4647                }
     
    6465                if ( empty( $readme->name ) ) {
    6566                        /* Translators: Plugin header tag; */
    66                         $errors[] = sprintf( __( "No plugin name detected. Plugin names look like: %s", 'wporg-plugins' ), '<code>=== Plugin Name ===</code>' );
     67                        $errors[] = sprintf( __( 'No plugin name detected. Plugin names look like: %s', 'wporg-plugins' ), '<code>=== Plugin Name ===</code>' );
    6768                }
    6869
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-developers.php

    r5920 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_I18n;
    45use WordPressdotorg\Plugin_Directory\Tools;
     
    1516         */
    1617        static function display() {
    17                 $post   = get_post();
    18                 $slug   = $post->post_name;
    19                 $title  = get_the_title( $post );
     18                $post  = get_post();
     19                $slug  = $post->post_name;
     20                $title = get_the_title( $post );
    2021
    2122                $output = '<div class="plugin-contributors">';
     
    4445                        $output .= '<p>';
    4546
    46                         $wp_locales = wp_list_pluck( $locales,'wp_locale' );
     47                        $wp_locales    = wp_list_pluck( $locales, 'wp_locale' );
    4748                        $locales_count = get_sites( [
    4849                                'network_id' => WPORG_GLOBAL_NETWORK_ID,
     
    7677                }
    7778
    78                 $output .= '<p>' . sprintf( '<a href="%1$s">%2$s</a>',
     79                $output .= '<p>' . sprintf(
     80                        '<a href="%1$s">%2$s</a>',
    7981                        esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $slug ),
    8082                        sprintf(
     
    8486                        )
    8587                ) . '</p>';
    86 
    8788
    8889                $output .= '<h3>' . __( 'Interested in development?', 'wporg-plugins' ) . '</h3>';
     
    115116                }
    116117                $output .= '</div>';
     118
    117119                return $output;
    118120        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-readme-validator.php

    r5333 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
     3
    34use WordPressdotorg\Plugin_Directory\Readme\Validator;
    45
     
    2122                        <form method="post" action="">
    2223                                <p>
    23                                         <input type="text" name="readme_url" size="70" placeholder="https://" value="<?php if ( isset( $_POST['readme_url'] ) ) { echo esc_attr( $_POST['readme_url'] ); } ?>" />
    24                                         <input type="submit" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" />
     24                                        <input type="text" name="readme_url" size="70" placeholder="https://" value="
     25                                        <?php
     26                                        if ( isset( $_POST['readme_url'] ) ) {
     27                                                echo esc_attr( $_POST['readme_url'] );
     28                                        }
     29                                        ?>
     30                                        " />
     31                                        <input type="submit" class="button button-secondary" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" />
    2532                                </p>
    2633                        </form>
     
    2835                        <p><?php _e( '... or paste your <code>readme.txt</code> here:', 'wporg-plugins' ); ?></p>
    2936                        <form method="post" action="">
    30                                 <textarea rows="20" cols="100" name="readme_contents" placeholder="=== Plugin Name ==="><?php
     37                                <textarea rows="20" cols="100" name="readme_contents" placeholder="=== Plugin Name ===">
     38                                        <?php
    3139                                        if ( isset( $_POST['readme_contents'] ) ) {
    3240                                                echo esc_textarea( wp_unslash( $_POST['readme_contents'] ) );
    3341                                        }
    34                                 ?></textarea>
    35                                 <p><input type="submit" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" /></p>
     42                                        ?>
     43                                </textarea>
     44                                <p><input type="submit" class="button button-secondary" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" /></p>
    3645                        </form>
    3746                </div>
     
    4352         */
    4453        protected static function validate_readme() {
    45                 if (  !empty( $_POST['readme_url'] ) ) {
     54                if ( ! empty( $_POST['readme_url'] ) ) {
    4655                        $errors = Validator::instance()->validate_url( wp_unslash( $_POST['readme_url'] ) );
    4756
    48                 } elseif ( !empty( $_POST['readme_contents'] ) ) {
     57                } elseif ( ! empty( $_POST['readme_contents'] ) ) {
    4958                        $errors = Validator::instance()->validate_content( wp_unslash( $_REQUEST['readme_contents'] ) );
    5059
     
    5867                        'errors'   => __( 'Fatal Errors:', 'wporg-plugins' ),
    5968                        'warnings' => __( 'Warnings:', 'wporg-plugins' ),
    60                         'notes'    => __( 'Notes:', 'wporg-plugins' )
     69                        'notes'    => __( 'Notes:', 'wporg-plugins' ),
    6170                );
    6271                foreach ( $error_types as $field => $warning_label ) {
    63                         if ( !empty( $errors[ $field ] ) ) {
     72                        if ( ! empty( $errors[ $field ] ) ) {
    6473                                $output .= "{$warning_label}\n<ul class='{$field} error'>\n";
    6574                                foreach ( $errors[ $field ] as $notice ) {
     
    7281                if ( empty( $output ) ) {
    7382                        $output .= '<div class="notice notice-success notice-alt">';
    74                         $output .= '<p>' . __( 'Congratulations! No errors found.', 'wporg-plugins' ) .'</p>' ;
     83                        $output .= '<p>' . __( 'Congratulations! No errors found.', 'wporg-plugins' ) . '</p>';
    7584                        $output .= '</div>';
    7685                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-reviews.php

    r5229 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
     3
    34use WordPressdotorg\Plugin_Directory\Template;
    45use WordPressdotorg\Plugin_Directory\Tools;
     
    1516         */
    1617        static function display() {
    17                 $reviews = Tools::get_plugin_reviews( get_post()->post_name );
    18                 $ratings = get_post_meta( get_the_ID(), 'ratings', true ) ?: array();
     18                $reviews      = Tools::get_plugin_reviews( get_post()->post_name );
     19                $ratings      = get_post_meta( get_the_ID(), 'ratings', true ) ?: array();
    1920                $review_count = array_sum( $ratings );
    2021
     
    3839                                                        <?php if ( ! empty( $review->ID ) ) : ?>
    3940                                                                <h3 class="review-title"><a class="url" href="<?php echo esc_url( add_query_arg( array( 'p' => $review->ID ), 'https://wordpress.org/support/plugin/' ) ); ?>"><?php echo get_the_title( $review ); ?></a></h3>
    40                                                         <?php else: ?>
     41                                                        <?php else : ?>
    4142                                                                <h3 class="review-title"><?php echo get_the_title( $review ); ?></h3>
    4243                                                        <?php endif; ?>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php

    r5197 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
     3
    34use WordPressdotorg\Plugin_Directory\Template;
    45use WordPressdotorg\Plugin_Directory\Plugin_i18n;
     
    2021                // All indexed from 1.
    2122                $descriptions = get_post_meta( $plugin->ID, 'screenshots', true ) ?: array();
    22                 $screen_shots = get_post_meta( $plugin->ID, 'assets_screenshots', true ) ?: array();;
     23                $screen_shots = get_post_meta( $plugin->ID, 'assets_screenshots', true ) ?: array();
    2324
    2425                if ( empty( $screen_shots ) ) {
     
    3334                 */
    3435                foreach ( $screen_shots as $image ) {
    35                         $screen_shot = sprintf( '<a href="%1$s" rel="nofollow"><img class="screenshot" src="%1$s" alt="" /></a>',
     36                        $screen_shot = sprintf(
     37                                '<a href="%1$s" rel="nofollow"><img class="screenshot" src="%1$s" alt="" /></a>',
    3638                                esc_url( Template::get_asset_url( $plugin, $image ) )
    3739                        );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r6045 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
     3
    34use WordPressdotorg\Plugin_Directory\Readme\Parser;
    45use WordPressdotorg\Plugin_Directory\Plugin_Directory;
     
    4445         */
    4546        public function __construct() {
    46                 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    47                 require_once( ABSPATH . 'wp-admin/includes/image.php' );
    48                 require_once( ABSPATH . 'wp-admin/includes/file.php' );
    49                 require_once( ABSPATH . 'wp-admin/includes/media.php' );
     47                require_once ABSPATH . 'wp-admin/includes/plugin.php';
     48                require_once ABSPATH . 'wp-admin/includes/image.php';
     49                require_once ABSPATH . 'wp-admin/includes/file.php';
     50                require_once ABSPATH . 'wp-admin/includes/media.php';
    5051        }
    5152
     
    5859         */
    5960        public function process_upload() {
    60                 $zip_file = $_FILES['zip_file']['tmp_name'];
     61                $zip_file         = $_FILES['zip_file']['tmp_name'];
    6162                $this->plugin_dir = Filesystem::unzip( $zip_file );
    6263
     
    6566                        $plugin_data = get_plugin_data( $plugin_file, false, false ); // No markup/translation needed.
    6667                        if ( ! empty( $plugin_data['Name'] ) ) {
    67                                 $this->plugin = $plugin_data;
     68                                $this->plugin      = $plugin_data;
    6869                                $this->plugin_root = dirname( $plugin_file );
    6970                                break;
     
    104105                if ( $this->has_reserved_slug() ) {
    105106                        $error = __( 'Error: The plugin has a reserved name.', 'wporg-plugins' );
    106                        
     107
    107108                        return new \WP_Error( 'reserved_name', $error . ' ' . sprintf(
    108109                                /* translators: 1: plugin slug, 2: 'Plugin Name:' */
     
    118119                if ( $plugin_post && $plugin_post->post_author != get_current_user_id() ) {
    119120                        $error = __( 'Error: The plugin already exists.', 'wporg-plugins' );
    120                        
     121
    121122                        return new \WP_Error( 'already_exists', $error . ' ' . sprintf(
    122123                                /* translators: 1: plugin slug, 2: 'Plugin Name:' */
     
    130131                if ( $plugin_post ) {
    131132                        $error = __( 'Error: The plugin has already been submitted.', 'wporg-plugins' );
    132                        
     133
    133134                        return new \WP_Error( 'already_submitted', $error . ' ' . sprintf(
    134135                                /* translators: 1: plugin slug, 2: plugins@wordpress.org */
     
    163164                if ( preg_match( '|[^\d\.]|', $this->plugin['Version'] ) ) {
    164165                        $error = __( 'Error: Plugin versions are expected to be numbers.', 'wporg-plugins' );
    165                        
     166
    166167                        return new \WP_Error( 'invalid_version', $error . ' ' . sprintf(
    167168                                /* translators: %s: 'Version:' */
     
    174175                if ( ! empty( $this->plugin['PluginURI'] ) && ! empty( $this->plugin['AuthorURI'] ) && $this->plugin['PluginURI'] == $this->plugin['AuthorURI'] ) {
    175176                        $error = __( 'Error: Your plugin and author URIs are the same.', 'wporg-plugins' );
    176                        
    177                         return new \WP_Error( 'plugin_author_uri', $error . ' ' .
     177
     178                        return new \WP_Error(
     179                                'plugin_author_uri', $error . ' ' .
    178180                                __( 'A plugin URL is a page/site that provides details about this specific plugin. An author URL is a page/site that provides information about the author of the plugin. You are not required to provide both, so pick the one that best applies to your URL.', 'wporg-plugins' )
    179181                        );
     
    183185                if ( empty( $readme ) ) {
    184186                        $error = __( 'Error: The plugin has no readme.', 'wporg-plugins' );
    185                        
     187
    186188                        return new \WP_Error( 'no_readme', $error . ' ' . sprintf(
    187189                                /* translators: 1: readme.txt, 2: readme.md */
     
    199201                if ( ! $result ) {
    200202                        $error = __( 'Error: The plugin has failed the automated checks.', 'wporg-plugins' );
    201                        
     203
    202204                        return new \WP_Error( 'failed_checks', $error . ' ' . sprintf(
    203205                                /* translators: 1: Plugin Check Plugin URL, 2: make.wordpress.org/plugins */
     
    210212                // Passed all tests!
    211213                // Let's save everything and get things wrapped up.
    212 
    213214                // Create a new post on first-time submissions.
    214215                if ( ! $plugin_post ) {
     
    225226                                'post_content' => $content,
    226227                                'post_excerpt' => $this->plugin['Description'],
    227                         //      'tax_input'    => wp_unslash( $_POST['tax_input'] ), // for category selection
     228                                // 'tax_input'    => wp_unslash( $_POST['tax_input'] ), // for category selection
    228229                                'meta_input'   => array(
    229230                                        'tested'                   => $readme->tested,
     
    277278
    278279                /* translators: 1: plugin name, 2: plugin slug, 3: plugins@wordpress.org */
    279                 $message = sprintf( __( 'Thank you for uploading %1$s to the WordPress Plugin Directory. It has been given the initial plugin slug of %2$s, however that is subject to change based on the results of your code review.' ),
     280                $message = sprintf(
     281                        __( 'Thank you for uploading %1$s to the WordPress Plugin Directory. It has been given the initial plugin slug of %2$s, however that is subject to change based on the results of your code review.' ),
    280282                        esc_html( $this->plugin['Name'] ),
    281283                        '<code>' . $this->plugin_slug . '</code>'
     
    283285
    284286                /* translators: 1: plugins@wordpress.org */
    285                 $message .= sprintf( __( 'We&rsquo;ve sent you an email verifying this submission. Please make sure to whitelist our email address - <a href="mailto:%1$s">%1$s</a> - to ensure you receive all our communications.' ),
     287                $message .= sprintf(
     288                        __( 'We&rsquo;ve sent you an email verifying this submission. Please make sure to whitelist our email address - <a href="mailto:%1$s">%1$s</a> - to ensure you receive all our communications.' ),
    286289                        'plugins@wordpress.org'
    287290                ) . '</p><p>';
     
    394397
    395398                /* translators: %s: plugin name */
    396                 $email_subject = sprintf( __( '[WordPress Plugin Directory] New Plugin - %s', 'wporg-plugins' ),
     399                $email_subject = sprintf(
     400                        __( '[WordPress Plugin Directory] New Plugin - %s', 'wporg-plugins' ),
    397401                        $this->plugin['Name']
    398402                );
    399403
    400404                /* translators: 1: plugin name, 2: plugin slug */
    401                 $email_content = sprintf( __( 'Thank you for uploading %1$s to the WordPress Plugin Directory. We will review your submission as soon as possible and send you a follow up email with the results.
     405                $email_content = sprintf(
     406                        __(
     407'Thank you for uploading %1$s to the WordPress Plugin Directory. We will review your submission as soon as possible and send you a follow up email with the results.
    402408
    403409Your plugin has been given the initial slug of %2$s, however this is subject to change based on the results of your review.
     
    411417--
    412418The WordPress Plugin Directory Team
    413 https://make.wordpress.org/plugins', 'wporg-plugins' ),
     419https://make.wordpress.org/plugins', 'wporg-plugins'
     420                        ),
    414421                        $this->plugin['Name'],
    415422                        $this->plugin_slug
     
    422429
    423430        // Helper
    424 
    425431        /**
    426432         * Whitelist zip files to be allowed to be uploaded to the media library.
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php

    r6119 r6287  
    5555                        ) :
    5656                                if ( UPLOAD_ERR_OK === $_FILES['zip_file']['error'] ) :
    57                                         $uploader      = new Upload_Handler;
     57                                        $uploader      = new Upload_Handler();
    5858                                        $upload_result = $uploader->process_upload();
    5959
     
    7676
    7777                                <div class="plugin-queue-message notice notice-info notice-alt">
    78                                         <p><?php
    79                                                 if ( 1 === ( $plugins->new + $plugins->pending ) ) {
    80                                                          _e( 'Currently there is 1 plugin in the review queue.', 'wporg-plugins' );
     78                                        <p>
     79                                        <?php
     80                                        if ( 1 === ( $plugins->new + $plugins->pending ) ) {
     81                                                 _e( 'Currently there is 1 plugin in the review queue.', 'wporg-plugins' );
     82                                        } else {
     83                                                printf(
     84                                                        _n(
     85                                                                'Currently there are %1$s plugins in the review queue, %2$s of which is awaiting its initial review.',
     86                                                                'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.',
     87                                                                $plugins->new,
     88                                                                'wporg-plugins'
     89                                                        ),
     90                                                        '<strong>' . ( $plugins->new + $plugins->pending ) . '</strong>',
     91                                                        '<strong>' . $plugins->new . '</strong>'
     92                                                );
     93                                        }
     94                                        ?>
     95                                        </p>
     96                                </div>
     97
     98                                <?php if ( $submitted_counts->total ) : ?>
     99
     100                                        <div class="plugin-queue-message notice notice-warning notice-alt">
     101                                                <p>
     102                                                <?php
     103                                                if ( 1 === $submitted_counts->total ) {
     104                                                        _e( 'You already have a plugin in the review queue. Please wait for it to be approved before submitting any more.', 'wporg-plugins' );
    81105                                                } else {
    82106                                                        printf(
    83107                                                                _n(
    84                                                                         'Currently there are %1$s plugins in the review queue, %2$s of which is awaiting its initial review.',
    85                                                                         'Currently there are %1$s plugins in the review queue, %2$s of which are awaiting their initial review.',
    86                                                                         $plugins->new,
     108                                                                        'You have %1$s plugins in the review queue, %2$s is being actively reviewed. Please wait for them to be approved before submitting any more.',
     109                                                                        'You have %1$s plugins in the review queue, %2$s are being actively reviewed. Please wait for them to be approved before submitting any more.',
     110                                                                        $submitted_counts->pending,
    87111                                                                        'wporg-plugins'
    88112                                                                ),
    89                                                                 '<strong>' . ( $plugins->new + $plugins->pending ) . '</strong>',
    90                                                                 '<strong>' . $plugins->new . '</strong>'
     113                                                                '<strong>' . $submitted_counts->total . '</strong>',
     114                                                                '<strong>' . $submitted_counts->pending . '</strong>'
    91115                                                        );
    92116                                                }
    93                                         ?></p>
    94                                 </div>
    95 
    96                                 <?php if ( $submitted_counts->total ) : ?>
    97 
    98                                         <div class="plugin-queue-message notice notice-warning notice-alt">
    99                                                 <p><?php
    100                                                         if ( 1 === $submitted_counts->total ) {
    101                                                                 _e( 'You already have a plugin in the review queue. Please wait for it to be approved before submitting any more.', 'wporg-plugins' );
    102                                                         } else {
    103                                                                 printf(
    104                                                                         _n(
    105                                                                                 'You have %1$s plugins in the review queue, %2$s is being actively reviewed. Please wait for them to be approved before submitting any more.',
    106                                                                                 'You have %1$s plugins in the review queue, %2$s are being actively reviewed. Please wait for them to be approved before submitting any more.',
    107                                                                                 $submitted_counts->pending,
    108                                                                                 'wporg-plugins'
    109                                                                         ),
    110                                                                         '<strong>' . $submitted_counts->total . '</strong>',
    111                                                                         '<strong>' . $submitted_counts->pending . '</strong>'
    112                                                                 );
    113                                                         }
    114                                                 ?></p>
    115 
    116                                                 <ul><?php
    117                                                         foreach ( $submitted_plugins as $plugin ) {
    118                                                                 echo '<li>' . esc_html( $plugin->post_title ) . ' &#8212; ' . $plugin->status . "</li>\n";
    119                                                         }
    120                                                 ?></ul>
    121 
    122                                                 <p><?php
     117                                                ?>
     118                                                </p>
     119
     120                                                <ul>
     121                                                <?php
     122                                                foreach ( $submitted_plugins as $plugin ) {
     123                                                        echo '<li>' . esc_html( $plugin->post_title ) . ' &#8212; ' . $plugin->status . "</li>\n";
     124                                                }
     125                                                ?>
     126                                                </ul>
     127
     128                                                <p>
     129                                                <?php
    123130                                                        /* translators: %s: plugins@wordpress.org */
    124                                                         printf( __( 'Please wait at least 7 business days before asking for an update status from <a href="mailto:%1$s">%1$s</a>.', 'wporg-plugins' ),
     131                                                        printf(
     132                                                                __( 'Please wait at least 7 business days before asking for an update status from <a href="mailto:%1$s">%1$s</a>.', 'wporg-plugins' ),
    125133                                                                'plugins@wordpress.org'
    126134                                                        );
    127                                                 ?></p>
     135                                                ?>
     136                                                </p>
    128137                                        </div>
    129138
     
    137146                                        <?php wp_nonce_field( 'wporg-plugins-upload' ); ?>
    138147                                        <input type="hidden" name="action" value="upload"/>
    139                                         <?php /* <fieldset>
     148                                        <?php
     149                                        /*
     150                                        <fieldset>
    140151                                                <legend><?php _e( 'Select categories (up to 3)', 'wporg-plugins' ); ?></legend>
    141152                                                <ul class="category-checklist">
    142153                                                        <?php wp_terms_checklist( 0, array( 'taxonomy' => 'plugin_category' ) ); ?>
    143154                                                </ul>
    144                                         </fieldset> */ ?>
     155                                        </fieldset> */
     156?>
    145157
    146158                                        <input type="file" id="zip_file" class="plugin-file" name="zip_file" size="25" accept=".zip"/>
     
    175187                        <p><?php printf( __( 'Before you can upload a new plugin, <a href="%s">please log in</a>.', 'wporg-plugins' ), esc_url( wp_login_url() ) ); ?></p>
    176188
    177                 <?php endif; // is_user_logged_in()
     189                <?php
     190                endif; // is_user_logged_in()
    178191
    179192                return ob_get_clean();
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php

    r5841 r6287  
    66 */
    77class Plugins_Info_API_Request {
    8         public $locale = 'en_US';
    9         protected $args = array();
     8        public $locale              = 'en_US';
     9        protected $args             = array();
    1010        protected $requested_fields = array();
    1111
     
    3636
    3737        static $plugins_info_fields_defaults = array(
    38                 'added'             => true,
    39                 'compatibility'     => true,
    40                 'contributors'      => true,
    41                 'downloaded'        => true,
    42                 'downloadlink'      => true,
    43                 'donate_link'       => true,
    44                 'homepage'          => true,
    45                 'last_updated'      => true,
    46                 'rating'            => true,
    47                 'ratings'           => true,
    48                 'requires'          => true,                           
    49                 'requires_php'      => true,
    50                 'sections'          => true,
    51                 'tags'              => true,
    52                 'tested'            => true,
     38                'added'         => true,
     39                'compatibility' => true,
     40                'contributors'  => true,
     41                'downloaded'    => true,
     42                'downloadlink'  => true,
     43                'donate_link'   => true,
     44                'homepage'      => true,
     45                'last_updated'  => true,
     46                'rating'        => true,
     47                'ratings'       => true,
     48                'requires'      => true,
     49                'requires_php'  => true,
     50                'sections'      => true,
     51                'tags'          => true,
     52                'tested'        => true,
    5353        );
    5454
     
    6464                'rating'            => true,
    6565                'ratings'           => true,
    66                 'requires'          => true,                           
     66                'requires'          => true,
    6767                'requires_php'      => true,
    6868                'sections'          => true,
     
    7575                $args = (object) $args;
    7676
    77                 if ( !empty( $args->locale ) ) {
     77                if ( ! empty( $args->locale ) ) {
    7878                        $this->locale = $args->locale; // TODO: sanitize?
    7979                }
    80                 if ( !empty( $args->fields ) ) {
     80                if ( ! empty( $args->fields ) ) {
    8181                        $this->requested_fields = $this->parse_requested_fields( $args->fields );
    8282                }
     
    112112
    113113                // In WordPress x.y we start sending 'contributors' which means respond with a more detailed list of contributors.
    114                 if ( !isset( $this->requested_fields['contributors'] ) ) {
     114                if ( ! isset( $this->requested_fields['contributors'] ) ) {
    115115                        $fields['bare_contributors'] = true;
    116116                }
     
    122122
    123123        /**
    124          * Sanitizes/parses the given fields parameter into a standard format. 
     124         * Sanitizes/parses the given fields parameter into a standard format.
    125125         */
    126126        protected function parse_requested_fields( $fields ) {
    127                 $fields = is_string( $fields ) ? explode( ',', $fields ) : (array)$fields;
     127                $fields = is_string( $fields ) ? explode( ',', $fields ) : (array) $fields;
    128128
    129129                $requested_fields = array();
    130130                foreach ( $fields as $field => $include ) {
    131131                        if ( is_int( $field ) ) {
    132                                 $field = $include;
     132                                $field   = $include;
    133133                                $include = true;
    134134                                if ( '-' == substr( $field, 0, 1 ) ) {
    135135                                        $include = false;
    136                                         $field = substr( $field, 1 );
     136                                        $field   = substr( $field, 1 );
    137137                                }
    138138                        }
     
    151151                $query = array();
    152152                // Paging
    153                 $query['paged']          = isset( $this->args->page )     ? $this->args->page    : 1;
     153                $query['paged']          = isset( $this->args->page ) ? $this->args->page : 1;
    154154                $query['posts_per_page'] = isset( $this->args->per_page ) ? $this->args->per_page : 24;
    155155
     
    157157                if ( ! empty( $this->args->browse ) ) {
    158158                        $query['browse'] = $this->args->browse;
    159                         if ( !empty( $this->args->installed_plugins ) )
     159                        if ( ! empty( $this->args->installed_plugins ) ) {
    160160                                $query['installed_plugins'] = is_array( $this->args->installed_plugins ) ? $this->args->installed_plugins : array();
    161 
     161                        }
    162162                } elseif ( ! empty( $this->args->user ) ) {
    163                         $query['browse'] = 'favorites';
     163                        $query['browse']         = 'favorites';
    164164                        $query['favorites_user'] = $this->args->user;
    165165
     
    180180                                $query['author_name'] = $this->args->author;
    181181                        }
    182 
    183182                }
    184183
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php

    r5389 r6287  
    33
    44// The API caches here expire every 24~25hours, avoids cache races when multiple change at the same time.
    5 define( 'API_CACHE_EXPIRY', 24*60*60 + rand( 0, 60*60 ) );
     5define( 'API_CACHE_EXPIRY', 24 * 60 * 60 + rand( 0, 60 * 60 ) );
    66class Plugins_Info_API {
    77
     
    99        const CACHE_EXPIRY = API_CACHE_EXPIRY;
    1010
    11         protected $format = 'json';
    12         protected $jsonp  = false;
     11        protected $format  = 'json';
     12        protected $jsonp   = false;
    1313        protected $formats = array(
    1414                'jsonp' => 'application/javascript',
     
    2121                if ( is_array( $format ) && 'jsonp' == $format[0] ) {
    2222                        $this->jsonp = preg_replace( '/[^a-zA-Z0-9_]/', '', $format[1] );
    23                         $format = 'jsonp';
     23                        $format      = 'jsonp';
    2424                }
    2525                $this->format = $format;
     
    5353                                } else {
    5454                                        $this->output( (object) array(
    55                                                 'error' => 'Action not implemented'
     55                                                'error' => 'Action not implemented',
    5656                                        ) );
    5757                                }
     
    7272                        if ( 200 != $response->status ) {
    7373                                $response = array( 'error' => 'Plugin not found.' );
    74                                 wp_cache_set( $cache_key, $response, self::CACHE_GROUP, 15*60 ); // shorter TTL for missing/erroring plugins.
     74                                wp_cache_set( $cache_key, $response, self::CACHE_GROUP, 15 * 60 ); // shorter TTL for missing/erroring plugins.
    7575                        } else {
    7676                                $response = $response->data;
     
    8888                        return;
    8989                }
    90 
    9190
    9291                // Only include the fields requested.
     
    129128                // Back-compatible routines.
    130129                // WordPress 4.x and older need a "bare" contributor map
    131                 if ( !empty( $fields['bare_contributors'] ) ) {
    132                         $contribs = $response['contributors'];
     130                if ( ! empty( $fields['bare_contributors'] ) ) {
     131                        $contribs                 = $response['contributors'];
    133132                        $response['contributors'] = array();
    134133                        if ( $contribs ) {
     
    147146        public function query_plugins( $request ) {
    148147                $response = array(
    149                         'info' => array(
    150                                 'page' => 0,
    151                                 'pages' => 0,
     148                        'info'    => array(
     149                                'page'    => 0,
     150                                'pages'   => 0,
    152151                                'results' => 0,
    153152                        ),
    154                         'plugins' => array()
     153                        'plugins' => array(),
    155154                );
    156155
     
    175174                // Fill in the plugin details
    176175                foreach ( $response['plugins'] as $i => $plugin_slug ) {
    177                         $plugin = $this->plugin_information( new Plugins_Info_API_Request( array( 'slug' => $plugin_slug, 'locale' => $request->locale ) ), true );
     176                        $plugin = $this->plugin_information(
     177                                new Plugins_Info_API_Request(
     178                                        array(
     179                                                'slug'   => $plugin_slug,
     180                                                'locale' => $request->locale,
     181                                        )
     182                                ), true
     183                        );
    178184                        if ( isset( $plugin['error'] ) ) {
    179185                                unset( $response['plugins'][ $i ] );
     
    186192                // Trim fields and cast to object
    187193                foreach ( $response['plugins'] as $i => $plugin_data ) {
    188                         $response['plugins'][$i] = (object) $this->remove_unexpected_fields( $plugin_data, $request, 'query_plugins' );
     194                        $response['plugins'][ $i ] = (object) $this->remove_unexpected_fields( $plugin_data, $request, 'query_plugins' );
    189195                }
    190196
     
    216222
    217223                $number_items_requested = 100;
    218                 if ( !empty( $request->number ) ) {
     224                if ( ! empty( $request->number ) ) {
    219225                        $number_items_requested = $request->number;
    220226                }
     
    242248                switch ( $this->format ) {
    243249                        default:
    244                         case 'json' :
    245                         case 'jsonp' :
     250                        case 'json':
     251                        case 'jsonp':
    246252                                if ( ! function_exists( 'wp_json_encode' ) && defined( 'WPORGAPIPATH' ) ) {
    247253                                        require WPORGAPIPATH . '/includes/wp-json-encode.php';
     
    254260                                }
    255261                                break;
    256        
    257                         case 'php' :
     262
     263                        case 'php':
    258264                                echo serialize( $response ? (object) $response : $response );
    259265                                break;
    260        
    261                         case 'xml' :
     266
     267                        case 'xml':
    262268                                echo '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n";
    263269                                echo "<plugin>\n";
     
    281287                define( 'REST_REQUEST', true );
    282288
    283                 $host = $_SERVER['HTTP_HOST'];
    284                 $request_uri = $_SERVER['REQUEST_URI'];
    285                 $_SERVER['HTTP_HOST'] = 'wordpress.org';
     289                $host                   = $_SERVER['HTTP_HOST'];
     290                $request_uri            = $_SERVER['REQUEST_URI'];
     291                $_SERVER['HTTP_HOST']   = 'wordpress.org';
    286292                $_SERVER['REQUEST_URI'] = '/plugins/';
    287293
    288294                require_once WPORGPATH . '/wp-load.php';
    289295
    290                 $_SERVER['HTTP_HOST'] = $host;
     296                $_SERVER['HTTP_HOST']   = $host;
    291297                $_SERVER['REQUEST_URI'] = $request_uri;
    292298
     
    322328                        $xml_tag = function( $tag, $type, $empty = false ) {
    323329                                static $NameStartChar = ':A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\x{2FF}\x{370}-\x{37D}\x{37F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}';
    324                                 static $NameChar = '.0-9\xB7\x{0300}-\x{036F}\x{203F}-\x{2040}-';
     330                                static $NameChar      = '.0-9\xB7\x{0300}-\x{036F}\x{203F}-\x{2040}-';
    325331
    326332                                $start_right = $empty ? ' />' : '>';
     
    340346                echo str_repeat( "\t", $tabs );
    341347                switch ( $type = gettype( $data ) ) {
    342                         case 'string' :
     348                        case 'string':
    343349                                $data = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $data ) . ']]>';
    344                         case 'boolean' :
    345                         case 'integer' :
    346                         case 'double' :
    347                         case 'float' :
     350                        case 'boolean':
     351                        case 'integer':
     352                        case 'double':
     353                        case 'float':
    348354                                list( $start, $close ) = $xml_tag( $key, $type, false );
    349355                                echo "$start$data$close";
    350356                                break;
    351                         case 'NULL' :
     357                        case 'NULL':
    352358                                list( $start, $close ) = $xml_tag( $key, $type, true );
    353359                                echo $start;
    354360                                break;
    355                         case 'array' :
     361                        case 'array':
    356362                                if ( empty( $data ) ) {
    357363                                        list( $start, $close ) = $xml_tag( $key, $type, true );
     
    368374                                echo $close;
    369375                                break;
    370                         case 'object' :
    371                                 if ( !$array = get_object_vars( $data ) ) {
    372                                         if ( !$tabs ) {
     376                        case 'object':
     377                                if ( ! $array = get_object_vars( $data ) ) {
     378                                        if ( ! $tabs ) {
    373379                                                break;
    374380                                        }
    375381
    376                                         list( $start, $close ) = $xml_tag( $key, $type, true);
     382                                        list( $start, $close ) = $xml_tag( $key, $type, true );
    377383                                        echo $start;
    378384                                        break;
     
    391397                                }
    392398                                break;
    393                         case 'resource' :
    394                         case 'unknown type' :
    395                         default :
     399                        case 'resource':
     400                        case 'unknown type':
     401                        default:
    396402                                break;
    397403                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/downloads.php

    r3289 r6287  
    55 * This is a stand alone script, it operates with the expectation that the
    66 * global `$wpdb` is available and the object cache is configured.
    7  * 
     7 *
    88 * Examples of URLs which are accepted:
    99 * - downloads.wordpress.org/plugin/hello-dolly.zip (trunk)
     
    1212 */
    1313
    14 include dirname( __DIR__ ) . '/class-autoloader.php';
     14require dirname( __DIR__ ) . '/class-autoloader.php';
    1515Autoloader\register_class_path( __NAMESPACE__, dirname( __DIR__ ) );
    1616$serve = new Zip\Serve();
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/plugins-info-api.php

    r3289 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory;
     3
    34die();
    45
     
    1213
    1314$_REQUEST = array(
    14         'method' => 'plugin_information',
     15        'method'  => 'plugin_information',
    1516        'request' => array(
    16                 'slug' => 'hello-dolly',
     17                'slug'   => 'hello-dolly',
    1718                'fields' => 'active_installs',
    18         )
     19        ),
    1920);
    2021
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/bootstrap.php

    r4223 r6287  
    66}
    77
    8 require_once( $_tests_dir . '/includes/functions.php' );
     8require_once $_tests_dir . '/includes/functions.php';
    99
    1010/**
     
    1212 */
    1313function _manually_load_plugin_directory_plugin() {
    14         require_once( dirname( __FILE__ ) . '/../plugin-directory.php' );
     14        require_once dirname( __FILE__ ) . '/../plugin-directory.php';
    1515}
    1616
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/api/svn-access.php

    r5434 r6287  
    99        function test_permission_denied() {
    1010                $response = wp_remote_get( 'https://wordpress.org/plugins/wp-json/plugins/v1/svn-access' );
    11                 $data = json_decode( wp_remote_retrieve_body( $response ), true );
     11                $data     = json_decode( wp_remote_retrieve_body( $response ), true );
    1212
    1313                $this->assertEquals( 'not_authorized', $data['code'] );
     
    1717                $response = wp_remote_get( 'https://wordpress.org/plugins/wp-json/plugins/v1/svn-access', array(
    1818                        'headers' => array(
    19                                 'Authorization' => 'lol like this would be a real auth key'
     19                                'Authorization' => 'lol like this would be a real auth key',
    2020                        ),
    2121                ) );
    22                 $data = json_decode( wp_remote_retrieve_body( $response ), true );
     22                $data     = json_decode( wp_remote_retrieve_body( $response ), true );
    2323
    2424                $this->assertEquals( 'not_authorized', $data['code'] );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/wporg-plugin-api-performance.php

    r5841 r6287  
    1010class Tests_Plugins_API_Performance extends WP_UnitTestCase {
    1111
    12         public $api_endpoint_1_0 = 'http://api.wordpress.org/plugins/info/1.0/';
    13         public $api_endpoint_1_1 = 'http://api.wordpress.org/plugins/info/1.1/';
    14         public $api_endpoint_plugin_php = 'http://api.wordpress.org/plugins/info/1.0/jetpack.php';
    15         public $api_endpoint_plugin_xml = 'http://api.wordpress.org/plugins/info/1.0/jetpack.xml';
     12        public $api_endpoint_1_0         = 'http://api.wordpress.org/plugins/info/1.0/';
     13        public $api_endpoint_1_1         = 'http://api.wordpress.org/plugins/info/1.1/';
     14        public $api_endpoint_plugin_php  = 'http://api.wordpress.org/plugins/info/1.0/jetpack.php';
     15        public $api_endpoint_plugin_xml  = 'http://api.wordpress.org/plugins/info/1.0/jetpack.xml';
    1616        public $api_endpoint_plugin_json = 'http://api.wordpress.org/plugins/info/1.0/jetpack.json';
    1717
    18         public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end
     18        public $user_agent      = 'WordPress/4.8'; // Tell the API to use the v3 back-end
    1919        public $timeout_seconds = 5.0;
    2020
     
    6161                $median = $values[ floor( count( $values ) / 2 ) ];
    6262
    63                 return "mean ". number_format( $mean, $decimals ) . ", median " . number_format( $median, $decimals );
     63                return 'mean ' . number_format( $mean, $decimals ) . ', median ' . number_format( $median, $decimals );
    6464
    6565        }
     
    6868                global $wporg_plugin_api_performance;
    6969
    70                 echo "Performance summary for ". get_called_class() . ":\n";
     70                echo 'Performance summary for ' . get_called_class() . ":\n";
    7171                foreach ( $wporg_plugin_api_performance[ get_called_class() ] as $type => $deltas ) {
    7272                        echo "$type: " . self::averages( $deltas ) . "\n";
     
    100100
    101101                // The 50 most common plugin tags
    102                 $common_terms = explode( ' ', 'widget post admin woocommerce posts comments shortcode twitter google images facebook sidebar image seo page gallery social email links login ecommerce widgets video rss buddypress pages jquery spam content security ajax media slider feed category search analytics menu embed javascript e-commerce link css form comment share youtube custom categories theme');
     102                $common_terms = explode( ' ', 'widget post admin woocommerce posts comments shortcode twitter google images facebook sidebar image seo page gallery social email links login ecommerce widgets video rss buddypress pages jquery spam content security ajax media slider feed category search analytics menu embed javascript e-commerce link css form comment share youtube custom categories theme' );
    103103
    104104                // Each item represents the function arguments to a plugins_api() call.
    105105                $r = array(
    106                         array( 'plugin_information', array( 'slug' => 'jetpack', 'fields' => $this->fields ) ),
    107                         array( 'query_plugins', array( 'browse' => 'updated', 'per_page' => 24, 'page'=> 103, 'fields' => $this->fields )),
    108                         array( 'query_plugins', array( 'user' => 'dd32', 'fields' => $this->fields )),
    109                         array( 'query_plugins', array( 'browse' => 'popular', 'per_page' => 20, 'fields' => $this->fields ) ),
    110                         array( 'query_plugins', array( 'browse' => 'recommended', 'installed_plugins' => array( 'akismet', 'jetpack' ), 'fields' => $this->fields ) )
     106                        array(
     107                                'plugin_information',
     108                                array(
     109                                        'slug'   => 'jetpack',
     110                                        'fields' => $this->fields,
     111                                ),
     112                        ),
     113                        array(
     114                                'query_plugins',
     115                                array(
     116                                        'browse'   => 'updated',
     117                                        'per_page' => 24,
     118                                        'page'     => 103,
     119                                        'fields'   => $this->fields,
     120                                ),
     121                        ),
     122                        array(
     123                                'query_plugins',
     124                                array(
     125                                        'user'   => 'dd32',
     126                                        'fields' => $this->fields,
     127                                ),
     128                        ),
     129                        array(
     130                                'query_plugins',
     131                                array(
     132                                        'browse'   => 'popular',
     133                                        'per_page' => 20,
     134                                        'fields'   => $this->fields,
     135                                ),
     136                        ),
     137                        array(
     138                                'query_plugins',
     139                                array(
     140                                        'browse'            => 'recommended',
     141                                        'installed_plugins' => array( 'akismet', 'jetpack' ),
     142                                        'fields'            => $this->fields,
     143                                ),
     144                        ),
    111145                );
    112146
    113147                // 20 random searches
    114                 for ( $i=0; $i < 20; $i++ ) {
     148                for ( $i = 0; $i < 20; $i++ ) {
    115149                        $random_search = join( ' ', array_rand( array_flip( $common_terms ), 3 ) ); // 3 random terms
    116                         $r[] = array( 'query_plugins', array( 'search'   => $random_search, 'per_page' => 15, 'page' => 3, 'fields' => $this->fields ) );
     150                        $r[]           = array(
     151                                'query_plugins',
     152                                array(
     153                                        'search'   => $random_search,
     154                                        'per_page' => 15,
     155                                        'page'     => 3,
     156                                        'fields'   => $this->fields,
     157                                ),
     158                        );
    117159                }
    118160
    119161                // 100 recently updated plugins
    120                 $recently_updated_plugins = plugins_api( 'query_plugins',
    121                                 array(
    122                                         'browse' => 'updated',
    123                                         'fields' => array( 'description' => false, 'short_description' => false ),
    124                                         'per_page' => 100,
    125                                         'page' => rand(0 , 400),
    126                                         )
    127                                 );
     162                $recently_updated_plugins = plugins_api( 'query_plugins', array(
     163                        'browse'   => 'updated',
     164                        'fields'   => array(
     165                                'description'       => false,
     166                                'short_description' => false,
     167                        ),
     168                        'per_page' => 100,
     169                        'page'     => rand( 0, 400 ),
     170                ) );
    128171                $this->assertFalse( is_wp_error( $recently_updated_plugins ) );
    129                 $this->assertEquals( 100, count( $recently_updated_plugins->plugins ));
    130                 foreach ( $recently_updated_plugins->plugins as $plugin )
    131                         $r[] = array( 'plugin_information', array( 'slug' => $plugin->slug, 'fields' => $this->fields ) );
     172                $this->assertEquals( 100, count( $recently_updated_plugins->plugins ) );
     173                foreach ( $recently_updated_plugins->plugins as $plugin ) {
     174                        $r[] = array(
     175                                'plugin_information',
     176                                array(
     177                                        'slug'   => $plugin->slug,
     178                                        'fields' => $this->fields,
     179                                ),
     180                        );
     181                }
    132182
    133183                return $r;
     
    139189         * @dataProvider performanceTestProvider
    140190         */
    141          function test_api_performance( $action, $args ) {
    142                 global $wporg_plugin_api_performance;
    143 
    144                 $start = microtime( true );
     191        function test_api_performance( $action, $args ) {
     192                global $wporg_plugin_api_performance;
     193
     194                $start    = microtime( true );
    145195                $response = plugins_api( $action, $args );
    146                 $delta = microtime( true ) - $start;
    147 
    148                 #error_log( get_class( $this ) . ": $action ". array_keys($args)[0]." ".array_values($args)[0]." took $delta" );
    149                 $wporg_plugin_api_performance[ get_class( $this ) ][ $action . ' ' . array_keys($args)[0] ][] = $delta;
     196                $delta    = microtime( true ) - $start;
     197
     198                // error_log( get_class( $this ) . ": $action ". array_keys($args)[0]." ".array_values($args)[0]." took $delta" );
     199                $wporg_plugin_api_performance[ get_class( $this ) ][ $action . ' ' . array_keys( $args )[0] ][] = $delta;
    150200
    151201                $this->assertLessThan( $this->timeout_seconds, $delta, "API call $action took $delta seconds" );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/wporg-plugin-api.php

    r5841 r6287  
    99class Tests_Plugins_API extends WP_UnitTestCase {
    1010
    11         public $api_endpoint_1_0 = 'http://api.wordpress.org/plugins/info/1.0/';
    12         public $api_endpoint_1_1 = 'http://api.wordpress.org/plugins/info/1.1/';
    13         public $api_endpoint_plugin_php = 'http://api.wordpress.org/plugins/info/1.0/jetpack.php';
    14         public $api_endpoint_plugin_xml = 'http://api.wordpress.org/plugins/info/1.0/jetpack.xml';
     11        public $api_endpoint_1_0         = 'http://api.wordpress.org/plugins/info/1.0/';
     12        public $api_endpoint_1_1         = 'http://api.wordpress.org/plugins/info/1.1/';
     13        public $api_endpoint_plugin_php  = 'http://api.wordpress.org/plugins/info/1.0/jetpack.php';
     14        public $api_endpoint_plugin_xml  = 'http://api.wordpress.org/plugins/info/1.0/jetpack.xml';
    1515        public $api_endpoint_plugin_json = 'http://api.wordpress.org/plugins/info/1.0/jetpack.json';
    1616
    17         public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end
     17        public $user_agent           = 'WordPress/4.8'; // Tell the API to use the v3 back-end
    1818        public $require_tested_value = true;
    1919
     
    4242                'active_installs'   => true,
    4343                'contributors'      => true,
    44                 'donate_link'           => true,
     44                'donate_link'       => true,
    4545        );
    4646
     
    7979
    8080        function test_wporg_plugin_api_serialize_php() {
    81                 $response = $this->api_remote_post( $this->api_endpoint_1_0, 'plugin_information', array( 'slug' => 'jetpack', 'fields' => $this->fields ) );
    82                 $plugins = maybe_unserialize( wp_remote_retrieve_body( $response ) );
     81                $response = $this->api_remote_post( $this->api_endpoint_1_0, 'plugin_information', array(
     82                        'slug'   => 'jetpack',
     83                        'fields' => $this->fields,
     84                ) );
     85                $plugins  = maybe_unserialize( wp_remote_retrieve_body( $response ) );
    8386
    8487                $this->_check_response_attributes( $plugins );
     
    8689
    8790        function test_wporg_plugin_api_serialize_php_get() {
    88                 $url      = add_query_arg( 'fields', implode( ',' , array_keys( $this->fields ) ), $this->api_endpoint_plugin_php );
     91                $url      = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_php );
    8992                $response = $this->api_remote_get( $url );
    9093                $plugins  = maybe_unserialize( wp_remote_retrieve_body( $response ) );
     
    9497
    9598        function test_wporg_plugin_api_xml() {
    96                 $url      = add_query_arg( 'fields', implode( ',' , array_keys( $this->fields ) ), $this->api_endpoint_plugin_xml );
     99                $url      = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_xml );
    97100                $response = $this->api_remote_get( $url );
    98101                $plugins  = wp_remote_retrieve_body( $response );
     
    104107
    105108        function test_wporg_plugin_api_json() {
    106                 $url      = add_query_arg( 'fields', implode( ',' , array_keys( $this->fields ) ), $this->api_endpoint_plugin_json );
     109                $url      = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_json );
    107110                $response = $this->api_remote_get( $url );
    108111                $plugins  = (object) json_decode( wp_remote_retrieve_body( $response ), true );
     
    116119                        'body'    => array(
    117120                                'action'  => 'plugin_information',
    118                                 'request' => (object) array( 'slug' => 'jetpack', 'fields' => $this->fields ),
     121                                'request' => (object) array(
     122                                        'slug'   => 'jetpack',
     123                                        'fields' => $this->fields,
     124                                ),
    119125                        ),
    120126                        'headers' => array( 'Host', 'api.wordpress.org' ),
    121 
    122127                ) );
    123128
     
    127132
    128133        function test_plugins_api_function_action_plugin_information() {
    129                 $plugins = plugins_api( 'plugin_information', array( 'slug' => 'jetpack', 'fields' => $this->fields ) );
     134                $plugins = plugins_api( 'plugin_information', array(
     135                        'slug'   => 'jetpack',
     136                        'fields' => $this->fields,
     137                ) );
    130138                $this->_check_response_attributes( $plugins );
    131139        }
     
    145153
    146154                // If search term exactly matches a slug, it should be returned first.
    147                 $plugins  = plugins_api( 'query_plugins', array( 'search' => $slug ) );
     155                $plugins = plugins_api( 'query_plugins', array( 'search' => $slug ) );
    148156                $this->assertEquals( $plugins->plugins[0]->slug, $slug );
    149157        }
     
    152160        function test_plugins_api_function_action_query_plugins_tag() {
    153161                $tag     = 'widget';
    154                 $plugins = plugins_api( 'query_plugins', array( 'tag' => $tag, 'fields' => $this->fields ) );
     162                $plugins = plugins_api( 'query_plugins', array(
     163                        'tag'    => $tag,
     164                        'fields' => $this->fields,
     165                ) );
    155166
    156167                foreach ( $plugins->plugins as $plugin ) {
     
    163174        function test_plugins_api_function_action_query_plugins_author() {
    164175                $author  = 'wordpressdotorg';
    165                 $plugins = plugins_api( 'query_plugins', array( 'author' => $author, 'fields' => $this->fields ) );
     176                $plugins = plugins_api( 'query_plugins', array(
     177                        'author' => $author,
     178                        'fields' => $this->fields,
     179                ) );
    166180
    167181                foreach ( $plugins->plugins as $plugin ) {
     
    173187        // Favorites.
    174188        function test_plugins_api_function_action_query_plugins_user() {
    175                 $plugins = plugins_api( 'query_plugins', array( 'user' => 'markjaquith', 'fields' => $this->fields ) );
     189                $plugins = plugins_api( 'query_plugins', array(
     190                        'user'   => 'markjaquith',
     191                        'fields' => $this->fields,
     192                ) );
    176193                $this->_check_response_plugin_query( $plugins, 1 );
    177194        }
    178195
    179196        function test_plugins_api_function_action_query_plugins_browse() {
    180                 $plugins = plugins_api( 'query_plugins', array( 'browse' => 'popular', 'fields' => $this->fields ) );
     197                $plugins = plugins_api( 'query_plugins', array(
     198                        'browse' => 'popular',
     199                        'fields' => $this->fields,
     200                ) );
    181201                $this->_check_response_plugin_query( $plugins );
    182202        }
    183203
    184204        function test_plugins_api_function_action_query_plugins_installed_plugins() {
    185                 $plugins = plugins_api( 'query_plugins', array( 'browse' => 'recommended', 'installed_plugins' => array( 'jetpack' ), 'fields' => $this->fields ) );
     205                $plugins = plugins_api( 'query_plugins', array(
     206                        'browse'            => 'recommended',
     207                        'installed_plugins' => array( 'jetpack' ),
     208                        'fields'            => $this->fields,
     209                ) );
    186210                $this->_check_response_plugin_query( $plugins, 1 );
    187211        }
     
    189213        function test_plugins_api_function_action_query_plugins_local() {
    190214                // Not yet implemented. Shouldn't change the structure of the response though.
    191                 $plugins = plugins_api( 'query_plugins', array( 'local' => 'hello', 'fields' => $this->fields ) );
     215                $plugins = plugins_api( 'query_plugins', array(
     216                        'local'  => 'hello',
     217                        'fields' => $this->fields,
     218                ) );
    192219                $this->_check_response_plugin_query( $plugins, 1 );
    193220        }
     
    321348class Tests_Plugins_API_Old extends Tests_Plugins_API {
    322349        public $user_agent = 'WordPress/4.7'; // Tell the API to use the old back-end
     350
    323351        public $require_tested_value = false; // Old API omits 'tested' if its value is empty
    324 
    325 
    326352}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/wporg-url-schemes.php

    r5172 r6287  
    55        function http_get( $uri ) {
    66                $base_url = 'https://wordpress.org';
    7                 $url = $base_url . $uri;
     7                $url      = $base_url . $uri;
    88
    99                $http_args = array(
    1010                        'timeout' => 15,
    11                         #'body' => array(
    12                         #       'action' => $action,
    13                         #       'request' => serialize( $args )
    14                         #),
    15                         #'user-agent' => $user_agent,
     11                        // 'body' => array(
     12                        // 'action' => $action,
     13                        // 'request' => serialize( $args )
     14                        // ),
     15                        // 'user-agent' => $user_agent,
    1616                );
    1717                $request = wp_remote_get( $url, $http_args );
     
    2323                return [
    2424                        [ '/plugins/add/' ],
    25                         [ '/plugins/about/'],
     25                        [ '/plugins/about/' ],
    2626                        [ '/plugins/about/guidelines/' ],
    2727                        [ '/plugins/about/svn/' ],
     
    6161        /**
    6262         * @dataProvider urlProvider
    63         */
     63         */
    6464        function test_url( $url ) {
    6565                $response = $this->http_get( $url );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-committers.php

    r5716 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Widgets;
     3
    34use WordPressdotorg\Plugin_Directory\Template;
    45use WordPressdotorg\Plugin_Directory\Tools;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-contributors.php

    r5924 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Widgets;
     3
    34use WordPressdotorg\Plugin_Directory\Template;
    45
     
    3031
    3132                $contributors = get_terms( array(
    32                         'taxonomy' => 'plugin_contributors',
     33                        'taxonomy'   => 'plugin_contributors',
    3334                        'object_ids' => array( $post->ID ),
    34                         'orderby' => 'term_order',
    35                         'fields' => 'names',
     35                        'orderby'    => 'term_order',
     36                        'fields'     => 'names',
    3637                ) );
    3738
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-meta.php

    r6033 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Widgets;
     3
    34use WordPressdotorg\Plugin_Directory\Plugin_I18n;
    45use WordPressdotorg\Plugin_Directory\Template;
     
    4344                        <li>
    4445                                <?php
    45                                 printf( __( 'Last updated: %s', 'wporg-plugins' ),
     46                                printf(
     47                                        __( 'Last updated: %s', 'wporg-plugins' ),
    4648                                        /* Translators: Plugin modified time. */
    4749                                        '<strong>' . sprintf( __( '%s ago', 'wporg-plugins' ), '<span>' . human_time_diff( get_post_modified_time() ) . '</span>' ) . '</strong>'
     
    5254
    5355                        <?php if ( $requires = (string) get_post_meta( $post->ID, 'requires', true ) ) : ?>
    54                                 <li><?php
     56                                <li>
     57                                <?php
    5558                                _e( 'Requires WordPress Version:', 'wporg-plugins' );
    5659                                echo '<strong>' . esc_html( $requires ) . '</strong>';
    57                                 ?></li>
     60                                ?>
     61                                </li>
    5862                        <?php endif; ?>
    5963
     
    6367
    6468                        <?php if ( $requires_php = (string) get_post_meta( $post->ID, 'requires_php', true ) ) : ?>
    65                                 <li><?php
     69                                <li>
     70                                <?php
    6671                                _e( 'Requires PHP Version:', 'wporg-plugins' );
    6772                                echo '<strong>' . esc_html( $requires_php ) . '</strong>';
    68                                 ?></li>
     73                                ?>
     74                                </li>
    6975                        <?php endif; ?>
    7076
     
    7682                                <li>
    7783                                        <?php
    78                                         if ( 1 === $available_languages_count ) {
    79                                                 _e( 'Language:', 'wporg-plugins' );
    80                                         } else {
    81                                                 _e( 'Languages:', 'wporg-plugins' );
    82                                         }
     84                                        echo esc_html( _n( 'Language:', 'Languages:', 'wporg-plugins', $available_languages_count ) );
    8385
    8486                                        echo '<div class="languages">';
     
    104106                                                        <div class="popover-inner">
    105107                                                                <p><?php echo wp_sprintf( '%l.', $available_languages ); ?></p>
    106                                                                 <p><?php
    107                                                                         printf( '<a href="%s">%s</a>',
     108                                                                <p>
     109                                                                <?php
     110                                                                        printf(
     111                                                                                '<a href="%s">%s</a>',
    108112                                                                                esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $post->post_name ),
    109113                                                                                __( 'Translate into your language', 'wporg-plugins' )
    110114                                                                        );
    111                                                                 ?></p>
     115                                                                ?>
     116                                                                </p>
    112117                                                        </div>
    113118                                                </div>
     
    125130
    126131                        <?php if ( $tags = get_the_term_list( $post->ID, 'plugin_tags', '<div class="tags">', '', '</div>' ) ) : ?>
    127                                 <li class="clear"><?php
     132                                <li class="clear">
     133                                        <?php
    128134                                        $terms = get_the_terms( $post, 'plugin_tags' );
    129                                         if ( 1 == count( $terms ) ) {
    130                                                 /* translators: %s: tag list */
    131                                                 printf( __( 'Tag: %s', 'wporg-plugins' ), $tags );
    132                                         } else {
    133                                                 /* translators: %s: tag list */
    134                                                 printf( __( 'Tags: %s', 'wporg-plugins' ), $tags );
    135                                         }
    136                                 ?></li>
     135                                        /* translators: %s: tag list */
     136                                        printf( _n( 'Tag: %s', 'Tags: %s', count( $terms ), 'wporg-plugins' ), $tags );
     137                                        ?>
     138                                </li>
    137139                        <?php endif; ?>
    138140
     
    140142                                <li class="hide-if-no-js">
    141143                                        <?php
    142                                                 printf( '<strong><a class="plugin-admin" href="%s">%s</a></strong>', esc_url( get_permalink() . 'advanced/' ), __( 'Advanced View', 'wporg-plugins' ) );
     144                                        printf(
     145                                                '<strong><a class="plugin-admin" href="%s">%s</a></strong>',
     146                                                esc_url( get_permalink() . 'advanced/' ),
     147                                                __( 'Advanced View', 'wporg-plugins' )
     148                                        );
    143149                                        ?>
    144150                                </li>
     
    156162         */
    157163        private function available_languages() {
    158                 $post    = get_post();
    159                 $slug    = $post->post_name;
    160                 $locales = Plugin_I18n::instance()->get_translations( $slug );
     164                $post      = get_post();
     165                $slug      = $post->post_name;
     166                $locales   = Plugin_I18n::instance()->get_translations( $slug );
    161167                $languages = [];
    162168
    163169                if ( ! empty( $locales ) ) {
    164170                        $locale_names = wp_list_pluck( $locales, 'name', 'wp_locale' );
    165                         $wp_locales = wp_list_pluck( $locales,'wp_locale' );
     171                        $wp_locales   = wp_list_pluck( $locales, 'wp_locale' );
    166172
    167173                        $sites = get_sites( [
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php

    r5457 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Widgets;
     3
    34use WordPressdotorg\Plugin_Directory\Template;
    45
     
    3637                echo $args['before_widget'];
    3738                echo $args['before_title'] . $title . $args['after_title'];
     39
     40                if ( $rating ) :
    3841                ?>
    39 
    40                 <?php if ( $rating ) : ?>
    4142                        <a class="reviews-link" href="<?php echo esc_url( 'https://wordpress.org/support/plugin/' . $post->post_name . '/reviews/' ); ?>"><?php _ex( 'See all', 'reviews', 'wporg-plugins' ); ?></a>
    4243
     
    4647
    4748                        <ul class="ratings-list">
    48                                 <?php foreach ( range( 5, 1 ) as $stars ) :
     49                                <?php
     50                                foreach ( range( 5, 1 ) as $stars ) :
    4951                                        $rating_bar_width = $num_ratings ? 100 * $ratings[ $stars ] / $num_ratings : 0;
    5052                                        ?>
     
    6769                        </div>
    6870
    69                 <?php endif; // $rating
     71                <?php endif; // $rating ?>
    7072
    71                 if ( is_user_logged_in() ) : ?>
     73                <?php if ( is_user_logged_in() ) : ?>
    7274                        <div class="user-rating">
    7375                                <a class="button button-secondary" href="<?php echo esc_url( 'https://wordpress.org/support/plugin/' . $post->post_name . '/reviews/#new-post' ); ?>"><?php _e( 'Add my review', 'wporg-plugins' ); ?></a>
    7476                        </div>
    75                         <?php
     77                <?php
    7678                endif;
    7779
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support-reps.php

    r5867 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Widgets;
     3
    34use WordPressdotorg\Plugin_Directory\Template;
    45use WordPressdotorg\Plugin_Directory\Tools;
     
    1011 */
    1112class Support_Reps extends \WP_Widget {
     13
    1214        /**
    1315         * Support Reps constructor.
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support.php

    r5404 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Widgets;
    3 use WordPressdotorg\Plugin_Directory\Template;
     3
     4use WordPressdotorg\Plugin_Directory\Template;
    45
    56/**
     
    3536                $support_url = Template::get_support_url();
    3637
    37                 if ( false === strpos( $support_url, 'https://wordpress.org' ) ) { 
     38                if ( false === strpos( $support_url, 'https://wordpress.org' ) ) {
    3839                        $resolutions = false;
    39                 } 
     40                }
    4041
    4142                echo $args['before_widget'];
     
    4344
    4445                if ( $resolutions ) :
    45                         ?>
     46                ?>
    4647                        <p class="aside"><?php _e( 'Issues resolved in last two months:', 'wporg-plugins' ); ?></p>
    4748                        <p class="counter-container">
     
    5758                        </p>
    5859
    59                 <?php else: ?>
     60                <?php else : ?>
    6061                        <p><?php _e( 'Got something to say? Need help?', 'wporg-plugins' ); ?></p>
    6162                <?php endif; ?>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-builder.php

    r6281 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Zip;
     3
    34use WordPressdotorg\Plugin_Directory\Tools\SVN;
    45use Exception;
     
    1112class Builder {
    1213
    13         const TMP_DIR = '/tmp/plugin-zip-builder';
    14         const SVN_URL = 'https://plugins.svn.wordpress.org';
     14        const TMP_DIR     = '/tmp/plugin-zip-builder';
     15        const SVN_URL     = 'https://plugins.svn.wordpress.org';
    1516        const ZIP_SVN_URL = PLUGIN_ZIP_SVN_URL;
    1617
     
    6061                        $this->tmp_dir,
    6162                        array(
    62                                 'depth' => 'empty',
     63                                'depth'    => 'empty',
    6364                                'username' => PLUGIN_ZIP_SVN_USER,
    6465                                'password' => PLUGIN_ZIP_SVN_PASS,
     
    7071                        // Ensure the plugins folder exists within svn
    7172                        $plugin_folder = "{$this->tmp_dir}/{$this->slug}/";
     73
    7274                        $res = SVN::up(
    7375                                $plugin_folder,
    7476                                array(
    75                                         'depth' => 'empty'
     77                                        'depth' => 'empty',
    7678                                )
    7779                        );
     
    105107                        // This is done within the checksum generation function due to us not knowing the checksum filename until export_plugin().
    106108                        // SVN::up( $this->checksum_file );
    107 
    108109                        try {
    109110
    110                                 $this->tmp_build_dir  = $this->zip_file . '-files';
     111                                $this->tmp_build_dir = $this->zip_file . '-files';
    111112                                mkdir( $this->tmp_build_dir, 0777, true );
    112113
     
    120121                                $this->cleanup_plugin_tmp();
    121122
    122                         } catch( Exception $e ) {
     123                        } catch ( Exception $e ) {
    123124                                // In event of error, skip this file this time.
    124125                                $this->cleanup_plugin_tmp();
     
    203204
    204205                $skip_bad_files = array();
    205                 $checksums = array();
    206                 foreach ( array( 'md5' => 'md5sum', 'sha256' => 'sha256sum' ) as $checksum_type => $checksum_bin ) {
     206                $checksums      = array();
     207                foreach ( array(
     208                        'md5'    => 'md5sum',
     209                        'sha256' => 'sha256sum',
     210                ) as $checksum_type => $checksum_bin ) {
    207211                        $checksum_output = array();
    208212                        $this->exec( sprintf(
     
    212216
    213217                        if ( $return_value ) {
    214                         //      throw new Exception( __METHOD__ . ': Checksum generation failed, return code: ' . $return_value, 503 );
    215                         // TODO For now, just silently keep going.
     218                                // throw new Exception( __METHOD__ . ': Checksum generation failed, return code: ' . $return_value, 503 );
     219                                // TODO For now, just silently keep going.
    216220                                continue;
    217221                        }
     
    219223                        foreach ( $checksum_output as $line ) {
    220224                                list( $checksum, $filename ) = preg_split( '!\s+!', $line, 2 );
     225
    221226                                $filename = trim( preg_replace( '!^./!', '', $filename ) );
    222227                                $checksum = trim( $checksum );
     
    228233
    229234                                if ( ! isset( $checksums[ $filename ] ) ) {
    230                                         $checksums[ $filename ] = array( 'md5' => array(), 'sha256' => array() );
     235                                        $checksums[ $filename ] = array(
     236                                                'md5'    => array(),
     237                                                'sha256' => array(),
     238                                        );
    231239                                }
    232240
     
    249257                        // Sometimes plugin versions exist in multiple tags/zips, include all the SVN urls & ZIP urls
    250258                        foreach ( array( 'source', 'zip' ) as $maybe_different ) {
    251                                 if ( !empty( $existing_json_checksum_file->{$maybe_different} ) &&
     259                                if ( ! empty( $existing_json_checksum_file->{$maybe_different} ) &&
    252260                                        $existing_json_checksum_file->{$maybe_different} != $json_checksum_file->{$maybe_different}
    253261                                ) {
    254262                                        $json_checksum_file->{$maybe_different} = array_unique( array_merge(
    255263                                                (array) $existing_json_checksum_file->{$maybe_different},
    256                                                 (array) $json_checksum_file->{$maybe_different}
     264                                                (array) $json_checksum_file->{$maybe_different}
    257265                                        ) );
    258266
     
    282290                                                $json_checksum_file->files[ $file ][ $checksum_type ] = array_unique( array_merge(
    283291                                                        (array) $checksums->{$checksum_type}, // May already be an array
    284                                                         (array) $json_checksum_file->files[ $file ][ $checksum_type ]
     292                                                        (array) $json_checksum_file->files[ $file ][ $checksum_type ]
    285293                                                ) );
     294
    286295                                                // Reduce single arrays back to a string when possible.
    287296                                                if ( 1 == count( $json_checksum_file->files[ $file ][ $checksum_type ] ) ) {
     
    291300                                }
    292301                        }
    293 
    294302                }
    295303
     
    317325                $i = 0;
    318326                do {
    319                         $rand = uniqid();
     327                        $rand     = uniqid();
    320328                        $filename = "{$dir}/{$prefix}-{$rand}{$i}{$suffix}";
    321                 } while ( false === ($fp = @fopen( $filename, 'x' ) ) && $i++ < 50 );
     329                } while ( false === ( $fp = @fopen( $filename, 'x' ) ) && $i++ < 50 );
    322330
    323331                if ( $i >= 50 ) {
     
    358366                // Handle tags which we store as 0.blah but are in /tags/.blah
    359367                if ( ! $res['result'] && '0.' == substr( $this->version, 0, 2 ) ) {
    360                         $_version = substr( $this->version, 1 );
     368                        $_version                     = substr( $this->version, 1 );
    361369                        $this->plugin_version_svn_url = self::SVN_URL . "/{$this->slug}/tags/{$_version}/";
    362                         $res = SVN::export( $this->plugin_version_svn_url, $build_dir, $svn_params );
     370                        $res                          = SVN::export( $this->plugin_version_svn_url, $build_dir, $svn_params );
    363371                }
    364372                if ( ! $res['result'] ) {
     
    449457                        foreach ( $plugins_downloads_load_balancer /* TODO */ as $lb ) {
    450458                                $url = 'http://' . $lb . PLUGIN_ZIP_X_ACCEL_REDIRECT_LOCATION . $zip;
    451                                 wp_remote_request(
    452                                         $url,
    453                                         array(
    454                                                 'method' => 'PURGE',
    455                                         )
    456                                 );
     459
     460                                wp_remote_request( $url, array(
     461                                        'method' => 'PURGE',
     462                                ) );
    457463                        }
    458464                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-serve.php

    r6163 r6287  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Zip;
     3
    34use Exception;
    45
     
    2223                                $this->record_stats( $request );
    2324                        }
    24 
    25                 } catch ( Exception $e )  {
     25                } catch ( Exception $e ) {
    2626                        $this->error();
    2727                }
     
    3838                $zip  = basename( $path );
    3939
    40                 if ( preg_match( "!^(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.zip$!i", $zip, $m ) ) {
     40                if ( preg_match( '!^(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.zip$!i', $zip, $m ) ) {
    4141                        // ZIP
    4242                        $checksum_request = false;
    43                 } elseif ( preg_match( "!^/plugin-checksums/(?P<slug>[a-z0-9-_]+)/(?P<version>.+?)(\.json)?$!i", $path, $m ) ) {
     43                } elseif ( preg_match( '!^/plugin-checksums/(?P<slug>[a-z0-9-_]+)/(?P<version>.+?)(\.json)?$!i', $path, $m ) ) {
    4444                        // Checksums
    4545                        $checksum_request = true;
    4646                } else {
    47                         throw new Exception( __METHOD__ . ": Invalid URL." );
     47                        throw new Exception( __METHOD__ . ': Invalid URL.' );
    4848                }
    4949
     
    6060                // Checksum requests for 'trunk' are not possible.
    6161                if ( $checksum_request && 'trunk' == $version ) {
    62                         throw new Exception( __METHOD__ . ": Checksum requests must include a version." );
     62                        throw new Exception( __METHOD__ . ': Checksum requests must include a version.' );
    6363                }
    6464
     
    7474
    7575                } elseif ( isset( $_GET['nostats'] ) ) {
    76                         $args['stats'] = !empty( $_GET['nostats'] );
     76                        $args['stats'] = ! empty( $_GET['nostats'] );
    7777                }
    7878
     
    9393                // Determine the stable_tag
    9494                $meta = wp_cache_get( $post_id, 'post_meta' );
     95
    9596                $version = false;
    9697                if ( isset( $meta['stable_tag'][0] ) ) {
     
    191192                global $wpdb;
    192193
    193                 $stats_dedup_log_table = PLUGINS_TABLE_PREFIX . 'downloads';
    194                 $stats_download_table = PLUGINS_TABLE_PREFIX . 'download_counts';
     194                $stats_dedup_log_table      = PLUGINS_TABLE_PREFIX . 'downloads';
     195                $stats_download_table       = PLUGINS_TABLE_PREFIX . 'download_counts';
    195196                $stats_download_daily_table = PLUGINS_TABLE_PREFIX . 'stats';
    196197
     
    201202                        WHERE
    202203                                plugin_slug = %s AND
    203                                 client_ip = %s AND
    204                                 user_agent = %s AND
    205                                 stamp BETWEEN %s AND %s
     204                                client_ip = %s AND
     205                                user_agent = %s AND
     206                                stamp BETWEEN %s AND %s
    206207                        LIMIT 1",
    207208                        $request['slug'],
     
    231232                        'client_ip'   => $_SERVER['REMOTE_ADDR'],
    232233                        'user_agent'  => $_SERVER['HTTP_USER_AGENT'],
    233                         'stamp'       => gmdate( 'Y-m-d H:i:s' )
    234                 ) );
    235 
     234                        'stamp'       => gmdate( 'Y-m-d H:i:s' ),
     235                ) );
    236236        }
    237237
     
    240240         */
    241241        protected function error() {
    242                 $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
     242                $protocol  = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
    243243                $protocol .= ' ';
    244244
Note: See TracChangeset for help on using the changeset viewer.