Changeset 3290923
- Timestamp:
- 05/10/2025 02:29:58 PM (8 months ago)
- Location:
- quote-comments/trunk
- Files:
-
- 2 edited
-
quote-comments.php (modified) (22 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
quote-comments/trunk/quote-comments.php
r2632905 r3290923 4 4 Plugin URI: https://github.com/metodiew/Quote-Comments 5 5 Description: Creates a little quote icon in comment boxes which, when clicked, copies that comment to the comment box wrapped in blockquotes. 6 Version: 2.2.1 6 Version: 3.0.0 7 Requires at least: 4.0 8 Requires PHP: 7.2 7 9 Author: Stanko Metodiev 8 10 Author URI: https://metodiew.com 11 License: GPLv2 or later 12 Text Domain: quote-comments 9 13 */ 10 14 11 15 /** 12 * @TODO 13 * 14 * This is the real TO DO list: 15 * - fix all notifications, notes, issues and errors 16 * - improve the code base 16 * @TODO: apply some coding styling updates 17 17 */ 18 18 19 20 /** 21 * That's the previous @TODO: 22 * 23 - phase out "get_comment_time" option 24 - clean up remaining functions for reply 25 - improve reply layout 26 - recode JS 27 */ 28 29 load_plugin_textdomain('quote-comments', NULL, dirname(plugin_basename(__FILE__)) . "/languages"); 30 31 // Add a define variable, we'll need it later :) 19 /** 20 * Load plugin textdomain. 21 */ 22 function quote_comments_load_textdomain() { 23 load_plugin_textdomain( 'quote-comments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 24 } 25 add_action( 'init', 'quote_comments_load_textdomain' ); 26 27 /** 28 * Define variable for the plugin version. 29 */ 32 30 if ( ! defined( 'QUOTE_COMMENTS_VERSION' ) ) { 33 define( 'QUOTE_COMMENTS_VERSION', '2.2.1' ); 34 } 35 36 function quote_scripts () { 37 38 if ( function_exists('plugin_url') ) 39 $plugin_url = plugin_url(); 40 else 41 $plugin_url = get_option('siteurl') . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__)); 42 43 wp_register_script('quote_comments_js', ($plugin_url . '/quote-comments.js'), false, '1.0'); 44 wp_enqueue_script('quote_comments_js'); 45 46 } 47 if (!is_admin()) { 48 add_action('init', 'quote_scripts'); 49 } 50 51 52 53 54 55 56 function add_quote_button($output) { 57 31 define( 'QUOTE_COMMENTS_VERSION', '3.0.0' ); 32 } 33 34 /** 35 * Enqueue Plugin Assets 36 */ 37 function quote_comments_assets () { 38 wp_enqueue_script( 'quote-comments', plugins_url( 'quote-comments.js' , __FILE__ ), array(), QUOTE_COMMENTS_VERSION, array( 'strategy' => 'defer', 'in_footer' => true ) ); 39 40 } 41 add_action( 'wp_enqueue_scripts', 'quote_comments_assets' ); 42 43 44 function add_quote_button( $output ) { 58 45 59 46 global $user_ID; 60 if ( get_option('comment_registration') && !$user_ID) {47 if ( get_option( 'comment_registration' ) && ! $user_ID ) { 61 48 62 49 return $output; … … 79 66 $button .= '</a>'; 80 67 //} 81 68 82 69 $button .= ' '; 83 70 $button .= '<span id="name'.get_comment_ID().'" style="display: none;">'.get_comment_author().'</span>'; … … 94 81 $button .= 'try { addComment.moveForm(\'div-comment-'.get_comment_ID().'\', \''.get_comment_ID().'\', \'respond\', \''.get_the_ID().'\'); } catch(e) {}; '; 95 82 $button .= 'return false;">'; 96 $button .= "" . get_option('quote_comments_title') . "";83 $button .= "" . esc_attr( get_option( 'quote_comments_title' ) ) . ""; 97 84 98 85 … … 105 92 $button .= 'try { addComment.moveForm(\'div-comment-'.get_comment_ID().'\', \''.get_comment_ID().'\', \'respond\', \''.get_the_ID().'\'); } catch(e) {}; '; 106 93 $button .= 'return false;">'; 107 $button .= "" . get_option('quote_comments_replytitle') . "";94 $button .= "" . esc_attr( get_option( 'quote_comments_replytitle' ) ) . ""; 108 95 } 109 96 … … 151 138 // quote link 152 139 $button = ""; 153 $button .= '</a> ';140 // $button .= '</a> '; 154 141 $button .= '<span id="name'.get_comment_ID().'" style="display: none;">'.get_comment_author().'</span>'; 155 142 $button .= '<a class="comment_quote_link" '; … … 165 152 $button .= 'try { addComment.moveForm(\'div-comment-'.get_comment_ID().'\', \''.get_comment_ID().'\', \'respond\', \''.get_the_ID().'\'); } catch(e) {}; '; 166 153 $button .= 'return false;">'; 167 $button .= "" . get_option('quote_comments_title') . "";154 $button .= "" . esc_attr( get_option('quote_comments_title') ) . ""; 168 155 169 156 … … 176 163 $button .= 'try { addComment.moveForm(\'div-comment-'.get_comment_ID().'\', \''.get_comment_ID().'\', \'respond\', \''.get_the_ID().'\'); } catch(e) {}; '; 177 164 $button .= 'return false;">'; 178 $button .= "" . get_option('quote_comments_replytitle') . "";165 $button .= "" . esc_attr( get_option('quote_comments_replytitle') ) . ""; 179 166 } 180 167 … … 184 171 } 185 172 186 187 188 173 if (comments_open() && have_comments() && get_comment_type() != "pingback" && get_comment_type() != "trackback") { 189 174 return($output . $button); … … 210 195 } else { 211 196 if (!is_admin()) { 212 //add_action('get_comment_text', 'add_quote_button');213 197 add_filter('get_comment_text', 'add_quote_button'); 214 198 } … … 272 256 273 257 /** 274 * Options Page 258 * Options Page values 275 259 */ 276 277 278 // Options 279 $qc_themename = "Quote Comments"; 280 $qc_shortname = "quote_comments"; 281 282 283 $qc_options = array ( 284 285 array( "name" => __('Quote-link title?','quote-comments'), 286 //"desc" => __('Title of comment link.','quote-comments'), 287 "id" => $qc_shortname."_title", 288 "std" => "(Quote)", 289 "type" => "text"), 290 291 array( "name" => __('Show author in quote?','quote-comments'), 292 "desc" => __('Show authors','quote-comments'), 293 "id" => $qc_shortname."_author", 294 "std" => true, 295 "type" => "checkbox"), 296 297 array( "name" => __('Show reply link?','quote-comments'), 298 "desc" => __('Show reply link','quote-comments'), 299 "id" => $qc_shortname."_replylink", 300 "std" => false, 301 "type" => "checkbox"), 302 303 array( "name" => __('Reply-link title?','quote-comments'), 304 //"desc" => __('Title of comment link.','quote-comments'), 305 "id" => $qc_shortname."_replytitle", 306 "std" => "(Reply)", 307 "type" => "text"), 308 309 array( "name" => __('Insert Quote link using which hook?','quote-comments'), 310 "desc" => __('Which plugin hook should be used to insert the quote link?','quote-comments'), 311 "id" => $qc_shortname."_pluginhook", 312 "std" => 'get_comment_text', 313 "type" => "radio", 314 "options" => array( 'get_comment_time' => "<code>get_comment_time</code> (places the link close to the authors name)", 315 'get_comment_text' => "<code>get_comment_text</code> (places the link after the comment body text -- most compatible)") ), 316 317 318 ); 260 function quote_comments_options_values() { 261 $qc_options = array ( 262 263 array( "name" => __('Quote-link title?','quote-comments'), 264 "desc" => __('Title of comment link.','quote-comments'), 265 "id" => "quote_comments_title", 266 "std" => "(Quote)", 267 "type" => "text"), 268 269 array( "name" => __('Show author in quote?','quote-comments'), 270 "desc" => __('Show authors','quote-comments'), 271 "id" => "quote_comments_author", 272 "std" => true, 273 "type" => "checkbox"), 274 275 array( "name" => __('Show reply link?','quote-comments'), 276 "desc" => __('Show reply link','quote-comments'), 277 "id" => "quote_comments_replylink", 278 "std" => false, 279 "type" => "checkbox"), 280 281 array( "name" => __('Reply-link title?','quote-comments'), 282 //"desc" => __('Title of comment link.','quote-comments'), 283 "id" => "quote_comments_replytitle", 284 "std" => "(Reply)", 285 "type" => "text"), 286 287 array( "name" => __('Insert Quote link using which hook?','quote-comments'), 288 "desc" => __('Which plugin hook should be used to insert the quote link?','quote-comments'), 289 "id" => "quote_comments_pluginhook", 290 "std" => 'get_comment_text', 291 "type" => "radio", 292 "options" => array( 'get_comment_time' => "<code>get_comment_time</code> (places the link close to the authors name)", 293 'get_comment_text' => "<code>get_comment_text</code> (places the link after the comment body text -- most compatible)") ), 294 ); 295 296 return $qc_options; 297 } 319 298 320 299 … … 324 303 function quotecomments_add_admin() { 325 304 326 global $qc_themename, $qc_shortname, $qc_options, $blog_id;305 $qc_options = quote_comments_options_values(); 327 306 328 307 if ( ! empty( $_GET['page'] ) && $_GET['page'] == basename(__FILE__) ) { … … 332 311 // update options 333 312 foreach ($qc_options as $value) { 334 update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } 335 336 foreach ($qc_options as $value) { 337 if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } 313 if( isset( $_REQUEST[ $value['id'] ] ) ) { 314 update_option( esc_attr( $value['id'] ), sanitize_text_field( $_REQUEST[ $value['id'] ] ) ); 315 316 } else { 317 delete_option( esc_attr( $value['id'] ) ); 318 } 319 } 338 320 339 321 header("Location: options-general.php?page=quote-comments.php&saved=true"); … … 344 326 345 327 // add options page 346 add_options_page( $qc_themename, $qc_themename, 'manage_options', basename(__FILE__), 'quotecomments_admin');328 add_options_page( 'Quote Comments', 'Quote Comments', 'manage_options', basename(__FILE__), 'quotecomments_admin'); 347 329 //add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function); 348 330 … … 351 333 function quotecomments_admin() { 352 334 353 global $qc_themename, $qc_shortname, $qc_options;335 $qc_options = quote_comments_options_values(); 354 336 355 337 if (! empty( $_REQUEST['saved'] ) ) { 356 echo '<div id="message" class="updated fade"><p><strong> '.$qc_themename.''.__('settings saved.','quote-comments').'</strong></p></div>';338 echo '<div id="message" class="updated fade"><p><strong> Quote Comments '.__('settings saved.','quote-comments').'</strong></p></div>'; 357 339 } 358 340 … … 361 343 ?> 362 344 <div class="wrap"> 363 <h2><?php echo $qc_themename; _e(': General Options', 'quote-comments'); ?></h2>345 <h2><?php _e('Quote Comments: General Options', 'quote-comments'); ?></h2> 364 346 365 347 <form method="post" action=""> 366 367 <p class="submit">368 <input class="button-primary" name="save" type="submit" value="<?php _e('Save changes','quote-comments'); ?>" />369 <input type="hidden" name="action" value="save" />370 </p>371 372 373 348 <?php // Smart options ?> 374 349 <table class="form-table"> … … 379 354 ?> 380 355 <tr valign="top"> 381 <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'quote-comments'); ?></label></th>356 <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></th> 382 357 <td> 383 <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != "") { echo get_option( $value['id']); } else { echo $value['std']; } ?>" />358 <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != "") { echo esc_attr( get_option( $value['id'] ) ); } else { echo $value['std']; } ?>" /> 384 359 <?php 385 360 if ( ! empty( $value['desc'] ) ) { 386 _e($value['desc'],'quote-comments');361 echo $value['desc']; 387 362 } 388 363 ?> … … 396 371 ?> 397 372 <tr valign="top"> 398 <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'quote-comments'); ?></label></th>373 <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></th> 399 374 <td> 400 375 <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"> … … 412 387 ?> 413 388 <tr valign="top"> 414 <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'quote-comments'); ?></label></th>389 <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></th> 415 390 <td><textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" cols="<?php echo $ta_options['cols']; ?>" rows="<?php echo $ta_options['rows']; ?>"><?php 416 391 if( get_option($value['id']) != "") { 417 echo __(stripslashes(get_option($value['id'])),'quote-comments');392 echo stripslashes( esc_attr( get_option($value['id'] ) ) ); 418 393 }else{ 419 echo __($value['std'],'quote-comments');420 }?></textarea><br /><?php echo __($value['desc'],'quote-comments'); ?></td>394 echo $value['std']; 395 }?></textarea><br /><?php echo $value['desc']; ?></td> 421 396 </tr> 422 397 <?php … … 426 401 ?> 427 402 <tr valign="top"> 428 <th scope="row"><?php echo __($value['name'],'quote-comments'); ?></th>403 <th scope="row"><?php echo $value['name']; ?></th> 429 404 <td> 430 405 <?php foreach ($value['options'] as $key=>$option) { 431 $radio_setting = get_option($value['id']);406 $radio_setting = esc_attr( get_option($value['id'] ) ); 432 407 if($radio_setting != ''){ 433 408 if ($key == get_option($value['id']) ) { … … 453 428 ?> 454 429 <tr valign="top"> 455 <th scope="row"><?php echo __($value['name'],'quote-comments'); ?></th>430 <th scope="row"><?php echo $value['name']; ?></th> 456 431 <td> 457 432 <?php … … 463 438 ?> 464 439 <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> 465 <label for="<?php echo $value['id']; ?>"><?php echo __($value['desc'],'quote-comments'); ?></label>440 <label for="<?php echo $value['id']; ?>"><?php echo $value['desc']; ?></label> 466 441 </td> 467 442 </tr> … … 492 467 493 468 add_action('admin_menu' , 'quotecomments_add_admin'); 494 495 496 497 ?> -
quote-comments/trunk/readme.txt
r2632905 r3290923 1 1 === Quote Comments === 2 Contributors: metodiew , Joen2 Contributors: metodiew 3 3 Donate link: https://metodiew.com/ 4 4 Tags: quote, comments, javascript, textile, wysiwyg 5 Requires at least: 2.5.06 Tested up to: 5.8.25 Requires at least: 5.0.0 6 Tested up to: 6.8.1 7 7 Stable tag: 2.2 8 8 Stable tag: trunk … … 30 30 31 31 1. The default look: a little (Quote) link next to the comment time. 32 2. An alternate look, where the icon has been styled to look like a Quote icon. Click the tiny quote icon to quote. 33 3. Quote Comments options page. 32 2. Quote Comments options page. 34 33 35 34 == Frequently Asked Questions == … … 78 77 == Changelog == 79 78 79 = 3.0.0 = 80 * Release date - May 10, 2025 81 * Address the vulnerability report from https://patchstack.com/database/report-preview/d7891563-a582-42b3-95ef-8985948d7d74?pin=InwTOqOOYguvviZ6 82 * Add additional escaping 83 * Optimize the code base 84 80 85 = 2.2.1 = 81 86 * Release date - November 20, 2021
Note: See TracChangeset
for help on using the changeset viewer.