admin-dashboard.js
5 years ago
admin-post.js
5 years ago
admin-quick-edit.js
5 years ago
admin-settings.js
5 years ago
admin-widgets.js
5 years ago
frontend.js
5 years ago
gutenberg.min.js
6 years ago
admin-quick-edit.js
62 lines
| 1 | ( function( $ ) { |
| 2 | |
| 3 | // we create a copy of the WP inline edit post function |
| 4 | var $wp_inline_edit = inlineEditPost.edit; |
| 5 | |
| 6 | // and then we overwrite the function with our own code |
| 7 | inlineEditPost.edit = function( id ) { |
| 8 | // call the original WP edit function, we don't want to leave WordPress hanging |
| 9 | $wp_inline_edit.apply( this, arguments ); |
| 10 | |
| 11 | // get the post ID |
| 12 | var $post_id = 0; |
| 13 | |
| 14 | if ( typeof ( id ) == 'object' ) |
| 15 | $post_id = parseInt( this.getId( id ) ); |
| 16 | |
| 17 | if ( $post_id > 0 ) { |
| 18 | // define the edit row |
| 19 | var $edit_row = $( '#edit-' + $post_id ), |
| 20 | $post_row = $( '#post-' + $post_id ); |
| 21 | |
| 22 | // get the data |
| 23 | var $post_views = $( '.column-post_views', $post_row ).text(); |
| 24 | |
| 25 | // populate the data |
| 26 | $( ':input[name="post_views"]', $edit_row ).val( $post_views ); |
| 27 | $( ':input[name="current_post_views"]', $edit_row ).val( $post_views ); |
| 28 | } |
| 29 | |
| 30 | return false; |
| 31 | }; |
| 32 | |
| 33 | $( document ).on( 'click', '#bulk_edit', function() { |
| 34 | // define the bulk edit row |
| 35 | var $bulk_row = $( '#bulk-edit' ); |
| 36 | |
| 37 | // get the selected post ids that are being edited |
| 38 | var $post_ids = new Array(); |
| 39 | |
| 40 | $bulk_row.find( '#bulk-titles' ).children().each( function() { |
| 41 | $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) ); |
| 42 | } ); |
| 43 | |
| 44 | // get the data |
| 45 | var $post_views = $bulk_row.find( 'input[name="post_views"]' ).val(); |
| 46 | |
| 47 | // save the data |
| 48 | $.ajax( { |
| 49 | url: ajaxurl, // this is a variable that WordPress has already defined for us |
| 50 | type: 'post', |
| 51 | async: false, |
| 52 | cache: false, |
| 53 | data: { |
| 54 | action: 'save_bulk_post_views', // this is the name of our WP AJAX function that we'll set up next |
| 55 | post_ids: $post_ids, // and these are the 2 parameters we're passing to our function |
| 56 | post_views: $post_views, |
| 57 | current_post_views: $post_views, |
| 58 | } |
| 59 | } ); |
| 60 | } ); |
| 61 | |
| 62 | } )( jQuery ); |