User Tools

Site Tools


wordpress:disqusrecents

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wordpress:disqusrecents [2014/01/09 11:13] gfsadministratorwordpress:disqusrecents [2020/10/25 19:39] (current) gfsadministrator
Line 2: Line 2:
 ====== Disqus: Recent Comments for Wordpress ====== ====== Disqus: Recent Comments for Wordpress ======
  
-Work in progress.+Riporto direttamente dall'[[http://gioxx.org/2014/01/10/disqus-recent-comments-per-wordpress/|articolo originale sul blog]]:
  
-<file php disqusrecents.php> +>Come forse molti di voi sapranno già Disqus è un sistema di commenti per siti web, blog e comunità online che si integra perfettamente con i social network, permettendo infatti il login con il proprio utente Twitter, Facebook e non soloLa gestione dello spam, gli strumenti di moderazione e analisi, le notifiche mail, il pannello commenti e molto altro ancora è centralizzato per offrire a utilizzatori e possessori dei siti il massimo della praticitàIl fatto che vengano poi supportati tutti i principali browser da PC ed in parte quelli mobile per smartphone e tablet è un valore aggiunto non da poco.
-<?php +
-/* +
-  Plugin Name: Disqus Recent Comments Widget +
-  Plugin URI: http://public.gfsolone.com/wiki/doku.php?id=wordpress:disqusrecents +
-  Description: Mostra gli ultimi commenti lasciati nel sistema Disqus installato nel vostro Wordpress. +
-  Version: 0.2 +
-  Author: Gioxx +
-  Author URI: http://gioxx.org +
-  License: CC BY-NC-SA 3.0 IT +
- */+
  
