I am trying to making a Wordpress function to insert custom colours via an ACF repeater field. But trying to get the custom colours to make an array is a problem.
Example colour that works:
$default_colours = '"000000", "Black",
"993300", "Burnt orange",
"333300", "Dark olive",
"003300", "Dark green",
"003366", "Dark azure",
"000080", "Navy Blue",
"333399", "Indigo",
"333333", "Very dark gray",
"800000", "Maroon",
"FF6600", "Orange",
"808000", "Olive",
"008000", "Green",
"008080", "Teal",
"0000FF", "Blue",
"666699", "Grayish blue",
"808080", "Gray",
"FF0000", "Red",
"FF9900", "Amber",
"99CC00", "Yellow green",
"339966", "Sea green",
"33CCCC", "Turquoise",
"3366FF", "Royal blue",
"800080", "Purple",
"999999", "Medium gray",
"FF00FF", "Magenta",
"FFCC00", "Gold",
"FFFF00", "Yellow",
"00FF00", "Lime",
"00FFFF", "Aqua",
"00CCFF", "Sky blue",
"993366", "Red violet",
"FFFFFF", "White",
"FF99CC", "Pink",
"FFCC99", "Peach",
"FFFF99", "Light yellow",
"CCFFCC", "Pale green",
"CCFFFF", "Pale cyan",
"99CCFF", "Light sky blue",
"CC99FF", "Plum"';
$custom_colours = '"FB2768", "Love Pink",
"98C144", "BDHH Primary",
"385A29", "BDHH Secondary",
"707173", "BDHH Grey"';
// build colour grid default+custom colors
$init['textcolor_map'] = '['.$default_colours.','.$custom_colours.']';
// enable 6th row for custom colours in grid
$init['textcolor_rows'] = 6;
return $init;
}
add_filter('tiny_mce_before_init', 'my_mce4_options', 20);
Now I have an ACF options field:
get_field('advanced_editor_custom_colours', 'option') which is a repeater with a Colour and Text field.
This is my $custom_colours code I am trying to get working:
custom_colours = '.
foreach($advanced_editor_custom_colours as $colour) {
'.
$colour_colour = $colour['colour'];
$colour_text = $colour['text'];
$comma = ","
// .'
"'. echo($colour_colour) .'" , "'. echo($colour_text) .'",
}
'.endforeach.';
.'
But not having luck because it needs to comma in between the $colour_colour and $colour_text along within those two variables being wrapped in double-quotes > "
I hope you guys can help, I am going around in circles. I hope that makes sense.
Thanks.