Changeset 2659
- Timestamp:
- 03/01/2016 07:59:36 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php
r2655 r2659 27 27 28 28 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 29 add_action( 'wp_ajax_save-note', array( $this, 'save_note' ) ); 29 30 } 30 31 … … 55 56 if ( 'post.php' == $hook_suffix && 'plugin' == $post_type ) { 56 57 wp_enqueue_style( 'plugin-admin-edit-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 1 ); 57 wp_enqueue_script( 'plugin-admin-edit-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( ), 1 );58 wp_enqueue_script( 'plugin-admin-edit-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util' ), 1 ); 58 59 } 59 60 } … … 75 76 array( __NAMESPACE__ . '\Metabox\Committers', 'display' ), 76 77 'plugin', 'side' 78 ); 79 80 add_meta_box( 81 'plugin-notes', 82 __( 'Internal Notes', 'wporg-plugins' ), 83 array( __NAMESPACE__ . '\Metabox\Notes', 'display' ), 84 'plugin', 'normal', 'high' 77 85 ); 78 86 … … 118 126 } 119 127 128 /** 129 * Saves a plugin note. 130 */ 131 public function save_note() { 132 check_admin_referer( 'save-note', 'notce' ); 133 134 if ( empty( $_POST['id'] ) ) { 135 wp_send_json_error( array( 'errorCode' => 'no_post_specified' ) ); 136 } 137 138 if ( ! current_user_can( 'review_plugin', absint( $_POST['id'] ) ) ) { 139 wp_send_json_error( array( 140 'error' => __( 'You do not have sufficient permissions to edit notes on this site.' ), 141 ) ); 142 } 143 144 update_post_meta( absint( $_POST['id'] ), 'note', wp_kses_post( $_POST['note'] ) ); 145 146 wp_send_json_success( array( 147 'note' => wpautop( wp_kses_post( $_POST['note'] ) ), 148 ) ); 149 } 120 150 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-controls.php
r2655 r2659 22 22 } 23 23 echo '</div>'; 24 24 25 25 echo '<div id="major-publishing-actions"><div id="publishing-action">'; 26 26 echo '<span class="spinner"></span>'; … … 41 41 <div class="misc-pub-section misc-pub-plugin-status"> 42 42 <label for="post_status"><?php _e( 'Status:', 'wporg-plugins' ); ?></label> 43 <span id="plugin-status-display"><?php echo esc_html( get_post_status_object( $post->post_status )->label ); ?></span> 44 <a href="#plugin_status" class="edit-plugin-status hide-if-no-js"><span aria-hidden="true">Edit</span> <span class="screen-reader-text">Edit status</span></a> 45 46 <div id="plugin-status-select" class="hide-if-js"> 47 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( $post->post_status ); ?>"> 48 <select name="post_status" id="plugin_status"> 43 <strong id="plugin-status-display"><?php echo esc_html( get_post_status_object( $post->post_status )->label ); ?></strong> 44 <button type="button" class="button-link edit-plugin-status hide-if-no-js"> 45 <span aria-hidden="true"><?php _e( 'Edit', 'wporg-plugins' ); ?></span> 46 <span class="screen-reader-text"><?php _e( 'Edit plugin status', 'wporg-plugins' ); ?></span> 47 </button> 48 49 <div id="plugin-status-select" class="plugin-control-select hide-if-js"> 50 <input type="hidden" name="hidden_post_status" id="hidden-post-status" value="<?php echo esc_attr( $post->post_status ); ?>"> 51 <select name="post_status" id="plugin-status"> 49 52 <?php 50 53 foreach ( $statuses as $statii ) { 51 54 $status_object = get_post_status_object( $statii ); 52 $selected = selected( $post->post_status, $statii, false );53 55 printf( 54 56 '<option value="%s" %s>%s</option>', 55 57 esc_attr( $statii ), 56 $selected,58 selected( $post->post_status, $statii, false ), 57 59 esc_html( $status_object->label ) 58 60 ); … … 60 62 ?> 61 63 </select> 62 < a href="#plugin_status" class="save-plugin-status hide-if-no-js button">OK</a>63 < a href="#plugin_status" class="cancel-plugin-status hide-if-no-js button-cancel">Cancel</a>64 <button type="button" class="save-plugin-status hide-if-no-js button"><?php _e( 'OK', 'wporg-plugins' ); ?></button> 65 <button type="button" class="cancel-plugin-status hide-if-no-js button-link"><?php _e( 'Cancel', 'wporg-plugins' ); ?></button> 64 66 </div> 65 67 66 68 </div><!-- .misc-pub-section --><?php 67 69 } … … 71 73 */ 72 74 protected static function display_tested_up_to() { 73 $post = get_post();74 $tested_up_to = (string) get_post_meta( $post->ID, 'tested', true );75 $versions = self::get_tested_up_to_versions( $tested_up_to );76 $tested_up_to = $versions['tested_up_to'];75 $post = get_post(); 76 $tested_up_to = (string) get_post_meta( $post->ID, 'tested', true ); 77 $versions = self::get_tested_up_to_versions( $tested_up_to ); 78 $tested_up_to = $versions['tested_up_to']; 77 79 $unknown_string = _x( 'Unknown', 'unknown version', 'wporg-plugins' ); 78 80 ?> 79 81 <div class="misc-pub-section misc-pub-tested"> 80 82 <label for="tested_with"><?php _e( 'Tested With:', 'wporg-plugins' ); ?></label> 81 <span id="tested-with-display"><?php echo ( $tested_up_to ? sprintf( 'WordPress %s', $tested_up_to ) : $unknown_string ); ?></span> 82 <a href="#tested_with" class="edit-tested-with hide-if-no-js"><span aria-hidden="true">Edit</span> <span class="screen-reader-text">Edit status</span></a> 83 84 <div id="tested-with-select" class="hide-if-js"> 85 <input type="hidden" name="hidden_tested_with" id="hidden_tested_with" value="<?php echo esc_attr( $tested_up_to ); ?>"> 86 <select name="tested_with" id="tested_with"> 83 <strong id="tested-with-display"><?php echo ( $tested_up_to ? sprintf( 'WordPress %s', $tested_up_to ) : $unknown_string ); ?></strong> 84 <button type="button" class="button-link edit-tested-with hide-if-no-js"> 85 <span aria-hidden="true"><?php _e( 'Edit', 'wporg-plugins' ); ?></span> 86 <span class="screen-reader-text"><?php _e( 'Edit tested with version', 'wporg-plugins' ); ?></span> 87 </button> 88 89 <div id="tested-with-select" class="plugin-control-select hide-if-js"> 90 <input type="hidden" name="hidden_tested_with" id="hidden-tested-with" value="<?php echo esc_attr( $tested_up_to ); ?>"> 91 <select name="tested_with" id="tested-with"> 87 92 <?php 88 93 foreach ( $versions['versions'] as $ver ) { … … 96 101 ?> 97 102 </select> 98 < a href="#tested_with" class="save-tested-with hide-if-no-js button">OK</a>99 < a href="#tested_with" class="cancel-tested-with hide-if-no-js button-cancel">Cancel</a>103 <button type="button" class="save-tested-with hide-if-no-js button"><?php _e( 'OK', 'wporg-plugins' ); ?></button> 104 <button type="button" class="cancel-tested-with hide-if-no-js button-link"><?php _e( 'Cancel', 'wporg-plugins' ); ?></button> 100 105 </div> 101 106 102 107 </div><!-- .misc-pub-section --><?php 103 108 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css
r2655 r2659 2 2 * CSS Rules for the Plugin Admin screen 3 3 */ 4 #misc-publishing-actionslabel::before {4 .misc-pub-section label::before { 5 5 font: normal 20px/1 dashicons; 6 6 speak: none; … … 17 17 } 18 18 19 #misc-publishing-actionslabel[for="post_status"]::before {19 .misc-pub-section label[for="post_status"]::before { 20 20 content: "\f173"; 21 21 } 22 #misc-publishing-actionslabel[for="tested_with"]::before {22 .misc-pub-section label[for="tested_with"]::before { 23 23 content: "\f177"; 24 24 } 25 25 26 #misc-publishing-actions span#plugin-status-display, 27 #misc-publishing-actions span#tested-with-display { 28 font-weight: bold; 29 } 30 31 .inside-submitbox #plugin-status, 32 .inside-submitbox #tested-with { 33 margin: 2px 0 2px -2px; 34 } 35 36 #plugin-status-select, 37 #tested-with-select { 26 .plugin-control-select { 38 27 margin-top: 3px; 39 28 } … … 43 32 display: none; 44 33 } 34 35 .misc-pub-section .button-link { 36 color: #0073aa; 37 -webkit-transition-property: border, background, color; 38 transition-property: border, background, color; 39 -webkit-transition-duration: .05s; 40 transition-duration: .05s; 41 -webkit-transition-timing-function: ease-in-out; 42 transition-timing-function: ease-in-out; 43 text-decoration: underline; 44 } 45 46 .misc-pub-section .button-link:hover, 47 .misc-pub-section .button-link:active { 48 color: #00a0d2; 49 } 50 51 .misc-pub-section .button-link:focus { 52 color: #124964; 53 -webkit-box-shadow: 54 0 0 0 1px #5b9dd9, 55 0 0 2px 1px rgba(30, 140, 190, .8); 56 box-shadow: 57 0 0 0 1px #5b9dd9, 58 0 0 2px 1px rgba(30, 140, 190, .8); 59 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js
r2655 r2659 3 3 */ 4 4 5 jQuery(document).ready( function($) {5 ( function( $, wp ) { 6 6 7 var updateText, 8 $testedWithSelect = $('#tested-with-select'), 9 $pluginStatusSelect = $('#plugin-status-select'); 7 var PluginEdit = { 8 $notesBox: {}, 9 $testedWith: {}, 10 $pluginStatus: {}, 10 11 11 // submitdiv 12 if ( $('#submitdiv').length ) { 12 ready: function() { 13 PluginEdit.$notesBox = $( '#plugin-notes' ); 14 PluginEdit.$testedWith = $( '#tested-with-select' ); 15 PluginEdit.$pluginStatus = $( '#plugin-status-select' ); 13 16 14 updateText = function() { 15 $('#plugin-status-display').html( $('option:selected', $pluginStatusSelect).text() ); 16 $('#tested-with-display').html( $('option:selected', $testedWithSelect).text() ); 17 return true; 18 }; 17 $( '#submitdiv' ) 18 .on( 'click', '.edit-tested-with', PluginEdit.editTestedWith ) 19 .on( 'click', '.edit-plugin-status', PluginEdit.editPluginStatus ) 20 .on( 'click', '.save-tested-with', PluginEdit.updateTestedWith ) 21 .on( 'click', '.save-plugin-status', PluginEdit.updatePluginStatus ) 22 .on( 'click', '.cancel-tested-with', PluginEdit.cancelTestedWith ) 23 .on( 'click', '.cancel-plugin-status', PluginEdit.cancelPluginStatus ); 19 24 20 // Plugin Status / post_status 21 $pluginStatusSelect.siblings('a.edit-plugin-status').click( function( event ) { 22 if ( $pluginStatusSelect.is( ':hidden' ) ) { 23 $pluginStatusSelect.slideDown( 'fast', function() { 24 $pluginStatusSelect.find('select').focus(); 25 PluginEdit.$notesBox 26 .on( 'click', '.cancel-note', PluginEdit.showNote ) 27 .on( 'click', '.view-note', PluginEdit.editNote ) 28 .on( 'click', '.save-note', PluginEdit.saveNote ); 29 }, 30 31 editTestedWith: function() { 32 if ( PluginEdit.$testedWith.is( ':hidden' ) ) { 33 PluginEdit.$testedWith.slideDown( 'fast', function() { 34 $( 'select', PluginEdit.$testedWith ).focus(); 25 35 } ); 26 $( this).hide();36 $( this ).hide(); 27 37 } 28 event.preventDefault(); 29 }); 38 }, 30 39 31 $pluginStatusSelect.find('.save-plugin-status').click( function( event ) { 32 $pluginStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-plugin-status' ).show().focus(); 33 updateText(); 34 event.preventDefault(); 35 }); 40 editPluginStatus: function() { 41 if ( PluginEdit.$pluginStatus.is( ':hidden' ) ) { 42 PluginEdit.$pluginStatus.slideDown( 'fast', function() { 43 $( 'select', PluginEdit.$pluginStatus ).focus(); 44 } ); 45 $( this ).hide(); 46 } 47 }, 36 48 37 $pluginStatusSelect.find('.cancel-plugin-status').click( function( event ) { 38 $pluginStatusSelect.slideUp( 'fast' ).siblings( 'a.edit-plugin-status' ).show().focus(); 39 $('#post_status').val( $('#hidden_post_status').val() ); 40 updateText(); 41 event.preventDefault(); 42 }); 49 updateTestedWith: function() { 50 PluginEdit.$testedWith.slideUp( 'fast' ).siblings( 'button.edit-tested-with' ).show().focus(); 51 $( '#tested-with-display' ).text( $( 'option:selected', PluginEdit.$testedWith ).text() ); 52 }, 43 53 44 // Tested With 45 $testedWithSelect.siblings('a.edit-tested-with').click( function( event ) { 46 if ( $testedWithSelect.is( ':hidden' ) ) { 47 $testedWithSelect.slideDown( 'fast', function() { 48 $testedWithSelect.find('select').focus(); 54 updatePluginStatus: function() { 55 PluginEdit.$pluginStatus.slideUp( 'fast' ).siblings( 'button.edit-plugin-status' ).show().focus(); 56 $( '#plugin-status-display' ).text( $( 'option:selected', PluginEdit.$pluginStatus ).text() ); 57 }, 58 59 cancelTestedWith: function() { 60 $( '#tested-with' ).val( $( '#hidden-tested-with' ).val() ); 61 PluginEdit.updateTestedWith(); 62 }, 63 64 cancelPluginStatus: function() { 65 $( '#post-status' ).val( $( '#hidden-post-status' ).val() ); 66 PluginEdit.updatePluginStatus( event ); 67 }, 68 69 showNote: function() { 70 $( '.view-note', PluginEdit.$notesBox ).show(); 71 $( '.edit-note', PluginEdit.$notesBox ).hide(); 72 }, 73 74 editNote: function() { 75 var $textarea = $( '.note-content', PluginEdit.$notesBox ); 76 77 $( '.view-note', PluginEdit.$notesBox ).hide(); 78 $( '.edit-note', PluginEdit.$notesBox ).show(); 79 $textarea.text( $textarea.val() ).focus(); 80 }, 81 82 saveNote: function() { 83 wp.ajax.post( 'save-note', { 84 id: $( '#post_ID' ).val(), 85 note: $( '.note-content', PluginEdit.$notesBox ).val(), 86 notce: $( '#notce' ).val() 87 } ) 88 .done( function( response ) { 89 var note = response.note ? response.note : 'Add note'; 90 91 $( '.view-note', PluginEdit.$notesBox ).html( note ); 92 PluginEdit.showNote(); 49 93 } ); 50 $(this).hide(); 51 } 52 event.preventDefault(); 53 }); 94 } 95 }; 54 96 55 $testedWithSelect.find('.save-tested-with').click( function( event ) { 56 $testedWithSelect.slideUp( 'fast' ).siblings( 'a.edit-tested-with' ).show().focus(); 57 updateText(); 58 event.preventDefault(); 59 }); 60 61 $testedWithSelect.find('.cancel-tested-with').click( function( event ) { 62 $testedWithSelect.slideUp( 'fast' ).siblings( 'a.edit-tested-with' ).show().focus(); 63 $('#tested_with').val( $('#hidden_tested_with').val() ); 64 updateText(); 65 event.preventDefault(); 66 }); 67 } // end submitdiv 68 69 } ); 97 $( PluginEdit.ready ); 98 } )( window.jQuery, window.wp );
Note: See TracChangeset
for help on using the changeset viewer.