Using add_filter() in Widgets

<?php /** * Display the actual Widget * * @param Array $args * @param Array $instance */ public function widget($args, $instance){ … $wcss = apply_filters( ‘my-filter-name’, $wcss ); … } ?> To create your own filter hook just use the function “apply_filters” then as you mentioned add a function in your constructor i.e. function __constructor() … Read more

Widget to display custom taxonomy tag cloud

Don’t know of any but you can easily create your own: <?php add_action(“widgets_init”, array(‘Widget_Custom_tax_tag_cloud’, ‘register’)); class Widget_Custom_tax_tag_cloud { function control(){ echo ‘No control panel’; } function widget($args){ echo $args[‘before_widget’]; echo $args[‘before_title’] . ‘Your widget title’ . $args[‘after_title’]; $cloud_args = array(‘taxonomy’ => ‘Your taxonomy here’); wp_tag_cloud( $cloud_args ); echo $args[‘after_widget’]; } function register(){ register_sidebar_widget(‘Widget name’, array(‘Widget_Custom_tax_tag_cloud’, … Read more

Moving WordPress.com theme and widget settings to self-hosted site?

First off, check if the theme is available in wordpress.org themes: http://wordpress.org/extend/themes/ If it’s not, find the name of the theme developer and contact them. Many developers of wordpress.com themes are happy for people to use their themes on self-hosted WordPress blogs. The developer’s name and contact details can be found by looking at style.css. … Read more

How to add author details in the post sidebar?

global $authordata; This variable contains the current post’s author data. From an author data widget I have written: global $authordata; if ( ( is_singular() or is_author() ) and is_object( $authordata ) and isset ( $authordata->ID ) ) { return $authordata->ID; } To get the link to the author archive: get_author_posts_url( $authordata->ID ); Update Here is … Read more

Where to find the source code of a widget?

The default widgets are defined in wp-includes/default-widgets.php. To find specific code search the Codex or use queryposts.com. The best tool is your IDE (integrated development environment). All IDEs offer a full text search in a set of files. Here a screen shot from Eclipse PDT As you can see it is really flexible – and … Read more

How to add color picker to widgets?

Here is the code I used for one of my projects: <?php function load_color_picker_style() { wp_enqueue_style( ‘wp-color-picker’ ); } add_action(‘admin_print_scripts-widgets.php’, ‘load_color_picker_script’); add_action(‘admin_print_styles-widgets.php’, ‘load_color_picker_style’); ?> ///Javascript jQuery(document).ready(function($){ function updateColorPickers(){ $(‘#widgets-right .wp-color-picker’).each(function(){ $(this).wpColorPicker({ // you can declare a default color here, // or in the data-default-color attribute on the input defaultColor: false, // a callback to fire … Read more

Programmatically edit the text of a widget

I guess you want to locate the widget by it’s title, so you can try this function: /** * Update a widget text located by it’s title * * @see https://wordpress.stackexchange.com/a/155518/26350 * * @param string $search_title * @param string $new_text * @param boolean */ function wpse_155046_update_widget_text_by_title( $search_title, $new_text ) { // Get all data from … Read more

Filter Widget Title Wrap

The filter to do this is dynamic_sidebar_params also see this tutorial on this filter at ACF’s site (even if you don’t use ACF). function prefix_filter_widget_title_tag( $params ) { $params[0][‘before_title’] = ‘<h2 class=”widget-title widgettitle”>’ ; $params[0][‘after_title’] = ‘</h2>’ ; return $params; } add_filter( ‘dynamic_sidebar_params’ , ‘prefix_filter_widget_title_tag’ );

How wp_cache is supposed to work, and does it help with performance?

In WordPress v2.5+ the object cache is not persistent. It will save things in memory, but for persistent caching across page loads you will need a plugin see here: http://codex.wordpress.org/Class_Reference/WP_Object_Cache#Persistent_Caching Alternatively, use transients, which are persistent. The identifier must be 45 or less characters long, but the data attached to that identifier can be longer. … Read more

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