Changeset 2752
- Timestamp:
- 03/15/2016 08:02:51 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r2737 r2752 30 30 31 31 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 32 32 33 add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 ); 33 34 add_filter( 'postbox_classes_plugin_internal-notes', array( $this, 'postbox_classes' ) );35 34 add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 ); 35 36 add_filter( 'postbox_classes_plugin_internal-notes', array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'postbox_classes' ) ); 37 add_filter( 'postbox_classes_plugin_plugin-committers', array( __NAMESPACE__ . '\Metabox\Committers', 'postbox_classes' ) ); 38 add_filter( 'wp_ajax_add-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' ) ); 39 add_filter( 'wp_ajax_delete-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'remove_committer' ) ); 36 40 } 37 41 … … 61 65 global $post_type; 62 66 63 if ( 'post.php' == $hook_suffix && 'plugin'== $post_type ) {67 if ( 'post.php' === $hook_suffix && 'plugin' === $post_type ) { 64 68 wp_enqueue_style( 'plugin-admin-edit-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 1 ); 65 wp_enqueue_script( 'plugin-admin-edit-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util' ), 1 ); 69 wp_enqueue_script( 'plugin-admin-edit-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util', 'wp-lists' ), 1 ); 70 wp_localize_script( 'plugin-admin-edit-js', 'pluginDirectory', array( 71 'removeCommitterAYS' => __( 'Are you sure you want to remove this committer?', 'wporg-plugins' ), 72 ) ); 66 73 } 67 74 } … … 133 140 update_post_meta( $post_id, 'tested', wp_slash( wp_unslash( $_POST['tested_with'] ) ) ); 134 141 } 135 }136 137 /**138 * Filters the postbox classes for custom comment meta boxes.139 *140 * @param array $classes An array of postbox classes.141 * @return array142 */143 public function postbox_classes( $classes ) {144 $classes[] = 'comments-meta-box';145 146 return array_filter( $classes );147 142 } 148 143 … … 160 155 */ 161 156 public function custom_comment_row_actions( $actions, $comment ) { 162 if ( 'internal-note' === $comment->comment_type ) {157 if ( 'internal-note' === $comment->comment_type && isset( $_REQUEST['mode'] ) && 'single' === $_REQUEST['mode'] ) { 163 158 $allowed_actions = array( 'reply' => true ); 164 159 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php
r2655 r2752 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 use WordPressdotorg\Plugin_Directory\ Tools;3 use WordPressdotorg\Plugin_Directory\Admin\Committers_List_Table; 4 4 5 5 /** … … 9 9 */ 10 10 class Committers { 11 static function display() {12 $plugin_slug = get_post()->post_name;13 $existing_committers = Tools::get_plugin_committers( $plugin_slug );14 $existing_committers = array_map( function ( $user ) {15 return new \WP_User( $user );16 }, $existing_committers );17 11 18 $output = ''; 19 foreach ( $existing_committers as $committer ) { 20 $output .= sprintf( 21 '<li title="%s"><span class="avatar">%s</span> %s</li>', 22 esc_attr( $committer->user_login ), 23 get_avatar( $committer, '24' ), 24 esc_html( $committer->display_name ) 25 ); 12 /** 13 * Filters the postbox classes for custom comment meta boxes. 14 * 15 * @param array $classes An array of postbox classes. 16 * @return array 17 */ 18 public static function postbox_classes( $classes ) { 19 $classes[] = 'committers-meta-box'; 20 21 return array_filter( $classes ); 22 } 23 24 public static function display() { 25 $list = new Committers_List_Table(); 26 $list->prepare_items(); 27 $list->display(); 28 } 29 30 public static function add_committer() { 31 check_ajax_referer( 'add-committer' ); 32 33 $login = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : ''; 34 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 35 36 if ( ! $committer = get_user_by( 'login', $login ) ) { 37 wp_die( time() ); 26 38 } 27 echo '<ul class="committers">' . $output . '</ul>'; 39 40 if ( ! current_user_can( 'manage_committers', $post_id ) ) { 41 // wp_die( -1 ); 42 } 43 global $post, $wpdb; 44 45 $response = new \WP_Ajax_Response(); 46 $post = get_post( $post_id ); 47 48 $result = $wpdb->insert( PLUGINS_TABLE_PREFIX . 'svn_access', array( 49 'path' => "/{$post->post_name}", 50 'user' => $login, 51 'access' => 'rw', 52 ) ); 53 54 if ( ! $result ) { 55 $message = __( 'An error has occurred. Please reload the page and try again.' ); 56 if ( is_wp_error( $result ) && $result->get_error_message() ) { 57 $message = $result->get_error_message(); 58 } 59 60 $response->add( array( 61 'what' => 'committer', 62 'data' => new \WP_Error( 'error', $message ), 63 ) ); 64 $response->send(); 65 } 66 67 $wp_list_table = new Committers_List_Table(); 68 69 $response->add( array( 70 'what' => 'committer', 71 'id' => $committer->ID, 72 'data' => $wp_list_table->single_row( $committer ), 73 'position' => -1, 74 ) ); 75 $response->send(); 76 } 77 78 public static function remove_committer() { 79 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 80 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 81 82 check_ajax_referer( "remove-committer-$id" ); 83 84 if ( ! $committer = get_user_by( 'id', $id ) ) { 85 wp_die( time() ); 86 } 87 88 if ( ! current_user_can( 'manage_committers', $post_id ) ) { 89 // wp_die( -1 ); 90 } 91 92 $plugin_slug = get_post( $post_id )->post_name; 93 94 $result = $GLOBALS['wpdb']->delete( PLUGINS_TABLE_PREFIX . 'svn_access', array( 95 'path' => "/{$plugin_slug}", 96 'user' => $committer->user_login, 97 ) ); 98 99 wp_die( $result ); 28 100 } 29 101 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-internal-notes.php
r2735 r2752 11 11 12 12 /** 13 * Filters the postbox classes for custom comment meta boxes. 14 * 15 * @param array $classes An array of postbox classes. 16 * @return array 17 */ 18 public static function postbox_classes( $classes ) { 19 $classes[] = 'comments-meta-box'; 20 21 return array_filter( $classes ); 22 } 23 24 /** 13 25 * Displays comment box for internal notes. 14 26 */ 15 static function display() {27 public static function display() { 16 28 $wp_list_table = new Plugin_Comments_List_Table( array( 17 29 'comment_type' => 'internal-note', -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css
r2735 r2752 20 20 content: "\f173"; 21 21 } 22 22 23 .misc-pub-section label[for="tested_with"]::before { 23 24 content: "\f177"; … … 33 34 } 34 35 35 . misc-pub-section .button-link{36 .button-link:not(.handlediv) { 36 37 color: #0073aa; 37 38 -webkit-transition-property: border, background, color; … … 41 42 -webkit-transition-timing-function: ease-in-out; 42 43 transition-timing-function: ease-in-out; 43 44 text-decoration: underline; 44 45 } 45 46 46 . misc-pub-section .button-link:hover,47 . misc-pub-section .button-link:active {47 .button-link:not(.handlediv):hover, 48 .button-link:not(.handlediv):active { 48 49 color: #00a0d2; 49 50 } … … 67 68 } 68 69 69 .comments-meta-box.postbox .inside, 70 #poststuff .comments-meta-box.postbox .inside, 71 #poststuff .committers-meta-box.postbox .inside, 70 72 .comments-meta-box .column-comment p { 71 73 margin: 0; 72 74 padding: 0; 75 border: 0; 73 76 } 74 77 75 78 .comments-meta-box .inside .row-actions { 76 79 line-height:18px; 80 } 81 82 .comments-meta-box .inside .column-author { 83 width: 20%; 77 84 } 78 85 … … 90 97 } 91 98 92 .comments-meta-box .comments-box { 99 .comments-meta-box .comments-box, 100 .committers-meta-box .wp-list-table { 93 101 border: 0 none; 94 102 } … … 124 132 } 125 133 } 134 135 /* Committers meta box */ 136 .add-committer { 137 padding: 0 12px 12px; 138 } 139 140 .add-committer .button-link { 141 font-weight: 600; 142 margin: 10px 0; 143 } 144 145 .add-committer input[type="text"] { 146 margin: 0 0 1em; 147 max-width: 260px; 148 vertical-align: baseline; 149 width: 100%; 150 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js
r2735 r2752 3 3 */ 4 4 5 ( function( $, wp ) {5 ( function( $, wp, pluginDirectory ) { 6 6 var PluginEdit = { 7 7 $testedWith: {}, … … 22 22 _.each( $( '#post-body' ).find( '.comments-box' ), PluginEdit.loadComments ); 23 23 24 $( '#add-new-comment' ).on( 'click', 'a.button', function( event ) { 25 event.preventDefault(); 24 $( '#add-new-comment' ).on( 'click', 'a.button', PluginEdit.prepareCommentForm ); 26 25 27 window.commentReply && commentReply.addcomment( $( '#post_ID' ).val());26 $( '#add-committer-toggle' ).on( 'click', PluginEdit.toggleCommitterForm ); 28 27 29 $( '#replyrow' ).find( '.comment-reply' ).append( $( '<input/>' ).attr({ 30 type: 'hidden', 31 name: 'comment_type', 32 value: $( '.comments-box' ).data( 'comment-type' ) 33 }) ); 28 $( '#the-committer-list' ).wpList({ 29 alt: false, 30 confirm: function( element, settings, action ) { 31 if ( 'committer' === settings.what && 'delete' === action ) { 32 return confirm( pluginDirectory.removeCommitterAYS ); 33 } 34 return true; 35 } 36 }).on( 'wpListAddEnd', function() { 37 $( 'input[name="add_committer"]', '#add-committer' ).val( '' ).focus(); 34 38 } ); 35 39 }, … … 93 97 } 94 98 } ); 99 }, 100 101 prepareCommentForm: function( event ) { 102 event.preventDefault(); 103 104 window.commentReply && commentReply.addcomment( $( '#post_ID' ).val() ); 105 106 // Add a field with the custom comment type. 107 $( '#replyrow' ).find( '.comment-reply' ).append( $( '<input/>' ).attr({ 108 type: 'hidden', 109 name: 'comment_type', 110 value: $( '.comments-box' ).data( 'comment-type' ) 111 }) ); 112 }, 113 114 toggleCommitterForm: function( event ) { 115 var $form = $( '#add-committer' ); 116 117 // Show/hide form. 118 $form.toggleClass( 'wp-hidden-children' ); 119 120 // Focus on the input field, and on enter add the committer, don't save post. 121 $( 'input[name="add_committer"]', $form ).focus().on( 'keydown', function( event ) { 122 if ( 13 === event.which ) { 123 event.preventDefault(); 124 $( '#add-committer-submit', $form ).click(); 125 } 126 } ); 95 127 } 96 128 }; 97 129 98 130 $( PluginEdit.ready ); 99 } )( window.jQuery, window.wp );131 } )( window.jQuery, window.wp, window.pluginDirectory );
Note: See TracChangeset
for help on using the changeset viewer.