-/* +<WRAP center round alert 100%> 
-  Vedi dettaglio licenza di rilascio: http://creativecommons.org/licenses/by-nc-sa/3.0/it/deed.it +Attenzione, si tratta della versione nata nel 2014 e non più supportata
-  Basato su Codex Wordpress: http://codex.wordpress.org/Widgets_API +</WRAP>
-  Grazie a: https://gist.github.com/flowcomm/4174893 +
-  2013-2014 Gioxx (dev@gfsolone.com) +
-  IL CONTENUTO DI QUESTO FILE PHP VIENE FORNITO AS-IS +
-   +
- */ +
-  +
-class DsqRecents_Widget extends WP_Widget {+
  
- /** +A partire dalla versione 0.8 del widget, ho preferito spostare su GitHub il codice, lo puoi trovare all'indirizzo **https://gist.github.com/gioxx/219fa0546e252091503bec965a9f01f8**
- * Register widget with WordPress. +
- */ +
- public function __construct() { +
- parent::__construct( +
- 'dsqrecents_widget', // Base ID +
- 'Disqus Recents Widget', // Name +
- array( 'description' => __( 'Mostra gli ultimi commenti recuperati dal sistema Disqus (vedi documentazione)', 'text_domain' ), ) // Args +
- ); +
- }+
  
- /** +Puoi segnalarmi qualsiasi anomalia tramite l'area commenti del blogSe vuoi suggerire ulteriori modifiche personalizzazioni tramite CSS sei il benvenutopuoi contattarmi pure tramite mail (l'indirizzo lo trovi nella home di questo Wiki).
- * Front-end display of widget. +
-+
- * @see WP_Widget::widget() +
-+
- * @param array $args     Widget arguments. +
- * @param array $instance Saved values from database. +
- */ +
- public function widget( $args$instance ) { +
- extract( $args ); +
- $title = apply_filters( 'widget_title', $instance['title')+
- $dsqid = apply_filters( 'widget_dsqid', $instance['dsqid'] ); +
- $dsqitems = apply_filters( 'widget_dsqid', $instance['dsqitems'] );+
  
- echo $before_widget; +===== Disqus Recent Comments (JSON) =====
- if ( ! empty( $title ) ) +
- echo $before_title . $title . $after_title; +
- // echo __( 'Stringa debug, dovrebbe comparire nel widget', 'text_domain' ); +
- ?> +
- <!-- Blocco commenti Disqus --> +
- <div id="recentcomments" class="dsq-widget"> +
- <script type="text/javascript" src="http://<?php echo $dsqid; ?>.disqus.com/recent_comments_widget.js?num_items=<?php echo $dsqitems; ?>&hide_avatars=0&avatar_size=32&excerpt_length=200"></script> +
- </div><img src="http://public.gfsolone.com/wiki/lib/tpl/dokuwiki/images/logo.png" style="max-width: 16px; float: left;"><a href="http://public.gfsolone.com/wiki/doku.php?id=wordpress:disqusrecents" style="font-size: x-small; font-variant: small-caps;">Disqus Recent Comments</a> +
- <?php +
- echo $after_widget; +
- }+
  
- /** +<WRAP center round info 100%> 
-  * Sanitize widget form values as they are saved+Si tratta della versione 2020, quella attualmente supportata
-  * +</WRAP>
- * @see WP_Widget::update() +
-+
- * @param array $new_instance Values just sent to be saved. +
- * @param array $old_instance Previously saved values from database. +
-+
- * @return array Updated safe values to be saved. +
- */ +
- public function update( $new_instance, $old_instance ) { +
- $instance = array(); +
- $instance['title'] = strip_tags( $new_instance['title'] ); +
- $instance['dsqid'] = strip_tags( $new_instance['dsqid'] ); +
- $instance['dsqitems'] = strip_tags( $new_instance['dsqitems'] );+
  
- return $instance; +È la nuova versione del plugin (e quindi del widget) che permette di mostrare gli ultimi commenti del tuo blog prendendoli da Disqus e dalle sue nuove API. Faccio uso del JSON per evitare di dover salvare copia dei commenti nel database. Puoi leggere direttamente il JSON generato da Disqus (passando per i loro server) o creandoti la tua copia in locale (sul server che ospita il blog, per esempio). L'articolo sul blog è disponibile all'indirizzo **https://wp.me/pdQ5q-dC2**.\\ \\ 
- }+Trovi il codice sorgente del plugin su Gist, all'indirizzo **https://gist.github.com/gioxx/8764c0d66a7257866e51a03c833b4399**.
  
- /** +Per ogni domandadubbioproposta, //opera di bene od omissione di colpa// puoi contattarmi certamente tramite il blog (lascia un commento sotto all'articoloo su Gist stessoNon chiedere supporto via email, contattami invece via posta elettronica se hai trovato qualche problema o bug di sicurezza e vuoi aiutarmi correggerlo quanto prima.
- * Back-end widget form. +
-+
- * @see WP_Widget::form() +
-+
- * @param array $instance Previously saved values from database. +
- */ +
- public function form( $instance ) { +
- if ( isset( $instance[ 'title' ] ) ) { +
- $title = $instance[ 'title' ]; +
-+
- else { +
- $title = __( 'Recent Comments''text_domain' ); +
-+
- if ( isset( $instance[ 'dsqid' ] ) ) { +
- $dsqid = $instance[ 'dsqid' ]; +
-+
- else { +
- $dsqid = __( 'gioxx''text_domain' ); +
-+
- if ( isset( $instance[ 'dsqitems' ] ) ) { +
- $dsqitems = $instance[ 'dsqitems' ]; +
-+
- else { +
- $dsqitems = __( '5''text_domain' ); +
-+
- ?> +
- <p> +
- <!-- Titolo del widget --> +
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>  +
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /+
- <!-- ID DISQUS: ID.disqus.com --> +
- <label for="<?php echo $this->get_field_id( 'dsqid' ); ?>"><?php _e( 'Disqus ID (ID.disqus.com):' ); ?></label>  +
- <input class="widefat" id="<?php echo $this->get_field_id( 'dsqid' ); ?>" name="<?php echo $this->get_field_name( 'dsqid' ); ?>" type="text" value="<?php echo esc_attr( $dsqid ); ?>" /+
- <!-- Numero commenti da caricare --> +
- <label for="<?php echo $this->get_field_id( 'dsqitems' ); ?>"><?php _e( 'Items to load:' ); ?></label>  +
- <input class="widefat" id="<?php echo $this->get_field_id( 'dsqitems' ); ?>" name="<?php echo $this->get_field_name( 'dsqitems' ); ?>" type="text" value="<?php echo esc_attr( $dsqitems ); ?>" /> +
- <br /><br /> +
- <a href="http://public.gfsolone.com/wiki/doku.php?id=wordpress:disqusrecents">Help me!</a><br /> +
- <a href="http://gfsolone.com"><img src="http://gfsolone.com/images/gfsolone.footer.png"></a> +
- </p> +
- <?php  +
- }+
  
-} // class Widget terminata +**#StaySafe**
- +
-// Registrazione del widget +
-add_action( 'widgets_init', create_function( '', 'register_widget( "dsqrecents_widget" );' ) ); +
-?> +
-</file>+
wordpress/disqusrecents.1389262436.txt.gz · Last modified: 2014/01/09 11:13 by gfsadministrator