| 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 |
|
| 9 |
// "call" the original WP edit function |
| 10 |
// we don't want to leave WordPress hanging |
| 11 |
$wp_inline_edit.apply( this, arguments ); |
| 12 |
|
| 13 |
// now we take care of our business |
| 14 |
|
| 15 |
// get the post ID |
| 16 |
var $post_id = 0; |
| 17 |
if ( typeof( id ) == 'object' ) |
| 18 |
$post_id = parseInt( this.getId( id ) ); |
| 19 |
|
| 20 |
if ( $post_id > 0 ) { |
| 21 |
|
| 22 |
// define the edit row |
| 23 |
var $edit_row = $( '#edit-' + $post_id ); |
| 24 |
|
| 25 |
// get the term |
| 26 |
var $mark_posts_term_id = $( '#mark_posts_term_id-' + $post_id ).data('val'); |
| 27 |
|
| 28 |
// set the term |
| 29 |
$edit_row.find( 'select[name="mark_posts_term_id"]' ).val( $mark_posts_term_id ); |
| 30 |
|
| 31 |
} |
| 32 |
|
| 33 |
}; |
| 34 |
|
| 35 |
$( '#bulk_edit' ).live( 'click', function() { |
| 36 |
|
| 37 |
// define the bulk edit row |
| 38 |
var $bulk_row = $( '#bulk-edit' ); |
| 39 |
|
| 40 |
// get the selected post ids that are being edited |
| 41 |
var $post_ids = new Array(); |
| 42 |
$bulk_row.find( '#bulk-titles' ).children().each( function() { |
| 43 |
$post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) ); |
| 44 |
}); |
| 45 |
|
| 46 |
// get the custom fields |
| 47 |
var $mark_posts_term_id = $bulk_row.find( 'select[name="mark_posts_term_id"]' ).val(); |
| 48 |
|
| 49 |
// mark_posts_save the data |
| 50 |
$.ajax({ |
| 51 |
url: ajaxurl, |
| 52 |
type: 'POST', |
| 53 |
async: false, |
| 54 |
cache: false, |
| 55 |
data: { |
| 56 |
action: 'mark_posts_save_bulk_edit', |
| 57 |
post_ids: $post_ids, |
| 58 |
mark_posts_term_id: $mark_posts_term_id |
| 59 |
} |
| 60 |
}); |
| 61 |
|
| 62 |
}); |
| 63 |
|
| 64 |
})(jQuery); |