Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get it to work #20

Open
idlevibes95 opened this issue Jan 17, 2022 · 2 comments
Open

Unable to get it to work #20

idlevibes95 opened this issue Jan 17, 2022 · 2 comments

Comments

@idlevibes95
Copy link

idlevibes95 commented Jan 17, 2022

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

@joyously
Copy link

You have use \WPTRT\... but did you actually load the file with require or include?

@idlevibes95
Copy link
Author

I've added it and the error is gone, but the control is not showing up at all. The Colors section is empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants