Changeset 5867 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support-reps.php
- Timestamp:
- 09/03/2017 09:43:53 PM (7 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support-reps.php
r5864 r5867 5 5 6 6 /** 7 * A Widget to display committerinformation about a plugin.7 * A Widget to display support rep information about a plugin. 8 8 * 9 9 * @package WordPressdotorg\Plugin_Directory\Widgets 10 10 */ 11 class Committers extends \WP_Widget {11 class Support_Reps extends \WP_Widget { 12 12 /** 13 * Committers constructor.13 * Support Reps constructor. 14 14 */ 15 15 public function __construct() { 16 parent::__construct( 'plugin_ committers', __( 'Plugin Committers', 'wporg-plugins' ), array(17 'classname' => 'plugin- committers',18 'description' => __( 'Displays committerinformation.', 'wporg-plugins' ),16 parent::__construct( 'plugin_support_reps', __( 'Plugin Support Reps', 'wporg-plugins' ), array( 17 'classname' => 'plugin-support-reps', 18 'description' => __( 'Displays support rep information.', 'wporg-plugins' ), 19 19 ) ); 20 20 } … … 29 29 $post = get_post(); 30 30 31 $ committers = Tools::get_plugin_committers( $post->post_name );32 $ committers = array_map( function ( $user_login ) {33 return get_user_by( ' login', $user_login );34 }, $ committers );31 $support_reps = Tools::get_plugin_support_reps( $post->post_name ); 32 $support_reps = array_map( function ( $user_login ) { 33 return get_user_by( 'slug', $user_login ); 34 }, $support_reps ); 35 35 36 if ( current_user_can( 'plugin_add_ committer', $post ) || current_user_can( 'plugin_remove_committer', $post ) ) {37 wp_enqueue_script( 'wporg-plugins- committers', plugins_url( 'js/committers.js', __FILE__ ), array( 'wp-util' ), true );38 wp_localize_script( 'wporg-plugins- committers', 'committersWidget', array(39 'restUrl' => get_rest_url(),40 'restNonce' => wp_create_nonce( 'wp_rest' ),41 'pluginSlug' => $post->post_name,42 'remove CommitterAYS' => __( 'Are you sure you want to remove this committer?', 'wporg-plugins' ),36 if ( current_user_can( 'plugin_add_support_rep', $post ) || current_user_can( 'plugin_remove_support_rep', $post ) ) { 37 wp_enqueue_script( 'wporg-plugins-support-reps', plugins_url( 'js/support-reps.js', __FILE__ ), array( 'wp-util' ), true ); 38 wp_localize_script( 'wporg-plugins-support-reps', 'supportRepsWidget', array( 39 'restUrl' => get_rest_url(), 40 'restNonce' => wp_create_nonce( 'wp_rest' ), 41 'pluginSlug' => $post->post_name, 42 'removeSupportRepAYS' => __( 'Are you sure you want to remove this support rep?', 'wporg-plugins' ), 43 43 ) ); 44 44 } 45 45 46 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( ' Committers', 'wporg-plugins' ) : $instance['title'], $instance, $this->id_base );46 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Support Reps', 'wporg-plugins' ) : $instance['title'], $instance, $this->id_base ); 47 47 48 48 echo $args['before_widget']; … … 50 50 ?> 51 51 52 <ul id=" committer-list" class="committer-list">52 <ul id="support-rep-list" class="support-rep-list"> 53 53 54 <?php foreach ( $ committers as $committer) : ?>55 <li data-user="<?php echo esc_attr( $ committer->user_nicename ); ?>">56 <?php echo get_avatar( $ committer->ID, 32 ); ?>57 <a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . $ committer->user_nicename ); ?>">58 <?php echo Template::encode( $ committer->display_name ); ?>54 <?php foreach ( $support_reps as $support_rep ) : ?> 55 <li data-user="<?php echo esc_attr( $support_rep->user_nicename ); ?>"> 56 <?php echo get_avatar( $support_rep->ID, 32 ); ?> 57 <a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . $support_rep->user_nicename ); ?>"> 58 <?php echo Template::encode( $support_rep->display_name ); ?> 59 59 </a><br> 60 60 61 <?php if ( current_user_can( 'plugin_remove_ committer', $post ) ) : ?>61 <?php if ( current_user_can( 'plugin_remove_support_rep', $post ) ) : ?> 62 62 <small> 63 <?php echo current_user_can( 'plugin_review' ) ? esc_html( $ committer->user_email ) . ' ' : ''; ?>63 <?php echo current_user_can( 'plugin_review' ) ? esc_html( $support_rep->user_email ) . ' ' : ''; ?> 64 64 <button class="button-link remove"><?php _e( 'Remove', 'wporg-plugins' ); ?></button> 65 65 </small> … … 68 68 <?php endforeach; ?> 69 69 70 <?php if ( current_user_can( 'plugin_add_ committer', $post ) ) : ?>70 <?php if ( current_user_can( 'plugin_add_support_rep', $post ) ) : ?> 71 71 <li class="new"> 72 <form id="add- committer" action="POST">73 <input type="text" name=" committer" placeholder="<?php esc_attr_e( 'Login, Slug, or Email.', 'wporg-plugins' ); ?>">72 <form id="add-support-rep" action="POST"> 73 <input type="text" name="support_rep" placeholder="<?php esc_attr_e( 'Login, Slug, or Email.', 'wporg-plugins' ); ?>"> 74 74 <button type="submit" class="button button-secondary"><?php esc_attr_e( 'Add', 'wporg-plugins' ); ?></button> 75 75 </form> 76 76 77 <script id="tmpl-new- committer" type="text/template">77 <script id="tmpl-new-support-rep" type="text/template"> 78 78 <li data-user="{{ data.nicename }}"> 79 79 <a class="profile" href="{{ data.profile }}">
Note: See TracChangeset
for help on using the changeset viewer.