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 );