Support

Account

Home Forums ACF PRO tinyMCE(Custome) Color Picker Problem

Solving

tinyMCE(Custome) Color Picker Problem

  • Hello,

    I am trying to create my own colors via acf in the tinymce color picker, but I have a problem with the output.

    
    function wfl_color_picker($init) {
    $custom_colours = array();
    $args = array(
         'post_type' => 'posttype',
         'posts_per_page' => '-1'
    );
    
    $postcolor = new WP_Query($args);
    
    if($postcolor->have_posts()) : 
    while ( $postcolor->have_posts() ) : 
    	$postcolor->the_post(); 
    	array_push($custom_colours, strtoupper(substr( get_field( 'hex' ), 1, 6 ) ) );
    	array_push($custom_colours, get_the_title() );
    endwhile; //end the while loop
    wp_reset_postdata();
    
    $colors = '["'. join("\", \"", $custom_colours) .'"]';
    // build colour grid default+custom colors
    $init['textcolor_map'] = $colors;
    // change the number of rows in the grid if the number of colors changes
    // 8 swatches per row
    $init['textcolor_rows'] = 1;
    return $init;
    endif; // end of the loop. 
    }
    add_filter('tiny_mce_before_init', 'wfl_color_picker');
  • What is wrong with the output? What isn’t working as expected?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.