Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created October 26, 2021 13:11
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 plugin-republic/032e8b02524dc2546f3a750f558b2244 to your computer and use it in GitHub Desktop.
Save plugin-republic/032e8b02524dc2546f3a750f558b2244 to your computer and use it in GitHub Desktop.
<?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