• I’m not here talking about the color palette UI but about the :root color variables defined by Twenty Twenty One in the Twenty_Twenty_One_Custom_Colors class.

    I have defined my own colors for variables and in the child theme front they work properly. For example –global–color-primary is not black but blue.
    The problem is in the editor the text is still black because the theme’s colors take priority over my editor-style.css file.

    How do I override them, or remove the actions that Twenty Twenty One uses to add them?

    i have tried removing the actions but it does not work. Any suggestion to get rid of those actions ?

     * This class is in charge of color customization via the Customizer.
     */
    class Twenty_Twenty_One_Custom_Colors {
    
    	/**
    	 * Instantiate the object.
    	 *
    	 * @since Twenty Twenty-One 1.0
    	 */
    	public function __construct() {
    
    		// Enqueue color variables for customizer & frontend.
    		add_action( 'wp_enqueue_scripts', array( $this, 'custom_color_variables' ) );
    
    		// Enqueue color variables for editor.
    		add_action( 'enqueue_block_assets', array( $this, 'editor_custom_color_variables' ) );
    
    		// Add body-class if needed.
    		add_filter( 'body_class', array( $this, 'body_class' ) );
    	}

    I wanted to remove custom_color_variables and editor_custom_color_variables but it does not work. Any help welcome.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter julianoe

    (@julianoe)

    I could have of course removed it entirely by commenting out the class call in functions.php in the parent theme but that’s not good practice and would want to know how to do it the proper way.

    Thanks in advance.

    Looks like the PHP for TT1 instantiates new objects with no way of accessing them. And when an object adds its methods to a filter/action when doing this, it makes it near impossible to remove that filter/action (like the one generating color variables). ???♀?

    There are probably some workarounds. If the child theme is using the same CSS custom property names, that’d be easiest, you can override them in your CSS. Is that the case?

    Or, it may just be matter of loading your child theme’s stylesheet last. Can you share how you’re loading your stylesheet in the editor?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘What is the proper way of removing the theme’s custom colors in editor ?’ is closed to new replies.