levitra france acheter isotretinoine levitra 20 mg acheter kamagra acquisto viagra in farmacia achat levitra levitra ricetta levitra farmacia viagra en ligne cialis generico sicuro acheter cialis moins cher acquisto viagra svizzera levitra italia acquisto viagra originale impuissance erection acheter cialis sur la net viagra kosten curare impotenza acheter cialis en belgique sildenafil kaufen citrate de sildenafil acheter kamagra oral jelly achat viagra en ligne comprar viagra generico viagra acquisto online viagra donna vente de cialis sur internet medicament impuissance levitra en ligne dysfonction erectile viagra europe impotenza rimedi compro sildenafil kamagra rezeptfrei vente levitra sildenafil rezeptfrei achat de viagra comprar cialis propecia sans ordonnance pilule cialis comprar sildenafil achat cialis 20mg pastilla viagra acheter du cialis trouver du viagra viagra bestellen kamagra gel compro cialis koop viagra prix de cialis comprare levitra sildenafil generique cialis receta prezzi viagra cialis generico 10 mg kamagra te koop levitra venta generische cialis cialis sur ordonnance levitra pharmacie acheter viagra pas chere kamagra apcalis levitra kopen cialis 10 mg cialis pharmacie levitra naturale comprar vardenafil acheter cialis pas chere impuissance sexuelle cialis vente libre sildenafil precio cialis en pharmacie vendo levitra acheter kamagra 100mg achat vardenafil generische viagra levitra sin receta acquisto viagra net viagra preço viagra ricetta trouver du levitra cialis preço compro levitra viagra pharmacie vendo viagra costo viagra cialis venta pastilla levitra acquista levitra costo levitra cialis ohne rezept traitement impuissance acquistare viagra farmaci impotenza cialis indien cialis precio cialis vente libre receta viagra levitra rezeptfrei posologia viagra levitra ordonnance cialis quebec viagra vendita italia sildenafil costo pilule viagra acheter finasteride vente cialis sildenafil generico pildoras cialis commander du cialis viagra senza ricetta prozac prix achat tadalafil cialis inde viagra sans prescription tadalafil bestellen viagra rezeptfrei compra viagra cialis effet secondaire acquista viagra levitra donne levitra sans ordonnance acheter clomid en france acheter kamagra france cialis svizzera acheter cialis pas cher zyban prix zithromax prix cialis marche pas cialis france vardenafil bestellen acheter cialis en espagne viagra prijs

WordPress Development: Replacing Default Widgets

Posted April 10th, 2008

I’ve been working on a little WordPress project these last few weeks with a colleague. When I first heard the idea, I thought, “That should be easy enough to build.” I decided the best way to tackle the feature would be a custom widget, but when I finally sat down to get it working I quickly began to realize that there were a few obstacles to overcome.

The project was really meant to extend an existing widget, and it seemed confusing to have both the default and extended version there side by side (plus it would be really nice to call them the same thing for transparency). I needed to get rid of it. You can’t just overwrite an existing widget by registering a new one by the same name – WordPress ignores it. And if I did manage to find a way to remove a default widget, when do you have to do it?

Luckily, some digging around found a solution.

1
2
3
4
5
6
7
8
9
10
function gdm_widget_meta_register() {
	// unregister the widget and its control
	wp_unregister_sidebar_widget('meta');
 
	// register the new and improved widget and control
	wp_register_sidebar_widget('meta', __('Meta'), 'gdm_widget_meta');
	wp_register_widget_control('meta', __('Meta'), 'gdm_widget_meta_control');
}
 
add_action('widgets_init', 'gdm_widget_meta_register', 1);

The really important pieces are the wp_unregister_sidebar_widget function and the widgets_init action hook. widgets_init actions are run right after all the default widgets are registered, giving us the perfect opportunity to call wp_unregister_sidebar_widget with the ID of the widget you’re getting rid of. Now you can register your own widget and control, effectively replacing a default WordPress widget.

20 Responses to “WordPress Development: Replacing Default Widgets”

Спасибо, хорошая статья. Подписался.

Честно говоря, сначала до конца не понял, но со второго раза дошло – спасибо!

This is one good looking, sexy theme, love it! What theme are you using?

Спасибо, интересно было прочитать.

Nowadays WP is replacing many good plugins needed in the past.

There is no plan nor capital for a so-called electric economy. ,

This total includes 52 new measures. ,

But a casual fling might be just what she needs to take her mind off bridezillas. ,

Very interesting stuff about WordPress Development: Replacing Default Widgets | Garrett Murphey . Thanks and keep up the good work. Merry christmas to u all ;)

Leave a Reply