Skip to content

Instantly share code, notes, and snippets.

@thekendog
Last active September 11, 2024 15:40
Show Gist options
  • Save thekendog/69b28bd0bda0b949a909602173c2e95a to your computer and use it in GitHub Desktop.
Save thekendog/69b28bd0bda0b949a909602173c2e95a to your computer and use it in GitHub Desktop.
Set Kadence Blocks colors to those from Blocksy theme.
/**
* Set the colors from Blocksy to match those of Kadence blocks
*/
add_filter('kadence_blocks_pattern_global_colors', function($kadence_colors) {
if ( !function_exists('blocksy_get_theme_mod') ) {
return $kadence_colors;
}
$colorPalette = (array) blocksy_get_theme_mod('colorPalette');
for ($i = 1; $i <= count($colorPalette); $i++) {
$kadence_colors['--global-palette' . $i] = $colorPalette['color' . $i]['color'];
}
$buttonTextColor = blocksy_get_theme_mod('buttonTextColor');
$kadence_colors['--global-palette-btn'] = $buttonTextColor['default']['color'] ?? '#ffffff';
$kadence_colors['--global-palette-btn-hover'] = $buttonTextColor['hover']['color'] ?? '#ffffff';
$buttonColor = blocksy_get_theme_mod('buttonColor');
$kadence_colors['--global-palette-btn-bg'] = $buttonColor['default']['color'] ?? $colorPalette['color1']['color'];
$kadence_colors['--global-palette-btn-bg-hover'] = $buttonColor['hover']['color'] ?? $colorPalette['color2']['color'];
return $kadence_colors;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment