Skip to content

Unable to get it to work #20

@idlevibes95

Description

@idlevibes95

Sorry in advance if my question is stupid and I know it's probably an easy fix, but I've been trying to make it work for hours and I just don't know what I'm doing wrong.

I've added the ColorAlpha.php, WPTRTColorAlphaControl.js, WPTRTColorAlphaForm.js and index.js files to the inc file in my theme.

I've added this in functions.php:

add_action( 'customize_register', function( $wp_customize ) { $wp_customize->register_control_type( '\WPTRT\Customize\Control\ColorAlpha' ); } );

I've added these codes in customizer.php (also in inc, if it matters):

use \WPTRT\Customize\Control\ColorAlpha;

add_action( 'customize_register', function( $wp_customize ) {

	$wp_customize->add_setting( 'your_setting_id' , [
		'default'           => 'rgba(0,0,0,0.5)', // Use any HEX or RGBA value.
		'transport'         => 'refresh',
		'sanitize_callback' => 'my_custom_sanitization_callback'
	] );
	$wp_customize->add_control( new ColorAlpha( $wp_customize, 'your_setting_id', [
		'label'      => __( 'My Color', 'mytheme' ),
		'section'    => 'colors',
		'settings'   => 'your_setting_id',
	] ) );

} );

And when I try to check the customizer, I get a critical error message:

Uncaught Error: Class 'WPTRT\Customize\Control\ColorAlpha' not found in /wp-content/themes/theme-name/inc/customizer.php:17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions