Skip to content

Instantly share code, notes, and snippets.

@PluginRepublicSupport
Created November 10, 2023 12:34
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 PluginRepublicSupport/b1e041a677fea4efd66b09d3905a5337 to your computer and use it in GitHub Desktop.
Save PluginRepublicSupport/b1e041a677fea4efd66b09d3905a5337 to your computer and use it in GitHub Desktop.
Set predefined color palettes in the color picker
<?php
add_action( 'wp_footer', function() {
?>
<script>
jQuery(document).ready(function($) {
let apc = $('.apaou-customer-fields').find('.apaou-color-field').get(0);
// Specify your color palettes here
let colorPalettes = ['#000', '#000', '#000', '#fff', '#ff0'];
// Convert the array to a JSON string and set it as the data-palettes attribute
apc.dataset.palettes = JSON.stringify(colorPalettes);
});
</script>
<?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment