Changeset 2406957
- Timestamp:
- 10/26/2020 05:22:21 PM (5 years ago)
- Location:
- comment-guestbook/trunk
- Files:
-
- 6 edited
-
comment-guestbook.php (modified) (2 diffs)
-
includes/comments-functions.php (modified) (10 diffs)
-
includes/comments-template.php (modified) (3 diffs)
-
includes/options.php (modified) (1 diff)
-
includes/shortcode.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
comment-guestbook/trunk/comment-guestbook.php
r2381922 r2406957 4 4 * Plugin URI: https://wordpress.org/plugins/comment-guestbook/ 5 5 * Description: Add a guestbook page which uses the WordPress integrated comments. 6 * Version: 0.7. 46 * Version: 0.7.5 7 7 * Author: mibuthu 8 8 * Author URI: https://wordpress.org/plugins/comment-guestbook/ … … 72 72 73 73 // Always! 74 add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ) );74 add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ), 10 ); 75 75 add_shortcode( 'comment-guestbook', array( &$this, 'shortcode_comment_guestbook' ) ); 76 76 add_action( 'widgets_init', array( &$this, 'widget_init' ) ); -
comment-guestbook/trunk/includes/comments-functions.php
r2381922 r2406957 102 102 103 103 /** 104 * Show the comments list with the required adaptations 105 * 106 * @return void 104 * Get the comments list html with the required plugin modifications 105 * 106 * For the modifications the available arguments for the wp_list_comments function are used. 107 * 108 * @return string 107 109 */ 108 110 public function list_comments() { 109 $args = array( );111 $args = array( 'echo' => false ); 110 112 // Comment list args. 111 113 if ( '' !== $this->options->get( 'cgb_clist_args' ) ) { … … 136 138 } 137 139 // Print comments. 138 wp_list_comments( $args );140 return wp_list_comments( $args ); 139 141 } 140 142 … … 186 188 187 189 /** 188 * Show the navigation bar190 * Get the navigation bar html 189 191 * 190 192 * @param string $location The position where the navigation bar should be displayed. 191 193 * 192 * @return void194 * @return string 193 195 */ 194 196 public function show_nav_html( $location ) { 195 197 if ( get_comment_pages_count() > 1 && (bool) get_option( 'page_comments' ) ) { 196 198 $nav_id = 'comment-nav-' . ( 'above_comments' === $location ? 'above' : 'below' ); 197 echo'<nav id="' . esc_attr( $nav_id ) . '">';199 $out = '<nav id="' . esc_attr( $nav_id ) . '">'; 198 200 199 201 if ( '' !== $this->options->get( 'cgb_clist_num_pagination' ) ) { 200 202 // Numbered Pagination. 201 echo'<div class="pagination" style="text-align:center;">';202 paginate_comments_links(203 $out .= '<div class="pagination" style="text-align:center;">'; 204 $out .= paginate_comments_links( 203 205 array( 206 'echo' => false, 204 207 'prev_text' => $this->nav_label_prev, 205 208 'next_text' => $this->nav_label_next, … … 207 210 ) 208 211 ); 209 echo'</div>';212 $out .= '</div>'; 210 213 } else { 211 214 // Only previous and next links. 212 215 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- $this->get_comment_nav_label is already escaped. 213 216 // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralDomain -- using a variable is required here. 214 echo'<h1 class="assistive-text">' . esc_html__( 'Comment navigation', $this->l10n_domain ) . '</h1>217 $out .= '<h1 class="assistive-text">' . esc_html__( 'Comment navigation', $this->l10n_domain ) . '</h1> 215 218 <div class="nav-previous">' . $this->get_comment_nav_label( true ) . '</div> 216 219 <div class="nav-next">' . $this->get_comment_nav_label() . '</div>'; … … 218 221 } 219 222 220 echo '</nav>'; 221 } 223 $out .= '</nav>'; 224 return $out; 225 } 226 return ''; 222 227 } 223 228 … … 231 236 */ 232 237 private function get_comment_nav_label( $previous = false ) { 233 ob_start();234 238 if ( $previous ) { 235 previous_comments_link( $this->nav_label_prev );239 return get_previous_comments_link( $this->nav_label_prev ); 236 240 } else { 237 next_comments_link( $this->nav_label_next ); 238 } 239 $out = strval( ob_get_contents() ); 240 ob_end_clean(); 241 242 return $out; 243 } 244 245 246 /** 247 * Show the comment form with thre required plugin adaptations 241 return get_next_comments_link( $this->nav_label_next ); 242 } 243 } 244 245 246 /** 247 * Get the comment form html with the required plugin modifications 248 248 * 249 249 * @param string $location The location where the comment form shall be displayed. 250 250 * 251 * @return void251 * @return string 252 252 */ 253 253 public function show_comment_form_html( $location ) { 254 // Print custom form styles. 254 $out = ''; 255 // Custom form styles. 255 256 if ( ! (bool) $this->num_forms ) { 256 257 $styles = $this->options->get( 'cgb_form_styles' ); … … 269 270 // Print styles. 270 271 if ( '' !== $styles ) { 271 echo'272 $out .= ' 272 273 <style> 273 274 ' . esc_html( $styles ) . ' … … 276 277 } 277 278 $this->num_forms ++; 278 // Showform.279 // Comment form. 279 280 if ( ( 'above_comments' === $location && '' !== $this->options->get( 'cgb_form_above_comments' ) ) 280 281 || ( 'below_comments' === $location && '' !== $this->options->get( 'cgb_form_below_comments' ) ) … … 283 284 // Add required parts for foldable comment form. 284 285 if ( 'false' !== $this->options->get( 'cgb_form_expand_type' ) ) { 285 echo'286 $out .= ' 286 287 <a class="form-link" id="show-form-' . esc_attr( strval( $this->num_forms ) ) . '" href="#show-form-' . esc_attr( strval( $this->num_forms ) ) . '">' . 287 288 esc_html( $this->options->get( 'cgb_form_expand_link_text' ) ) . '</a> … … 289 290 } 290 291 // Print form. 291 comment_form( $this->get_guestbook_comment_form_args() ); 292 ob_start(); 293 comment_form( $this->get_guestbook_comment_form_args() ); 294 $out .= ob_get_contents(); 295 ob_end_clean(); 292 296 if ( 'false' !== $this->options->get( 'cgb_form_expand_type' ) ) { 293 echo '</div>'; 294 } 295 } 297 $out .= '</div>'; 298 } 299 } 300 return $out; 296 301 } 297 302 -
comment-guestbook/trunk/includes/comments-template.php
r2381922 r2406957 18 18 19 19 global $wp_query; 20 $cgb_in_page = ! isset( $wp_query->comments );21 20 22 // Prepare $wp_query when template is displayed in post/page content. 23 if ( $cgb_in_page ) { 24 // Avoid phpcs warning for WordPress hook name. 25 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound 26 $wp_query->comments = apply_filters( 'comments_array', $cgb_func->get_comments( $wp_query->post->ID ) ); 27 $wp_query->comment_count = count( $wp_query->comments ); 28 } 29 30 // Show comment incl comment forms. 31 if ( ( '' === $cgb_options->get( 'cgb_clist_in_page_content' ) && ! $cgb_in_page ) || 32 ( '' !== $cgb_options->get( 'cgb_clist_in_page_content' ) && $cgb_in_page ) ) { 21 // Show comment including the comment forms (in page content or in comment area). 22 if ( ( '' === $cgb_options->get( 'cgb_clist_in_page_content' ) && ! isset( $GLOBALS['cgb_comment_template_in_page'] ) ) || 23 ( '' !== $cgb_options->get( 'cgb_clist_in_page_content' ) && isset( $GLOBALS['cgb_comment_template_in_page'] ) ) ) { 33 24 echo ' 34 25 <div id="comments">'; 35 36 26 // Comment form above comments. 37 $cgb_func->show_comment_form_html( 'above_comments' ); 27 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- no escaping required here 28 echo $cgb_func->show_comment_form_html( 'above_comments' ); 38 29 39 30 // Is a password required? … … 52 43 53 44 // Are comments available? 54 if ( have_comments() ) {45 if ( count( $wp_query->comments ) ) { 55 46 // Print custom list styles. 56 47 $cgb_styles = $cgb_options->get( 'cgb_clist_styles' ); … … 67 58 } 68 59 // Show comment list. 69 $cgb_func->show_nav_html( 'above_comments' ); 60 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- no escaping required here 61 echo $cgb_func->show_nav_html( 'above_comments' ); 70 62 echo '<ol class="commentlist cgb-commentlist">'; 71 $cgb_func->list_comments();63 echo $cgb_func->list_comments(); 72 64 echo '</ol>'; 73 $cgb_func->show_nav_html( 'below_comments' ); 65 echo $cgb_func->show_nav_html( 'below_comments' ); 66 // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped 74 67 } 75 68 76 69 // Comment form below comments. 77 $cgb_func->show_comment_form_html( 'below_comments' ); 70 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- no escaping required here 71 echo $cgb_func->show_comment_form_html( 'below_comments' ); 78 72 echo ' 79 73 </div><!-- #comments -->'; -
comment-guestbook/trunk/includes/options.php
r2381922 r2406957 63 63 */ 64 64 private function __construct() { 65 add_action( 'init', array( &$this, 'init' ), 1 ); 65 // Inititialize options directly after loading the plugins textdomain (action: plugins_loaded, priority: 10). 66 add_action( 'plugins_loaded', array( &$this, 'init' ), 11 ); 66 67 add_action( 'admin_init', array( &$this, 'register' ) ); 67 68 } -
comment-guestbook/trunk/includes/shortcode.php
r2381922 r2406957 76 76 */ 77 77 ob_start(); 78 include CGB_PATH . 'includes/comments-template.php'; 78 $GLOBALS['cgb_comment_template_in_page'] = true; 79 comments_template(); 79 80 $out = strval( ob_get_contents() ); 80 81 ob_end_clean(); 82 unset( $GLOBALS['cgb_comment_template_in_page'] ); 81 83 return $out; 82 84 } elseif ( '' !== $this->options->get( 'cgb_form_in_page' ) && ( '' === $this->options->get( 'cgb_form_above_comments' ) || '' === $this->options->get( 'cgb_adjust_output' ) ) ) { … … 86 88 */ 87 89 require_once CGB_PATH . 'includes/comments-functions.php'; 88 ob_start(); 89 CGB_Comments_Functions::get_instance()->show_comment_form_html( 'in_page' ); 90 $out = strval( ob_get_contents() ); 91 ob_end_clean(); 92 return $out; 90 return CGB_Comments_Functions::get_instance()->show_comment_form_html( 'in_page' ); 93 91 } else { 94 92 /** -
comment-guestbook/trunk/readme.txt
r2381922 r2406957 4 4 Tags: comment, guestbook, site, comments, integrated, shortcode, modify, list, form 5 5 Requires at least: 4.5 6 Tested up to: 5. 56 Tested up to: 5.6 7 7 Requires PHP: 5.2 8 Stable tag: 0.7. 48 Stable tag: 0.7.5 9 9 Plugin URI: https://wordpress.org/plugins/comment-guestbook/ 10 10 Licence: GPLv2 … … 91 91 == Changelog == 92 92 93 = 0.7.5 (2020-10-26) = 94 * fixed plugin error with some themes and in the customizer 95 * fixed show comment list in page content option 96 93 97 = 0.7.4 (2020-09-15) = 94 98 * complete code rewrite:
Note: See TracChangeset
for help on using the changeset viewer.