Changeset 780613
- Timestamp:
- 09/30/2013 11:32:07 PM (12 years ago)
- Location:
- disqus-recent-comments-widget/trunk
- Files:
-
- 3 edited
-
disqus_rcw.css (modified) (2 diffs)
-
disqus_recent_comments_widget.php (modified) (10 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
disqus-recent-comments-widget/trunk/disqus_rcw.css
r699186 r780613 15 15 .disqus_rcw_thread_title { 16 16 font-weight: bold; 17 text-decoration: none; 18 } 19 20 .disqus_rcw_thread_title:hover { 21 text-decoration: underline; 17 22 } 18 23 … … 24 29 clear: both; 25 30 } 31 32 /* Props to BramVanroy for the below css */ 33 .disqus_rcw_author_wrapper { 34 margin-bottom: 7px; 35 } 36 37 img.disqus_rcw_avatar_html5 { 38 float: left; 39 width: 35px; 40 margin-right: 7px; 41 } 42 43 div.disqus_rcw_author { 44 float: left; 45 } 46 47 .disqus_rcw_post_time_html5 { 48 font-size: 75%; 49 } 50 51 ul.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 4 4 * Description: Add a widget to display recent comments from disqus 5 5 * Author: Deus Machine LLC 6 * Version: 1. 06 * Version: 1.1 7 7 * Author URI: http://deusmachine.com 8 8 * Ported to WordPress by: Andrew Bartel, web developer for Deus Machine … … 12 12 13 13 class disqus_recent_comments_widget extends WP_Widget { 14 14 15 15 public function __construct() { 16 $widget_ops = array( 'classname' => 'd eus_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' ) ); 17 17 $control_ops = array( 'width' => 300, 'height' => 230 ); 18 18 parent::__construct( 'disqus_recent_comments', __( 'Disqus Recent Comments' , 'disqus_rcw' ), $widget_ops, $control_ops); 19 }20 19 } 20 21 21 public function widget($args, $instance) { 22 22 23 23 try { 24 24 $api_key = get_option( 'disqus_rcw_api_key' ); 25 25 26 26 $forum_name = get_option( 'disqus_rcw_forum_name' ); 27 27 $comment_limit = $instance['comment_limit']; 28 28 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) 31 31 $filter_users = $instance['filter_users']; 32 32 33 33 $date_format = get_option( 'disqus_rcw_date_format' ); 34 34 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 36 42 $comment_length = $instance['comment_length']; 37 43 if(!$comment_length) $comment_length = 200; 38 44 45 $title = $instance['title']; 46 if(!$title) $title = 'Recent Comments'; 47 39 48 $api_version = '3.0'; 40 49 41 50 $resource = 'posts/list'; 42 51 $output_type = 'json'; 43 52 44 53 $style_params = array( 45 54 "comment_limit" => $comment_limit, 46 55 "date_format" => $date_format, 47 56 "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 51 63 $style_params = apply_filters( 'disqus_rcw_style_parameters' , $style_params ); 52 53 //put request parameters in an array54 $disqus_params = array(55 "api_key" => $api_key,56 "forum" => $forum_name,57 "include" => "approved",58 "limit" => $comment_limit * 359 );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 61 73 $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 ); 85 98 } 86 99 else … … 88 101 $this->no_comments(true); 89 102 } 90 }91 else92 {93 $this->no_comments();94 }103 } 104 else 105 { 106 $this->no_comments(); 107 } 95 108 } 96 else97 {98 $this->no_comments();99 }100 109 else 110 { 111 $this->no_comments(); 112 } 113 101 114 } 102 115 catch(Exception $e) 103 116 { 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) { 110 123 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 )."..."; 117 130 } 118 131 } … … 121 134 122 135 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_id127 );128 $dq_request = $this->add_query_str($dq_request, $dq_parameter);129 130 // convert response to php object131 $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 else138 {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 } 145 158 } 146 159 147 160 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; 160 173 } 161 174 162 175 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>'; 166 179 } 167 180 168 181 protected function file_get_contents_curl( $url ) { 169 //Source: http://www.codeproject.com/Questions/171271/file_get_contents-url-failed-to-open-stream182 //Source: http://www.codeproject.com/Questions/171271/file_get_contents-url-failed-to-open-stream 170 183 $ch = curl_init(); 171 184 curl_setopt($ch, CURLOPT_HEADER, 0); … … 177 190 curl_close($ch); 178 191 return $data; 179 }180 192 } 193 181 194 public function disqus_rcw_trim(&$val) { 182 195 $val = trim($val); 183 196 } 184 197 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); 186 203 //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 193 218 do_action( 'disqus_rcw_before_comments_loop' ); 194 219 195 220 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"> 237 258 <div> 238 259 <div> … … 251 272 </div> 252 273 </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 257 297 } else $recent_comments .= 'Invalid API Key'; 258 298 259 299 do_action( 'disqus_rcw_after_comments_loop'); 260 300 261 $recent_comments .= '</div>'; 262 301 if($style_params['markup_style'] == 'html5') $recent_comments .= '</ul></aside>'; 302 $recent_comments .= $after_widget; 303 263 304 $recent_comments = apply_filters( 'disqus_rcw_recent_comments' , $recent_comments ); 264 305 265 306 echo($recent_comments); 266 307 } 267 308 268 309 public function update($new_instance, $old_instance) { 269 270 $instance = $old_instance;271 310 311 $instance = $old_instance; 312 272 313 $instance['comment_limit'] = strip_tags($new_instance['comment_limit']); 273 314 $instance['comment_length'] = strip_tags($new_instance['comment_length']); 274 315 $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 } 279 321 280 322 public function form($instance) { 281 323 282 324 $comment_limit = isset($instance['comment_limit']) ? esc_attr($instance['comment_limit']) : 5; 283 325 $comment_length = isset($instance['comment_length']) ? esc_attr($instance['comment_length']) : 200; 284 326 $filter_users = isset($instance['filter_users']) ? esc_attr($instance['filter_users']) : ''; 285 327 $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; 328 286 329 ?> 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 288 333 <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 291 336 <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 294 339 <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 <?php298 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 } 300 345 301 346 } … … 306 351 add_action( 'widgets_init' , 'disqus_rcw_init' ); 307 352 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; 353 function 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; 312 357 } 313 $disqus_rcw_basename = plugin_basename(__FILE__); 358 $disqus_rcw_basename = plugin_basename(__FILE__); 314 359 add_filter("plugin_action_links_$disqus_rcw_basename", 'disqus_rcw_settings_link' ); 315 360 … … 319 364 320 365 class disqus_rcw_settings { 321 366 322 367 public function __construct() { 323 368 add_action( 'admin_init' , array( $this , 'settings_api_init' ) ); 324 369 add_action( 'admin_menu' , array( $this , 'disqus_rcw_add_settings_menu_page' ) ); 325 370 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 327 376 if(get_option('disqus_rcw_date_format')) $this->date_format = get_option('disqus_rcw_date_format'); 328 377 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 331 383 public function enqueue_styles() { 332 384 wp_enqueue_style( 'disqus_rcw.css' , plugins_url().'/'.basename(dirname(__FILE__)).'/disqus_rcw.css' ); 333 385 } 334 386 335 387 public function install() { 336 388 337 389 if( !in_array( 'disqus-comment-system/disqus.php' , (array) get_option( 'active_plugins', array() ) ) ) 338 390 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 { 340 392 add_option( 'disqus_rcw_settings_do_activation_redirect' , true ); 341 342 } 343 393 } 394 395 } 396 344 397 public function install_redirect() { 345 398 346 399 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 352 410 public function settings_api_init() { 353 411 412 add_settings_section( 'disqus_rcw_settings_section' ,'', array( $this , 'disqus_rcw_section_callback' ), 'disqus_rcw' ); 413 354 414 register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_forum_name' ); 355 415 register_setting( 'disqus_rcw_settings_group' , 'disqus_rcw_api_key' ); 356 416 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 360 421 add_settings_field( 'disqus_rcw_forum_name' , __( 'Short Name' , 'disqus_rcw' ), array( $this , 'forum_name_callback' ), 'disqus_rcw' , 'disqus_rcw_settings_section' ); 361 422 add_settings_field( 'disqus_rcw_api_key' , __( 'API Key' , 'disqus_rcw' ) , array( $this , 'api_key_callback' ), 'disqus_rcw' , 'disqus_rcw_settings_section' ); 362 423 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 365 429 public function disqus_rcw_display_settings() { 366 430 ?> … … 373 437 </form> 374 438 </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>‹span class="my_custom_class"›{title}‹/span›</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 378 463 public function disqus_rcw_section_callback() { 379 464 _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' ); 380 465 } 381 466 382 467 public function date_format_callback() { 383 468 echo '<input type="text" name="disqus_rcw_date_format" size="10" value="'. esc_attr( $this->date_format ).'">'; … … 387 472 echo '<input type="text" name="disqus_rcw_api_key" size="90" value="'. esc_attr( get_option( 'disqus_rcw_api_key' ) ).'">'; 388 473 } 389 474 390 475 public function forum_name_callback() { 391 476 echo '<input type="text" name="disqus_rcw_forum_name" value="'. esc_attr( get_option( 'disqus_rcw_forum_name' ) ).'">'; 392 477 } 393 478 394 479 public function disqus_rcw_add_settings_menu_page() { 395 480 add_options_page( 'Disqus Comments','Disqus Comments','update_plugins','disqus_rcw',array($this,'disqus_rcw_display_settings' ) ); 396 481 } 397 482 398 483 } 399 484 -
disqus-recent-comments-widget/trunk/readme.txt
r699325 r780613 3 3 Tags: disqus, comments, widget, sidebar 4 4 Requires at least: 3.4.1 5 Tested up to: 3. 5.15 Tested up to: 3.6.1 6 6 Stable tag: trunk 7 7 License: GPLv2 or later 8 8 License 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. 9 Creates a configurable widget that will display the latest Disqus comments from your site. 13 10 14 11 == Installation == … … 21 18 == Frequently Asked Questions == 22 19 23 = The widget is saying, "No Recent Comments Found," but there are comments, why aren't theyappearing? =20 = Why did the comments stop appearing? = 24 21 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.22 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. 26 23 27 = I blocked a user, but their comments are still appearing , what gives?=24 = I blocked a user, but their comments are still appearing = 28 25 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.26 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. 30 27 31 28 = I can't figure out this API key stuff, help? = … … 33 30 Please see this guide: http://deusmachine.com/disqus-instructions.php 34 31 32 = I found a bug or I have an idea for a new feature = 33 34 Fork 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 35 If 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 39 You 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 40 Or, 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 44 Not 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 35 46 == Screenshots == 36 47 37 48 1. The Settings Page 38 39 49 2. Adding the widget to a sidebar 40 50 41 51 == 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 42 62 = 1.0 = 63 43 64 * Initial build
Note: See TracChangeset
for help on using the changeset viewer.