Come aggiungere una descrizione ai Widget in WordPress?

7 dic 2010, 01:50:13
Visualizzazioni: 2.68K
Voti: 2

La documentazione codex non sembra spiegare come aggiungere una descrizione a un widget personalizzato registrato con wp_register_sidebar_widget(). La descrizione predefinita sembra essere il nome del widget stesso.

function myFunc(){
  /* codice del widget */
}
wp_register_sidebar_widget( 'wdgt1', 'Mappa del Sito', 'myFunc', array() );

Esempio di widget WordPress con descrizione personalizzata

0
Tutte le risposte alla domanda 3
0

Ecco quello che stavi cercando:

class WP_Widget_Sitemap extends WP_Widget {

    function WP_Widget_Sitemap() {
        $widget_ops = array( 'classname' => 'widget_sitemap', 'description' => __( "Questa è la descrizione" ) );
        $this->WP_Widget( 'sitemap', __('Mappa del Sito'), $widget_ops);
    }

    function widget() { ... }
    function form() { ... }
    function update() { ... }
...

Vedi: http://codex.wordpress.org/Widgets_API#Developing_Widgets

7 dic 2010 10:03:27
0

Questo è il vecchio (e complicato) metodo per creare widget in WordPress. Utilizza invece l'API Widget: http://codex.wordpress.org/Widget_API.

7 dic 2010 02:08:57
2
-1

Fornisce un parametro per la descrizione nell'array della funzione per registrare un widget:

register_sidebar()

Un esempio può essere visto in questo articolo o in questo codice.

if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
        'name' => 'La Mia Sidebar Lorem Ipsum',
        'description' => __('Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.', 'your_textdomain'),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
}
7 dic 2010 08:07:49
Commenti

Stai aggiungendo una nuova barra laterale, penso che Jonathan voglia aggiungere un nuovo widget alla barra laterale.

Jan Fabry Jan Fabry
7 dic 2010 10:08:13

hai ragione, scusa. il parametro è anche lo stesso.

bueltge bueltge
7 dic 2010 19:13:32