Changeset 6287
- Timestamp:
- 12/19/2017 04:22:37 PM (7 years ago)
- 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 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin; 3 3 4 use \WordPressdotorg\Plugin_Directory; 4 5 use \WordPressdotorg\Plugin_Directory\Tools; … … 49 50 add_action( 'do_meta_boxes', array( $this, 'replace_title_global' ) ); 50 51 51 add_filter( 'postbox_classes_plugin_internal-notes', 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', 54 add_filter( 'wp_ajax_add-committer', 55 add_filter( 'wp_ajax_delete-committer', 56 add_filter( 'wp_ajax_add-support-rep', 57 add_filter( 'wp_ajax_delete-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' ) ); 58 59 add_action( 'wp_ajax_plugin-author-lookup', array( __NAMESPACE__ . '\Metabox\Author', 'lookup_author' ) ); 59 60 } … … 204 205 205 206 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 ) ); 212 215 } 213 216 … … 277 280 278 281 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 ) ); 280 283 } 281 284 } … … 331 334 return $data; 332 335 } 333 336 334 337 $existing_plugin = Plugin_Directory\Plugin_Directory::get_plugin_post( $data['post_name'] ); 335 338 … … 416 419 ); 417 420 418 419 421 add_meta_box( 420 422 'plugin-fields', … … 449 451 450 452 // Remove unnecessary metaboxes. 451 remove_meta_box( 'commentsdiv', 453 remove_meta_box( 'commentsdiv', 'plugin', 'normal' ); 452 454 remove_meta_box( 'commentstatusdiv', 'plugin', 'normal' ); 453 455 … … 489 491 * Changes the permalink for internal notes to link to the edit post screen. 490 492 * 491 * @param string $link The comment permalink with '#comment-$id' appended.493 * @param string $link The comment permalink with '#comment-$id' appended. 492 494 * @param \WP_Comment $comment The current comment object. 493 495 * @return string The permalink to the given comment. … … 602 604 ob_start(); 603 605 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'; 605 607 _wp_dashboard_recent_comments_row( $comment ); 606 608 } else { … … 618 620 'id' => $comment->comment_ID, 619 621 'data' => $comment_list_item, 620 'position' => $position 622 'position' => $position, 621 623 ); 622 624 … … 631 633 _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments', 'wporg-plugins' ), 632 634 number_format_i18n( $counts->moderated ) 633 ) 635 ), 634 636 ); 635 637 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
r6229 r6287 96 96 97 97 // ...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( 99 100 'new', 100 101 'pending', 101 ) ) ) { 102 ) 103 ) ) { 102 104 return $data; 103 105 } … … 131 133 $this->approved( $post->ID, $post ); 132 134 break; 135 133 136 case 'rejected': 134 137 $this->rejected( $post->ID, $post ); 135 138 break; 139 136 140 case 'publish': 137 141 $this->clean_closed_date( $post->ID ); 138 142 break; 143 139 144 case 'disabled': 140 145 case 'closed': … … 163 168 } 164 169 165 /* Temporarily disable SVN prefill from ZIP files 170 /* 171 Temporarily disable SVN prefill from ZIP files 166 172 if ( $attachments ) { 167 173 $attachment = end( $attachments ); … … 191 197 192 198 /* 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. 194 202 195 203 Within 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. … … 223 231 -- 224 232 The WordPress Plugin Directory Team 225 https://make.wordpress.org/plugins', 'wporg-plugins' ), 233 https://make.wordpress.org/plugins', 'wporg-plugins' 234 ), 226 235 $post->post_title, 227 236 $post->post_name … … 256 265 257 266 /* 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. 259 270 260 271 If 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. … … 262 273 -- 263 274 The WordPress Plugin Directory Team 264 https://make.wordpress.org/plugins', 'wporg-plugins' ), 275 https://make.wordpress.org/plugins', 'wporg-plugins' 276 ), 265 277 $post->post_title, 266 278 'plugins@wordpress.org' … … 340 352 'comment_author' => $user->display_name, 341 353 'comment_author_email' => $user->user_email, 342 'comment_author_url' => $user->user_url, 354 'comment_author_url' => $user->user_url, 343 355 'comment_type' => 'internal-note', 344 356 'comment_post_ID' => $post_id, -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-committers.php
r5867 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\List_Table; 3 3 4 use WordPressdotorg\Plugin_Directory\Tools; 4 5 … … 45 46 */ 46 47 public function prepare_items() { 47 $plugin_slug 48 $plugin_slug = get_post()->post_name; 48 49 if ( ! $plugin_slug ) { 49 50 return; 50 51 } 51 $existing_committers = Tools::get_plugin_committers( $plugin_slug ); 52 $this->items 52 53 $this->items = array_map( function ( $user ) { 53 54 return new \WP_User( $user ); 54 }, $existing_committers);55 }, Tools::get_plugin_committers( $plugin_slug ) ); 55 56 } 56 57 … … 148 149 $user_object = get_userdata( (int) $user_object ); 149 150 } 150 $user_object->filter = 'display';151 $user_object->filter = 'display'; 151 152 list( $columns, $hidden, $primary ) = $this->get_column_info(); 152 153 … … 157 158 $post_id = get_post()->ID; 158 159 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&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&committer=' . $user_object->ID, "remove-committer-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . '</a>'; 160 161 } 161 162 … … 188 189 189 190 case 'username': 190 $row .= sprintf( '<strong><a href="%s">%s</a></strong><br /><%s>', 191 $row .= sprintf( 192 '<strong><a href="%s">%s</a></strong><br /><%s>', 191 193 esc_url( '//profiles.wordpress.org/' . $user_object->user_nicename ), 192 194 $user_object->user_login, -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-comments.php
r2764 r6287 38 38 $singular = $this->_args['singular']; 39 39 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' ); 41 41 ?> 42 42 <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" data-comment-type="<?php echo esc_attr( $this->comment_type ); ?>" style="display:none;"> … … 47 47 <tbody id="the-comment-list"<?php if ( $singular ) { echo " data-wp-lists='list:$singular'"; } ?>> 48 48 <?php 49 50 51 49 if ( ! $output_empty ) { 50 $this->display_rows_or_placeholder(); 51 } 52 52 ?> 53 53 </tbody> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
r5797 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\List_Table; 3 3 4 use \WordPressdotorg\Plugin_Directory\Tools; 4 5 use \WordPressdotorg\Plugin_Directory\Template; … … 21 22 22 23 $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' ); 24 25 25 26 /** This filter is documented in wp-admin/includes/post.php */ … … 33 34 $post_counts = (array) wp_count_posts( $post_type, 'readable' ); 34 35 35 if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] 36 if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati ) ) { 36 37 $total_items = $post_counts[ $_REQUEST['post_status'] ]; 37 38 } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { … … 60 61 $this->set_pagination_args( array( 61 62 'total_items' => $total_items, 62 'per_page' => $per_page63 'per_page' => $per_page, 63 64 ) ); 64 65 } … … 69 70 */ 70 71 protected function get_bulk_actions() { 71 $actions = array();72 $actions = array(); 72 73 $post_type_obj = get_post_type_object( $this->screen->post_type ); 73 74 … … 92 93 $post_type = $this->screen->post_type; 93 94 $posts_columns = array( 94 'cb' 95 'cb' => '<input type="checkbox" />', 95 96 /* translators: manage posts column name */ 96 'title' 97 'author' 97 'title' => _x( 'Title', 'column name', 'wporg-plugins' ), 98 'author' => __( 'Submitter', 'wporg-plugins' ), 98 99 ); 99 100 … … 104 105 105 106 foreach ( $taxonomies as $taxonomy ) { 106 $column_key = 'taxonomy-' . $taxonomy;107 $column_key = 'taxonomy-' . $taxonomy; 107 108 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; 108 109 } 109 110 110 111 $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' ); 112 113 113 114 /** … … 133 134 * 134 135 * @param int|\WP_Post $post 135 * @param int $level136 * @param int $level 136 137 */ 137 138 public function single_row( $post, $level = 0 ) { 138 139 $global_post = get_post(); 139 140 140 $post = get_post( $post );141 $post = get_post( $post ); 141 142 $this->current_level = $level; 142 143 … … 155 156 156 157 if ( $post->post_parent ) { 157 $count = count( get_post_ancestors( $post->ID ) );158 $count = count( get_post_ancestors( $post->ID ) ); 158 159 $classes[] = 'level-' . $count; 159 160 } else { … … 184 185 185 186 $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(); 189 190 190 191 if ( $can_edit_post && 'trash' != $post->post_status ) { … … 260 261 $screen = $this->screen; 261 262 262 $taxonomy_names = get_object_taxonomies( $screen->post_type );263 $taxonomy_names = get_object_taxonomies( $screen->post_type ); 263 264 $hierarchical_taxonomies = array(); 264 265 265 266 foreach ( $taxonomy_names as $taxonomy_name ) { 266 267 267 $taxonomy = get_taxonomy( $taxonomy_name ); 268 268 … … 302 302 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> 303 303 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> 305 305 <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 ) ); ?> 308 308 </ul> 309 309 … … 355 355 $mine = ''; 356 356 357 $plugins = Tools::get_users_write_access_plugins( $current_user_id );358 $plugins = array_map( 'sanitize_title_for_query', $plugins );359 $exclude_states 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( 360 360 'show_in_admin_all_list' => false, 361 361 ) ); … … 378 378 379 379 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 ); 381 381 } 382 382 … … 395 395 $mine_args = array( 396 396 'post_type' => $post_type, 397 'author' => $current_user_id 397 'author' => $current_user_id, 398 398 ); 399 399 … … 410 410 411 411 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 413 414 return $status_links; 414 415 } else { … … 417 418 418 419 $all_args['all_posts'] = 1; 419 $class = '';420 $class = ''; 420 421 } 421 422 … … 440 441 } 441 442 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 ) { 443 444 $class = ''; 444 445 … … 453 454 } 454 455 455 if ( isset( $_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) {456 if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) { 456 457 $class = 'current'; 457 458 } … … 459 460 $status_args = array( 460 461 'post_status' => $status_name, 461 'post_type' => $post_type,462 'post_type' => $post_type, 462 463 ); 463 464 … … 474 475 475 476 $sticky_args = array( 476 'post_type' 477 'show_sticky' => 1 477 'post_type' => $post_type, 478 'show_sticky' => 1, 478 479 ); 479 480 … … 490 491 491 492 $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 ), 493 494 ); 494 495 495 496 // 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 ) ); 497 498 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); 498 499 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-support-reps.php
r5867 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\List_Table; 3 3 4 use WordPressdotorg\Plugin_Directory\Tools; 4 5 … … 45 46 */ 46 47 public function prepare_items() { 47 $plugin_slug 48 $plugin_slug = get_post()->post_name; 48 49 if ( ! $plugin_slug ) { 49 50 return; 50 51 } 51 $existing_support_reps = Tools::get_plugin_support_reps( $plugin_slug ); 52 $this->items 52 53 $this->items = array_map( function ( $user ) { 53 54 return new \WP_User( $user ); 54 }, $existing_support_reps);55 }, Tools::get_plugin_support_reps( $plugin_slug ) ); 55 56 } 56 57 … … 148 149 $user_object = get_userdata( (int) $user_object ); 149 150 } 150 $user_object->filter = 'display';151 $user_object->filter = 'display'; 151 152 list( $columns, $hidden, $primary ) = $this->get_column_info(); 152 153 … … 157 158 $post_id = get_post()->ID; 158 159 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&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&support-rep=' . $user_object->ID, "remove-support-rep-{$user_object->ID}" ) . "'>" . __( 'Remove', 'wporg-plugins' ) . '</a>'; 160 161 } 161 162 … … 188 189 189 190 case 'username': 190 $row .= sprintf( '<strong><a href="%s">%s</a></strong><br /><%s>', 191 $row .= sprintf( 192 '<strong><a href="%s">%s</a></strong><br /><%s>', 191 193 esc_url( '//profiles.wordpress.org/' . $user_object->user_nicename ), 192 194 $user_object->user_login, -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-card.php
r6170 r6287 24 24 add_action( 'wporg_usercards_after_content', array( 25 25 __NAMESPACE__ . '\Author_Card', 26 'show_warning_flags' 26 'show_warning_flags', 27 27 ), 10, 6 ); 28 28 … … 39 39 } 40 40 41 $author_commit = Tools::get_users_write_access_plugins( $author );41 $author_commit = Tools::get_users_write_access_plugins( $author ); 42 42 $author_plugins_q = array( 43 43 'author' => $author->ID, … … 50 50 } 51 51 $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' ) ) ) . "')" ); 53 53 ?> 54 54 <div class="profile"> … … 59 59 <?php 60 60 $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>', 62 63 urlencode( esc_attr( $author->user_nicename ) ), 63 64 esc_attr__( 'Click to search Pluginrepo P2 for mentions of this author', 'wporg-plugins' ) 64 65 ), 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>', 66 68 urlencode( esc_attr( $author->user_nicename ) ), 67 69 esc_attr__( 'Click to search Pluginrepo SupportPress for mentions of this author', 'wporg-plugins' ) … … 77 79 <div class="profile-email"> 78 80 <<?php echo $author->user_email; ?>> 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> ]', 81 85 esc_attr( $author->user_email ), 82 86 esc_attr__( 'Click to search Pluginrepo SupportPress for emails sent to/from this email address', 'wporg-plugins' ) 83 87 ); 84 ?></span> 88 ?> 89 </span> 85 90 </div> 86 <div class="profile-join"><?php 91 <div class="profile-join"> 92 <?php 87 93 /* 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' ), 89 96 human_time_diff( strtotime( $author->user_registered ) ), 90 97 date( 'Y-M-d', strtotime( $author->user_registered ) ) 91 98 ); 92 ?></div> 99 ?> 100 </div> 93 101 </div> 94 102 </div> … … 103 111 <?php 104 112 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 ); 106 114 $statuses = array(); 107 115 … … 123 131 $labels = array(); 124 132 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>', 126 135 esc_attr( $status['desc'] ), 127 136 $status['text'] … … 150 159 151 160 /* 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>', 153 163 implode( ', ', array_map( array( __NAMESPACE__ . '\Author_Card', 'link_ip' ), $user_ips ) ) 154 164 ); … … 170 180 foreach ( $all_plugins as $plugin ) { 171 181 echo '<li>'; 172 $note = false;173 $extra = '';174 $classes = $tooltips = array();182 $note = false; 183 $extra = ''; 184 $classes = $tooltips = array(); 175 185 $last_updated = get_post_meta( $plugin->ID, 'last_updated', true ); 176 186 … … 187 197 if ( in_array( $plugin->post_status, array( 'new', 'pending' ) ) ) { 188 198 /* translators: %s: time ago */ 189 $extra .= sprintf( __( '(requested %s ago)', 'wporg-plugins' ), 199 $extra .= sprintf( 200 __( '(requested %s ago)', 'wporg-plugins' ), 190 201 human_time_diff( strtotime( $last_updated ) ) 191 202 ); … … 200 211 } elseif ( 'closed' === $plugin->post_status ) { 201 212 /* translators: %s: close/disable reason */ 202 $extra .= sprintf( __( '(closed: %s)', 'wporg-plugins' ), 213 $extra .= sprintf( 214 __( '(closed: %s)', 'wporg-plugins' ), 203 215 Template::get_close_reason( $plugin ) 204 216 ); … … 208 220 } elseif ( 'disabled' === $plugin->post_status ) { 209 221 /* translators: %s: close/disable reason */ 210 $extra .= sprintf( __( '(disabled: %s)', 'wporg-plugins' ), 222 $extra .= sprintf( 223 __( '(disabled: %s)', 'wporg-plugins' ), 211 224 Template::get_close_reason( $plugin ) 212 225 ); 213 226 $tooltips[] = __( 'Plugin is disabled (updates are active).', 'wporg-plugins' ); 214 227 $classes[] = 'profile-plugin-closed'; 215 $note = true;228 $note = true; 216 229 217 230 } else { … … 226 239 $tooltips[] = __( 'Plugin is open.', 'wporg-plugins' ); 227 240 } 228 $classes[] 241 $classes[] = 'profile-plugin-open'; 229 242 } 230 243 231 244 echo '<span>'; 232 245 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>', 234 248 esc_attr( implode( ' ', $classes ) ), 235 249 esc_attr( implode( ' ', $tooltips ) ), … … 243 257 244 258 $plugin_links = array( 245 sprintf( '<a href="%s" title="%s">%s</a>', 259 sprintf( 260 '<a href="%s" title="%s">%s</a>', 246 261 esc_url( get_edit_post_link( $plugin->ID, '' ) ), 247 262 esc_attr__( 'Edit this plugin', 'wporg-plugins' ), 248 263 __( 'Edit', 'wporg-plugins' ) 249 264 ), 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>', 251 267 urlencode( esc_attr( $plugin_slug ) ), 252 268 esc_attr__( 'Click to search Pluginrepo P2 for mentions of this plugin', 'wporg-plugins' ) 253 269 ), 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>', 255 272 urlencode( esc_attr( $plugin_slug ) ), 256 273 esc_attr__( 'Click to search Pluginrepo SupportPress for mentions of this plugin', 'wporg-plugins' ) … … 290 307 */ 291 308 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 ); 296 317 } 297 318 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author.php
r3506 r6287 15 15 */ 16 16 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' ) ); 20 24 21 25 ?> … … 27 31 jQuery( function( $ ) { 28 32 $( '#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 ); ?>', 30 34 minLength: 2, 31 35 delay: 700, -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php
r2994 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 3 4 use WordPressdotorg\Plugin_Directory\Admin\List_Table; 4 5 use WordPressdotorg\Plugin_Directory\Tools; … … 36 37 */ 37 38 public static function add_committer() { 38 $login 39 $post_id 39 $login = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : ''; 40 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 40 41 41 42 check_ajax_referer( 'add-committer' ); … … 85 86 */ 86 87 public static function remove_committer() { 87 $id = isset( $_POST['id'] ) ? (int) $_POST['id']: 0;88 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 88 89 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 89 90 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
r6162 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 3 4 use WordPressdotorg\Plugin_Directory\Admin\Status_Transitions; 4 5 use WordPressdotorg\Plugin_Directory\Template; … … 90 91 } 91 92 92 $close_reasons 93 $close_reason 93 $close_reasons = Template::get_close_reasons(); 94 $close_reason = (string) get_post_meta( $post->ID, '_close_reason', true ); 94 95 95 96 $reason_label = Template::get_close_reason(); … … 110 111 <?php endif; ?> 111 112 112 <?php if ( 113 <?php 114 if ( 113 115 ( in_array( 'closed', $statuses, true ) || in_array( 'disabled', $statuses, true ) ) 114 116 && 115 117 ( ! in_array( $post->post_status, array( 'closed', 'disabled' ) ) || $reason_unknown ) 116 ) : ?> 118 ) : 119 ?> 117 120 118 121 <p> … … 134 137 135 138 <?php endforeach; ?> 136 </div><!-- .misc-pub-section --><?php 139 </div><!-- .misc-pub-section --> 140 <?php 137 141 } 138 142 … … 148 152 <label for="tested_with"><?php _e( 'Tested With:', 'wporg-plugins' ); ?></label> 149 153 <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 --><?php154 </div><!-- .misc-pub-section --> 155 <?php 152 156 } 153 157 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-custom-fields.php
r5841 r6287 11 11 $post = get_post(); 12 12 $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', 23 23 'header_description' => 'Plugin Description', 24 24 ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-internal-notes.php
r2763 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 3 4 use WordPressdotorg\Plugin_Directory\Admin\List_Table\Plugin_Comments; 4 5 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-review-tools.php
r6028 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 3 4 use WordPressdotorg\Plugin_Directory\Tools; 4 5 … … 14 15 $zip_files = array(); 15 16 foreach ( get_attached_media( 'application/zip', $post ) as $zip_file ) { 16 $zip_files[ $zip_file->post_date ] = array( 17 $zip_files[ $zip_file->post_date ] = array( wp_get_attachment_url( $zip_file->ID ), $zip_file ); 17 18 } 18 19 uksort( $zip_files, function( $a, $b ) { … … 22 23 if ( $zip_url = get_post_meta( $post->ID, '_submitted_zip', true ) ) { 23 24 // Back-compat only. 24 $zip_files[ 'User provided URL'] = array( $zip_url, null );25 $zip_files['User provided URL'] = array( $zip_url, null ); 25 26 } 26 27 27 28 foreach ( $zip_files as $zip_date => $zip ) { 28 29 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>', 31 33 sprintf( '%s <a href="%s">%s</a> (%s)', esc_html( $zip_date ), esc_url( $zip_url ), esc_html( $zip_url ), esc_html( $zip_size ) ) 32 34 ); … … 65 67 $subject = sprintf( __( '[WordPress Plugin Directory] Notice: %s', 'wporg-plugins' ), $post->post_title ); 66 68 } 67 69 68 70 ?> 69 71 <form id="contact-author" class="contact-author" method="POST" action="https://supportpress.wordpress.org/plugins/thread-new.php"> … … 75 77 </form> 76 78 <?php 79 77 80 return $string; 78 81 } ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-support-reps.php
r5867 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 3 4 use WordPressdotorg\Plugin_Directory\Admin\List_Table; 4 5 use WordPressdotorg\Plugin_Directory\Tools; … … 36 37 */ 37 38 public static function add_support_rep() { 38 $login 39 $post_id 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; 40 41 41 42 check_ajax_referer( 'add-support-rep' ); … … 85 86 */ 86 87 public static function remove_support_rep() { 87 $id = isset( $_POST['id'] ) ? (int) $_POST['id']: 0;88 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 88 89 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 89 90 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-author-cards.php
r5314 r6287 25 25 */ 26 26 private function __construct() { 27 add_action( 'admin_menu', 27 add_action( 'admin_menu', array( $this, 'add_to_menu' ) ); 28 28 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 29 29 } … … 38 38 case 'tools_page_authorcards': 39 39 wp_enqueue_style( 'plugin-admin-post-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 4 ); 40 break;40 break; 41 41 } 42 42 } 43 43 44 44 public function add_to_menu() { 45 45 add_submenu_page( -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php
r5919 r6287 42 42 * Returns the stats. 43 43 * 44 * @param array 45 * 44 * @param array $args { 45 * Optional. Array of override arguments 46 46 * 47 47 * @type string $date The date (in Y-m-d format) for the end of the stats time interval (non-inclusive). Default today. … … 88 88 // Plugin Status Changes 89 89 // -------------- 90 91 90 $states = array( 'plugin_approve', 'plugin_delist', 'plugin_new', 'plugin_reject' ); 92 91 foreach ( $states as $state ) { 93 92 // The stats table used by bbPress1 (and could still be used, but isn't yet). 94 93 // 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( 96 95 "SELECT SUM(views) FROM stats_extras WHERE name = 'plugin' AND date < %s AND date > DATE_SUB( %s, INTERVAL %d DAY ) AND value = %s", 97 96 $args['date'], … … 104 103 // Temporary until the above is updated to work with the new directory: 105 104 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 } 107 108 } 108 109 … … 110 111 // Plugin Queue 111 112 // -------------- 112 113 113 // # of plugins currently in the queue that are new (have not been processed/replied to yet) 114 114 $stats['in_queue_new'] = $wpdb->get_var( … … 142 142 // SupportPress Queue 143 143 // -------------- 144 145 144 // # of currently open threads 146 145 $stats['supportpress_queue_total_open'] = $wpdb->get_var( … … 194 193 } 195 194 196 $args['num_days'] = empty( $_POST['days'] ) ? '' : absint( $_POST['days'] );195 $args['num_days'] = empty( $_POST['days'] ) ? '' : absint( $_POST['days'] ); 197 196 $args['recentdays'] = empty( $_POST['recentdays'] ) ? '' : absint( $_POST['recentdays'] ); 198 197 … … 212 211 <tr><th scope="row"><label for="date"><?php _e( 'Date', 'wporg-plugins' ); ?></label></th><td> 213 212 <input name="date" type="text" id="date" value="<?php echo esc_attr( $args['date'] ); ?>" class="text"> 214 <p><?php 213 <p> 214 <?php 215 215 /* 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' ), 217 218 $date 218 219 ); 219 ?></p> 220 ?> 221 </p> 220 222 </td></tr> 221 223 222 224 <tr><th scope="row"><label for="days"><?php _e( 'Number of days', 'wporg-plugins' ); ?></label></th><td> 223 225 <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 225 228 /* 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' ), 227 231 7 228 232 ); 229 ?></p> 233 ?> 234 </p> 230 235 </td></tr> 231 236 232 237 <tr><th scope="row"><label for="recentdays"><?php _e( '"Recent" number of days', 'wporg-plugins' ); ?></label></th><td> 233 238 <input name="recentdays" type="text" id="recentdays" value="<?php echo esc_attr( $args['recentdays'] ); ?>" class="small-text"> 234 <p><?php 239 <p> 240 <?php 235 241 /* 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' ), 237 244 7 238 245 ); 239 ?></p> 246 ?> 247 </p> 240 248 </td></tr> 241 249 … … 246 254 <h2><?php _e( 'Stats', 'wporg-plugins' ); ?></h2> 247 255 248 <p><?php 256 <p> 257 <?php 249 258 /* 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' ), 251 261 $stats['num_days'], 252 262 $stats['date'], 253 263 $stats['recentdays'] 254 264 ); 255 ?></p> 265 ?> 266 </p> 256 267 257 268 <h3><?php _e( 'Plugin Status Change Stats', 'wporg-plugins' ); ?></h3> 258 269 259 270 <ul style="font-family:Courier New;"> 260 <li><?php 271 <li> 272 <?php 261 273 /* translators: %d: number of requested plugins */ 262 printf( __( 'Plugins requested : %d', 'wporg-plugins' ), 274 printf( 275 __( 'Plugins requested : %d', 'wporg-plugins' ), 263 276 $stats['plugin_new'] 264 277 ); 265 ?></li> 266 <li><?php 278 ?> 279 </li> 280 <li> 281 <?php 267 282 /* translators: %s: number of rejected plugins */ 268 printf( __( 'Plugins rejected : %s', 'wporg-plugins' ), 283 printf( 284 __( 'Plugins rejected : %s', 'wporg-plugins' ), 269 285 $stats['plugin_reject'] 270 286 ); 271 ?></li> 272 <li><?php 287 ?> 288 </li> 289 <li> 290 <?php 273 291 /* translators: %s: number of closed plugins */ 274 printf( __( 'Plugins closed : %s', 'wporg-plugins' ), 292 printf( 293 __( 'Plugins closed : %s', 'wporg-plugins' ), 275 294 $stats['plugin_delist'] 276 295 ); 277 ?></li> 278 <li><?php 296 ?> 297 </li> 298 <li> 299 <?php 279 300 /* translators: %s: number of approved plugins */ 280 printf( __( 'Plugins approved : %s', 'wporg-plugins' ), 301 printf( 302 __( 'Plugins approved : %s', 'wporg-plugins' ), 281 303 $stats['plugin_approve'] 282 304 ); 283 ?></li> 305 ?> 306 </li> 284 307 </ul> 285 308 … … 287 310 288 311 <ul style="font-family:Courier New;"> 289 <li><?php 312 <li> 313 <?php 290 314 /* 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' ), 292 317 $stats['in_queue'] 293 318 ); 294 ?></li> 295 <li><?php 319 ?> 320 </li> 321 <li> 322 <?php 296 323 /* translators: 1: number of most recent days, 2: number of older plugins in the queue */ 297 printf( __( '→ (older than %1$d days ago)** : %2$d', 'wporg-plugins' ), 324 printf( 325 __( '→ (older than %1$d days ago)** : %2$d', 'wporg-plugins' ), 298 326 $stats['recentdays'], 299 327 $stats['in_queue_old'] 300 328 ); 301 ?></li> 302 <li><?php 329 ?> 330 </li> 331 <li> 332 <?php 303 333 /* translators: 1: start date, 2: end date, 3: number of plugins in the queue within defined time window */ 304 printf( __( '→ (%1$s - %2$s) : %3$d', 'wporg-plugins' ), 334 printf( 335 __( '→ (%1$s - %2$s) : %3$d', 'wporg-plugins' ), 305 336 $start_date, 306 337 $stats['date'], 307 338 $stats['in_queue_from_time_window'] 308 339 ); 309 ?></li> 310 <li><?php 340 ?> 341 </li> 342 <li> 343 <?php 311 344 /* translators: %d: number of new plugins */ 312 printf( __( '→ (new; not processed or replied to yet)* : %d', 'wporg-plugins' ), 345 printf( 346 __( '→ (new; not processed or replied to yet)* : %d', 'wporg-plugins' ), 313 347 $stats['in_queue_new'] 314 348 ); 315 ?></li> 316 <li><?php 349 ?> 350 </li> 351 <li> 352 <?php 317 353 /* translators: %d: number of pending plugins */ 318 printf( __( '→ (pending; replied to)* : %d', 'wporg-plugins' ), 354 printf( 355 __( '→ (pending; replied to)* : %d', 'wporg-plugins' ), 319 356 $stats['in_queue_pending'] 320 357 ); 321 ?></li> 358 ?> 359 </li> 322 360 </ul> 323 361 … … 325 363 326 364 <ul style="font-family:Courier New;"> 327 <li><?php 365 <li> 366 <?php 328 367 /* translators: %d: number of open tickets */ 329 printf( __( 'Total open tickets* : %d', 'wporg-plugins' ), 368 printf( 369 __( 'Total open tickets* : %d', 'wporg-plugins' ), 330 370 $stats['supportpress_queue_total_open'] 331 371 ); 332 ?></li> 333 <li><?php 372 ?> 373 </li> 374 <li> 375 <?php 334 376 /* translators: 1: number of most recent days, 2: number of plugins with no activity */ 335 printf( __( ' → (with no activity in last %1$d days)** : %2$d', 'wporg-plugins' ), 377 printf( 378 __( ' → (with no activity in last %1$d days)** : %2$d', 'wporg-plugins' ), 336 379 $stats['recentdays'], 337 380 $stats['supportpress_queue_total_open_old'] 338 381 ); 339 ?></li> 340 <li><?php 382 ?> 383 </li> 384 <li> 385 <?php 341 386 /* 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' ), 343 389 $stats['num_days'] 344 390 ); 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 347 395 /* translators: %d: total number of plugins within defined time window */ 348 printf( __( 'Total : %d', 'wporg-plugins' ), 396 printf( 397 __( 'Total : %d', 'wporg-plugins' ), 349 398 $stats['supportpress_queue_interval_all'] 350 399 ); 351 ?></li> 352 <li><?php 400 ?> 401 </li> 402 <li> 403 <?php 353 404 /* translators: %d: number of closed plugins within defined time window */ 354 printf( __( 'Closed : %d', 'wporg-plugins' ), 405 printf( 406 __( 'Closed : %d', 'wporg-plugins' ), 355 407 $stats['supportpress_queue_interval_closed'] 356 408 ); 357 ?></li> 358 <li><?php 409 ?> 410 </li> 411 <li> 412 <?php 359 413 /* translators: %d: number of open plugins within defined time window */ 360 printf( __( 'Open : %d', 'wporg-plugins' ), 414 printf( 415 __( 'Open : %d', 'wporg-plugins' ), 361 416 $stats['supportpress_queue_interval_open'] 362 417 ); 363 ?></li> 418 ?> 419 </li> 364 420 </ul> 365 421 </li> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/class-base.php
r5867 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 5 use WordPressdotorg\Plugin_Directory\Plugin_I18n; 6 use WordPressdotorg\Plugin_Directory\Template; 4 7 5 8 /** 6 9 * @package WordPressdotorg_Plugin_Directory 7 10 */ 8 9 11 class Base { 10 12 /** 11 * Initiali ses each API route we offer.13 * Initializes REST API customizations. 12 14 */ 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() { 14 24 new Routes\Internal_Stats(); 15 25 new Routes\Plugin(); … … 22 32 new Routes\Plugin_Committers(); 23 33 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(); 24 45 } 25 46 … … 58 79 return true; 59 80 } 60 61 81 } 62 63 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-commit-subscriptions.php
r3510 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\API\Base; … … 14 15 public function __construct() { 15 16 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( 19 20 'plugin_slug' => array( 20 21 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 21 22 ), 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 }, 24 27 ), 25 28 'unsubscribe' => array( 26 'validate_callback' => function( $bool ) { return is_numeric( $bool ); }, 29 'validate_callback' => function( $bool ) { 30 return is_numeric( $bool ); 31 }, 27 32 ), 28 33 ), 29 'permission_callback' => 'is_user_logged_in' 34 'permission_callback' => 'is_user_logged_in', 30 35 ) ); 31 36 } … … 42 47 43 48 $result = array( 44 "location"=> $location,49 'location' => $location, 45 50 ); 46 51 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-internal-stats.php
r5839 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\API\Base; … … 19 20 function __construct() { 20 21 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' ), 23 24 'permission_callback' => array( $this, 'permission_check_internal_api_bearer' ), 24 25 ) ); … … 112 113 protected function sanitize_usage_numbers( $usage, $plugin ) { 113 114 $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 ) ); 115 116 116 117 // Exclude any version strings higher than the latest plugin version (ie. 99.9) … … 126 127 127 128 // Calculate the percentage of each version branch 128 $total = array_sum( $usage );129 $total = array_sum( $usage ); 129 130 $others = array(); 130 131 foreach ( $usage as $version => $count ) { … … 141 142 // If there was only one version < $percent_cut_off then display it as-is 142 143 if ( count( $others ) == 1 ) { 143 $version = array_keys( $others );144 $version = array_shift( $version );144 $version = array_keys( $others ); 145 $version = array_shift( $version ); 145 146 $usage[ $version ] = round( $others[ $version ] / $total * 100, 2 ); 146 // Else we'll add an 'others' version.147 // Else we'll add an 'others' version. 147 148 } elseif ( count( $others ) > 1 ) { 148 149 $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 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\API\Base; 4 5 use WP_REST_Server; … … 15 16 'methods' => WP_REST_Server::EDITABLE, 16 17 'callback' => array( $this, 'locale_banner' ), 17 'args' => array(18 'args' => array( 18 19 'plugin_slug' => array( 19 20 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), … … 69 70 70 71 // 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 ); 73 74 $current_locale_is_translated = in_array( $current_locale, $translated_locales ); 74 75 … … 116 117 } 117 118 118 // Multiple locale suggestions.119 // Multiple locale suggestions. 119 120 } elseif ( ! empty( $suggest_named_locales ) ) { 120 $primary_locale = key( $suggest_named_locales );121 $primary_locale = key( $suggest_named_locales ); 121 122 $primary_language = current( $suggest_named_locales ); 122 123 array_shift( $suggest_named_locales ); … … 169 170 } 170 171 171 // Non-English locale in header, no translations.172 // Non-English locale in header, no translations. 172 173 } elseif ( $locales_from_header ) { 173 174 $locale = reset( $locales_from_header ); … … 180 181 } 181 182 182 // Localized directory.183 // Localized directory. 183 184 } elseif ( ! $current_locale_is_suggested && ! $current_locale_is_translated && $is_plugin_request ) { 184 185 $suggest_string = sprintf( … … 254 255 protected function get_http_locales( $header ) { 255 256 $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 257 259 if ( preg_match_all( "/$locale_re/i", $header, $matches ) ) { 258 260 return $matches[0]; … … 271 273 */ 272 274 protected function map_locale( $lang, $region, $available_locales ) { 273 $uregion = strtoupper( $region );274 $ulang = strtoupper( $lang );275 $uregion = strtoupper( $region ); 276 $ulang = strtoupper( $lang ); 275 277 $variants = array( 276 278 "$lang-$region", … … 353 355 354 356 // Strings for the POT file. 355 356 357 /* translators: %s: native language name. */ 357 358 __( '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 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\Template; … … 20 21 register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/committers/?', array( 21 22 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' ), 24 25 'permission_callback' => function( $request ) { 25 26 return current_user_can( … … 28 29 ); 29 30 }, 30 'args' => array(31 'args' => array( 31 32 'plugin_slug' => array( 32 33 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 33 'required' => true,34 'required' => true, 34 35 ), 35 ) 36 ), 36 37 ), 37 38 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' ), 40 41 'permission_callback' => function( $request ) { 41 42 return current_user_can( … … 44 45 ); 45 46 }, 46 'args' => array(47 'args' => array( 47 48 'plugin_slug' => array( 48 49 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 49 'required' => true,50 'required' => true, 50 51 ), 51 ) 52 ) 52 ), 53 ), 53 54 ) ); 54 55 55 56 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' ), 58 59 'permission_callback' => function( $request ) { 59 60 return current_user_can( … … 62 63 ); 63 64 }, 64 'args' => array(65 'args' => array( 65 66 'plugin_slug' => array( 66 67 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 67 'required' => true,68 'required' => true, 68 69 ), 69 'committer' => array(70 'committer' => array( 70 71 'validate_callback' => array( $this, 'validate_user_slug_callback' ), 71 'required' => true,72 ) 73 ) 72 'required' => true, 73 ), 74 ), 74 75 ) ); 75 76 } … … 83 84 $committers = array(); 84 85 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 ); 86 87 $committers[] = $this->user_committer_details( $user ); 87 88 } … … 158 159 'profile' => esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename ), 159 160 'avatar' => get_avatar_url( $user->ID, 32 ), 160 'name' => Template::encode( $user->display_name ) 161 'name' => Template::encode( $user->display_name ), 161 162 ); 162 163 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-favorites.php
r3545 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\API\Base; … … 14 15 public function __construct() { 15 16 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( 19 20 'plugin_slug' => array( 20 21 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 21 22 ), 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 }, 24 27 ), 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 }, 27 32 ), 28 33 ), 29 'permission_callback' => 'is_user_logged_in' 34 'permission_callback' => 'is_user_logged_in', 30 35 ) ); 31 36 } … … 42 47 43 48 $result = array( 44 "location"=> $location,49 'location' => $location, 45 50 ); 46 51 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-support-reps.php
r5930 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\Template; … … 20 21 register_rest_route( 'plugins/v1', '/plugin/(?P<plugin_slug>[^/]+)/support-reps/?', array( 21 22 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' ), 24 25 'permission_callback' => function( $request ) { 25 26 return current_user_can( … … 28 29 ); 29 30 }, 30 'args' => array(31 'args' => array( 31 32 'plugin_slug' => array( 32 33 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 33 'required' => true,34 'required' => true, 34 35 ), 35 ) 36 ), 36 37 ), 37 38 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' ), 40 41 'permission_callback' => function( $request ) { 41 42 return current_user_can( … … 44 45 ); 45 46 }, 46 'args' => array(47 'args' => array( 47 48 'plugin_slug' => array( 48 49 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 49 'required' => true,50 'required' => true, 50 51 ), 51 ) 52 ) 52 ), 53 ), 53 54 ) ); 54 55 55 56 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' ), 58 59 'permission_callback' => function( $request ) { 59 60 return current_user_can( … … 62 63 ); 63 64 }, 64 'args' => array(65 'args' => array( 65 66 'plugin_slug' => array( 66 67 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 67 'required' => true,68 'required' => true, 68 69 ), 69 70 'support_rep' => array( 70 71 'validate_callback' => array( $this, 'validate_user_slug_callback' ), 71 'required' => true,72 ) 73 ) 72 'required' => true, 73 ), 74 ), 74 75 ) ); 75 76 } … … 83 84 $support_reps = array(); 84 85 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 ); 86 87 $support_reps[] = $this->user_support_rep_details( $user ); 87 88 } … … 158 159 'profile' => esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename ), 159 160 'avatar' => get_avatar_url( $user->ID, 32 ), 160 'name' => Template::encode( $user->display_name ) 161 'name' => Template::encode( $user->display_name ), 161 162 ); 162 163 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
r5924 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\Plugin_i18n; … … 22 23 'methods' => WP_REST_Server::READABLE, 23 24 'callback' => array( $this, 'plugin_info' ), 24 'args' => array(25 'args' => array( 25 26 'plugin_slug' => array( 26 27 'validate_callback' => array( $this, 'validate_plugin_slug_callback' ), 27 ) 28 ) 28 ), 29 ), 29 30 ) ); 30 31 } … … 50 51 'status' => \WP_HTTP::BAD_REQUEST, 51 52 'params' => array( 52 'plugin_slug' => 'Invalid parameter.' 53 ) 53 'plugin_slug' => 'Invalid parameter.', 54 ), 54 55 ) 55 56 ); … … 57 58 58 59 // 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' ) ) ) { 60 61 switch_to_locale( $request['locale'] ); 61 62 } … … 63 64 $post_id = $post->ID; 64 65 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; 68 69 $result['version'] = get_post_meta( $post_id, 'version', true ) ?: '0.0'; 69 70 … … 75 76 // Profile of the original plugin submitter 76 77 $result['author_profile'] = $this->get_user_profile_link( $post->post_author ); 77 $result['contributors'] = array();78 $result['contributors'] = array(); 78 79 79 80 $contributors = get_terms( array( 80 'taxonomy' => 'plugin_contributors',81 'taxonomy' => 'plugin_contributors', 81 82 'object_ids' => array( $post->ID ), 82 'orderby' => 'term_order',83 'fields' => 'names',83 'orderby' => 'term_order', 84 'fields' => 'names', 84 85 ) ); 85 86 … … 94 95 } 95 96 } 97 96 98 foreach ( $contributors as $contributor ) { 97 99 $user = get_user_by( 'slug', $contributor ); … … 101 103 102 104 $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, 106 111 ); 107 112 } 108 113 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; 112 117 $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..100114 $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 ) ); 115 120 krsort( $result['ratings'] ); 116 121 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 ) ); 119 124 $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 ); 128 133 for ( $i = 0; $i < count( $_pages ); $i += 2 ) { 129 134 $result['sections'][ $_pages[ $i ] ] = apply_filters( 'the_content', $_pages[ $i + 1 ], $_pages[ $i ] ); 130 135 } 131 136 $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'] ) ) { 135 140 $result['sections']['faq'] = $this->get_simplified_faq_markup( $result['sections']['faq'] ); 136 141 } 137 142 138 143 $result['description'] = $result['sections']['description']; 139 144 140 145 $result['short_description'] = get_the_excerpt(); 141 $result['download_link'] = Template::download_link( $post );146 $result['download_link'] = Template::download_link( $post ); 142 147 143 148 $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(); 146 151 147 152 /* … … 150 155 */ 151 156 foreach ( $screen_shots as $image ) { 152 $src = Template::get_asset_url( $post, $image );157 $src = Template::get_asset_url( $post, $image ); 153 158 $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'] ]; 156 161 $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $post->ID ] ); 157 162 } … … 199 204 $result['icons'] = array(); 200 205 if ( $icons = Template::get_plugin_icon( $post ) ) { 201 if ( ! empty( $icons['icon'] ) && empty( $icons['generated'] ) ) {206 if ( ! empty( $icons['icon'] ) && empty( $icons['generated'] ) ) { 202 207 $result['icons']['1x'] = $icons['icon']; 203 } elseif ( ! empty( $icons['icon'] ) && ! empty( $icons['generated'] ) ) {208 } elseif ( ! empty( $icons['icon'] ) && ! empty( $icons['generated'] ) ) { 204 209 $result['icons']['default'] = $icons['icon']; 205 210 } 206 if ( ! empty( $icons['icon_2x'] ) ) {211 if ( ! empty( $icons['icon_2x'] ) ) { 207 212 $result['icons']['2x'] = $icons['icon_2x']; 208 213 } 209 if ( ! empty( $icons['svg'] ) ) {214 if ( ! empty( $icons['svg'] ) ) { 210 215 $result['icons']['svg'] = $icons['svg']; 211 216 } … … 213 218 214 219 // That's all folks! 215 216 220 return $result; 217 221 } … … 225 229 protected function get_user_profile_link( $user ) { 226 230 $u = false; 227 if ( $user instance Of \WP_User ) {231 if ( $user instanceof \WP_User ) { 228 232 $u = $user; 229 233 } else { … … 274 278 <div class="review-title-section"> 275 279 <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 277 282 /* Core has .star-rating .star colour styling, which is why we use a custom wrapper and template */ 278 283 echo Template::dashicons_stars( array( 279 'rating' => $review->post_rating,284 'rating' => $review->post_rating, 280 285 'template' => '<span class="star %1$s"></span>', 281 286 ) ); 282 ?></div> 287 ?> 288 </div> 283 289 </div> 284 290 <p class="reviewer"> 285 291 <?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 ); 300 307 ?> 301 308 </p> … … 306 313 <?php 307 314 return ob_get_clean(); 308 309 315 } 310 316 … … 320 326 $markup = str_replace( 321 327 array( '<dl>', '</dl>', '<dt>', '</dt>', '<dd>', '</dd>' ), 322 array( '', '','<h4>', '</h4>', '<p>', '</p>' ),328 array( '', '', '<h4>', '</h4>', '<p>', '</p>' ), 323 329 $markup 324 330 ); … … 349 355 return $markup; 350 356 } 351 352 357 } 353 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-popular-tags.php
r4559 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\API\Base; 4 5 use WP_REST_Server; … … 27 28 $terms = get_terms( 'plugin_tags', array( 28 29 'hide_empty' => true, 29 'orderby' => 'count',30 'order' => 'DESC',31 'number' => 100030 'orderby' => 'count', 31 'order' => 'DESC', 32 'number' => 1000, 32 33 ) ); 33 34 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-query-plugins.php
r5484 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\API\Base; 4 5 use WP_REST_Server; … … 21 22 'author_name', 22 23 'installed_plugins', 23 'plugin_tags' 24 'plugin_tags', 24 25 ); 25 26 … … 41 42 42 43 $response = array( 43 'info' => array(44 'info' => array( 44 45 'page' => 0, 45 46 'pages' => 0, … … 69 70 70 71 $response['info']['page'] = (int) $wp_query->get( 'paged' ) ?: 1; 71 $response['info']['pages'] = (int) $wp_query->max_num_pages 72 $response['info']['results'] = (int) $wp_query->found_posts 72 $response['info']['pages'] = (int) $wp_query->max_num_pages ?: 0; 73 $response['info']['results'] = (int) $wp_query->found_posts ?: 0; 73 74 74 75 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 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\API\Routes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\API\Base; … … 21 22 22 23 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' ), 25 26 'permission_callback' => array( $this, 'permission_check_internal_api_bearer' ), 26 27 ) ); … … 42 43 if ( empty( $svn_access ) ) { 43 44 return false; 44 45 } 45 46 46 47 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 15 15 if ( empty( $opts ) && $argc == 2 ) { 16 16 $opts['plugin'] = $argv[1]; 17 $argv[1] = '--plugin ' . $argv[1];17 $argv[1] = '--plugin ' . $argv[1]; 18 18 } 19 19 if ( empty( $opts['url'] ) ) { … … 42 42 $_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH ); 43 43 44 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';44 require rtrim( $opts['abspath'], '/' ) . '/wp-load.php'; 45 45 46 46 if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) { … … 48 48 if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { 49 49 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" ); 51 51 } 52 52 die(); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/import-plugin.php
r4563 r6287 14 14 if ( empty( $opts ) && $argc == 2 ) { 15 15 $opts['plugin'] = $argv[1]; 16 $argv[1] = '--plugin ' . $argv[1];16 $argv[1] = '--plugin ' . $argv[1]; 17 17 } 18 18 if ( empty( $opts['url'] ) ) { … … 44 44 $_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH ); 45 45 46 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';46 require rtrim( $opts['abspath'], '/' ) . '/wp-load.php'; 47 47 48 48 if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) { … … 50 50 if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { 51 51 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" ); 53 53 } 54 54 die(); … … 57 57 $plugin_slug = $opts['plugin']; 58 58 $changed_tags = $opts['changed-tags']; 59 $start_time = microtime( 1);59 $start_time = microtime( 1 ); 60 60 61 61 // If async, queue it to be parsed instead. … … 68 68 echo "Processing Import for $plugin_slug... "; 69 69 try { 70 $importer = new CLI\Import ;70 $importer = new CLI\Import(); 71 71 $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"; 75 75 76 76 fwrite( STDERR, "[{$plugin_slug}] Plugin Import Failed: " . $e->getMessage() . "\n" ); 77 exit( 1);77 exit( 1 ); 78 78 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/quick-stats.php
r6261 r6287 20 20 $_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH ); 21 21 22 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';22 require rtrim( $opts['abspath'], '/' ) . '/wp-load.php'; 23 23 24 24 if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) { … … 26 26 if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { 27 27 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" ); 29 29 } 30 30 die(); … … 38 38 function display_top_table( $stats, $n = 20 ) { 39 39 40 $top = array_slice( $stats, 0, $n );40 $top = array_slice( $stats, 0, $n ); 41 41 $tail = array_slice( $stats, $n ); 42 42 43 43 foreach ( $top as $row ) { 44 #$vals = array_values( (array) $row );44 // $vals = array_values( (array) $row ); 45 45 echo $row[0] . "\t\t\t" . number_format( $row[1] ) . "\n"; 46 46 } 47 47 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"; 49 49 50 50 $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"; 52 52 53 53 } 54 54 55 function tested_to_summary( $pfx_where = '1=1') {55 function tested_to_summary( $pfx_where = '1=1' ) { 56 56 global $wpdb; 57 57 … … 61 61 } 62 62 63 $where = $wpdb->prepare( "post_status = %s", 'publish' );63 $where = $wpdb->prepare( 'post_status = %s', 'publish' ); 64 64 65 if ( !empty( $opts['age'] ) && strtotime( $opts['age'] ) > 0 ) 66 $where .= $wpdb->prepare( " AND post_modified >= %s", strftime( '%Y-%m-%d', strtotime( $opts['age'] ) ) ); 65 if ( ! empty( $opts['age'] ) && strtotime( $opts['age'] ) > 0 ) { 66 $where .= $wpdb->prepare( ' AND post_modified >= %s', strftime( '%Y-%m-%d', strtotime( $opts['age'] ) ) ); 67 } 67 68 68 // TODO: add some more reports, and a CLI argument for choosing them69 // TODO: add some more reports, and a CLI argument for choosing them 69 70 display_top_table( tested_to_summary( $where ) ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/rebuild-zip.php
r6235 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\Tools\SVN; … … 17 18 if ( empty( $opts ) && $argc == 2 ) { 18 19 $opts['plugin'] = $argv[1]; 19 $argv[1] = '--plugin ' . $argv[1];20 $argv[1] = '--plugin ' . $argv[1]; 20 21 } 21 22 if ( empty( $opts ) && $argc == 3 ) { 22 23 $opts['plugin'] = $argv[1]; 23 $argv[1] = '--plugin ' . $argv[1];24 $argv[1] = '--plugin ' . $argv[1]; 24 25 25 26 $opts['versions'] = $argv[2]; 26 $argv[2] = '--versions ' . $argv[2];27 $argv[2] = '--versions ' . $argv[2]; 27 28 } 28 29 if ( empty( $opts['url'] ) ) { … … 41 42 fwrite( STDERR, "Usage: php {$argv[0]} --plugin hello-dolly --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" ); 42 43 fwrite( STDERR, "--url and --abspath will be guessed if possible.\n" ); 43 exit( 1);44 exit( 1 ); 44 45 } 45 46 } … … 49 50 $_SERVER['REQUEST_URI'] = parse_url( $opts['url'], PHP_URL_PATH ); 50 51 51 include rtrim( $opts['abspath'], '/' ) . '/wp-load.php';52 require rtrim( $opts['abspath'], '/' ) . '/wp-load.php'; 52 53 53 54 if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) { … … 55 56 if ( defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) { 56 57 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" ); 58 59 } 59 exit( 1);60 exit( 1 ); 60 61 } 61 62 62 63 $plugin_slug = $opts['plugin']; 63 64 $versions = array_filter( array_unique( array_map( 'trim', (array) explode( ',', $opts['versions'] ) ) ), 'strlen' ); 64 $start_time = microtime( 1);65 $start_time = microtime( 1 ); 65 66 66 67 if ( empty( $versions ) ) { … … 72 73 } 73 74 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 ); 78 78 $versions[] = 'trunk'; 79 79 } … … 81 81 if ( ! $versions ) { 82 82 fwrite( STDERR, "{$plugin_slug}: Error! No versions specified.\n" ); 83 exit( 1);83 exit( 1 ); 84 84 } 85 85 … … 90 90 $plugin_post = Plugin_Directory::get_plugin_post( $plugin_slug ); 91 91 if ( ! $plugin_post ) { 92 throw new Exception( "Could not locate plugin post");92 throw new Exception( 'Could not locate plugin post' ); 93 93 } 94 94 $stable_tag = get_post_meta( $plugin_post->ID, 'stable_tag', true ) ?? 'trunk'; … … 99 99 $plugin_slug, 100 100 $versions_to_build, 101 "{$plugin_slug}: Rebuild triggered by " . php_uname( 'n' ),101 "{$plugin_slug}: Rebuild triggered by " . php_uname( 'n' ), 102 102 $stable_tag 103 103 ); 104 104 } 105 105 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 ) { 108 108 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 ); 111 111 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php
r5867 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use WordPressdotorg\Plugin_Directory\Tools; 4 5 … … 23 24 public static function map_meta_cap( $required_caps, $cap, $user_id, $context ) { 24 25 $plugin_edit_cap = false; 25 switch ( $cap ) {26 switch ( $cap ) { 26 27 case 'plugin_admin_edit': 27 28 case 'plugin_add_committer': … … 30 31 case 'plugin_remove_support_rep': 31 32 $plugin_edit_cap = true; 33 32 34 // 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. 35 36 case 'plugin_admin_view': 36 37 // Committers + Contributors. 37 38 // If no committers, post_author. 38 39 $required_caps = array(); 39 $post = get_post( $context[0] );40 $post = get_post( $context[0] ); 40 41 41 42 if ( ! $post ) { … … 98 99 */ 99 100 public static function add_roles() { 100 101 101 $reviewer = array( 102 102 'read' => true, … … 121 121 // Remove the roles first, incase we've changed the permission set. 122 122 remove_role( 'plugin_reviewer' ); 123 remove_role( 'plugin_admin' 124 add_role( 'plugin_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 ); 126 126 127 127 $wp_admin_role = get_role( 'administrator' ); … … 135 135 } 136 136 } 137 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-i18n.php
r5450 r6287 38 38 * 39 39 * This function is never called, and only exists so that out pot tools can detect the strings. 40 * 40 41 * @ignore 41 42 */ … … 43 44 44 45 // Category terms. 45 _x( 'Accessibility', 46 _x( 'Advertising', 47 _x( 'Analytics', 48 _x( 'Arts & Entertainment', 49 _x( 'Authentication', 50 _x( 'Business', 51 _x( 'Calendar & Events', 52 _x( 'Communication', 53 _x( 'Contact Forms', 54 _x( 'Customization', 55 _x( 'Discussion & Community', 56 _x( 'eCommerce', 57 _x( 'Editor & Writing', 58 _x( 'Education & Support', 59 _x( 'Language Tools', 60 _x( 'Maps & Location', 61 _x( 'Media', 62 _x( 'Multisite', 63 _x( 'Performance', 64 _x( 'Ratings & Reviews', 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' ); 65 66 _x( 'Security & Spam Protection', 'Plugin Category Name', 'wporg-plugins' ); 66 _x( 'SEO & Marketing', 67 _x( 'Social & Sharing', 68 _x( 'Taxonomy', 69 _x( 'User Management', 70 _x( 'Utilities & Tools', 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' ); 71 72 72 73 // Section terms. 73 _x( 'Adopt Me', 74 _x( 'Beta', 74 _x( 'Adopt Me', 'Plugin Section Name', 'wporg-plugins' ); 75 _x( 'Beta', 'Plugin Section Name', 'wporg-plugins' ); 75 76 _x( 'My Favorites', 'Plugin Section Name', 'wporg-plugins' ); 76 _x( 'Featured', 77 _x( 'Popular', 77 _x( 'Featured', 'Plugin Section Name', 'wporg-plugins' ); 78 _x( 'Popular', 'Plugin Section Name', 'wporg-plugins' ); 78 79 79 80 // Section descriptions. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-markdown.php
r3511 r6287 42 42 * markdown will preserve things like underscores in code blocks. 43 43 */ 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 ); 45 45 $text = str_replace( array( "\r\n", "\r" ), "\n", $text ); 46 46 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r6217 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use WordPressdotorg\Plugin_Directory\Admin\Customizations; 4 5 use WordPressdotorg\Plugin_Directory\Admin\Tools\Author_Cards; … … 59 60 60 61 // 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' ) ); 62 63 63 64 // Allow post_modified not to be modified when we don't specifically bump it. … … 65 66 66 67 // Work around caching issues 67 add_filter( 'pre_option_jetpack_sync_full__started' 68 add_filter( 'pre_option_jetpack_sync_full__started', array( $this, 'bypass_options_cache' ), 10, 2 ); 68 69 add_filter( 'default_option_jetpack_sync_full__started', '__return_null' ); 69 add_filter( 'pre_option_jetpack_sync_full__params' 70 add_filter( 'pre_option_jetpack_sync_full__params', array( $this, 'bypass_options_cache' ), 10, 2 ); 70 71 add_filter( 'default_option_jetpack_sync_full__params', '__return_null' ); 71 add_filter( 'pre_option_jetpack_sync_full__queue_finished' 72 add_filter( 'pre_option_jetpack_sync_full__queue_finished', array( $this, 'bypass_options_cache' ), 10, 2 ); 72 73 add_filter( 'default_option_jetpack_sync_full__queue_finished', '__return_null' ); 73 add_filter( 'pre_option_jetpack_sync_full__send_started' 74 add_filter( 'pre_option_jetpack_sync_full__send_started', array( $this, 'bypass_options_cache' ), 10, 2 ); 74 75 add_filter( 'default_option_jetpack_sync_full__send_started', '__return_null' ); 75 add_filter( 'pre_option_jetpack_sync_full__finished' 76 add_filter( 'pre_option_jetpack_sync_full__finished', array( $this, 'bypass_options_cache' ), 10, 2 ); 76 77 add_filter( 'default_option_jetpack_sync_full__finished', '__return_null' ); 77 78 … … 88 89 Stats_Report::instance(); 89 90 90 add_action( 'wp_insert_post_data', 91 add_action( 'wp_insert_post_data', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'can_change_post_status' ), 10, 2 ); 91 92 add_action( 'transition_post_status', array( __NAMESPACE__ . '\Admin\Status_Transitions', 'instance' ) ); 92 93 } … … 124 125 register_post_type( 'plugin', array( 125 126 'labels' => array( 126 'name' => __( 'Repo Plugins', 127 'singular_name' => __( 'Repo Plugin', 128 'menu_name' => __( 'Repo Plugins', 129 'add_new' => __( 'Add New', 130 'add_new_item' => __( 'Add New Plugin', 131 'new_item' => __( 'New Plugin', 132 'view_item' => __( 'View Plugin', 133 'search_items' => __( 'Search Plugins', 134 'not_found' => __( 'No plugins found', 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' ), 135 136 'not_found_in_trash' => __( 'No plugins found in Trash', 'wporg-plugins' ), 136 137 … … 138 139 'edit_item' => is_admin() ? __( 'Editing Plugin: %s', 'wporg-plugins' ) : __( 'Edit Plugin', 'wporg-plugins' ), 139 140 ), 140 'description' 141 'supports' 142 'public' 143 'show_ui' 144 'show_in_rest' 145 'has_archive' 146 'rewrite' 147 'menu_icon' 148 'capabilities' 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( 149 150 'edit_post' => 'plugin_edit', 150 151 'read_post' => 'read', … … 184 185 'labels' => array( 185 186 'name' => __( 'Plugin Categories', 'wporg-plugins' ), 186 'singular_name' => __( 'Plugin Category', 187 'edit_item' => __( 'Edit Category', 188 'update_item' => __( 'Update Category', 189 'add_new_item' => __( 'Add New Category', 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' ), 190 191 'new_item_name' => __( 'New Category Name', 'wporg-plugins' ), 191 192 'search_items' => __( 'Search Categories', 'wporg-plugins' ), … … 237 238 'rewrite' => false, 238 239 'labels' => array( 239 'name' => __( 'Contributors', 'wporg-plugins' ),240 'name' => __( 'Contributors', 'wporg-plugins' ), 240 241 'singular_name' => __( 'Contributor', 'wporg-plugins' ), 241 242 ), … … 253 254 'rewrite' => false, 254 255 'labels' => array( 255 'name' => __( 'Committers', 'wporg-plugins' ),256 'name' => __( 'Committers', 'wporg-plugins' ), 256 257 'singular_name' => __( 'Committer', 'wporg-plugins' ), 257 258 ), … … 269 270 'rewrite' => false, 270 271 'labels' => array( 271 'name' => __( 'Support Reps', 'wporg-plugins' ),272 'name' => __( 'Support Reps', 'wporg-plugins' ), 272 273 'singular_name' => __( 'Support Rep', 'wporg-plugins' ), 273 274 ), … … 291 292 'labels' => array( 292 293 'name' => __( 'Plugin Tags', 'wporg-plugins' ), 293 'singular_name' => __( 'Plugin Tag', 294 'edit_item' => __( 'Edit Tag', 295 'update_item' => __( 'Update Tag', 296 'add_new_item' => __( 'Add New Tag', 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' ), 297 298 'new_item_name' => __( 'New Tag Name', 'wporg-plugins' ), 298 299 'search_items' => __( 'Search Tags', 'wporg-plugins' ), … … 352 353 353 354 register_meta( 'post', 'rating', array( 354 'type' 355 'description' 356 'single' 355 'type' => 'number', 356 'description' => __( 'Overall rating of the plugin.', 'wporg-plugins' ), 357 'single' => true, 357 358 // todo 'sanitize_callback' => 'absint', 358 'show_in_rest' 359 'show_in_rest' => true, 359 360 ) ); 360 361 … … 376 377 377 378 register_meta( 'post', 'tested', array( 378 'description' 379 'single' 379 'description' => __( 'The version of WordPress the plugin was tested with.', 'wporg-plugins' ), 380 'single' => true, 380 381 // TODO 'sanitize_callback' => 'absint', 381 'show_in_rest' 382 'show_in_rest' => true, 382 383 ) ); 383 384 384 385 register_meta( 'post', 'requires', array( 385 'description' 386 'single' 386 'description' => __( 'The minimum version of WordPress the plugin needs to run.', 'wporg-plugins' ), 387 'single' => true, 387 388 // TODO 'sanitize_callback' => 'absint', 388 'show_in_rest' 389 'show_in_rest' => true, 389 390 ) ); 390 391 391 392 register_meta( 'post', 'requires_php', array( 392 'description' 393 'single' 393 'description' => __( 'The minimum version of PHP the plugin needs to run.', 'wporg-plugins' ), 394 'single' => true, 394 395 // TODO 'sanitize_callback' => 'absint', 395 'show_in_rest' 396 'show_in_rest' => true, 396 397 ) ); 397 398 398 399 register_meta( 'post', 'stable_tag', array( 399 'description' 400 'single' 400 'description' => __( 'Stable version of the plugin.', 'wporg-plugins' ), 401 'single' => true, 401 402 // TODO 'sanitize_callback' => 'absint', 402 'show_in_rest' 403 'show_in_rest' => true, 403 404 ) ); 404 405 … … 411 412 412 413 register_meta( 'post', 'version', array( 413 'description' 414 'single' 414 'description' => __( 'Current stable version.', 'wporg-plugins' ), 415 'single' => true, 415 416 // TODO 'sanitize_callback' => 'esc_url_raw', 416 'show_in_rest' 417 'show_in_rest' => true, 417 418 ) ); 418 419 419 420 register_meta( 'post', 'header_name', array( 420 'description' 421 'single' 421 'description' => __( 'Name of the plugin.', 'wporg-plugins' ), 422 'single' => true, 422 423 // TODO 'sanitize_callback' => 'esc_url_raw', 423 'show_in_rest' 424 'show_in_rest' => true, 424 425 ) ); 425 426 … … 432 433 433 434 register_meta( 'post', 'header_name', array( 434 'description' 435 'single' 435 'description' => __( 'Name of the plugin.', 'wporg-plugins' ), 436 'single' => true, 436 437 // TODO 'sanitize_callback' => 'esc_url_raw', 437 'show_in_rest' 438 'show_in_rest' => true, 438 439 ) ); 439 440 440 441 register_meta( 'post', 'header_author', array( 441 'description' 442 'single' 442 'description' => __( 'Name of the plugin author.', 'wporg-plugins' ), 443 'single' => true, 443 444 // TODO 'sanitize_callback' => 'esc_url_raw', 444 'show_in_rest' 445 'show_in_rest' => true, 445 446 ) ); 446 447 … … 453 454 454 455 register_meta( 'post', 'header_description', array( 455 'description' 456 'single' 456 'description' => __( 'Description of the plugin.', 'wporg-plugins' ), 457 'single' => true, 457 458 // TODO 'sanitize_callback' => 'esc_url_raw', 458 'show_in_rest' 459 'show_in_rest' => true, 459 460 ) ); 460 461 461 462 register_meta( 'post', 'assets_icons', array( 462 'type' 463 'description' 464 'single' 463 'type' => 'array', 464 'description' => __( 'Icon images of the plugin.', 'wporg-plugins' ), 465 'single' => true, 465 466 // TODO 'sanitize_callback' => 'esc_url_raw', 466 'show_in_rest' 467 'show_in_rest' => true, 467 468 ) ); 468 469 469 470 register_meta( 'post', 'assets_banners_color', array( 470 'description' 471 'single' 471 'description' => __( 'Fallback color for the plugin.', 'wporg-plugins' ), 472 'single' => true, 472 473 // TODO 'sanitize_callback' => 'esc_url_raw', 473 'show_in_rest' 474 'show_in_rest' => true, 474 475 ) ); 475 476 … … 510 511 511 512 // If changing capabilities around, uncomment this. 512 // Capabilities::add_roles();513 // Capabilities::add_roles(); 513 514 514 515 // Remove the /admin$ redirect to wp-admin … … 523 524 if ( class_exists( 'Jetpack' ) && \Jetpack::get_option( 'id' ) && ! class_exists( 'Jetpack_Search' ) 524 525 && ! 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'; 526 527 \Jetpack_Search::instance(); 527 528 } … … 532 533 */ 533 534 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' ) ); 536 537 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' ) ); 539 540 } 540 541 … … 552 553 'wporg-plugins-screenshots', 553 554 'wporg-plugins-reviews', 554 'readme-validator' 555 'readme-validator', 555 556 ); 556 557 … … 568 569 */ 569 570 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' ); 577 578 } 578 579 … … 669 670 /** 670 671 * Filter content to make links rel=nofollow on plugin pages only 671 * @param string $content The content. 672 * 673 * @param string $content The content. 672 674 * @return string 673 675 */ … … 675 677 if ( get_post_type() == 'plugin' ) { 676 678 // 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 ); 678 680 } 679 681 return $content; … … 706 708 $wp_query->query_vars['order'] = 'DESC'; 707 709 break; 710 708 711 case 'favorites': 709 712 $favorites_user = wp_get_current_user(); … … 723 726 724 727 $wp_query->query_vars['orderby'] = 'post_title'; 725 $wp_query->query_vars['order'] = 'ASC';728 $wp_query->query_vars['order'] = 'ASC'; 726 729 } 727 730 … … 766 769 array( 767 770 'taxonomy' => 'plugin_contributors', 768 'field' => 'slug',769 'terms' => $user770 ) 771 'field' => 'slug', 772 'terms' => $user, 773 ), 771 774 ); 772 775 … … 776 779 $wp_query->query_vars['tax_query'][] = array( 777 780 'taxonomy' => 'plugin_committers', 778 'field' => 'slug',779 'terms' => $user781 'field' => 'slug', 782 'terms' => $user, 780 783 ); 781 784 } 782 785 783 786 $wp_query->query_vars['orderby'] = 'post_title'; 784 $wp_query->query_vars['order'] = 'ASC';787 $wp_query->query_vars['order'] = 'ASC'; 785 788 786 789 // Treat it as a taxonomy query now, not the author archive. 787 790 $wp_query->is_author = false; 788 $wp_query->is_tax = true;791 $wp_query->is_tax = true; 789 792 790 793 unset( $wp_query->query_vars['author_name'], $wp_query->query_vars['author'] ); … … 796 799 $wp_query->query_vars['post_status'] = array( 'approved', 'publish', 'closed', 'disabled' ); 797 800 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 ) { 799 802 if ( $this_wp_query != $wp_query ) { 800 803 return $posts; … … 825 828 // Allow anyone to view a closed plugin directly from its page. It won't show in search results or lists. 826 829 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']; 828 831 $wp_query->query_vars['post_status'][] = 'closed'; 829 832 $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'] ); 831 834 } 832 835 … … 856 859 public function bypass_options_cache( $value, $option ) { 857 860 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 ) ); 864 865 $value = maybe_unserialize( $value ); 865 866 … … 874 875 public function fix_login_url( $login_url, $redirect, $force_reauth ) { 875 876 // 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' ) ) { 877 878 // Note that this is not normal because of the code in /mu-plugins/wporg-sso/class-wporg-sso.php. 878 879 // The login_url function there expects the redirect_to as the first parameter passed into it instead of the second … … 884 885 // parse_url is used here to remove any additional query args from the REQUEST_URI before redirection 885 886 // 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; 889 890 } 890 891 return $login_url; … … 940 941 * @global string $locale Current locale. 941 942 * 942 * @param int $post_idPost ID to update.943 * @param int $min_translatedTranslations 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. 944 945 * @return array 945 946 */ 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_' ) ) { 947 948 948 949 $locales_to_sync = array(); 949 $post = get_post( $post_id );950 $post = get_post( $post_id ); 950 951 if ( $post ) { 951 952 $translations = Plugin_I18n::instance()->find_all_translations_for_plugin( $post->post_name, 'stable-readme', $min_translated ); // at least $min_translated % translated … … 953 954 // Eliminate translations that start with unwanted prefixes, so we don't waste space on near-duplicates like en_AU, en_CA etc. 954 955 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 ) { 957 958 unset( $translations[ $i ] ); 959 } 960 } 958 961 } 959 962 $locales_to_sync = array_unique( $translations ); … … 961 964 } 962 965 963 if ( count( $locales_to_sync) > 0 ) {966 if ( count( $locales_to_sync ) > 0 ) { 964 967 foreach ( $locales_to_sync as $locale ) { 965 968 $this->sync_translation_to_meta( $post_id, $locale ); … … 975 978 * @global string $locale Current locale. 976 979 * 977 * @param int $post_idPost ID to update.978 * @param string $localeLocale to translate.980 * @param int $post_id Post ID to update. 981 * @param string $locale Locale to translate. 979 982 */ 980 983 public function sync_translation_to_meta( $post_id, $_locale ) { … … 983 986 $old_locale = $locale; 984 987 // Keep track of the original untranslated strings 985 $orig_title = get_the_title( $post_id );988 $orig_title = get_the_title( $post_id ); 986 989 $orig_excerpt = get_the_excerpt( $post_id ); 987 990 $orig_content = get_post_field( 'post_content', $post_id ); 988 $locale = $_locale;991 $locale = $_locale; 989 992 990 993 // Update postmeta values for the translated title, excerpt, and content, if they are available and different from the originals. 991 994 // 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 993 995 $the_title = Plugin_I18n::instance()->translate( 'title', $orig_title, [ 'post_id' => $post_id ] ); 994 996 if ( $the_title && $the_title != $orig_title ) { … … 1003 1005 // Split up the content to translate it in sections. 1004 1006 $the_content = array(); 1005 $sections = $this->split_post_content_into_pages( $orig_content );1007 $sections = $this->split_post_content_into_pages( $orig_content ); 1006 1008 foreach ( $sections as $section => $section_content ) { 1007 1009 $translated_section = $this->translate_post_content( $section_content, $section, $post_id ); … … 1012 1014 } 1013 1015 1014 if ( ! empty( $the_content ) ) {1016 if ( ! empty( $the_content ) ) { 1015 1017 update_post_meta( $post_id, 'content_' . $locale, implode( $the_content ) ); 1016 1018 } … … 1109 1111 1110 1112 if ( 'tags' === $path[2] ) { 1111 if ( isset( $path[3] ) && ! empty( $path[3] ) ) {1113 if ( isset( $path[3] ) && ! empty( $path[3] ) ) { 1112 1114 wp_safe_redirect( home_url( '/search/' . urlencode( $path[3] ) . '/' ) ); 1113 1115 die(); … … 1145 1147 } 1146 1148 1147 // Otherwise, let's redirect to the search page1148 if ( isset( $path[2] ) && ! empty( $path[2] ) ) {1149 // Otherwise, let's redirect to the search page 1150 if ( isset( $path[2] ) && ! empty( $path[2] ) ) { 1149 1151 wp_safe_redirect( home_url( '/search/' . urlencode( $path[2] ) . '/' ) ); 1150 1152 die(); … … 1205 1207 */ 1206 1208 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 ); 1208 1210 $content_pages = array( 1209 1211 'screenshots' => '[wporg-plugins-screenshots]', … … 1318 1320 public static function create_plugin_post( array $args ) { 1319 1321 $title = $args['post_title'] ?: $args['post_name']; 1320 $slug = $args['post_name'] 1322 $slug = $args['post_name'] ?: sanitize_title( $title ); 1321 1323 1322 1324 $args = wp_parse_args( $args, array( -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-geopattern-svg.php
r2994 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use RedeyeVentures\GeoPattern\SVG; 4 5 … … 41 42 42 43 /** 43 * @param 44 * @param 45 * @param 46 * @param 47 * @param 48 * @param array $args44 * @param string $text 45 * @param string $x 46 * @param string $y 47 * @param string $text_anchor 48 * @param string $style 49 * @param array $args 49 50 * 50 51 * @return $this 51 52 */ 52 53 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 ); 54 55 $this->svgString .= $element; 55 56 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-geopattern-svgtext.php
r2994 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use RedeyeVentures\GeoPattern\SVGElements\Base; 4 5 … … 21 22 22 23 /** 23 * @param 24 * @param 25 * @param 26 * @param 27 * @param 28 * @param array $args24 * @param string $text 25 * @param string $x 26 * @param string $y 27 * @param string $text_anchor 28 * @param string $style 29 * @param array $args 29 30 */ 30 31 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 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use RedeyeVentures\GeoPattern\GeoPattern; 4 5 … … 91 92 $this->generatePattern(); 92 93 93 #if ( $this->svg->getWidth() < $width || $this->svg->getHeight() < $height ) {94 // if ( $this->svg->getWidth() < $width || $this->svg->getHeight() < $height ) { 94 95 $this->svg->setViewBox( 0, 0, $this->svg->getWidth(), $this->svg->getHeight() ); 95 #} 96 96 // } 97 97 if ( $this->text ) { 98 98 $inner = $this->svg; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-i18n.php
r5982 r6287 64 64 * 65 65 * @access private 66 *67 66 */ 68 67 private function __construct() { … … 237 236 $translation_set_id = $wpdb->get_var( $wpdb->prepare( 238 237 'SELECT id FROM ' . GLOTPRESS_TABLE_PREFIX . 'translation_sets WHERE project_id = %d AND locale = %s', 239 $branch_id, $locale ) ); 238 $branch_id, $locale 239 ) ); 240 240 241 241 if ( empty( $translation_set_id ) ) { … … 456 456 $translation_sets = $this->cache_get( $post->post_name, $branch, $cache_suffix ); 457 457 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' ] ); 459 459 $response = wp_remote_get( $api_url ); 460 460 … … 462 462 $translation_sets = []; 463 463 } else { 464 $result = json_decode( wp_remote_retrieve_body( $response ) );464 $result = json_decode( wp_remote_retrieve_body( $response ) ); 465 465 $translation_sets = isset( $result->translation_sets ) ? $result->translation_sets : []; 466 466 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r6250 r6287 3 3 4 4 // 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' );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'; 8 8 9 9 /** … … 137 137 138 138 if ( is_singular( 'plugin' ) ) { 139 $metas[] = sprintf( '<meta name="description" value="%s" />', 139 $metas[] = sprintf( 140 '<meta name="description" value="%s" />', 140 141 esc_attr( get_the_excerpt() ) 141 142 ); … … 192 193 193 194 // 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 ) ); 195 196 196 197 wp_cache_set( $post->ID, $count, 'plugin_download_count', HOUR_IN_SECONDS ); … … 212 213 global $wpdb; 213 214 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`' ); 215 216 wp_cache_set( 'plugin_download_count', $count, 'plugin_download_count', DAY_IN_SECONDS ); 216 217 } … … 234 235 $num_ratings = array_sum( $ratings ); 235 236 236 return 237 '<div class="plugin-rating">' . 237 return '<div class="plugin-rating">' . 238 238 Template::dashicons_stars( $rating ) . 239 239 '<span class="rating-count">(' . … … 356 356 */ 357 357 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 359 364 $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; 362 366 363 367 foreach ( $raw_icons as $file => $info ) { … … 391 395 $generated = true; 392 396 393 $icon = new Plugin_Geopattern ;397 $icon = new Plugin_Geopattern(); 394 398 $icon->setString( $plugin->post_name ); 395 399 … … 412 416 $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$icon_2x}'); } }"; 413 417 } 414 $html .= "</style>";418 $html .= '</style>'; 415 419 $html .= "<div class='plugin-icon' id='{$id}'></div>"; 416 420 … … 425 429 426 430 /** 427 * Retrieve the Plugin Icondetails for a plugin.431 * Retrieve the Plugin banner details for a plugin. 428 432 * 429 433 * @static … … 436 440 $plugin = get_post( $post ); 437 441 438 if ( in_array( $plugin->post_status, [ 'disabled', 'closed'], true ) ) {442 if ( in_array( $plugin->post_status, [ 'disabled', 'closed' ], true ) ) { 439 443 return false; 440 444 } … … 488 492 $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$banner_2x}'); } }"; 489 493 } 490 $html .= "</style>";494 $html .= '</style>'; 491 495 $html .= "<div class='plugin-banner' id='{$id}'></div>"; 492 496 … … 580 584 */ 581 585 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( 583 588 'rating' => 0, 584 589 'template' => '<span class="%1$s"></span>', … … 629 634 630 635 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 ); 632 637 } 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 ); 634 639 } 635 640 } … … 662 667 663 668 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', 666 671 ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' ) ); 667 672 } … … 759 764 'locale' => 'en_US', 760 765 'hreflang' => 'en', 761 'subdomain' => '' 766 'subdomain' => '', 762 767 ); 763 768 … … 766 771 } ); 767 772 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 ); 769 774 } 770 775 … … 773 778 'https://%swordpress.org%s', 774 779 $site->subdomain ? "{$site->subdomain}." : '', 775 $_SERVER[ 'REQUEST_URI']780 $_SERVER['REQUEST_URI'] 776 781 ); 777 782 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
r5910 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 use WP_User; 4 5 … … 54 55 55 56 $reviews = $wpdb->get_results( $wpdb->prepare( 56 "SELECT57 "SELECT 57 58 ID, post_content, post_title, post_author, post_modified, 58 59 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 ) ); 64 68 65 69 wp_cache_set( "{$plugin_slug}_last{$number}", $reviews, 'plugin-reviews', HOUR_IN_SECONDS ); … … 241 245 242 246 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 ); 244 248 $support_reps = wp_get_object_terms( $post->ID, 'plugin_support_reps', array( 'fields' => 'names' ) ); 245 249 … … 341 345 if ( $subscribe ) { 342 346 $users[] = $user->ID; 343 $users = array_unique( $users );347 $users = array_unique( $users ); 344 348 } else { 345 349 if ( false !== ( $pos = array_search( $user->ID, $users, true ) ) ) { … … 423 427 } 424 428 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(); 427 430 $already_favorited = in_array( $post->post_name, $users_favorites, true ); 428 431 … … 447 450 * 448 451 * @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. 450 453 * @return array Array of \WP_User's who are subscribed. 451 454 */ … … 468 471 469 472 // Plugin Committers are always subscrived to plugin commits. 470 $committers 473 $committers = self::get_plugin_committers( $plugin_slug ); 471 474 foreach ( $committers as $committer ) { 472 475 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 62 62 $data = $this->export_and_parse_plugin( $plugin_slug ); 63 63 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']; 68 68 $tagged_versions = $data['tagged_versions']; 69 69 … … 89 89 */ 90 90 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 ) ) || 92 92 $plugin->post_modified == '0000-00-00 00:00:00' || 93 93 ( $svn_changed_tags && in_array( ( $stable_tag ?: 'trunk' ), $svn_changed_tags, true ) ) … … 150 150 } 151 151 152 update_post_meta( $plugin->ID, 'tagged_versions', 153 update_post_meta( $plugin->ID, '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 ) ) ); 154 154 update_post_meta( $plugin->ID, 'assets_screenshots', wp_slash( $assets['screenshot'] ) ); 155 update_post_meta( $plugin->ID, 'assets_icons', 156 update_post_meta( $plugin->ID, 'assets_banners', 157 update_post_meta( $plugin->ID, 'last_updated', 158 update_post_meta( $plugin->ID, 'plugin_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 ) ); 159 159 160 160 // Calculate the 'plugin color' from the average color of the banner if provided. This is used for fallback icons. … … 172 172 // Finally, set the new version live. 173 173 update_post_meta( $plugin->ID, 'stable_tag', wp_slash( $stable_tag ) ); 174 update_post_meta( $plugin->ID, 'version', 174 update_post_meta( $plugin->ID, 'version', wp_slash( $headers->Version ) ); 175 175 176 176 // Ensure that the API gets the updated data … … 208 208 $svn_revision_triggered ? 209 209 "{$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' ), 211 211 $stable_tag 212 212 ); 213 } catch ( Exception $e ) {213 } catch ( Exception $e ) { 214 214 return false; 215 215 } … … 247 247 $tagged_versions = array_map( function( $item ) { 248 248 $trimmed_item = rtrim( $item, '/' ); 249 249 250 if ( $trimmed_item == $item ) { 250 251 // If attempting to trim `/` off didn't do anything, it was a file and we want to discard it. … … 288 289 289 290 $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 ); 291 292 292 293 $stable_tag = $trunk_readme->stable_tag; … … 300 301 array( 301 302 'ignore-externals', 302 'depth' => 'files' 303 'depth' => 'files', 303 304 ) 304 305 ); … … 306 307 if ( ! $svn_export['result'] && '0.' == substr( $stable_tag, 0, 2 ) ) { 307 308 $_stable_tag = substr( $stable_tag, 1 ); 308 $svn_export = SVN::export(309 $svn_export = SVN::export( 309 310 self::PLUGIN_SVN_BASE . "/{$plugin_slug}/tags/{$_stable_tag}", 310 311 $tmp_dir . '/export', 311 312 array( 312 313 'ignore-externals', 313 'depth' => 'files' 314 'depth' => 'files', 314 315 ) 315 316 ); … … 335 336 array( 336 337 'ignore-externals', 337 'depth' => 'files' // Only export the root files, we don't need the rest to read the plugin headers/screenshots338 'depth' => 'files', // Only export the root files, we don't need the rest to read the plugin headers/screenshots 338 339 ) 339 340 ); … … 354 355 355 356 // 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 ); 357 362 $svn_assets_folder = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/assets/", true /* verbose */ ); 358 363 if ( $svn_assets_folder ) { // /assets/ may not exist. … … 362 367 continue; 363 368 } 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'; 368 374 $resolution = isset( $m['resolution'] ) ? $m['resolution'] : false; 375 369 376 $assets[ $type ][ $asset['filename'] ] = compact( 'filename', 'revision', 'resolution', 'location' ); 370 377 } … … 373 380 // Find screenshots in the stable plugin folder (but don't overwrite /assets/) 374 381 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 ); 376 383 $screenshot_id = substr( $filename, strpos( $filename, '-' ) + 1 ); 377 384 $screenshot_id = substr( $screenshot_id, 0, strpos( $screenshot_id, '.' ) ); 378 385 379 if ( isset( $assets['screenshot'][ $filename ] 386 if ( isset( $assets['screenshot'][ $filename ] ) ) { 380 387 // Skip it, it exists within /assets/ already 381 388 continue; … … 383 390 384 391 $assets['screenshot'][ $filename ] = array( 385 'filename' => $filename,386 'revision' => $svn_export['revision'],392 'filename' => $filename, 393 'revision' => $svn_export['revision'], 387 394 'resolution' => $screenshot_id, 388 'location' => 'plugin',395 'location' => 'plugin', 389 396 ); 390 397 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-svn-watcher.php
r5449 r6287 13 13 class SVN_Watcher { 14 14 15 const SVN_URL 16 const PHP 15 const SVN_URL = 'https://plugins.svn.wordpress.org/'; 16 const PHP = '/usr/local/bin/php'; 17 17 18 18 /** … … 77 77 wp_schedule_single_event( time() + 30, 'plugin_directory_check_cronjobs' ); 78 78 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'] ) ); 80 80 } else { 81 81 // If the job fails again within the next minute, throw an exception (as above) … … 104 104 if ( ! isset( $plugins[ $plugin_slug ] ) ) { 105 105 $plugins[ $plugin_slug ] = array( 106 'tags_touched' => array(), // trunk is a tag too!106 'tags_touched' => array(), // trunk is a tag too! 107 107 'readme_touched' => false, // minor optimization, only parse readme i18n on readme-related commits 108 'code_touched' => false,108 'code_touched' => false, 109 109 'assets_touched' => false, 110 'revisions' => array(),110 'revisions' => array(), 111 111 ); 112 112 } … … 116 116 $plugin['revisions'][] = $log['revision']; 117 117 foreach ( $log['paths'] as $path ) { 118 $path_parts = explode( '/', trim( $path, '/' ) );118 $path_parts = explode( '/', trim( $path, '/' ) ); 119 119 120 120 if ( ! isset( $path_parts[1] ) ) { … … 140 140 $plugin['code_touched'] = true; 141 141 } 142 143 142 } 144 143 $plugin['tags_touched'] = array_unique( $plugin['tags_touched'] ); … … 168 167 wp_schedule_single_event( time() + 30, 'plugin_directory_check_cronjobs' ); 169 168 170 throw new Exception( "Unable to determine HEAD revision");169 throw new Exception( 'Unable to determine HEAD revision' ); 171 170 } 172 171 return array_keys( $log['log'] )[0]; … … 182 181 protected function get_option( $option_name ) { 183 182 global $wpdb; 183 184 184 return maybe_unserialize( $wpdb->get_var( $wpdb->prepare( 185 185 "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 30 30 } 31 31 32 $tmp_directory = Filesystem::temp_directory( $this->plugin . '-code-' . $tag );32 $tmp_directory = Filesystem::temp_directory( $this->plugin . '-code-' . $tag ); 33 33 $export_directory = $tmp_directory . '/export'; 34 34 … … 48 48 49 49 $pot_file = "{$tmp_directory}/{$this->plugin}-code.pot"; 50 $makepot = new \MakePOT ;50 $makepot = new \MakePOT(); 51 51 52 52 if ( ! $makepot->wp_plugin( $export_directory, $pot_file, $this->plugin ) || ! file_exists( $pot_file ) ) { … … 81 81 // Whether plugin files should be checked for valid text domains. 82 82 if ( empty( $readme->requires ) || version_compare( $readme->requires, '4.6', '<' ) ) { 83 $error = new WP_Error();83 $error = new WP_Error(); 84 84 $esc_export_directory = escapeshellarg( $export_directory ); 85 85 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-i18n-import.php
r5488 r6287 76 76 77 77 $return_code = 0; 78 $output = [];78 $output = []; 79 79 exec( $cmd, $output, $return_code ); 80 80 $last_line = array_pop( $output ); … … 104 104 $return = new WP_Error( 'create-failure', 'An undefined error occurred while creating the main GlotPress project.' ); 105 105 break; 106 default 106 default: 107 107 $return = new WP_Error( 'undefined', 'An undefined error occurred while setting the GlotPress projects.' ); 108 108 } … … 118 118 * @param string $branch GP project branch to import to (dev|stable) 119 119 * @param string $file Path to POT file 120 * @param array $str_priorities GP string priorities120 * @param array $str_priorities GP string priorities 121 121 */ 122 122 public function import_pot_to_glotpress_project( $project, $branch, $file, $str_priorities = array() ) { … … 172 172 // Fix some locales. 173 173 switch ( $language ) { 174 case 'ga_IR' 174 case 'ga_IR': 175 175 $language = 'ga'; 176 176 break; 177 case 'ca_ES' 177 case 'ca_ES': 178 178 $language = 'ca'; 179 179 break; 180 case 'el_GR' 180 case 'el_GR': 181 181 $language = 'el'; 182 182 break; 183 case 'af_ZA' 183 case 'af_ZA': 184 184 $language = 'af'; 185 185 break; 186 case 'zh_cn' 187 case 'zh_ZH' 186 case 'zh_cn': 187 case 'zh_ZH': 188 188 $language = 'zh_CN'; 189 189 break; 190 case 'uk_UA' 190 case 'uk_UA': 191 191 $language = 'uk'; 192 192 break; 193 case 'sq_AL' 193 case 'sq_AL': 194 194 $language = 'sq'; 195 195 break; 196 case 'ga_IE' 196 case 'ga_IE': 197 197 $language = 'ga'; 198 198 break; 199 case 'gu_IN' 199 case 'gu_IN': 200 200 $language = 'gu'; 201 201 break; 202 case 'hy_AM' 202 case 'hy_AM': 203 203 $language = 'hy'; 204 204 break; 205 case 'eo_EO' 205 case 'eo_EO': 206 206 $language = 'eo'; 207 207 break; 208 case 'ar_AR' 208 case 'ar_AR': 209 209 $language = 'ar'; 210 210 break; 211 case 'hr_HR' 211 case 'hr_HR': 212 212 $language = 'hr'; 213 213 break; 214 case 'cs_CS' 214 case 'cs_CS': 215 215 $language = 'cs_CZ'; 216 216 break; 217 case 'vi_VN' 217 case 'vi_VN': 218 218 $language = 'vi'; 219 219 break; 220 case 'ja_JP' 220 case 'ja_JP': 221 221 $language = 'ja'; 222 222 break; 223 case 'tr' 223 case 'tr': 224 224 $language = 'tr_TR'; 225 225 break; 226 case 'be_BY' 227 case 'be' 226 case 'be_BY': 227 case 'be': 228 228 $language = 'bel'; 229 229 break; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-readme-import.php
r5485 r6287 45 45 46 46 $readme_file = "{$svn_url}{$readme_file}"; 47 $readme = new Parser( $readme_file );47 $readme = new Parser( $readme_file ); 48 48 49 49 if ( ! class_exists( '\PO' ) ) { … … 51 51 } 52 52 53 $pot = new PO ;53 $pot = new PO(); 54 54 $pot->set_header( 'MIME-Version', '1.0' ); 55 55 $pot->set_header( 'Content-Type', 'text/plain; charset=UTF-8' ); … … 129 129 130 130 $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"; 132 132 133 133 $exported = $pot->export_to_file( $pot_file ); … … 148 148 * Handles GlotPress "extracted comments" for translators to get context for each string translations. 149 149 * 150 * @param array $array Empty or existing arrays of string and comments150 * @param array $array Empty or existing arrays of string and comments 151 151 * @param string $key Unique key 152 152 * @param string $val Comment value -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/clients/class-slack.php
r5446 r6287 36 36 */ 37 37 private $success_emoji = [ 38 ':green_heart:', ':white_check_mark:', ':smiley:', ':ok: ', 38 ':green_heart:', 39 ':white_check_mark:', 40 ':smiley:', 41 ':ok: ', 39 42 ]; 40 43 … … 45 48 */ 46 49 private $failure_emoji = [ 47 ':broken_heart:', ':umbrella_with_rain_drops:', ':cry:', ':sos:', 50 ':broken_heart:', 51 ':umbrella_with_rain_drops:', 52 ':cry:', 53 ':sos:', 48 54 ]; 49 55 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-api-update-updater.php
r6195 r6287 58 58 59 59 if ( ! $post || ! in_array( $post->post_status, array( 'publish', 'disabled', 'closed' ) ) ) { 60 $wpdb->delete( 60 $wpdb->delete( $wpdb->prefix . 'update_source', compact( 'plugin_slug' ) ); 61 61 return true; 62 62 } 63 63 64 $data = array(64 $data = array( 65 65 'plugin_id' => $post->ID, 66 66 'plugin_slug' => $post->post_name, … … 102 102 103 103 foreach ( $locales as $locale ) { 104 $cache_key = "plugin_information:"104 $cache_key = 'plugin_information:' 105 105 . ( strlen( $plugin_slug ) > 200 ? 'md5:' . md5( $plugin_slug ) : $plugin_slug ) 106 106 . ":{$locale}"; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php
r5453 r6287 18 18 19 19 // The actual cron hooks. 20 add_action( 'plugin_directory_meta_sync', 21 add_action( 'plugin_directory_svn_sync', 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' ) ); 22 22 add_action( 'plugin_directory_update_api_check', array( __NAMESPACE__ . '\API_Update_Updater', 'cron_trigger' ) ); 23 23 24 24 // A cronjob to check cronjobs 25 add_action( 'plugin_directory_check_cronjobs', 25 add_action( 'plugin_directory_check_cronjobs', array( $this, 'register_cron_tasks' ) ); 26 26 27 27 // Register the wildcard cron hook tasks. … … 36 36 */ 37 37 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 ); 40 46 41 47 return $schedules; … … 121 127 if ( ! $next_timestamp || $next_timestamp === $timestamp ) { 122 128 $events[] = [ 123 'hook' 124 'args' 125 'nextrun' 129 'hook' => $cron_item['_job']->hook, 130 'args' => $cron_item['_job']->args, 131 'nextrun' => $timestamp, 126 132 ]; 127 133 } … … 164 170 } 165 171 166 $event['_job']->args = $data['args'];172 $event['_job']->args = $data['args']; 167 173 $event['_job']->nextrun = $data['nextrun']; 168 174 $event['_job']->save(); … … 227 233 */ 228 234 public function register_cron_tasks() { 229 if ( ! wp_next_scheduled 235 if ( ! wp_next_scheduled( 'plugin_directory_meta_sync' ) ) { 230 236 wp_schedule_event( time() + 60, 'hourly', 'plugin_directory_meta_sync' ); 231 237 } 232 if ( ! wp_next_scheduled 238 if ( ! wp_next_scheduled( 'plugin_directory_svn_sync' ) ) { 233 239 wp_schedule_event( time() + 60, 'every_30s', 'plugin_directory_svn_sync' ); 234 240 } 235 if ( ! wp_next_scheduled 241 if ( ! wp_next_scheduled( 'plugin_directory_update_api_check' ) ) { 236 242 wp_schedule_event( time() + 60, 'hourly', 'plugin_directory_update_api_check' ); 237 243 } 238 if ( ! wp_next_scheduled 244 if ( ! wp_next_scheduled( 'plugin_directory_check_cronjobs' ) ) { 239 245 wp_schedule_event( time() + 60, 'every_120s', 'plugin_directory_check_cronjobs' ); 240 246 } … … 257 263 ); 258 264 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 ) ) { 266 268 continue; 267 269 } 268 270 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 } 273 282 } 274 283 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-meta-sync.php
r5449 r6287 15 15 */ 16 16 public static function cron_trigger() { 17 $class = new Meta_Sync ;17 $class = new Meta_Sync(); 18 18 $class->sync(); 19 19 } … … 62 62 63 63 // 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`' ); 66 66 67 67 if ( strtotime( $last_review_time ) >= strtotime( $current_review_time ) ) { … … 70 70 71 71 // 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( 73 73 "SELECT distinct object_slug FROM `ratings` WHERE object_type = 'plugin' AND `date` >= %s AND `date` < %s", 74 74 $last_review_time, … … 107 107 } 108 108 109 $equivs = wporg_get_version_equivalents();109 $equivs = wporg_get_version_equivalents(); 110 110 $equivs_key = md5( serialize( $equivs ) ); 111 111 if ( $equivs_key === get_option( 'plugin_last_tested_sync' ) ) { … … 121 121 122 122 $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} )" ); 124 124 125 125 foreach ( $tested_values as $row ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-plugin-i18n-import.php
r5488 r6287 17 17 */ 18 18 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; 20 20 $next_scheduled = Manager::get_scheduled_time( "import_plugin_i18n:{$plugin_slug}", 'last' ); 21 21 22 22 // Update a scheduled event if it doesn't run in the next minute. 23 23 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 ); 25 25 if ( $next_scheduled_events ) { 26 26 $next_scheduled_event = array_shift( $next_scheduled_events ); … … 59 59 "import_plugin_i18n:{$plugin_slug}", 60 60 array( 61 array_merge( array( 'plugin' => $plugin_slug ), $plugin_data ) 61 array_merge( array( 'plugin' => $plugin_slug ), $plugin_data ), 62 62 ) 63 63 ); … … 99 99 * 100 100 * @param string $plugin_slug 101 * @param array $i18n_processes101 * @param array $i18n_processes 102 102 */ 103 103 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 23 23 "import_plugin:{$plugin_slug}", 24 24 array( 25 array_merge( array( 'plugin' => $plugin_slug ), $plugin_data ) 25 array_merge( array( 'plugin' => $plugin_slug ), $plugin_data ), 26 26 ) 27 27 ); … … 35 35 $changed_tags = isset( $plugin_data['tags_touched'] ) ? $plugin_data['tags_touched'] : array( 'trunk' ); 36 36 37 $revision = isset( $plugin_data['revisions'] ) ? max( (array) $plugin_data['revisions'] ) : false;37 $revision = isset( $plugin_data['revisions'] ) ? max( (array) $plugin_data['revisions'] ) : false; 38 38 39 39 try { 40 $importer = new CLI\Import ;40 $importer = new CLI\Import(); 41 41 $importer->import_from_svn( $plugin_slug, $changed_tags, $revision ); 42 } catch ( Exception $e ) {42 } catch ( Exception $e ) { 43 43 fwrite( STDERR, "[{$plugin_slug}] Plugin Import Failed: " . $e->getMessage() . "\n" ); 44 44 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/class.jetpack-searchresult-posts-iterator.php
r2934 r6287 8 8 9 9 /** 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 11 11 * search results that may or many not live on other sites. 12 12 * … … 19 19 /** 20 20 * The ES search result to retrieve posts for 21 * 21 * 22 22 * @var array 23 23 */ … … 26 26 /** 27 27 * An array of inflated posts represented in the $search_result 28 * 28 * 29 29 * @var array 30 30 */ … … 33 33 /** 34 34 * The current offset 35 * 35 * 36 36 * @var int 37 37 */ … … 40 40 /** 41 41 * Retrieve the ES search result 42 * 42 * 43 43 * @return array The ES search result 44 44 */ … … 49 49 /** 50 50 * Set the ES search result 51 * 51 * 52 52 * @param array $search_result The ES search result to associate with this iterator 53 53 */ … … 60 60 /** 61 61 * Retrieve a post from the database by id, and conditionally switch to the appropriate blog, if needed 62 * 63 * @param array 64 * @return WP_Post 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 65 65 */ 66 66 protected function inflate_post( $es_result ) { 67 67 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'] ); 74 72 $post = get_post( $es_result['fields']['post_id'] ); 75 73 … … 78 76 79 77 // Implement SeekableIterator 80 81 78 public function seek( $position ) { 82 79 $this->pointer = $position; 83 80 } 84 81 85 public function current 82 public function current() { 86 83 return $this->pointer; 87 84 } 88 85 89 public function key 86 public function key() { 90 87 return $this->pointer; 91 88 } … … 104 101 105 102 // Implement Countable 106 107 103 public function count() { 108 104 return count( $this->search_result['results']['hits'] ); … … 110 106 111 107 // Implement ArrayAccess 112 113 108 public function offsetExists( $index ) { 114 109 return isset( $this->search_result['results']['hits'][ $index ] ); … … 116 111 117 112 public function offsetGet( $index ) { 118 if ( ! $this->offsetExists( $index ) ) 113 if ( ! $this->offsetExists( $index ) ) { 119 114 return null; 115 } 120 116 121 117 // Lazy load the post 122 if ( ! isset( $this->posts[ $index ] ) ) 118 if ( ! isset( $this->posts[ $index ] ) ) { 123 119 $this->posts[ $index ] = $this->inflate_post( $this->search_result['results']['hits'][ $index ] ); 120 } 124 121 125 122 return $this->posts[ $index ]; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search-debug.php
r4456 r6287 1 1 <?php 2 2 3 add_filter( 'debug_bar_panels', function($panels) {3 add_filter( 'debug_bar_panels', function( $panels ) { 4 4 class Debug_Bar_Search extends Debug_Bar_Panel { 5 5 function init() { 6 $this->title( __( 'Search', 'debug-bar') );6 $this->title( __( 'Search', 'debug-bar' ) ); 7 7 } 8 8 … … 12 12 13 13 function render() { 14 15 14 $search = Jetpack_Search::instance(); 16 15 17 16 echo "<div id='debug-bar-jetpack-search'>"; 18 19 17 20 18 echo '<h3>', __( 'Elasticsearch Query:', 'debug-bar' ), '</h3>'; … … 30 28 $panels[] = new Debug_Bar_Search(); 31 29 return $panels; 32 } );30 } ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/site-search/jetpack-search.php
r6197 r6287 50 50 */ 51 51 52 require_once ( __DIR__ . '/class.jetpack-searchresult-posts-iterator.php' );52 require_once __DIR__ . '/class.jetpack-searchresult-posts-iterator.php'; 53 53 54 54 class Jetpack_Search { … … 67 67 protected static $instance; 68 68 69 // Languages with custom analyzers, other languages are supported,69 // Languages with custom analyzers, other languages are supported, 70 70 // but are analyzed with the default analyzer. 71 71 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' ); 72 72 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-'; 76 76 const ERROR_COUNT_WINDOW = 60; // seconds 77 77 … … 80 80 } 81 81 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" ); } 85 87 86 88 public static function instance() { 87 89 if ( ! isset( self::$instance ) ) { 88 self::$instance = new Jetpack_Search ;90 self::$instance = new Jetpack_Search(); 89 91 self::$instance->setup(); 90 92 } … … 93 95 94 96 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 98 99 $this->jetpack_blog_id = Jetpack::get_option( 'id' ); 99 100 … … 105 106 public function set_lang( $lang = false ) { 106 107 if ( ! $lang ) { 107 // TODO: don't think this works for Jetpack108 // TODO: don't think this works for Jetpack 108 109 $blog = get_blog_details( $blog_id ); 109 110 $lang = get_lang_code_by_id( $blog->lang_id ); … … 112 113 } 113 114 114 // ///////////////////////////////////////////////////115 // 115 116 // Lots of hooks 116 117 117 public function init_hooks() { 118 118 // Checks to see if we need to worry about found_posts 119 119 add_filter( 'post_limits_request', array( $this, 'filter__post_limits_request' ), 999, 2 ); 120 120 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 123 122 // Force $q['cache_results'] = false; this prevents the un-inflated WP_Post objects from being stored in cache 124 123 add_action( 'pre_get_posts', array( $this, 'action__pre_get_posts' ), 5 ); … … 142 141 143 142 // 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 } 146 146 } 147 147 … … 152 152 */ 153 153 public function register_loop_hooks() { 154 add_action( 'loop_start', 155 add_action( 'loop_end', 154 add_action( 'loop_start', array( $this, 'action__loop_start' ) ); 155 add_action( 'loop_end', array( $this, 'action__loop_end' ) ); 156 156 } 157 157 … … 162 162 */ 163 163 public function unregister_loop_hooks() { 164 remove_action( 'the_post', 165 remove_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 // 170 170 // Raw Search Query 171 172 /* 171 /* 173 172 * Return a count of the number of search API errors within the last ERROR_COUNT_WINDOW seconds 174 173 */ 175 174 protected function get_error_volume() { 176 175 // 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 /* 184 183 * Increment the recent error volume by $count. 185 184 */ 186 185 protected function increment_error_volume( $count = 1 ) { 187 186 // 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 ) ); 189 188 wp_cache_add( self::ERROR_COUNT_KEY . $tick, 0, self::CACHE_GROUP, self::ERROR_COUNT_WINDOW ); 190 189 return wp_cache_incr( self::ERROR_COUNT_KEY . $tick, $count, self::CACHE_GROUP ); … … 204 203 // For 20 errors, a 50% chance 205 204 // For 40+ errors, a 0% chance 206 207 205 $threshold = ceil( 10 / ( 1 + pow( $error_volume / 20, 4 ) ) ); 208 206 return mt_rand( 1, 10 ) <= $threshold; … … 213 211 */ 214 212 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 ); 216 214 return $this->increment_error_volume(); 217 215 } … … 224 222 */ 225 223 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'; 227 225 $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 231 229 $response = wp_cache_get( $cache_key, self::CACHE_GROUP ); 232 230 … … 238 236 if ( $this->error_volume_is_low() ) { 239 237 $request = wp_remote_post( $service_url, array( 240 'headers' => array(238 'headers' => array( 241 239 'Content-Type' => 'application/json', 242 240 ), 243 'timeout' => 10,241 'timeout' => 10, 244 242 'user-agent' => 'WordPress.org/jetpack_search', 245 'body' => $json_es_args,243 'body' => $json_es_args, 246 244 ) ); 247 245 } else { … … 258 256 wp_cache_set( $lock_key, 1, self::CACHE_GROUP, mt_rand( 3, 7 ) ); 259 257 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 } 264 263 265 264 // If we have a stale cached response, return that. Otherwise, return the error object. 266 if ( $response ) 265 if ( $response ) { 267 266 return $response; // Stale cached response. 267 } 268 268 return $request; // Fresh error object. 269 269 } … … 271 271 $fresh_response = json_decode( wp_remote_retrieve_body( $request ), true ); 272 272 273 if ( ! $fresh_response || isset( $fresh_response['error'] ) ) {273 if ( ! $fresh_response || isset( $fresh_response['error'] ) ) { 274 274 // As above, lock further requests for the same search for a few seconds 275 275 wp_cache_set( $lock_key, 1, self::CACHE_GROUP, mt_rand( 3, 7 ) ); 276 276 277 if ( isset( $fresh_response['error'] ) ) 278 $this->search_error( 'remote error ' .$fresh_response['error'], E_USER_WARNING );279 else277 if ( isset( $fresh_response['error'] ) ) { 278 $this->search_error( 'remote error ' . $fresh_response['error'], E_USER_WARNING ); 279 } else { 280 280 $this->search_error( 'invalid json response', E_USER_WARNING ); 281 } 281 282 282 283 // Return a stale response if we have one 283 if ( $response ) 284 if ( $response ) { 284 285 return $response; 286 } 285 287 return $fresh_response; // Fresh error object as a last resort 286 288 … … 294 296 } else { 295 297 // 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 ) { 297 299 trigger_error( 'Plugin directory search: no cached results available during stampede.', E_USER_WARNING ); 300 } 298 301 } 299 302 … … 301 304 } 302 305 303 //TODO: add secured search for posts/comments 304 305 ///////////////////////////////////////////////////////// 306 // TODO: add secured search for posts/comments 307 // 306 308 // Insert the ES results into the Loop when searching 307 309 // 308 309 310 public function filter__post_limits_request( $limits, $query ) { 310 if ( ! $query->is_search() ) 311 if ( ! $query->is_search() ) { 311 312 return $limits; 313 } 312 314 313 315 if ( empty( $limits ) || $query->get( 'no_found_rows' ) ) { … … 321 323 322 324 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() ) { 324 326 return $posts; 327 } 325 328 326 329 if ( ! is_array( $this->search_result ) || ! isset( $this->search_result['results'] ) ) { … … 340 343 $post = new stdClass(); 341 344 342 $post->ID 343 $post->blog_id 345 $post->ID = $result['fields']['post_id']; 346 $post->blog_id = $result['fields']['blog_id']; 344 347 345 348 // Run through get_post() to add all expected properties (even if they're empty) 346 349 $post = get_post( $post ); 347 350 348 if ( $post ) 351 if ( $post ) { 349 352 $posts[] = $post; 353 } 350 354 } 351 355 … … 359 363 global $wpdb; 360 364 361 if ( ! $query->is_main_query() || ! $query->is_search() ) 365 if ( ! $query->is_main_query() || ! $query->is_search() ) { 362 366 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; 365 370 $posts_per_page = $query->get( 'posts_per_page' ); 366 371 367 372 // ES API does not allow more than 15 results at a time 368 if ( $posts_per_page > 200 ) 373 if ( $posts_per_page > 200 ) { 369 374 $posts_per_page = 200; 375 } 370 376 371 377 // ES API does not allow fetching past the 10,000th post 372 378 $page = min( $page, floor( 9999 / $posts_per_page ) ); 373 379 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' ); 377 383 378 384 // Start building the WP-style search query args … … 385 391 'order' => $query->get( 'order' ), 386 392 // plugin directory specific: 387 #'date_range'=> array( 'field' => 'modified', 'gte' => $date_cutoff ),388 #'tested_range'=> array( 'field' => 'tested', 'gte' => $version_cutoff ),389 'filters' 393 // 'date_range' => array( 'field' => 'modified', 'gte' => $date_cutoff ), 394 // 'tested_range' => array( 'field' => 'tested', 'gte' => $version_cutoff ), 395 'filters' => array( 390 396 array( 'term' => array( 'disabled' => array( 'value' => false ) ) ), 391 397 ), … … 400 406 401 407 $es_wp_query_args['locale'] = get_locale(); 402 408 403 409 // You can use this filter to modify the search query parameters, such as controlling the post_type. 404 410 // These arguments are in the format for convert_wp_es_to_es_args(), i.e. WP-style. … … 408 414 $es_query_args = $this->convert_wp_es_to_es_args( $es_wp_query_args ); 409 415 410 // Only trust ES to give us IDs, not the content since it is a mirror416 // Only trust ES to give us IDs, not the content since it is a mirror 411 417 $es_query_args['fields'] = array( 412 418 'slug', … … 422 428 'plugin_modified', 423 429 'post_id', 424 'blog_id' 430 'blog_id', 425 431 ); 426 432 427 433 // 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 ); 429 435 $this->search_query = $es_query_args; 430 436 … … 447 453 448 454 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() ) { 450 456 return $sql; 457 } 451 458 452 459 return ''; … … 454 461 455 462 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() ) { 457 464 return $found_posts; 465 } 458 466 459 467 return $this->found_posts; … … 462 470 public function action__pre_get_posts( $query ) { 463 471 // 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' ) { 465 473 $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() ) { 468 477 return; 478 } 469 479 470 480 $query->set( 'cache_results', false ); … … 490 500 491 501 // 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 ) { 493 503 switch_to_blog( $this->original_blog_id ); 504 } 494 505 } 495 506 … … 499 510 $post = $this->get_post_by_index( $wp_query->current_post ); 500 511 501 if ( ! $post ) 512 if ( ! $post ) { 502 513 return; 514 } 503 515 504 516 // Do some additional setup that normally happens in setup_postdata(), but gets skipped 505 517 // in this plugin because the posts hadn't yet been inflated. 506 $authordata 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; 512 524 $multipage = 0; 513 $page = get_query_var('page');514 if ( ! $page ) 525 $page = get_query_var( 'page' ); 526 if ( ! $page ) { 515 527 $page = 1; 516 if ( is_single() || is_page() || is_feed() ) 528 } 529 if ( is_single() || is_page() || is_feed() ) { 517 530 $more = 1; 531 } 518 532 $content = $post->post_content; 519 533 if ( false !== strpos( $content, '<!--nextpage-->' ) ) { 520 if ( $page > 1 ) 534 if ( $page > 1 ) { 521 535 $more = 1; 536 } 522 537 $content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content ); 523 538 $content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content ); 524 539 $content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content ); 525 540 // Ignore nextpage at the beginning of the content. 526 if ( 0 === strpos( $content, '<!--nextpage-->' ) ) 541 if ( 0 === strpos( $content, '<!--nextpage-->' ) ) { 527 542 $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 ) { 531 547 $multipage = 1; 548 } 532 549 } else { 533 550 $pages = array( $post->post_content ); … … 543 560 544 561 public function get_search_result( $raw = false ) { 545 if ( $raw ) 562 if ( $raw ) { 546 563 return $this->search_result; 564 } 547 565 548 566 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; … … 553 571 } 554 572 555 // ///////////////////////////////////////////////573 // 556 574 // Standard Filters Applied to the search query 557 575 // 558 559 576 public function filter__add_date_filter_to_query( $es_wp_query_args, $query ) { 560 577 if ( $query->get( 'year' ) ) { … … 580 597 } 581 598 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 ); 583 604 } 584 605 … … 586 607 } 587 608 588 // ///////////////////////////////////////////////609 // 589 610 // Helpers for manipulating queries 590 611 // 591 592 612 // Someday: Should we just use ES_WP_Query??? 593 594 613 // Converts WP-style args to ES args 595 614 function convert_wp_es_to_es_args( $args ) { … … 608 627 609 628 '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' 611 'filters' 629 'tested_range' => null, 630 'filters' => array(), 612 631 613 632 'orderby' => null, // Defaults to 'relevance' if query is set, otherwise 'date'. Pass an array for multiple orders. … … 637 656 ); 638 657 639 //TODO: limit size to 15 640 658 // TODO: limit size to 15 641 659 // ES "from" arg (offset) 642 660 if ( $args['offset'] ) { … … 646 664 } 647 665 648 if ( ! is_array( $args['author_name'] ) ) {666 if ( ! is_array( $args['author_name'] ) ) { 649 667 $args['author_name'] = array( $args['author_name'] ); 650 668 } … … 652 670 // ES stores usernames, not IDs, so transform 653 671 if ( ! empty( $args['author'] ) ) { 654 if ( ! is_array( $args['author'] ) )672 if ( ! is_array( $args['author'] ) ) { 655 673 $args['author'] = array( $args['author'] ); 674 } 656 675 foreach ( $args['author'] as $author ) { 657 676 $user = get_user_by( 'id', $author ); … … 663 682 } 664 683 665 // ////////////////////////////////////////////////684 // 666 685 // Build the filters from the query elements. 667 686 // Filters rock because they are cached from one query to the next … … 671 690 672 691 if ( $args['post_type'] ) { 673 if ( ! is_array( $args['post_type'] ) )692 if ( ! is_array( $args['post_type'] ) ) { 674 693 $args['post_type'] = array( $args['post_type'] ); 694 } 675 695 $filters[] = array( 'terms' => array( 'post_type' => $args['post_type'] ) ); 676 696 } … … 680 700 } 681 701 682 if ( ! empty( $args['date_range'] ) && isset( $args['date_range']['field'] ) ) {702 if ( ! empty( $args['date_range'] ) && isset( $args['date_range']['field'] ) ) { 683 703 $field = $args['date_range']['field']; 684 704 unset( $args['date_range']['field'] ); … … 686 706 } 687 707 688 if ( ! empty( $args['tested_range'] ) && isset( $args['tested_range']['field'] ) ) {708 if ( ! empty( $args['tested_range'] ) && isset( $args['tested_range']['field'] ) ) { 689 709 $field = $args['tested_range']['field']; 690 710 unset( $args['tested_range']['field'] ); … … 721 741 $locale = $args['locale']; 722 742 723 // Because most plugins don't have any translations we need to743 // Because most plugins don't have any translations we need to 724 744 // correct for the very low scores that locale-specific fields. 725 745 // end up getting. This is caused by the average field length being … … 729 749 // As of 2017-01-23 it looked like we were off by about 10,000x, 730 750 // 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( 733 753 '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( 737 757 'title_' . $locale, 738 758 'excerpt_' . $locale, … … 743 763 'taxonomy.plugin_tags.name', 744 764 ); 745 $boost_ngram_fields = array(765 $boost_ngram_fields = array( 746 766 '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( 750 770 'title_' . $locale, 751 771 'title_en^' . $en_boost, … … 760 780 ); 761 781 } 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( 766 786 'title_en', 767 787 'excerpt_en', … … 769 789 'taxonomy.plugin_tags.name', 770 790 ); 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( 775 795 'title_en', 776 796 'slug_text', … … 782 802 ); 783 803 } 784 785 // /////////////////////////////////////////////////////////804 805 // 786 806 // Build the query - potentially extracting more filters 787 // 788 // 789 // 807 // TODO: add auto phrase searching 808 // TODO: add fuzzy searching to correct for spelling mistakes 809 // TODO: boost title, tag, and category matches 790 810 if ( $args['query'] ) { 791 811 $analyzer = Jetpack_Search::get_analyzer_name( $this->blog_lang ); 792 $query = array(812 $query = array( 793 813 'bool' => array( 794 'must' => array(814 'must' => array( 795 815 '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, 799 819 'operator' => 'and', 800 820 ), … … 805 825 'query' => $args['query'], 806 826 'fields' => $boost_phrase_fields, 807 'type' => 'phrase',808 'boost' => 2827 'type' => 'phrase', 828 'boost' => 2, 809 829 ), 810 830 ), … … 813 833 'query' => $args['query'], 814 834 'fields' => $boost_ngram_fields, 815 'type' => 'phrase',816 'boost' => 0.2835 'type' => 'phrase', 836 'boost' => 0.2, 817 837 ), 818 838 ), … … 821 841 'query' => $args['query'], 822 842 'fields' => $boost_title_fields, 823 'type' => 'best_fields',824 'boost' => 2843 'type' => 'best_fields', 844 'boost' => 2, 825 845 ), 826 846 ), … … 829 849 'query' => $args['query'], 830 850 'fields' => $boost_content_fields, 831 'type' => 'best_fields',832 'boost' => 2851 'type' => 'best_fields', 852 'boost' => 2, 833 853 ), 834 854 ), … … 840 860 'contributors', 841 861 ), 842 'type' => 'best_fields',843 'boost' => 2862 'type' => 'best_fields', 863 'boost' => 2, 844 864 ), 845 865 ), … … 854 874 } 855 875 } else { 856 $query = array( 'match_all' => array() );876 $query = array( 'match_all' => array() ); 857 877 $es_query_args['query'] = Jetpack_Search::score_query_by_recency( $query ); 858 878 if ( ! $args['orderby'] ) { … … 877 897 // todo: add support for sorting by title, num likes, num comments, num views, etc 878 898 switch ( $orderby ) { 879 case 'relevance' 880 // never order by score ascending899 case 'relevance': 900 // never order by score ascending 881 901 $es_query_args['sort'][] = array( '_score' => array( 'order' => 'desc' ) ); 882 902 break; 883 case 'date' 903 case 'date': 884 904 $es_query_args['sort'][] = array( 'date' => array( 'order' => $args['order'] ) ); 885 905 break; 886 case 'ID' 906 case 'ID': 887 907 $es_query_args['sort'][] = array( 'id' => array( 'order' => $args['order'] ) ); 888 908 break; 889 case 'author' 909 case 'author': 890 910 $es_query_args['sort'][] = array( 'author.raw' => array( 'order' => $args['order'] ) ); 891 911 break; 892 912 } 893 913 } 894 if ( empty( $es_query_args['sort'] ) ) 914 if ( empty( $es_query_args['sort'] ) ) { 895 915 unset( $es_query_args['sort'] ); 896 916 } 897 917 898 918 if ( ! empty( $filters ) ) { … … 911 931 } else { 912 932 $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 ) ) { 914 934 $analyzer = $split_lang[0] . '_analyzer'; 935 } 915 936 } 916 937 return $analyzer; 917 938 } 918 939 919 // //////////////////////////////////////////940 // 920 941 // ES Filter Manipulation 921 922 942 /* 923 943 * And an existing filter object with a list of additional filters. … … 925 945 */ 926 946 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 ) ) { 929 949 return $filters[0]; 950 } 930 951 931 952 return array( 'and' => $filters ); … … 935 956 } 936 957 937 // //////////////////////////////////////////958 // 938 959 // ES Query Manipulation 939 940 960 public static function score_query_by_recency( $query ) { 941 // Newer content gets weighted slightly higher942 $date_scale = '360d';961 // Newer content gets weighted slightly higher 962 $date_scale = '360d'; 943 963 $date_offset = '180d'; 944 $date_decay = 0.5;964 $date_decay = 0.5; 945 965 $date_origin = date( 'Y-m-d' ); 946 966 … … 949 969 'query' => array( 950 970 'function_score' => array( 951 'query' => $query,952 'functions' => array(971 'query' => $query, 972 'functions' => array( 953 973 array( 954 'exp' => array(974 'exp' => array( 955 975 'plugin_modified' => array( 956 976 'origin' => $date_origin, 957 977 'offset' => $date_offset, 958 'scale' => $date_scale,959 'decay' => $date_decay,978 'scale' => $date_scale, 979 'decay' => $date_decay, 960 980 ), 961 981 ), 962 982 ), 963 array( 983 array( 964 984 'exp' => array( 965 985 'tested' => array( 966 986 'origin' => sprintf( '%0.1f', WP_CORE_STABLE_BRANCH ), 967 987 'offset' => 0.1, 968 'scale' => 0.4,969 'decay' => 0.6,988 'scale' => 0.4, 989 'decay' => 0.6, 970 990 ), 971 991 ), … … 973 993 array( 974 994 'field_value_factor' => array( 975 'field' => 'active_installs',976 'factor' => 0.375,995 'field' => 'active_installs', 996 'factor' => 0.375, 977 997 'modifier' => 'log2p', 978 'missing' => 1,998 'missing' => 1, 979 999 ), 980 1000 ), 981 1001 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) 983 1003 // we don't need to differentiate them as much 984 1004 'filter' => array( 985 'range' => array( 'active_installs' => array( 986 'lte' => 1000000 987 ) ) 1005 'range' => array( 1006 'active_installs' => array( 1007 'lte' => 1000000, 1008 ), 1009 ), 988 1010 ), 989 'exp' => array(1011 'exp' => array( 990 1012 'active_installs' => array( 991 1013 'origin' => 1000000, 992 1014 'offset' => 0, 993 'scale' => 900000,994 'decay' => 0.75,1015 'scale' => 900000, 1016 'decay' => 0.75, 995 1017 ), 996 1018 ), … … 998 1020 array( 999 1021 'field_value_factor' => array( 1000 'field' => 'support_threads_resolved',1001 'factor' => 0.25,1022 'field' => 'support_threads_resolved', 1023 'factor' => 0.25, 1002 1024 'modifier' => 'log2p', 1003 'missing' => 0.5,1025 'missing' => 0.5, 1004 1026 ), 1005 1027 ), 1006 1028 array( 1007 1029 'field_value_factor' => array( 1008 'field' => 'rating',1009 'factor' => 0.25,1030 'field' => 'rating', 1031 'factor' => 0.25, 1010 1032 'modifier' => 'sqrt', 1011 'missing' => 2.5,1033 'missing' => 2.5, 1012 1034 ), 1013 1035 ), 1014 1036 ), 1015 1037 'boost_mode' => 'multiply', 1016 ) 1038 ), 1017 1039 ), 1018 ) 1040 ), 1019 1041 ); 1020 1042 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/plugin-directory.php
r3369 r6287 22 22 23 23 // Register an Autoloader for all files 24 include __DIR__ . '/class-autoloader.php';24 require __DIR__ . '/class-autoloader.php'; 25 25 Autoloader\register_class_path( __NAMESPACE__, __DIR__ ); 26 26 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php
r6285 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Readme; 3 3 4 use WordPressdotorg\Plugin_Directory\Markdown; 4 5 … … 159 160 protected function parse_readme( $file ) { 160 161 $contents = file_get_contents( $file ); 161 if ( preg_match( '!!u', $contents ) ) 162 if ( preg_match( '!!u', $contents ) ) { 162 163 $contents = preg_split( '!\R!u', $contents ); 163 else164 } else { 164 165 $contents = preg_split( '!\R!', $contents ); // regex failed due to invalid UTF8 in $contents, see #2298 166 } 165 167 $contents = array_map( array( $this, 'strip_newlines' ), $contents ); 166 168 … … 212 214 } 213 215 214 $bits = explode( ':', trim( $line ), 2 );216 $bits = explode( ':', trim( $line ), 2 ); 215 217 list( $key, $value ) = $bits; 216 $key = strtolower( trim( $key, " \t*-\r\n" ) );218 $key = strtolower( trim( $key, " \t*-\r\n" ) ); 217 219 if ( isset( $this->valid_headers[ $key ] ) ) { 218 220 $headers[ $this->valid_headers[ $key ] ] = trim( $value ); … … 252 254 if ( empty( $headers['license_uri'] ) && preg_match( '!(https?://\S+)!i', $headers['license'], $url ) ) { 253 255 $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" ); 255 257 } 256 258 $this->license = $headers['license']; … … 268 270 } 269 271 if ( ( '=' === $trimmed[0] && isset( $trimmed[1] ) && '=' === $trimmed[1] ) || 270 272 ( '#' === $trimmed[0] && isset( $trimmed[1] ) && '#' === $trimmed[1] ) 271 273 ) { 272 274 … … 295 297 // Stop only after a ## Markdown header, not a ###. 296 298 if ( ( '=' === $trimmed[0] && isset( $trimmed[1] ) && '=' === $trimmed[1] ) || 297 299 ( '#' === $trimmed[0] && isset( $trimmed[1] ) && '#' === $trimmed[1] && isset( $trimmed[2] ) && '#' !== $trimmed[2] ) 298 300 ) { 299 301 … … 312 314 // If we encounter an unknown section header, include the provided Title, we'll filter it to other_notes later. 313 315 if ( ! in_array( $section_name, $this->expected_sections ) ) { 314 $current .= '<h3>' . $section_title . '</h3>';316 $current .= '<h3>' . $section_title . '</h3>'; 315 317 $section_name = 'other_notes'; 316 318 } … … 334 336 335 337 // Suffix the Other Notes section to the description. 336 if ( ! empty( $this->sections['other_notes'] ) ) {338 if ( ! empty( $this->sections['other_notes'] ) ) { 337 339 $this->sections['description'] .= "\n" . $this->sections['other_notes']; 338 340 unset( $this->sections['other_notes'] ); … … 348 350 // Display FAQs as a definition list. 349 351 if ( isset( $this->sections['faq'] ) ) { 350 $this->faq = $this->parse_section( $this->sections['faq'] );352 $this->faq = $this->parse_section( $this->sections['faq'] ); 351 353 $this->sections['faq'] = ''; 352 354 } … … 356 358 $this->faq = array_merge( 357 359 array( 358 __( 'Installation Instructions', 'wporg-plugins' ) => $this->sections['installation'] 360 __( 'Installation Instructions', 'wporg-plugins' ) => $this->sections['installation'], 359 361 ), 360 362 $this->faq 361 363 ); 362 // unset( $this->sections['installation'] );364 // unset( $this->sections['installation'] ); 363 365 $this->sections['faq'] = ''; // Ensure it's set as per faq section above. 364 366 } … … 401 403 $this->sections['faq'] .= "\n<dl>\n"; 402 404 foreach ( $this->faq as $question => $answer ) { 403 $question_slug = sanitize_title_with_dashes( $question );405 $question_slug = sanitize_title_with_dashes( $question ); 404 406 $this->sections['faq'] .= "<dt id='{$question_slug}'>{$question}</dt>\n<dd>{$answer}</dd>\n"; 405 407 } … … 497 499 $text = force_balance_tags( $text ); 498 500 // TODO: make_clickable() will act inside shortcodes. 499 //$text = make_clickable( $text ); 500 501 // $text = make_clickable( $text ); 501 502 $text = wp_kses( $text, $allowed ); 502 503 503 504 // 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) 504 505 // 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 ); 507 507 $text = trim( $text ); 508 508 … … 516 516 * @return string 517 517 */ 518 protected function sanitize_text( $text ) { // not fancy 518 protected function sanitize_text( $text ) { 519 // not fancy 519 520 $text = strip_tags( $text ); 520 521 $text = esc_html( $text ); … … 583 584 */ 584 585 protected function parse_section( $lines ) { 585 $key = $value = '';586 $key = $value = ''; 586 587 $return = array(); 587 588 … … 606 607 $line_count = count( $lines ); 607 608 for ( $i = 0; $i < $line_count; $i++ ) { 608 $line = &$lines[ $i ];609 $line = &$lines[ $i ]; 609 610 $trimmed = &$trimmed_lines[ $i ]; 610 611 if ( ! $trimmed ) { … … 627 628 $value = ''; 628 629 // Trim off the first character of the line, as we know that's the heading style we're expecting to remove. 629 $key 630 $key = trim( $line, $trimmed[0] . " \t" ); 630 631 continue; 631 632 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php
r5841 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Readme; 3 3 4 use WordPressdotorg\Plugin_Directory\Tools\Filesystem; 4 5 … … 34 35 $error = sprintf( __( 'URL must end in %s!', 'wporg-plugins' ), '<code>readme.txt</code>' ); 35 36 return array( 36 'errors' => array( $error ) 37 'errors' => array( $error ), 37 38 ); 38 39 } … … 42 43 $error = __( 'Invalid readme.txt URL.', 'wporg-plugins' ); 43 44 return array( 44 'errors' => array( $error ) 45 'errors' => array( $error ), 45 46 ); 46 47 } … … 64 65 if ( empty( $readme->name ) ) { 65 66 /* 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>' ); 67 68 } 68 69 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-developers.php
r5920 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_I18n; 4 5 use WordPressdotorg\Plugin_Directory\Tools; … … 15 16 */ 16 17 static function display() { 17 $post 18 $slug 19 $title 18 $post = get_post(); 19 $slug = $post->post_name; 20 $title = get_the_title( $post ); 20 21 21 22 $output = '<div class="plugin-contributors">'; … … 44 45 $output .= '<p>'; 45 46 46 $wp_locales = wp_list_pluck( $locales,'wp_locale' );47 $wp_locales = wp_list_pluck( $locales, 'wp_locale' ); 47 48 $locales_count = get_sites( [ 48 49 'network_id' => WPORG_GLOBAL_NETWORK_ID, … … 76 77 } 77 78 78 $output .= '<p>' . sprintf( '<a href="%1$s">%2$s</a>', 79 $output .= '<p>' . sprintf( 80 '<a href="%1$s">%2$s</a>', 79 81 esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $slug ), 80 82 sprintf( … … 84 86 ) 85 87 ) . '</p>'; 86 87 88 88 89 $output .= '<h3>' . __( 'Interested in development?', 'wporg-plugins' ) . '</h3>'; … … 115 116 } 116 117 $output .= '</div>'; 118 117 119 return $output; 118 120 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-readme-validator.php
r5333 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\Readme\Validator; 4 5 … … 21 22 <form method="post" action=""> 22 23 <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' ); ?>" /> 25 32 </p> 26 33 </form> … … 28 35 <p><?php _e( '... or paste your <code>readme.txt</code> here:', 'wporg-plugins' ); ?></p> 29 36 <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 31 39 if ( isset( $_POST['readme_contents'] ) ) { 32 40 echo esc_textarea( wp_unslash( $_POST['readme_contents'] ) ); 33 41 } 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> 36 45 </form> 37 46 </div> … … 43 52 */ 44 53 protected static function validate_readme() { 45 if ( !empty( $_POST['readme_url'] ) ) {54 if ( ! empty( $_POST['readme_url'] ) ) { 46 55 $errors = Validator::instance()->validate_url( wp_unslash( $_POST['readme_url'] ) ); 47 56 48 } elseif ( ! empty( $_POST['readme_contents'] ) ) {57 } elseif ( ! empty( $_POST['readme_contents'] ) ) { 49 58 $errors = Validator::instance()->validate_content( wp_unslash( $_REQUEST['readme_contents'] ) ); 50 59 … … 58 67 'errors' => __( 'Fatal Errors:', 'wporg-plugins' ), 59 68 'warnings' => __( 'Warnings:', 'wporg-plugins' ), 60 'notes' => __( 'Notes:', 'wporg-plugins' ) 69 'notes' => __( 'Notes:', 'wporg-plugins' ), 61 70 ); 62 71 foreach ( $error_types as $field => $warning_label ) { 63 if ( ! empty( $errors[ $field ] ) ) {72 if ( ! empty( $errors[ $field ] ) ) { 64 73 $output .= "{$warning_label}\n<ul class='{$field} error'>\n"; 65 74 foreach ( $errors[ $field ] as $notice ) { … … 72 81 if ( empty( $output ) ) { 73 82 $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>'; 75 84 $output .= '</div>'; 76 85 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-reviews.php
r5229 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 use WordPressdotorg\Plugin_Directory\Tools; … … 15 16 */ 16 17 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(); 19 20 $review_count = array_sum( $ratings ); 20 21 … … 38 39 <?php if ( ! empty( $review->ID ) ) : ?> 39 40 <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 : ?> 41 42 <h3 class="review-title"><?php echo get_the_title( $review ); ?></h3> 42 43 <?php endif; ?> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php
r5197 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 use WordPressdotorg\Plugin_Directory\Plugin_i18n; … … 20 21 // All indexed from 1. 21 22 $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(); 23 24 24 25 if ( empty( $screen_shots ) ) { … … 33 34 */ 34 35 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>', 36 38 esc_url( Template::get_asset_url( $plugin, $image ) ) 37 39 ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r6045 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\Readme\Parser; 4 5 use WordPressdotorg\Plugin_Directory\Plugin_Directory; … … 44 45 */ 45 46 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'; 50 51 } 51 52 … … 58 59 */ 59 60 public function process_upload() { 60 $zip_file = $_FILES['zip_file']['tmp_name'];61 $zip_file = $_FILES['zip_file']['tmp_name']; 61 62 $this->plugin_dir = Filesystem::unzip( $zip_file ); 62 63 … … 65 66 $plugin_data = get_plugin_data( $plugin_file, false, false ); // No markup/translation needed. 66 67 if ( ! empty( $plugin_data['Name'] ) ) { 67 $this->plugin = $plugin_data;68 $this->plugin = $plugin_data; 68 69 $this->plugin_root = dirname( $plugin_file ); 69 70 break; … … 104 105 if ( $this->has_reserved_slug() ) { 105 106 $error = __( 'Error: The plugin has a reserved name.', 'wporg-plugins' ); 106 107 107 108 return new \WP_Error( 'reserved_name', $error . ' ' . sprintf( 108 109 /* translators: 1: plugin slug, 2: 'Plugin Name:' */ … … 118 119 if ( $plugin_post && $plugin_post->post_author != get_current_user_id() ) { 119 120 $error = __( 'Error: The plugin already exists.', 'wporg-plugins' ); 120 121 121 122 return new \WP_Error( 'already_exists', $error . ' ' . sprintf( 122 123 /* translators: 1: plugin slug, 2: 'Plugin Name:' */ … … 130 131 if ( $plugin_post ) { 131 132 $error = __( 'Error: The plugin has already been submitted.', 'wporg-plugins' ); 132 133 133 134 return new \WP_Error( 'already_submitted', $error . ' ' . sprintf( 134 135 /* translators: 1: plugin slug, 2: plugins@wordpress.org */ … … 163 164 if ( preg_match( '|[^\d\.]|', $this->plugin['Version'] ) ) { 164 165 $error = __( 'Error: Plugin versions are expected to be numbers.', 'wporg-plugins' ); 165 166 166 167 return new \WP_Error( 'invalid_version', $error . ' ' . sprintf( 167 168 /* translators: %s: 'Version:' */ … … 174 175 if ( ! empty( $this->plugin['PluginURI'] ) && ! empty( $this->plugin['AuthorURI'] ) && $this->plugin['PluginURI'] == $this->plugin['AuthorURI'] ) { 175 176 $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 . ' ' . 178 180 __( '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' ) 179 181 ); … … 183 185 if ( empty( $readme ) ) { 184 186 $error = __( 'Error: The plugin has no readme.', 'wporg-plugins' ); 185 187 186 188 return new \WP_Error( 'no_readme', $error . ' ' . sprintf( 187 189 /* translators: 1: readme.txt, 2: readme.md */ … … 199 201 if ( ! $result ) { 200 202 $error = __( 'Error: The plugin has failed the automated checks.', 'wporg-plugins' ); 201 203 202 204 return new \WP_Error( 'failed_checks', $error . ' ' . sprintf( 203 205 /* translators: 1: Plugin Check Plugin URL, 2: make.wordpress.org/plugins */ … … 210 212 // Passed all tests! 211 213 // Let's save everything and get things wrapped up. 212 213 214 // Create a new post on first-time submissions. 214 215 if ( ! $plugin_post ) { … … 225 226 'post_content' => $content, 226 227 'post_excerpt' => $this->plugin['Description'], 227 //'tax_input' => wp_unslash( $_POST['tax_input'] ), // for category selection228 // 'tax_input' => wp_unslash( $_POST['tax_input'] ), // for category selection 228 229 'meta_input' => array( 229 230 'tested' => $readme->tested, … … 277 278 278 279 /* 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.' ), 280 282 esc_html( $this->plugin['Name'] ), 281 283 '<code>' . $this->plugin_slug . '</code>' … … 283 285 284 286 /* translators: 1: plugins@wordpress.org */ 285 $message .= sprintf( __( 'We’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’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.' ), 286 289 'plugins@wordpress.org' 287 290 ) . '</p><p>'; … … 394 397 395 398 /* 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' ), 397 401 $this->plugin['Name'] 398 402 ); 399 403 400 404 /* 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. 402 408 403 409 Your plugin has been given the initial slug of %2$s, however this is subject to change based on the results of your review. … … 411 417 -- 412 418 The WordPress Plugin Directory Team 413 https://make.wordpress.org/plugins', 'wporg-plugins' ), 419 https://make.wordpress.org/plugins', 'wporg-plugins' 420 ), 414 421 $this->plugin['Name'], 415 422 $this->plugin_slug … … 422 429 423 430 // Helper 424 425 431 /** 426 432 * 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 55 55 ) : 56 56 if ( UPLOAD_ERR_OK === $_FILES['zip_file']['error'] ) : 57 $uploader = new Upload_Handler ;57 $uploader = new Upload_Handler(); 58 58 $upload_result = $uploader->process_upload(); 59 59 … … 76 76 77 77 <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' ); 81 105 } else { 82 106 printf( 83 107 _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, 87 111 'wporg-plugins' 88 112 ), 89 '<strong>' . ( $plugins->new + $plugins->pending ). '</strong>',90 '<strong>' . $ plugins->new. '</strong>'113 '<strong>' . $submitted_counts->total . '</strong>', 114 '<strong>' . $submitted_counts->pending . '</strong>' 91 115 ); 92 116 } 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 ) . ' — ' . $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 ) . ' — ' . $plugin->status . "</li>\n"; 124 } 125 ?> 126 </ul> 127 128 <p> 129 <?php 123 130 /* 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' ), 125 133 'plugins@wordpress.org' 126 134 ); 127 ?></p> 135 ?> 136 </p> 128 137 </div> 129 138 … … 137 146 <?php wp_nonce_field( 'wporg-plugins-upload' ); ?> 138 147 <input type="hidden" name="action" value="upload"/> 139 <?php /* <fieldset> 148 <?php 149 /* 150 <fieldset> 140 151 <legend><?php _e( 'Select categories (up to 3)', 'wporg-plugins' ); ?></legend> 141 152 <ul class="category-checklist"> 142 153 <?php wp_terms_checklist( 0, array( 'taxonomy' => 'plugin_category' ) ); ?> 143 154 </ul> 144 </fieldset> */ ?> 155 </fieldset> */ 156 ?> 145 157 146 158 <input type="file" id="zip_file" class="plugin-file" name="zip_file" size="25" accept=".zip"/> … … 175 187 <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> 176 188 177 <?php endif; // is_user_logged_in() 189 <?php 190 endif; // is_user_logged_in() 178 191 179 192 return ob_get_clean(); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php
r5841 r6287 6 6 */ 7 7 class Plugins_Info_API_Request { 8 public $locale = 'en_US';9 protected $args = array();8 public $locale = 'en_US'; 9 protected $args = array(); 10 10 protected $requested_fields = array(); 11 11 … … 36 36 37 37 static $plugins_info_fields_defaults = array( 38 'added' 39 'compatibility' 40 'contributors' 41 'downloaded' 42 'downloadlink' 43 'donate_link' 44 'homepage' 45 'last_updated' 46 'rating' 47 'ratings' 48 'requires' => true,49 'requires_php' 50 'sections' 51 'tags' 52 'tested' 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, 53 53 ); 54 54 … … 64 64 'rating' => true, 65 65 'ratings' => true, 66 'requires' => true, 66 'requires' => true, 67 67 'requires_php' => true, 68 68 'sections' => true, … … 75 75 $args = (object) $args; 76 76 77 if ( ! empty( $args->locale ) ) {77 if ( ! empty( $args->locale ) ) { 78 78 $this->locale = $args->locale; // TODO: sanitize? 79 79 } 80 if ( ! empty( $args->fields ) ) {80 if ( ! empty( $args->fields ) ) { 81 81 $this->requested_fields = $this->parse_requested_fields( $args->fields ); 82 82 } … … 112 112 113 113 // 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'] ) ) { 115 115 $fields['bare_contributors'] = true; 116 116 } … … 122 122 123 123 /** 124 * Sanitizes/parses the given fields parameter into a standard format. 124 * Sanitizes/parses the given fields parameter into a standard format. 125 125 */ 126 126 protected function parse_requested_fields( $fields ) { 127 $fields = is_string( $fields ) ? explode( ',', $fields ) : (array) $fields;127 $fields = is_string( $fields ) ? explode( ',', $fields ) : (array) $fields; 128 128 129 129 $requested_fields = array(); 130 130 foreach ( $fields as $field => $include ) { 131 131 if ( is_int( $field ) ) { 132 $field = $include;132 $field = $include; 133 133 $include = true; 134 134 if ( '-' == substr( $field, 0, 1 ) ) { 135 135 $include = false; 136 $field = substr( $field, 1 );136 $field = substr( $field, 1 ); 137 137 } 138 138 } … … 151 151 $query = array(); 152 152 // Paging 153 $query['paged'] = isset( $this->args->page ) ? $this->args->page: 1;153 $query['paged'] = isset( $this->args->page ) ? $this->args->page : 1; 154 154 $query['posts_per_page'] = isset( $this->args->per_page ) ? $this->args->per_page : 24; 155 155 … … 157 157 if ( ! empty( $this->args->browse ) ) { 158 158 $query['browse'] = $this->args->browse; 159 if ( ! empty( $this->args->installed_plugins ) )159 if ( ! empty( $this->args->installed_plugins ) ) { 160 160 $query['installed_plugins'] = is_array( $this->args->installed_plugins ) ? $this->args->installed_plugins : array(); 161 161 } 162 162 } elseif ( ! empty( $this->args->user ) ) { 163 $query['browse'] = 'favorites';163 $query['browse'] = 'favorites'; 164 164 $query['favorites_user'] = $this->args->user; 165 165 … … 180 180 $query['author_name'] = $this->args->author; 181 181 } 182 183 182 } 184 183 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api.php
r5389 r6287 3 3 4 4 // 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 ) );5 define( 'API_CACHE_EXPIRY', 24 * 60 * 60 + rand( 0, 60 * 60 ) ); 6 6 class Plugins_Info_API { 7 7 … … 9 9 const CACHE_EXPIRY = API_CACHE_EXPIRY; 10 10 11 protected $format = 'json';12 protected $jsonp = false;11 protected $format = 'json'; 12 protected $jsonp = false; 13 13 protected $formats = array( 14 14 'jsonp' => 'application/javascript', … … 21 21 if ( is_array( $format ) && 'jsonp' == $format[0] ) { 22 22 $this->jsonp = preg_replace( '/[^a-zA-Z0-9_]/', '', $format[1] ); 23 $format = 'jsonp';23 $format = 'jsonp'; 24 24 } 25 25 $this->format = $format; … … 53 53 } else { 54 54 $this->output( (object) array( 55 'error' => 'Action not implemented' 55 'error' => 'Action not implemented', 56 56 ) ); 57 57 } … … 72 72 if ( 200 != $response->status ) { 73 73 $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. 75 75 } else { 76 76 $response = $response->data; … … 88 88 return; 89 89 } 90 91 90 92 91 // Only include the fields requested. … … 129 128 // Back-compatible routines. 130 129 // 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']; 133 132 $response['contributors'] = array(); 134 133 if ( $contribs ) { … … 147 146 public function query_plugins( $request ) { 148 147 $response = array( 149 'info' => array(150 'page' => 0,151 'pages' => 0,148 'info' => array( 149 'page' => 0, 150 'pages' => 0, 152 151 'results' => 0, 153 152 ), 154 'plugins' => array() 153 'plugins' => array(), 155 154 ); 156 155 … … 175 174 // Fill in the plugin details 176 175 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 ); 178 184 if ( isset( $plugin['error'] ) ) { 179 185 unset( $response['plugins'][ $i ] ); … … 186 192 // Trim fields and cast to object 187 193 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' ); 189 195 } 190 196 … … 216 222 217 223 $number_items_requested = 100; 218 if ( ! empty( $request->number ) ) {224 if ( ! empty( $request->number ) ) { 219 225 $number_items_requested = $request->number; 220 226 } … … 242 248 switch ( $this->format ) { 243 249 default: 244 case 'json' 245 case 'jsonp' 250 case 'json': 251 case 'jsonp': 246 252 if ( ! function_exists( 'wp_json_encode' ) && defined( 'WPORGAPIPATH' ) ) { 247 253 require WPORGAPIPATH . '/includes/wp-json-encode.php'; … … 254 260 } 255 261 break; 256 257 case 'php' 262 263 case 'php': 258 264 echo serialize( $response ? (object) $response : $response ); 259 265 break; 260 261 case 'xml' 266 267 case 'xml': 262 268 echo '<' . '?xml version="1.0" encoding="utf-8"?' . ">\n"; 263 269 echo "<plugin>\n"; … … 281 287 define( 'REST_REQUEST', true ); 282 288 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'; 286 292 $_SERVER['REQUEST_URI'] = '/plugins/'; 287 293 288 294 require_once WPORGPATH . '/wp-load.php'; 289 295 290 $_SERVER['HTTP_HOST'] = $host;296 $_SERVER['HTTP_HOST'] = $host; 291 297 $_SERVER['REQUEST_URI'] = $request_uri; 292 298 … … 322 328 $xml_tag = function( $tag, $type, $empty = false ) { 323 329 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}-'; 325 331 326 332 $start_right = $empty ? ' />' : '>'; … … 340 346 echo str_repeat( "\t", $tabs ); 341 347 switch ( $type = gettype( $data ) ) { 342 case 'string' 348 case 'string': 343 349 $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': 348 354 list( $start, $close ) = $xml_tag( $key, $type, false ); 349 355 echo "$start$data$close"; 350 356 break; 351 case 'NULL' 357 case 'NULL': 352 358 list( $start, $close ) = $xml_tag( $key, $type, true ); 353 359 echo $start; 354 360 break; 355 case 'array' 361 case 'array': 356 362 if ( empty( $data ) ) { 357 363 list( $start, $close ) = $xml_tag( $key, $type, true ); … … 368 374 echo $close; 369 375 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 ) { 373 379 break; 374 380 } 375 381 376 list( $start, $close ) = $xml_tag( $key, $type, true );382 list( $start, $close ) = $xml_tag( $key, $type, true ); 377 383 echo $start; 378 384 break; … … 391 397 } 392 398 break; 393 case 'resource' 394 case 'unknown type' 395 default 399 case 'resource': 400 case 'unknown type': 401 default: 396 402 break; 397 403 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/downloads.php
r3289 r6287 5 5 * This is a stand alone script, it operates with the expectation that the 6 6 * global `$wpdb` is available and the object cache is configured. 7 * 7 * 8 8 * Examples of URLs which are accepted: 9 9 * - downloads.wordpress.org/plugin/hello-dolly.zip (trunk) … … 12 12 */ 13 13 14 include dirname( __DIR__ ) . '/class-autoloader.php';14 require dirname( __DIR__ ) . '/class-autoloader.php'; 15 15 Autoloader\register_class_path( __NAMESPACE__, dirname( __DIR__ ) ); 16 16 $serve = new Zip\Serve(); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/plugins-info-api.php
r3289 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory; 3 3 4 die(); 4 5 … … 12 13 13 14 $_REQUEST = array( 14 'method' => 'plugin_information',15 'method' => 'plugin_information', 15 16 'request' => array( 16 'slug' => 'hello-dolly',17 'slug' => 'hello-dolly', 17 18 'fields' => 'active_installs', 18 ) 19 ), 19 20 ); 20 21 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/bootstrap.php
r4223 r6287 6 6 } 7 7 8 require_once ( $_tests_dir . '/includes/functions.php' );8 require_once $_tests_dir . '/includes/functions.php'; 9 9 10 10 /** … … 12 12 */ 13 13 function _manually_load_plugin_directory_plugin() { 14 require_once ( dirname( __FILE__ ) . '/../plugin-directory.php' );14 require_once dirname( __FILE__ ) . '/../plugin-directory.php'; 15 15 } 16 16 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/api/svn-access.php
r5434 r6287 9 9 function test_permission_denied() { 10 10 $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 ); 12 12 13 13 $this->assertEquals( 'not_authorized', $data['code'] ); … … 17 17 $response = wp_remote_get( 'https://wordpress.org/plugins/wp-json/plugins/v1/svn-access', array( 18 18 'headers' => array( 19 'Authorization' => 'lol like this would be a real auth key' 19 'Authorization' => 'lol like this would be a real auth key', 20 20 ), 21 21 ) ); 22 $data = json_decode( wp_remote_retrieve_body( $response ), true );22 $data = json_decode( wp_remote_retrieve_body( $response ), true ); 23 23 24 24 $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 10 10 class Tests_Plugins_API_Performance extends WP_UnitTestCase { 11 11 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'; 16 16 public $api_endpoint_plugin_json = 'http://api.wordpress.org/plugins/info/1.0/jetpack.json'; 17 17 18 public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end18 public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end 19 19 public $timeout_seconds = 5.0; 20 20 … … 61 61 $median = $values[ floor( count( $values ) / 2 ) ]; 62 62 63 return "mean ". number_format( $mean, $decimals ) . ", median ". number_format( $median, $decimals );63 return 'mean ' . number_format( $mean, $decimals ) . ', median ' . number_format( $median, $decimals ); 64 64 65 65 } … … 68 68 global $wporg_plugin_api_performance; 69 69 70 echo "Performance summary for ". get_called_class() . ":\n";70 echo 'Performance summary for ' . get_called_class() . ":\n"; 71 71 foreach ( $wporg_plugin_api_performance[ get_called_class() ] as $type => $deltas ) { 72 72 echo "$type: " . self::averages( $deltas ) . "\n"; … … 100 100 101 101 // 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' ); 103 103 104 104 // Each item represents the function arguments to a plugins_api() call. 105 105 $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 ), 111 145 ); 112 146 113 147 // 20 random searches 114 for ( $i =0; $i < 20; $i++ ) {148 for ( $i = 0; $i < 20; $i++ ) { 115 149 $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 ); 117 159 } 118 160 119 161 // 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 ) ); 128 171 $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 } 132 182 133 183 return $r; … … 139 189 * @dataProvider performanceTestProvider 140 190 */ 141 142 143 144 $start = microtime( true );191 function test_api_performance( $action, $args ) { 192 global $wporg_plugin_api_performance; 193 194 $start = microtime( true ); 145 195 $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; 150 200 151 201 $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 9 9 class Tests_Plugins_API extends WP_UnitTestCase { 10 10 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'; 15 15 public $api_endpoint_plugin_json = 'http://api.wordpress.org/plugins/info/1.0/jetpack.json'; 16 16 17 public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end17 public $user_agent = 'WordPress/4.8'; // Tell the API to use the v3 back-end 18 18 public $require_tested_value = true; 19 19 … … 42 42 'active_installs' => true, 43 43 'contributors' => true, 44 'donate_link' 44 'donate_link' => true, 45 45 ); 46 46 … … 79 79 80 80 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 ) ); 83 86 84 87 $this->_check_response_attributes( $plugins ); … … 86 89 87 90 function test_wporg_plugin_api_serialize_php_get() { 88 $url = add_query_arg( 'fields', implode( ',' 91 $url = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_php ); 89 92 $response = $this->api_remote_get( $url ); 90 93 $plugins = maybe_unserialize( wp_remote_retrieve_body( $response ) ); … … 94 97 95 98 function test_wporg_plugin_api_xml() { 96 $url = add_query_arg( 'fields', implode( ',' 99 $url = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_xml ); 97 100 $response = $this->api_remote_get( $url ); 98 101 $plugins = wp_remote_retrieve_body( $response ); … … 104 107 105 108 function test_wporg_plugin_api_json() { 106 $url = add_query_arg( 'fields', implode( ',' 109 $url = add_query_arg( 'fields', implode( ',', array_keys( $this->fields ) ), $this->api_endpoint_plugin_json ); 107 110 $response = $this->api_remote_get( $url ); 108 111 $plugins = (object) json_decode( wp_remote_retrieve_body( $response ), true ); … … 116 119 'body' => array( 117 120 'action' => 'plugin_information', 118 'request' => (object) array( 'slug' => 'jetpack', 'fields' => $this->fields ), 121 'request' => (object) array( 122 'slug' => 'jetpack', 123 'fields' => $this->fields, 124 ), 119 125 ), 120 126 'headers' => array( 'Host', 'api.wordpress.org' ), 121 122 127 ) ); 123 128 … … 127 132 128 133 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 ) ); 130 138 $this->_check_response_attributes( $plugins ); 131 139 } … … 145 153 146 154 // If search term exactly matches a slug, it should be returned first. 147 $plugins 155 $plugins = plugins_api( 'query_plugins', array( 'search' => $slug ) ); 148 156 $this->assertEquals( $plugins->plugins[0]->slug, $slug ); 149 157 } … … 152 160 function test_plugins_api_function_action_query_plugins_tag() { 153 161 $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 ) ); 155 166 156 167 foreach ( $plugins->plugins as $plugin ) { … … 163 174 function test_plugins_api_function_action_query_plugins_author() { 164 175 $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 ) ); 166 180 167 181 foreach ( $plugins->plugins as $plugin ) { … … 173 187 // Favorites. 174 188 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 ) ); 176 193 $this->_check_response_plugin_query( $plugins, 1 ); 177 194 } 178 195 179 196 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 ) ); 181 201 $this->_check_response_plugin_query( $plugins ); 182 202 } 183 203 184 204 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 ) ); 186 210 $this->_check_response_plugin_query( $plugins, 1 ); 187 211 } … … 189 213 function test_plugins_api_function_action_query_plugins_local() { 190 214 // 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 ) ); 192 219 $this->_check_response_plugin_query( $plugins, 1 ); 193 220 } … … 321 348 class Tests_Plugins_API_Old extends Tests_Plugins_API { 322 349 public $user_agent = 'WordPress/4.7'; // Tell the API to use the old back-end 350 323 351 public $require_tested_value = false; // Old API omits 'tested' if its value is empty 324 325 326 352 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/phpunit/tests/wporg-url-schemes.php
r5172 r6287 5 5 function http_get( $uri ) { 6 6 $base_url = 'https://wordpress.org'; 7 $url = $base_url . $uri;7 $url = $base_url . $uri; 8 8 9 9 $http_args = array( 10 10 '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, 16 16 ); 17 17 $request = wp_remote_get( $url, $http_args ); … … 23 23 return [ 24 24 [ '/plugins/add/' ], 25 [ '/plugins/about/' ],25 [ '/plugins/about/' ], 26 26 [ '/plugins/about/guidelines/' ], 27 27 [ '/plugins/about/svn/' ], … … 61 61 /** 62 62 * @dataProvider urlProvider 63 */63 */ 64 64 function test_url( $url ) { 65 65 $response = $this->http_get( $url ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-committers.php
r5716 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 use WordPressdotorg\Plugin_Directory\Tools; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-contributors.php
r5924 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 … … 30 31 31 32 $contributors = get_terms( array( 32 'taxonomy' => 'plugin_contributors',33 'taxonomy' => 'plugin_contributors', 33 34 'object_ids' => array( $post->ID ), 34 'orderby' => 'term_order',35 'fields' => 'names',35 'orderby' => 'term_order', 36 'fields' => 'names', 36 37 ) ); 37 38 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-meta.php
r6033 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 3 4 use WordPressdotorg\Plugin_Directory\Plugin_I18n; 4 5 use WordPressdotorg\Plugin_Directory\Template; … … 43 44 <li> 44 45 <?php 45 printf( __( 'Last updated: %s', 'wporg-plugins' ), 46 printf( 47 __( 'Last updated: %s', 'wporg-plugins' ), 46 48 /* Translators: Plugin modified time. */ 47 49 '<strong>' . sprintf( __( '%s ago', 'wporg-plugins' ), '<span>' . human_time_diff( get_post_modified_time() ) . '</span>' ) . '</strong>' … … 52 54 53 55 <?php if ( $requires = (string) get_post_meta( $post->ID, 'requires', true ) ) : ?> 54 <li><?php 56 <li> 57 <?php 55 58 _e( 'Requires WordPress Version:', 'wporg-plugins' ); 56 59 echo '<strong>' . esc_html( $requires ) . '</strong>'; 57 ?></li> 60 ?> 61 </li> 58 62 <?php endif; ?> 59 63 … … 63 67 64 68 <?php if ( $requires_php = (string) get_post_meta( $post->ID, 'requires_php', true ) ) : ?> 65 <li><?php 69 <li> 70 <?php 66 71 _e( 'Requires PHP Version:', 'wporg-plugins' ); 67 72 echo '<strong>' . esc_html( $requires_php ) . '</strong>'; 68 ?></li> 73 ?> 74 </li> 69 75 <?php endif; ?> 70 76 … … 76 82 <li> 77 83 <?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 ) ); 83 85 84 86 echo '<div class="languages">'; … … 104 106 <div class="popover-inner"> 105 107 <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>', 108 112 esc_url( 'https://translate.wordpress.org/projects/wp-plugins/' . $post->post_name ), 109 113 __( 'Translate into your language', 'wporg-plugins' ) 110 114 ); 111 ?></p> 115 ?> 116 </p> 112 117 </div> 113 118 </div> … … 125 130 126 131 <?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 128 134 $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> 137 139 <?php endif; ?> 138 140 … … 140 142 <li class="hide-if-no-js"> 141 143 <?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 ); 143 149 ?> 144 150 </li> … … 156 162 */ 157 163 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 ); 161 167 $languages = []; 162 168 163 169 if ( ! empty( $locales ) ) { 164 170 $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' ); 166 172 167 173 $sites = get_sites( [ -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php
r5457 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 … … 36 37 echo $args['before_widget']; 37 38 echo $args['before_title'] . $title . $args['after_title']; 39 40 if ( $rating ) : 38 41 ?> 39 40 <?php if ( $rating ) : ?>41 42 <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> 42 43 … … 46 47 47 48 <ul class="ratings-list"> 48 <?php foreach ( range( 5, 1 ) as $stars ) : 49 <?php 50 foreach ( range( 5, 1 ) as $stars ) : 49 51 $rating_bar_width = $num_ratings ? 100 * $ratings[ $stars ] / $num_ratings : 0; 50 52 ?> … … 67 69 </div> 68 70 69 <?php endif; // $rating 71 <?php endif; // $rating ?> 70 72 71 if ( is_user_logged_in() ) : ?>73 <?php if ( is_user_logged_in() ) : ?> 72 74 <div class="user-rating"> 73 75 <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> 74 76 </div> 75 77 <?php 76 78 endif; 77 79 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support-reps.php
r5867 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 use WordPressdotorg\Plugin_Directory\Tools; … … 10 11 */ 11 12 class Support_Reps extends \WP_Widget { 13 12 14 /** 13 15 * Support Reps constructor. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support.php
r5404 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Widgets; 3 use WordPressdotorg\Plugin_Directory\Template; 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 5 6 /** … … 35 36 $support_url = Template::get_support_url(); 36 37 37 if ( false === strpos( $support_url, 'https://wordpress.org' ) ) { 38 if ( false === strpos( $support_url, 'https://wordpress.org' ) ) { 38 39 $resolutions = false; 39 } 40 } 40 41 41 42 echo $args['before_widget']; … … 43 44 44 45 if ( $resolutions ) : 45 46 ?> 46 47 <p class="aside"><?php _e( 'Issues resolved in last two months:', 'wporg-plugins' ); ?></p> 47 48 <p class="counter-container"> … … 57 58 </p> 58 59 59 <?php else : ?>60 <?php else : ?> 60 61 <p><?php _e( 'Got something to say? Need help?', 'wporg-plugins' ); ?></p> 61 62 <?php endif; ?> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-builder.php
r6281 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Zip; 3 3 4 use WordPressdotorg\Plugin_Directory\Tools\SVN; 4 5 use Exception; … … 11 12 class Builder { 12 13 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'; 15 16 const ZIP_SVN_URL = PLUGIN_ZIP_SVN_URL; 16 17 … … 60 61 $this->tmp_dir, 61 62 array( 62 'depth' => 'empty',63 'depth' => 'empty', 63 64 'username' => PLUGIN_ZIP_SVN_USER, 64 65 'password' => PLUGIN_ZIP_SVN_PASS, … … 70 71 // Ensure the plugins folder exists within svn 71 72 $plugin_folder = "{$this->tmp_dir}/{$this->slug}/"; 73 72 74 $res = SVN::up( 73 75 $plugin_folder, 74 76 array( 75 'depth' => 'empty' 77 'depth' => 'empty', 76 78 ) 77 79 ); … … 105 107 // This is done within the checksum generation function due to us not knowing the checksum filename until export_plugin(). 106 108 // SVN::up( $this->checksum_file ); 107 108 109 try { 109 110 110 $this->tmp_build_dir 111 $this->tmp_build_dir = $this->zip_file . '-files'; 111 112 mkdir( $this->tmp_build_dir, 0777, true ); 112 113 … … 120 121 $this->cleanup_plugin_tmp(); 121 122 122 } catch ( Exception $e ) {123 } catch ( Exception $e ) { 123 124 // In event of error, skip this file this time. 124 125 $this->cleanup_plugin_tmp(); … … 203 204 204 205 $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 ) { 207 211 $checksum_output = array(); 208 212 $this->exec( sprintf( … … 212 216 213 217 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. 216 220 continue; 217 221 } … … 219 223 foreach ( $checksum_output as $line ) { 220 224 list( $checksum, $filename ) = preg_split( '!\s+!', $line, 2 ); 225 221 226 $filename = trim( preg_replace( '!^./!', '', $filename ) ); 222 227 $checksum = trim( $checksum ); … … 228 233 229 234 if ( ! isset( $checksums[ $filename ] ) ) { 230 $checksums[ $filename ] = array( 'md5' => array(), 'sha256' => array() ); 235 $checksums[ $filename ] = array( 236 'md5' => array(), 237 'sha256' => array(), 238 ); 231 239 } 232 240 … … 249 257 // Sometimes plugin versions exist in multiple tags/zips, include all the SVN urls & ZIP urls 250 258 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} ) && 252 260 $existing_json_checksum_file->{$maybe_different} != $json_checksum_file->{$maybe_different} 253 261 ) { 254 262 $json_checksum_file->{$maybe_different} = array_unique( array_merge( 255 263 (array) $existing_json_checksum_file->{$maybe_different}, 256 264 (array) $json_checksum_file->{$maybe_different} 257 265 ) ); 258 266 … … 282 290 $json_checksum_file->files[ $file ][ $checksum_type ] = array_unique( array_merge( 283 291 (array) $checksums->{$checksum_type}, // May already be an array 284 292 (array) $json_checksum_file->files[ $file ][ $checksum_type ] 285 293 ) ); 294 286 295 // Reduce single arrays back to a string when possible. 287 296 if ( 1 == count( $json_checksum_file->files[ $file ][ $checksum_type ] ) ) { … … 291 300 } 292 301 } 293 294 302 } 295 303 … … 317 325 $i = 0; 318 326 do { 319 $rand = uniqid();327 $rand = uniqid(); 320 328 $filename = "{$dir}/{$prefix}-{$rand}{$i}{$suffix}"; 321 } while ( false === ( $fp = @fopen( $filename, 'x' ) ) && $i++ < 50 );329 } while ( false === ( $fp = @fopen( $filename, 'x' ) ) && $i++ < 50 ); 322 330 323 331 if ( $i >= 50 ) { … … 358 366 // Handle tags which we store as 0.blah but are in /tags/.blah 359 367 if ( ! $res['result'] && '0.' == substr( $this->version, 0, 2 ) ) { 360 $_version = substr( $this->version, 1 );368 $_version = substr( $this->version, 1 ); 361 369 $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 ); 363 371 } 364 372 if ( ! $res['result'] ) { … … 449 457 foreach ( $plugins_downloads_load_balancer /* TODO */ as $lb ) { 450 458 $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 ) ); 457 463 } 458 464 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-serve.php
r6163 r6287 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Zip; 3 3 4 use Exception; 4 5 … … 22 23 $this->record_stats( $request ); 23 24 } 24 25 } catch ( Exception $e ) { 25 } catch ( Exception $e ) { 26 26 $this->error(); 27 27 } … … 38 38 $zip = basename( $path ); 39 39 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 ) ) { 41 41 // ZIP 42 42 $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 ) ) { 44 44 // Checksums 45 45 $checksum_request = true; 46 46 } else { 47 throw new Exception( __METHOD__ . ": Invalid URL.");47 throw new Exception( __METHOD__ . ': Invalid URL.' ); 48 48 } 49 49 … … 60 60 // Checksum requests for 'trunk' are not possible. 61 61 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.' ); 63 63 } 64 64 … … 74 74 75 75 } elseif ( isset( $_GET['nostats'] ) ) { 76 $args['stats'] = ! empty( $_GET['nostats'] );76 $args['stats'] = ! empty( $_GET['nostats'] ); 77 77 } 78 78 … … 93 93 // Determine the stable_tag 94 94 $meta = wp_cache_get( $post_id, 'post_meta' ); 95 95 96 $version = false; 96 97 if ( isset( $meta['stable_tag'][0] ) ) { … … 191 192 global $wpdb; 192 193 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'; 195 196 $stats_download_daily_table = PLUGINS_TABLE_PREFIX . 'stats'; 196 197 … … 201 202 WHERE 202 203 plugin_slug = %s AND 203 204 205 204 client_ip = %s AND 205 user_agent = %s AND 206 stamp BETWEEN %s AND %s 206 207 LIMIT 1", 207 208 $request['slug'], … … 231 232 'client_ip' => $_SERVER['REMOTE_ADDR'], 232 233 '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 ) ); 236 236 } 237 237 … … 240 240 */ 241 241 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'; 243 243 $protocol .= ' '; 244 244
Note: See TracChangeset
for help on using the changeset viewer.