wrapper div for widgets not showing with all widgets

You’re not echoing the wrapping divs. The register_sidebar only defines the div, but doesn’t render it. You need to extract the texts and echo them, like this: public function widget( $args, $instance ) { extract( $args ); $title = apply_filters( ‘widget_title’, $instance[‘title’] ); echo $before_widget; if ( $title ) { echo $before_title . $title . … Read more

WordPress custom widget undefined variable notice

You can you wp_parse_args to merge $instance with a default array. So, you would start you form function not with extract($instance) but with $defaults = array( ‘title’ => ‘Your title’, ‘text’ => ‘…’, ‘image_url’ => ‘…’ ‘textarea’ => ‘…’ ); $instance = wp_parse_args((array) $instance, $defaults);

Ampersand breaking Widget title

SOLUTION: So, it turned out (of course) I myself was causing the problem (…) I am getting the widgets with the ‘the_widget()’ method and sending the instance params along as I go. The params are query-string-style parameters and are of course ‘glued’ together with ampersands. Now , I wasn’t encoding the individual params so the … Read more

add_action not working within widget() of WP_Wdiget

Not really following how the functions relate to each other and where (so what variables are available, how), but you might try something like: add_action(‘before_test_action’, array($this, ‘widget_test_func’)); public function widget_test_func( $instance) { $boolean = (isset($instance[‘boolean’])) ? $instance[‘boolean’] : ”; if ($boolean == ‘on’) { echo ‘within widget test func’; } }

How do I get an array of widgets?

How do I get an array of widgets? You can look into $sidebars_widgets = wp_get_sidebars_widgets(); print_r( $sidebars_widgets ); Here’s an output example: Array ( [orphaned_widgets_1] => Array ( [0] => text-6 ) [wp_inactive_widgets] => Array ( [0] => text-7 [1] => rss-2 ) [sidebar-1] => Array ( [0] => recent-posts-3 [1] => recent-posts-4 [2] => … Read more

Custom widget is not appearing in the admin area

Your code worked for me; The widget appears in the admin area under Appearance > Widgets and the widget does show output on the front end. Your widget() method is missing the output for $args[‘before_widget’]. echo $args[‘before_widget’]; should be added above <section id=”box” class=”box1″>. This would not cause the issue reported, where the widget does … Read more

Enqueue script only when side widget is used

is_widget_active is what you want e.g. function sidedish_slide_script() { wp_register_script(‘add-sd-js’, get_template_directory_uri() . ‘/form-slider/jquery-1.8.2.min.js’, array(‘jquery’),’null’, true ); wp_register_script(‘add-sd-custom’, get_template_directory_uri() . ‘/form-slider/formslider.js’, array(‘jquery’),’null’, true ); wp_register_style(‘add-sd-css’,get_stylesheet_directory_uri() . ‘/form-slider/styles.css’, ”,”,’screen’ ); if ( is_active_widget( false, ‘widget_id’, $this->id_base, true ) ) { wp_enqueue_script (‘add-sd-js’); wp_enqueue_script (‘add-sd-custom’); wp_enqueue_style (‘add-sd-css’); } } add_action(‘wp_enqueue_scripts’,’sidedish_slide_script’); https://codex.wordpress.org/Function_Reference/is_active_widget

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)