Reputation: 308
Hey i am trying to extend WP_Customize_Control class, to add custom dropdown of posts in Customizer using sage theme. I even tried to add class in customize_register action hook, but still i get not found error:
Fatal error: Class 'Roots\Sage\Customizer\WP_Customize_Control' not found in /home/wpsitesb/sites/rex2/wp-content/themes/rex-etyhadar_v1/lib/customizer.php on line 36
My code :
add_action('customize_register', __NAMESPACE__ . '\\customizer_register_callback');
function customizer_register_callback($wp_customize ) {
class Post_Dropdown_Custom_Control extends WP_Customize_Control {
// Dropdown code.
}
}
Upvotes: 1
Views: 1258
Reputation: 534
Check your WordPress version. It should be >= 3.4
If it is, the reason could be namespace , use '\'
Upvotes: 0
Reputation: 12391
Maybe it is not an answer actually, but I write here because for the length of it and code fomating.
The problem is (I think) is the namespace.
In your customiser.php you are under Roots\Sage\Customizer\
namespace.
When you want to create your class by extending the WP_Customize_Control
then you should use the global namespace.
Add a \
sign before WP_Customize_Control
.
class Post_Dropdown_Custom_Control extends \WP_Customize_Control {
//....
}
Please try it, and tell me the result.
Upvotes: 2