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