You have a function or method hooked on customize_register, right? In that function or method require once your new files just before adding your custom controls. Then PHP won’t complain about redefining classes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
add_action('customize_register', array('myAddControl', 'customize_register') ); class myAddControl{ public function customize_register() { global $wp_customize; //This will do the trick require_once(dirname(__FILE__).'/class-gctfw-theme-control.php'); $wp_customize->add_section( 'gctfw_switch_theme' , array( 'title' => 'Switch theme', 'priority' => 25, ) ); $wp_customize->add_setting( 'gctfw_select_theme' , array( 'default' => $wp_customize->theme()->get('Name'), 'transport' => 'refresh', 'capabilities' => 'manage_options' ) ); $myControl = new gctfw_Theme_Control( $wp_customize, 'gctfw_select_theme', array( 'label' => __( 'Select theme', 'mytheme' ), 'section' => 'gctfw_switch_theme', 'settings' => 'gctfw_select_theme', ) ) ; $wp_customize->add_control( $myControl ); } }//class |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.