Add class to the UPDATE button in wordpress admin, only if an input fields has changed

117 Views Asked by At

I want to make it more obvious for a the editor that they need to click the UPDATE button after they made any changes to a wordpress page.

If a class can be added to the UPDATE button once any field, be it title, description or a custom field, has changed, then I can change the colour or make it pulsate.

Thank you

1

There are 1 best solutions below

0
Melooo7 On

This goes into the functions.php of your child theme. To make your own animation you have to insert the CSS inside the Tag in the code snippet.

add_action('admin_head', 'orders_list_preview_css');
function orders_list_preview_css() {
    echo "<script>
jQuery(document).ready(function($) {
$('body').on('keydown', '*[contenteditable=\"true\"]', function() {
if ($('.editor-post-publish-button.clicktoupdate').length < 1) {
$('.editor-post-publish-button').addClass('clicktoupdate')}

})

$('body').on('keydown', 'input', function() {
if ($('.editor-post-publish-button.clicktoupdate').length < 1) {
$('.editor-post-publish-button').addClass('clicktoupdate')}

})
})</script>";
        
echo "<style>/*cssgoeshere*/</style>";