Support

Account

Forum Replies Created

  • Maybe this alternate solution is a little bit faster. It simply change the default option of the colorpicker when there are acf fields on the page.

    
    function change_acf_color_picker() {
      // Adds client custom colors to WYSIWYG editor and ACF color picker.
      $client_colors = array(
        "#222222",
        "#8dc4d5",
        "#e1523d",
        "#eeeeee",
        "#323232",
        "#ffffff",
        "#000000"
      );
    
      echo "<script>
      (function($){
        try {
          $.wp.wpColorPicker.prototype.options = {
            palettes: " . json_encode($client_colors) . "
          };
        }
        catch (e) {}
      })(jQuery)
      </script>";
    }
    
    add_action( 'acf/input/admin_head', 'change_acf_color_picker' );
    
Viewing 1 post (of 1 total)