Skip to content

Instantly share code, notes, and snippets.

@torian257x
Created January 12, 2021 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torian257x/d246e7f9bf5f8b4f476175f548e20678 to your computer and use it in GitHub Desktop.
Save torian257x/d246e7f9bf5f8b4f476175f548e20678 to your computer and use it in GitHub Desktop.
(function($) {
// we create a copy of the WP inline edit post function
var $wp_inline_edit = inlineEditPost.edit;
// and then we overwrite the function with our own code
inlineEditPost.edit = function( id ) {
// "call" the original WP edit function
// we don't want to leave WordPress hanging
$wp_inline_edit.apply( this, arguments );
// now we take care of our business
// get the post ID
var $post_id = 0;
if ( typeof( id ) == 'object' ) {
$post_id = parseInt( this.getId( id ) );
}
if ( $post_id > 0 ) {
// define the edit row
var $edit_row = $( '#edit-' + $post_id );
var $post_row = $( '#post-' + $post_id );
// get the data
var is_featured = $( '.myapp-post-id-helper', $post_row ).attr('data-myapp-featured');
var is_disabled = $( '.myapp-post-id-helper', $post_row ).attr('data-myapp-disabled');
// populate the data
$( 'select[name="in_myapp_featured"]', $edit_row ).val( is_featured );
$( 'select[name="in_myapp_disabled"]', $edit_row ).val( is_disabled );
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment