Can’t get wpColorPicker to work in a widget

Please try this modified code: class widget007 extends WP_Widget { function __construct() { add_action(‘admin_print_styles-widgets.php’, array( $this, ‘load_color_picker_style’ ) ); $args = array( ‘name’ => esc_html__( ‘widget007’, ‘txt-domaine’ ), ‘description’ => esc_html__( ‘Something’, ‘txt-domaine’ ) ); parent::__construct( ‘my_widget007’, ”, $args ); } function load_color_picker_style() { wp_enqueue_style( ‘wp-color-picker’ ); wp_enqueue_script( ‘wp-color-picker’ ); wp_enqueue_script( ‘underscore’ ); } function … Read more

Append php file to footer

This might help you. add_action(‘wp_footer’, ‘insert_my_js_to_footer’); function insert_my_js_to_footer(){ ?> <script> // your script here. </script> <?php }; UPDATE: And if you want to append the php file itself then you can try this. add_action(‘wp_footer’, ‘insert_php_file_to_footer’); function insert_php_file_to_footer(){ include( ‘your-php-file.php’ ); };

Don’t print customizer styles when no setting has been used

There’s not really any trick, you need to check all the values. You can save a little space though, by omitting the != ”, which is redundant: if ( get_theme_mod( ‘myplugin_h2_color’ ) || get_theme_mod( ‘myplugin_h3_color’ ) || get_theme_mod( ‘myplugin_p_color’ ) || get_theme_mod( ‘myplugin_p_size’ ) ) { However, it’s possible to save Customiser settings into a … Read more