| 1 |
/** |
| 2 |
* Quick Edit |
| 3 |
* |
| 4 |
* @package ConvertKit |
| 5 |
* @author ConvertKit |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Copies Quick Edit fields into WordPress' #inline-edit table row on load. |
| 10 |
* |
| 11 |
* Populates Quick Edit fields for this Plugin with the values output |
| 12 |
* in the `add_inline_data` WordPress action when the user clicks |
| 13 |
* a Quick Edit link in a Post, Page or Custom Post Type WP_List_Table. |
| 14 |
* |
| 15 |
* WordPress' built in Quick Edit functionality does not do this automatically |
| 16 |
* for Plugins that register settings, which is why we have this code here. |
| 17 |
* |
| 18 |
* @since 1.9.8.0 |
| 19 |
*/ |
| 20 |
jQuery( document ).ready( |
| 21 |
function( $ ) { |
| 22 |
|
| 23 |
// Move Quick Edit fields from footer into the hidden inline-edit table row. |
| 24 |
$( 'tr#inline-edit .inline-edit-wrapper fieldset.inline-edit-col-left' ).first().append( $( '#convertkit-quick-edit' ) ); |
| 25 |
|
| 26 |
// Show the Quick Edit fields, as they are now contained in the inline-edit row which WordPress will show/hide as necessary. |
| 27 |
$( '#convertkit-quick-edit' ).show(); |
| 28 |
|
| 29 |
var convertKitInlineEditPost = inlineEditPost.edit; |
| 30 |
|
| 31 |
// Extend WordPress' inline edit function to load the Plugin's Quick Edit fields. |
| 32 |
inlineEditPost.edit = function( id ) { |
| 33 |
|
| 34 |
// Merge arguments from original function. |
| 35 |
convertKitInlineEditPost.apply( this, arguments ); |
| 36 |
|
| 37 |
// Get Post ID. |
| 38 |
if ( typeof( id ) === 'object' ) { |
| 39 |
id = parseInt( this.getId( id ) ); |
| 40 |
} |
| 41 |
|
| 42 |
// Iterate through any ConvertKit inline data, assigning values to Quick Edit fields. |
| 43 |
$( '.convertkit', $( '#inline_' + id ) ).each( |
| 44 |
function() { |
| 45 |
|
| 46 |
// Assign the setting's value to the setting's Quick Edit field. |
| 47 |
$( '#convertkit-quick-edit select[name="wp-convertkit[' + $( this ).data( 'setting' ) + ']"]' ).val( $( this ).data( 'value' ) ); |
| 48 |
|
| 49 |
} |
| 50 |
); |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
} |
| 55 |
); |
| 56 |
|