Plugin Directory

Changeset 780613


Ignore:
Timestamp:
09/30/2013 11:32:07 PM (12 years ago)
Author:
DeusMachineLLC
Message:

Added new options and date display bug fix

Location:
disqus-recent-comments-widget/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • disqus-recent-comments-widget/trunk/disqus_rcw.css

    r699186 r780613  
    1515.disqus_rcw_thread_title {
    1616    font-weight: bold;
     17    text-decoration: none;
     18}
     19
     20.disqus_rcw_thread_title:hover {
     21    text-decoration: underline;
    1722}
    1823
     
    2429    clear: both;
    2530}
     31
     32/* Props to BramVanroy for the below css */
     33.disqus_rcw_author_wrapper {
     34    margin-bottom: 7px;
     35}
     36
     37img.disqus_rcw_avatar_html5 {
     38    float: left;
     39    width: 35px;
     40    margin-right: 7px;
     41}
     42
     43div.disqus_rcw_author {
     44    float: left;
     45}
     46
     47.disqus_rcw_post_time_html5 {
     48    font-size: 75%;
     49}
     50
     51ul.disqus_rcw_comments_list li {
     52    list-style-type: none;
     53}
     54
     55.disqus_rcw_message {
     56    text-decoration: none;
     57}
     58
     59.disqus_rcw_message:hover {
     60    text-decoration: underline;
     61}
  • disqus-recent-comments-widget/trunk/disqus_recent_comments_widget.php

    r699186 r780613  
    44 * Description: Add a widget to display recent comments from disqus
    55 * Author: Deus Machine LLC
    6  * Version: 1.0
     6 * Version: 1.1
    77 * Author URI: http://deusmachine.com
    88 * Ported to WordPress by: Andrew Bartel, web developer for Deus Machine
     
    1212
    1313class disqus_recent_comments_widget extends WP_Widget {
    14    
     14
    1515    public function __construct() {
    16         $widget_ops = array( 'classname' => 'deus_disqus_recent_comments_widget', 'description' => __( 'Display Recent Posts From Disqus' , 'disqus_rcw' ) );
     16        $widget_ops = array( 'classname' => 'disqus_recent_comments_widget_wrapper', 'description' => __( 'Display Recent Posts From Disqus' , 'disqus_rcw' ) );
    1717        $control_ops = array( 'width' => 300, 'height' => 230 );
    1818        parent::__construct( 'disqus_recent_comments', __( 'Disqus Recent Comments' , 'disqus_rcw' ), $widget_ops, $control_ops);
    19     }
    20    
     19    }
     20
    2121    public function widget($args, $instance) {
    22        
     22
    2323        try {
    2424            $api_key = get_option( 'disqus_rcw_api_key' );
    25            
     25
    2626            $forum_name = get_option( 'disqus_rcw_forum_name' );
    2727            $comment_limit = $instance['comment_limit'];
    2828            if(!$comment_limit) $comment_limit = 5;
    29            
    30             //comma delimited list  of author names."John Doe,Aaron J. White,third" (Not Usernames)
     29
     30            //comma delimited list of author names."John Doe,Aaron J. White,third" (Not Usernames)
    3131            $filter_users = $instance['filter_users'];
    32            
     32
    3333            $date_format = get_option( 'disqus_rcw_date_format' );
    3434            if(!$date_format) $date_format = 'n/j/Y';
    35            
     35
     36            $title_wrapper = get_option( 'disqus_rcw_title_wrapper' );
     37            if(!$title_wrapper) $title_wrapper = '{title}';
     38
     39            $markup_style = get_option( 'disqus_rcw_which_markup' );
     40            if(!$markup_style) $markup_style = 'classic';
     41
    3642            $comment_length = $instance['comment_length'];
    3743            if(!$comment_length) $comment_length = 200;
    38            
     44
     45            $title = $instance['title'];
     46            if(!$title) $title = 'Recent Comments';
     47
    3948            $api_version = '3.0';
    40            
     49
    4150            $resource = 'posts/list';
    4251            $output_type = 'json';
    43            
     52
    4453            $style_params = array(
    4554                "comment_limit" => $comment_limit,
    4655                "date_format" => $date_format,
    4756                "comment_length" => $comment_length,
    48                 "filter_users" =>$filter_users
    49                 );
    50              
     57                "filter_users" =>$filter_users,
     58                'title'=>$title,
     59                'markup_style'=>$markup_style,
     60                'title_wrapper'=>$title_wrapper
     61            );
     62
    5163            $style_params = apply_filters( 'disqus_rcw_style_parameters' , $style_params );
    52            
    53             //put request parameters in an array
    54             $disqus_params = array(
    55                 "api_key" => $api_key,
    56                 "forum" => $forum_name,
    57                 "include" => "approved",
    58                 "limit" =>  $comment_limit * 3
    59                 );
    60            
     64
     65            //put request parameters in an array
     66            $disqus_params = array(
     67                "api_key" => $api_key,
     68                "forum" => $forum_name,
     69                "include" => "approved",
     70                "limit" =>  $comment_limit * 3
     71            );
     72
    6173            $disqus_params = apply_filters( 'disqus_rcw_disqus_parameters' , $disqus_params );
    62              
    63             //Create base request string
    64             $url = "http://disqus.com/api/" . $api_version . "/" . $resource . "." . $output_type;
    65             //add parameters to request string
    66             $request = $this->add_query_str( $url , $disqus_params );
    67            
    68             // get response with finished request url
    69             $response = $this->file_get_contents_curl( $request );
    70            
    71             //check repsonse
    72             if( $response != false ) {
    73                 // convert response to php object
    74                 $response = @json_decode($response, true);
    75                 // get comment items from response
    76                 $comments = $response["response"];
    77                 //check comment count
    78                 if(count($comments) > 0) {
    79                     if($comments != 'You have exceeded your hourly limit of requests') {
    80                         $this->echo_comments(
    81                                 $comments,
    82                                 $api_key,
    83                                 $style_params
    84                               );
     74
     75            //Create base request string
     76            $url = "http://disqus.com/api/" . $api_version . "/" . $resource . "." . $output_type;
     77            //add parameters to request string
     78            $request = $this->add_query_str( $url , $disqus_params );
     79
     80            // get response with finished request url
     81            $response = $this->file_get_contents_curl( $request );
     82
     83            //check repsonse
     84            if( $response != false ) {
     85                // convert response to php object
     86                $response = @json_decode($response, true);
     87                // get comment items from response
     88                $comments = $response["response"];
     89                //check comment count
     90                if(count($comments) > 0) {
     91                    if($comments != 'You have exceeded your hourly limit of requests') {
     92                        $this->echo_comments(
     93                            $comments,
     94                            $api_key,
     95                            $style_params,
     96                            $args
     97                        );
    8598                    }
    8699                    else
     
    88101                        $this->no_comments(true);
    89102                    }
    90                 }
    91                 else
    92                 {
    93                     $this->no_comments();
    94                 }
     103                }
     104                else
     105                {
     106                    $this->no_comments();
     107                }
    95108            }
    96             else
    97             {
    98               $this->no_comments();
    99             }
    100        
     109            else
     110            {
     111                $this->no_comments();
     112            }
     113
    101114        }
    102115        catch(Exception $e)
    103116        {
    104             $this->no_comments();
    105         }
    106          
    107     }
    108    
    109     protected function shorten_comment($comment, $comment_length) { 
     117            $this->no_comments();
     118        }
     119
     120    }
     121
     122    protected function shorten_comment($comment, $comment_length) {
    110123        if($comment_length != 0) {
    111             if(strlen($comment) > $comment_length) {
    112            
    113             $comment = preg_replace(
    114                           '/\s+?(\S+)?$/', '',
    115                           substr($comment, 0, $comment_length+1)
    116                         )."...";
     124            if(strlen($comment) > $comment_length) {
     125
     126                $comment = preg_replace(
     127                        '/\s+?(\S+)?$/', '',
     128                        substr($comment, 0, $comment_length+1)
     129                    )."...";
    117130            }
    118131        }
     
    121134
    122135    protected function get_thread_info( $thread_id, $api_key, $api_version = "3.0", $resource = "threads/details", $output_type = "json" ) {
    123         $dq_request ="http://disqus.com/api/".$api_version."/".$resource.".".$output_type;
    124         $dq_parameter = array(
    125                     "api_key" => $api_key,
    126                     "thread" => $thread_id
    127                   );
    128         $dq_request = $this->add_query_str($dq_request, $dq_parameter);
    129    
    130         // convert response to php object
    131         $dq_response= $this->file_get_contents_curl($dq_request);
    132         if($dq_response !== false) {
    133           $dq_response = @json_decode($dq_response, true);
    134           $dq_thread = $dq_response["response"];
    135           return $dq_thread;
    136         }
    137         else
    138         {
    139           $dq_thread = array(
    140                     title=> "Article not found",
    141                     link => "#"
    142                   );
    143           return $dq_thread;
    144         }
     136        $dq_request ="http://disqus.com/api/".$api_version."/".$resource.".".$output_type;
     137        $dq_parameter = array(
     138            "api_key" => $api_key,
     139            "thread" => $thread_id
     140        );
     141        $dq_request = $this->add_query_str($dq_request, $dq_parameter);
     142
     143        // convert response to php object
     144        $dq_response= $this->file_get_contents_curl($dq_request);
     145        if($dq_response !== false) {
     146            $dq_response = @json_decode($dq_response, true);
     147            $dq_thread = $dq_response["response"];
     148            return $dq_thread;
     149        }
     150        else
     151        {
     152            $dq_thread = array(
     153                title=> "Article not found",
     154                link => "#"
     155            );
     156            return $dq_thread;
     157        }
    145158    }
    146159
    147160    protected function add_query_str($base_url,$parameters) {
    148         $i=0;
    149         if (count($parameters) > 0) {
    150             $new_url = $base_url;
    151             foreach($parameters as $key => $value) {
    152                 if($i == 0) $new_url .="?".$key."=".$value;
    153                 else $new_url .="&".$key."=".$value;
    154                 $i +=1;
    155             }
    156          
    157             return $new_url;
    158         }
    159         else return $base_url;
     161        $i=0;
     162        if (count($parameters) > 0) {
     163            $new_url = $base_url;
     164            foreach($parameters as $key => $value) {
     165                if($i == 0) $new_url .="?".$key."=".$value;
     166                else $new_url .="&".$key."=".$value;
     167                $i +=1;
     168            }
     169
     170            return $new_url;
     171        }
     172        else return $base_url;
    160173    }
    161174
    162175    protected function no_comments( $comment = false ) {
    163         echo '<div id="disqus_rcw_comment_wrap"><span id="disqus_rcw_no_comments">No Recent Comments Found</span>';
    164         if( $comment === true ) echo '<!-- hourly limit reached -->';
    165         echo '</div>';
     176        echo '<div id="disqus_rcw_comment_wrap"><span id="disqus_rcw_no_comments">No Recent Comments Found</span>';
     177        if( $comment === true ) echo '<!-- hourly limit reached -->';
     178        echo '</div>';
    166179    }
    167180
    168181    protected function file_get_contents_curl( $url ) {
    169         //Source: http://www.codeproject.com/Questions/171271/file_get_contents-url-failed-to-open-stream
     182        //Source: http://www.codeproject.com/Questions/171271/file_get_contents-url-failed-to-open-stream
    170183        $ch = curl_init();
    171184        curl_setopt($ch, CURLOPT_HEADER, 0);
     
    177190        curl_close($ch);
    178191        return $data;
    179     }
    180    
     192    }
     193
    181194    public function disqus_rcw_trim(&$val) {
    182195        $val = trim($val);
    183196    }
    184197
    185     protected function echo_comments($comment, $api_key, $style_params) {
     198    protected function echo_comments($comment, $api_key, $style_params,$args=false) {
     199
     200        $title_wrapper_final = str_replace('{title}',$style_params['title'],$style_params['title_wrapper']);
     201
     202        extract($args);
    186203        //basic counter
    187         $comment_counter = 0;
    188         //filtered user array
    189         $filtered_users = explode(",",$style_params["filter_users"]);
    190         //create html string
    191         $recent_comments = '<div id="disqus_rcw_title"><h4 class="widgettitle">Recent comments</h4>';
    192        
     204        $comment_counter = 0;
     205        //filtered user array
     206        $filtered_users = explode(",",$style_params["filter_users"]);
     207        //create html string
     208        $recent_comments = $before_widget;
     209
     210        if($style_params['markup_style'] == 'classic') {
     211            $recent_comments .= '<div id="disqus_rcw_title">'.$before_title.$title_wrapper_final.$after_title.'</div>';
     212        } elseif($style_params['markup_style'] == 'html5') {
     213            $recent_comments .= '<aside id="disqus_rcw_title" class="widget">';
     214            $recent_comments .= $before_title.$title_wrapper_final.$after_title;
     215            $recent_comments .= '<ul class="disqus_rcw_comments_list">';
     216        }
     217
    193218        do_action( 'disqus_rcw_before_comments_loop' );
    194        
     219
    195220        if($comment != 'Invalid API key') {
    196        
    197             foreach($comment as $comment_obj) {       
    198                 // first skip to next if user is filtered
    199                 $author_name = $comment_obj["author"]["name"];
    200                 if( !empty( $filtered_users ) )
    201                 {
    202                     array_walk( $filtered_users, array( $this , 'disqus_rcw_trim' ) );
    203                     if( in_array( $author_name , $filtered_users ) ) continue;
    204                 }
    205                 //everything is fine, let's keep going
    206                 $comment_counter++;
    207                  //alternate class
    208                 if($comment_counter % 2 !== 0) $wrap_class ="disqus_rcw_comment_wrap";
    209                 else $wrap_class ="disqus_rcw_comment_wrap alter";
    210                
    211                 //get rest of comment data
    212                 $author_profile = $comment_obj["author"]["profileUrl"];
    213                 $author_avatar = $comment_obj["author"]["avatar"]["large"]["cache"];
    214                 $message = $comment_obj["raw_message"];
    215                 $comment_id = '#comment-'.$comment_obj["id"];
    216                 $post_time = date(
    217                       $style_params["date_format"] ,
    218                       strtotime($comment_obj["created_at"].'+0000')
    219                     );
    220                    
    221                 $thread_info = $this->get_thread_info(
    222                               $comment_obj["thread"],
    223                               $api_key
    224                             );
    225                 $thread_title = $thread_info["title"];
    226                 $thread_link = $thread_info["link"];
    227              
    228                 // shorten comment
    229                 $message = $this->shorten_comment(
    230                             $message,
    231                             $style_params["comment_length"]
    232                           );
    233                      
    234                
    235                 //create comment html
    236                 $comment_html = '<div class="disqus_rcw_single_comment_wrapper">
     221
     222            foreach($comment as $comment_obj) {
     223                // first skip to next if user is filtered
     224                $author_name = $comment_obj["author"]["name"];
     225                if( !empty( $filtered_users ) ) {
     226                    array_walk( $filtered_users, array( $this , 'disqus_rcw_trim' ) );
     227                    if( in_array( $author_name , $filtered_users ) ) continue;
     228                }
     229                //everything is fine, let's keep going
     230                $comment_counter++;
     231
     232                //get rest of comment data
     233                $author_profile = $comment_obj["author"]["profileUrl"];
     234                $author_avatar = $comment_obj["author"]["avatar"]["large"]["cache"];
     235                $message = $comment_obj["raw_message"];
     236                $comment_id = '#comment-'.$comment_obj["id"];
     237                $post_time = date(
     238                    $style_params["date_format"] ,
     239                    strtotime($comment_obj['createdAt'])
     240                );
     241
     242                $thread_info = $this->get_thread_info(
     243                    $comment_obj["thread"],
     244                    $api_key
     245                );
     246                $thread_title = $thread_info["title"];
     247                $thread_link = $thread_info["link"];
     248
     249                // shorten comment
     250                $message = $this->shorten_comment(
     251                    $message,
     252                    $style_params["comment_length"]
     253                );
     254
     255                if($style_params['markup_style'] == 'classic') {
     256                    //create comment html
     257                    $comment_html = '<div class="disqus_rcw_single_comment_wrapper">
    237258                        <div>
    238259                          <div>
     
    251272                        </div>
    252273                      </div>';
    253                 $recent_comments .= $comment_html;
    254                 //stop loop when we reach limit
    255                 if($comment_counter == $style_params["comment_limit"]) break;
    256             }
     274                } elseif($style_params['markup_style'] == 'html5') {
     275                    $comment_html = '
     276                    <li class="disqus_rcw_single">
     277                        <div class="disqus_rcw_author_wrapper">
     278                            <img class="disqus_rcw_avatar_html5" src="'.$author_avatar.'" alt="'.$author_name.'">
     279                            <a href="'.$author_profile.'">
     280                                <span class="disqus_rcw_author">'.$author_name.'</span>
     281                            </a>
     282                        </div>
     283                        <div class="disqus_rcw_clear"></div>
     284                        <div class="disqus_rcw_content_wrapper">
     285                            <a class="disqus_rcw_thread_title" href="'.$thread_link.'">'.$thread_title.'</a>
     286                            <br />
     287                            <a class="disqus_rcw_message" href="'.$thread_link.$comment_id.'">'.$message.'</a>
     288                        </div>
     289                        <time datetime="'.$post_time.'" class="disqus_rcw_post_time_html5">'.$post_time.'</time>
     290                    </li>';
     291                }
     292                $recent_comments .= $comment_html;
     293                //stop loop when we reach limit
     294                if($comment_counter == $style_params["comment_limit"]) break;
     295            }
     296
    257297        } else $recent_comments .= 'Invalid API Key';
    258298
    259299        do_action( 'disqus_rcw_after_comments_loop');
    260300
    261         $recent_comments .= '</div>';
    262        
     301        if($style_params['markup_style'] == 'html5') $recent_comments .= '</ul></aside>';
     302        $recent_comments .= $after_widget;
     303
    263304        $recent_comments = apply_filters( 'disqus_rcw_recent_comments' , $recent_comments );
    264        
     305
    265306        echo($recent_comments);
    266307    }
    267308
    268309    public function update($new_instance, $old_instance) {
    269        
    270         $instance = $old_instance;
    271        
     310
     311        $instance = $old_instance;
     312
    272313        $instance['comment_limit'] = strip_tags($new_instance['comment_limit']);
    273314        $instance['comment_length'] = strip_tags($new_instance['comment_length']);
    274315        $instance['filter_users'] = strip_tags($new_instance['filter_users']);
    275            
    276         return $instance;
    277        
    278     }
     316        $instance['title'] = strip_tags($new_instance['title']);
     317
     318        return $instance;
     319
     320    }
    279321
    280322    public function form($instance) {
    281        
     323
    282324        $comment_limit = isset($instance['comment_limit']) ? esc_attr($instance['comment_limit']) : 5;
    283325        $comment_length = isset($instance['comment_length']) ? esc_attr($instance['comment_length']) : 200;
    284326        $filter_users = isset($instance['filter_users']) ? esc_attr($instance['filter_users']) : '';
    285        
     327        $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
     328
    286329        ?>
    287        
     330
     331        <p><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 $title; ?>" /></p>
     332
    288333        <p><label for="<?php echo $this->get_field_id('comment_limit'); ?>"><?php _e( 'Comment Limit:' , 'disqus_rcw' ); ?></label>
    289         <input id="<?php echo $this->get_field_id('comment_limit'); ?>" name="<?php echo $this->get_field_name('comment_limit'); ?>" type="text" value="<?php echo $comment_limit; ?>" /></p>
    290        
     334            <input id="<?php echo $this->get_field_id('comment_limit'); ?>" name="<?php echo $this->get_field_name('comment_limit'); ?>" type="text" value="<?php echo $comment_limit; ?>" /></p>
     335
    291336        <p><label for="<?php echo $this->get_field_id('comment_length'); ?>"><?php _e( 'Comment Length:' , 'disqus_rcw' ); ?></label>
    292         <input id="<?php echo $this->get_field_id('comment_length'); ?>" name="<?php echo $this->get_field_name('comment_length'); ?>" type="text" size="4" value="<?php echo $comment_length; ?>" /></p>
    293        
     337            <input id="<?php echo $this->get_field_id('comment_length'); ?>" name="<?php echo $this->get_field_name('comment_length'); ?>" type="text" size="4" value="<?php echo $comment_length; ?>" /></p>
     338
    294339        <p><label for="<?php echo $this->get_field_id('filter_users'); ?>"><?php _e( 'Filter Users (comma separated):' , 'disqus_rcw' ); ?></label>
    295         <textarea id="<?php echo $this->get_field_id('filter_users'); ?>" cols="30" name="<?php echo $this->get_field_name('filter_users'); ?>" type="text" ><?php echo $filter_users; ?></textarea></p>
    296        
    297         <?php
    298        
    299     }
     340            <textarea id="<?php echo $this->get_field_id('filter_users'); ?>" cols="30" name="<?php echo $this->get_field_name('filter_users'); ?>" type="text" ><?php echo $filter_users; ?></textarea></p>
     341
     342    <?php
     343
     344    }
    300345
    301346}
     
    306351add_action( 'widgets_init' , 'disqus_rcw_init' );
    307352
    308 function disqus_rcw_settings_link($links) { 
    309   $settings_link = '<a href="options-general.php?page=disqus_rcw.php">'.__('Settings').'</a>';
    310   array_unshift($links, $settings_link);
    311   return $links;
     353function disqus_rcw_settings_link($links) {
     354    $settings_link = '<a href="options-general.php?page=disqus_rcw.php">'.__('Settings').'</a>';
     355    array_unshift($links, $settings_link);
     356    return $links;
    312357}
    313 $disqus_rcw_basename = plugin_basename(__FILE__); 
     358$disqus_rcw_basename = plugin_basename(__FILE__);
    314359add_filter("plugin_action_links_$disqus_rcw_basename", 'disqus_rcw_settings_link' );
    315360
     
    319364
    320365class disqus_rcw_settings {
    321    
     366
    322367    public function __construct() {
    323368        add_action( 'admin_init' , array( $this , 'settings_api_init' ) );
    324369        add_action( 'admin_menu' , array( $this , 'disqus_rcw_add_settings_menu_page' ) );
    325370        add_action( 'admin_init' , array( $this , 'install_redirect' ) );
    326         add_action( 'wp_enqueue_scripts' , array( $this , 'enqueue_styles' ) );
     371
     372        if( get_option('disqus_rcw_dont_use_css') != 1) {
     373            add_action( 'wp_enqueue_scripts' , array( $this , 'enqueue_styles' ) );
     374        }
     375
    327376        if(get_option('disqus_rcw_date_format')) $this->date_format = get_option('disqus_rcw_date_format');
    328377        else $this->date_format = 'n/j/Y';
    329     }
    330    
     378
     379        if(get_option('disqus_rcw_title_wrapper')) $this->title_wrapper = get_option('disqus_rcw_title_wrapper');
     380        else $this->title_wrapper = '{title}';
     381    }
     382
    331383    public function enqueue_styles() {
    332384        wp_enqueue_style( 'disqus_rcw.css' , plugins_url().'/'.basename(dirname(__FILE__)).'/disqus_rcw.css' );
    333385    }
    334    
     386
    335387    public function install() {
    336        
     388
    337389        if( !in_array( 'disqus-comment-system/disqus.php' , (array) get_option( 'active_plugins', array() ) ) )
    338390            wp_die('<p>This plugin requires the <a href="http://wordpress.org/extend/plugins/disqus-comment-system/">Disqus comment system plugin</a> to be installed and activated on your WordPress site</p><p><a href="plugins.php">Return to plugins page</a></p>');
    339         else
     391        else {
    340392            add_option( 'disqus_rcw_settings_do_activation_redirect' , true );
    341        
    342     }
    343    
     393        }
     394
     395    }
     396
    344397    public function install_redirect() {
    345        
     398
    346399        if (get_option( 'disqus_rcw_settings_do_activation_redirect' , false ) ) {
    347             delete_option( 'disqus_rcw_settings_do_activation_redirect' );
    348             wp_redirect( 'options-general.php?page=disqus_rcw' );
    349         }
    350     }
    351    
     400            delete_option( 'disqus_rcw_settings_do_activation_redirect' );
     401            wp_redirect( 'options-general.php?page=disqus_rcw' );
     402        }
     403    }
     404
     405    public function validate_checkbox($val) {
     406        if($val == 1) return 1;
     407        else return 0;
     408    }
     409
    352410    public function settings_api_init() {
    353        
     411
     412        add_settings_section( 'disqus_rcw_settings_section' ,'', array( $this , 'disqus_rcw_section_callback' ), 'disqus_rcw' );
     413
    354414        register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_forum_name' );
    355415        register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_api_key' );
    356416        register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_date_format' );
    357        
    358         add_settings_section( 'disqus_rcw_settings_section' ,'', array( $this , 'disqus_rcw_section_callback' ), 'disqus_rcw' );
    359        
     417        register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_dont_use_css', array( $this, 'validate_checkbox') );
     418        register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_which_markup' );
     419        register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_title_wrapper' );
     420
    360421        add_settings_field( 'disqus_rcw_forum_name' , __( 'Short Name' , 'disqus_rcw' ), array( $this , 'forum_name_callback' ), 'disqus_rcw' , 'disqus_rcw_settings_section' );
    361422        add_settings_field( 'disqus_rcw_api_key' , __( 'API Key' , 'disqus_rcw' ) , array( $this , 'api_key_callback' ), 'disqus_rcw' , 'disqus_rcw_settings_section' );
    362423        add_settings_field( 'disqus_rcw_date_format' , __( 'Date Format' , 'disqus_rcw' ) , array( $this , 'date_format_callback' ), 'disqus_rcw' , 'disqus_rcw_settings_section' );
    363     }
    364    
     424        add_settings_field( 'disqus_rcw_dont_use_css' , __( "Disable The Plugin's CSS" , 'disqus_rcw' ) , array( $this, 'custom_css_callback' ), 'disqus_rcw' , 'disqus_rcw_settings_section');
     425        add_settings_field( 'disqus_rcw_title_wrapper' , __( 'Widget Title Markup' ), array( $this, 'widget_title_wrapper_callback' ), 'disqus_rcw', 'disqus_rcw_settings_section');
     426        add_settings_field( 'disqus_rcw_which_markup' , __( 'General Markup Style', 'disqus_rcw' ), array( $this, 'markup_style_callback' ), 'disqus_rcw', 'disqus_rcw_settings_section');
     427    }
     428
    365429    public function disqus_rcw_display_settings() {
    366430        ?>
     
    373437            </form>
    374438        </div>
    375         <?php
    376     }
    377    
     439    <?php
     440    }
     441
     442    public function widget_title_wrapper_callback() {
     443        echo '<input type="text" name="disqus_rcw_title_wrapper" size="45" value="'. esc_attr( $this->title_wrapper ) .'"><br />';
     444        echo _('Ex'). ': <code>&lsaquo;span class="my_custom_class"&rsaquo;{title}&lsaquo;/span&rsaquo;</code>' . '<em>' . __( 'You must have {title} in this field or the title will not display!', 'disqus_rcw' ) . '</em>';
     445        echo '<br />';
     446        echo '*' . __( 'You can set the titles individually when you add this widget to a sidebar', 'disqus_rcw' );
     447    }
     448
     449    public function markup_style_callback() {
     450        echo '<select name="disqus_rcw_which_markup">';
     451        echo '<option ' . selected( get_option( 'disqus_rcw_which_markup' ), 'classic' ) . 'value="classic">Classic 1.0</option>';
     452        echo '<option ' . selected( get_option( 'disqus_rcw_which_markup' ), 'html5' ) . 'value="html5">HTML5</option>';
     453        echo '</select>';
     454        echo '<br />';
     455        echo '<div id="disqus_rcw_markup_example"></div>';
     456    }
     457
     458    public function custom_css_callback() {
     459        echo '<input '.checked(get_option('disqus_rcw_dont_use_css'),1,false).' type="checkbox" name="disqus_rcw_dont_use_css" value="1" >';
     460        echo '<em> ' . __("Check this option to disable calling the plugin's stylesheet.  Your theme will need to have styles set if you enable this option.") . '</em>';
     461    }
     462
    378463    public function disqus_rcw_section_callback() {
    379464        _e( 'Enter your site\'s short name<a style="text-decoration: none" href="http://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname"><sup>What is this?</sup></a>, your api key<a href="http://deusmachine.com/disqus-instructions.php" style="text-decoration: none;"><sup>Help</sup></a> and your preferred <a href="http://php.net/date">date format</a> here.' , 'disqus_rcw' );
    380465    }
    381    
     466
    382467    public function date_format_callback() {
    383468        echo '<input type="text" name="disqus_rcw_date_format" size="10" value="'. esc_attr( $this->date_format ).'">';
     
    387472        echo '<input type="text" name="disqus_rcw_api_key" size="90" value="'. esc_attr( get_option( 'disqus_rcw_api_key' ) ).'">';
    388473    }
    389    
     474
    390475    public function forum_name_callback() {
    391476        echo '<input type="text" name="disqus_rcw_forum_name" value="'. esc_attr( get_option( 'disqus_rcw_forum_name' ) ).'">';
    392477    }
    393    
     478
    394479    public function disqus_rcw_add_settings_menu_page() {
    395480        add_options_page( 'Disqus Comments','Disqus Comments','update_plugins','disqus_rcw',array($this,'disqus_rcw_display_settings' ) );
    396481    }
    397    
     482
    398483}
    399484
  • disqus-recent-comments-widget/trunk/readme.txt

    r699325 r780613  
    33Tags: disqus, comments, widget, sidebar
    44Requires at least: 3.4.1
    5 Tested up to: 3.5.1
     5Tested up to: 3.6.1
    66Stable tag: trunk
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    9 
    10 == Description ==
    11 
    12 Disqus has dropped support for their recent comments widget for WordPress.  This plugin will create a configurable widget that will display the latest Disqus comments from your site in any widgetized area.
     9Creates a configurable widget that will display the latest Disqus comments from your site.
    1310
    1411== Installation ==
     
    2118== Frequently Asked Questions ==
    2219
    23 = The widget is saying, "No Recent Comments Found," but there are comments, why aren't they appearing? =
     20= Why did the comments stop appearing? =
    2421
    25 Disqus caps the number of requests you can make to their api at 1000 an hour for free accounts.  Comments will start appearing again next hour.
     22Disqus caps the number of requests you can make to their api at 1000 an hour for free accounts. Comments will start appearing again next hour.
    2623
    27 = I blocked a user, but their comments are still appearing, what gives? =
     24= I blocked a user, but their comments are still appearing =
    2825
    29 Make sure you entered the exact author name.  The plugin does its best to account for spaces, capitalization, etc but it can't read your mind. If all else fails, copy/paste their name into the filtered users field.
     26Make sure you entered the exact author name. The plugin does its best to account for spaces, capitalization, etc but it can't read your mind. If all else fails, copy/paste their name into the filtered users field.
    3027
    3128= I can't figure out this API key stuff, help? =
     
    3330Please see this guide: http://deusmachine.com/disqus-instructions.php
    3431
     32= I found a bug or I have an idea for a new feature =
     33
     34Fork the project and send us a pull request! We'll be happy to give you a shout out in the release notes. https://github.com/andrewbartel/Disqus_Recent_Comments
     35If you're not a developer, you can always drop us a line in the support forums and we'll do our best to integrate your requests into the next version or tackle the bug you found.
     36
     37= Where can I find the original version of the script that this plugin was based on? =
     38
     39You can view the original blog post on Aaron's site: http://www.aaronjwhite.org/index.php/14-web-development/php/11-updated-recent-comments-widget-in-php-for-disquss-api
     40Or, you can check out the script on github: https://github.com/AaronJWhite/Disqus_Recent_Comments
     41
     42= Is the plugin available in languages other than English? =
     43
     44Not currently, but if you'd like to put together a translation for us, please do!  We'll happily give you credit in the release notes.
     45
    3546== Screenshots ==
    3647
    37481. The Settings Page
    38 
    39492. Adding the widget to a sidebar
    4050
    4151== Changelog ==
     52
     53= 1.1 =
     54
     55* Added support for register_sidebars()
     56* Fixed a bug that caused the posted date to display as today's date
     57* Added the option to disable the plugin's css file
     58* Added options to control what markup is generated (props to BramVanroy for the suggestion and code)
     59* Added the ability to change the widget title
     60* Added the option to change the markup surrounding the title
     61
    4262= 1.0 =
     63
    4364* Initial build
Note: See TracChangeset for help on using the changeset viewer.