Where to get the unsaved list of widgets in customizer?

You can get the list of widgets in a sidebar via: wp.customize(‘sidebars_widgets[sidebar-1]’).get() This is a list of the widgets’ IDs. The sidebars_widgets[sidebar-1] is the setting ID for the sidebar. Replace sidebar-1 with the ID of your sidebar. So to get the count just do: wp.customize(‘sidebars_widgets[sidebar-1]’).get().length If you want to listen for when a widget is … Read more

Woocommerce Product Category Widget – hide categories that have no products in stock [closed]

Use the woocommerce_product_categories_widget_args and woocommerce_get_availability filters in a custom function to filter the product categories widget for out of stock products. See what you can come up using these filters and post the code back here if you get stuck. Here’s some code from my site which may help you get started. add_filter( ‘woocommerce_product_categories_widget_args’, ‘wpsites_exclude_product_cat_widget’ … Read more

Remove All Widgets from Sidebar

You could add this function to your functions.php file. add_filter( ‘sidebars_widgets’, ‘disable_all_widgets’ ); function disable_all_widgets( $sidebars_widgets ) { $sidebars_widgets = array( false ); return $sidebars_widgets; } You could also use the WordPress conditional tags to disable widgets only on certain pages. For example; this would only disable widgets on the home page. add_filter( ‘sidebars_widgets’, ‘disable_all_widgets’ … Read more

How to listen to color changes on the color picker?

I hate answering my own question, but hopefully this can help someone else with similar issues: WordPress uses Iris color picker. http://automattic.github.io/Iris/# WordPress also creates a jquery widget with default settings for Iris. The file can be found under wp-admin/js/color-picker.js At first I was trying to pass values directly to iris(), which works, but that … Read more

Why Can’t wp_editor Be Used in a Custom Widget?

Short answer: Because there is a hidden widget where the TinyMCE appears first. Long answer (sorry, a very long answer): Go to the Codex and copy the example widget Foo_Widget to make sure we are talking about the same code. Now open your IDE (not an editor) and write a short testing widget as plugin. … Read more

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