Modify WordPress widgets Screen

I’d personally suggest an enqueue, it’s preferable where possible to make use of caching and script compression. Firstly, the enqueue. add_action( ‘admin_enqueue_scripts’, ‘add_sidebar_ids_to_widget_admin’ ); function add_sidebar_ids_to_widget_admin( $current_page_hook ) { if( ‘widgets.php’ != $current_page_hook ) return; wp_enqueue_script( ‘widget-admin-jquery’, get_stylesheet_directory_uri() . ‘/widget-admin-jquery.js’, array( ‘jquery’ ), ‘1.0’, true ); } I placed the code in a child theme’s … Read more

Remove the Inactive Widgets

function andrew_unregister_widgets() { unregister_widget( ‘WP_Widget_Archives’ ); unregister_widget( ‘WP_Widget_Calendar’ ); unregister_widget( ‘WP_Widget_Categories’ ); unregister_widget( ‘WP_Widget_Links’ ); unregister_widget( ‘WP_Widget_Meta’ ); unregister_widget( ‘WP_Widget_Pages’ ); unregister_widget( ‘WP_Widget_Recent_Comments’ ); unregister_widget( ‘WP_Widget_Recent_Posts’ ); unregister_widget( ‘WP_Widget_RSS’ ); unregister_widget( ‘WP_Widget_Search’ ); unregister_widget( ‘WP_Widget_Tag_Cloud’ ); unregister_widget( ‘WP_Widget_Text’ ); } add_action( ‘widgets_init’, ‘andrew_unregister_widgets()’ ); This unregisters all in-built wordpress widgets. Which ones of those are … Read more

Dynamic Sidebar and XHTML Validity?

I’ve had similar issues in the past with custom sidebars. It was caused by the improper use of the <ul> and <li> tags. I was adding them in the sidebar.php file and not inside the function. Now I use this code and with 6 active widgets I have no errors. Take a look at the … Read more

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

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

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