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