Created
October 26, 2021 13:11
-
-
Save plugin-republic/032e8b02524dc2546f3a750f558b2244 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set text preview field to specific colours | |
*/ | |
function prefix_set_preview_colours() { | |
?> | |
<script> | |
jQuery( document ).ready( function( $ ) { | |
var colours = { | |
blue: "0000ff", | |
red: "ff0000" | |
} | |
var colour_field_id = 9484; | |
var preview_field_id = 9483; | |
$( '.pewc-field-' + colour_field_id + ' input' ).on( 'change', function( e ) { | |
var colour = $( this ).val(); | |
colour = colour.toLowerCase(); | |
var hex = colours[colour]; | |
$( '.apaou-text-layer-' + preview_field_id ).css( 'color', '#' + hex ); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'prefix_set_preview_colours' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment