displaying tags in a widget

By what code you’ve posted, it seems like you’ve got a secondary loop set up (using a WP_Query object). So to display the current’ posts tags you can use: the_tags – to print a list of the post’s tags wp_tag_cloud – to print a tag cloud. get_the_tags – to return an array of tag objects, … Read more

How to disable a widget when dependent plugin is inactive?

well first of all, is_plugin_active takes the name of the plugin sub-directory/file, so passing it a classname won’t work. I’m not sure why you’re passing anything widget related if you’re checking for plugins your widget depends on. other options are php’s class_exists and function_exists to check if plugin functions your widget uses exist. check in … Read more

Problem since update 3.5 [duplicate]

Short explanation The $wpdb->prepare() method works similar to sprintf()/printf() and therefore needs more than one argument (else it’s senseless to use it at all). So if one of your plugins or the theme makes a DB call, which is prepared to protect you against cross script attacks and similar and doesn’t do it properly, WordPress … Read more

How to make widget title accept php?

You can use the filter widget_title and a “virtual” shortcode. Of course, as One Trick Pony points out, the “why” (and the “what”) is essential to find a proper solution… Supposing the widget title was Title [php] More Title: add_filter( ‘widget_title’, ‘pseudo_php_wpse_90360’, 10, 3 ); function pseudo_php_wpse_90360( $title, $instance, $id_base ) { if( FALSE === … Read more

Validating widget’s configuration data on Admin page

@tf is almost there, I think. You can use JS on your widget’s admin form, as I’ve done it before (though not for validation). Within your widget’s constructor, add an action: add_action( “admin_print_scripts-widgets.php”, array( __CLASS__, ‘register_my_validation_script’ ) ); Then create the corresponding function inside your widget’s class: function register_my_validation_script() { wp_enqueue_script( ‘my-script-handle’, plugins_url( ‘/my-validation-script.js’, __FILE__ … Read more

disbale default widgets on theme activation

Default widgets are not usually activated with the theme. Themes add default widgets in the sidebar template file. For example take a look at twenty ten sidebar.php file: <?php /** * The Sidebar containing the primary and secondary widget areas. * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ ?> <div … Read more

Show a widget as a sidebar fallback

If you want to display a fallback sidebar, you can do the following. If you want to decide which widget gets displayed, then idk. Create 2 sidebars. Example: sidebar and fallback-sidebar. In your template you can use: if(is_active_sidebar( ‘sidebar’ )){ dynamic_sidebar( ‘sidebar’ ); } else { dynamic_sidebar( ‘fallback-sidebar’ ); } If you just trying to … Read more