/* global jQuery, inlineEditPost */ jQuery( document ).ready( function ( $ ) { // it is a copy of the inline edit function const wpInlineEditFunction = inlineEditPost.edit; // we overwrite the it with our own inlineEditPost.edit = function ( postId ) { // let's merge arguments of the original function wpInlineEditFunction.apply( this, arguments ); // get the post ID from the argument let id = 0; if ( typeof postId === 'object' ) { // if it is object, get the ID number id = parseInt( this.getId( postId ) ); } //if post id exists if ( id > 0 ) { // add rows to variables const specificPostEditRow = $( '#edit-' + id ), specificPostRow = $( '#post-' + id ), productPrice = $( '.column-price', specificPostRow ) .text() .substring( 1 ); // remove $ sign // add rows to variables let featuredProduct = false; // let's say by default checkbox is unchecked // check if the Featured Product column says Yes if ( $( '.column-featured', specificPostRow ).text() === 'Yes' ) featuredProduct = true; // populate the inputs with column data $( ':input[name="price"]', specificPostEditRow ).val( productPrice ); $( ':input[name="featured"]', specificPostEditRow ).prop( 'checked', featuredProduct ); } }; } );