Plugin Directory

Changeset 2406957


Ignore:
Timestamp:
10/26/2020 05:22:21 PM (5 years ago)
Author:
mibuthu
Message:

version 0.7.5

Location:
comment-guestbook/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • comment-guestbook/trunk/comment-guestbook.php

    r2381922 r2406957  
    44 * Plugin URI: https://wordpress.org/plugins/comment-guestbook/
    55 * Description: Add a guestbook page which uses the WordPress integrated comments.
    6  * Version: 0.7.4
     6 * Version: 0.7.5
    77 * Author: mibuthu
    88 * Author URI: https://wordpress.org/plugins/comment-guestbook/
     
    7272
    7373        // Always!
    74         add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ) );
     74        add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ), 10 );
    7575        add_shortcode( 'comment-guestbook', array( &$this, 'shortcode_comment_guestbook' ) );
    7676        add_action( 'widgets_init', array( &$this, 'widget_init' ) );
  • comment-guestbook/trunk/includes/comments-functions.php

    r2381922 r2406957  
    102102
    103103    /**
    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
    107109     */
    108110    public function list_comments() {
    109         $args = array();
     111        $args = array( 'echo' => false );
    110112        // Comment list args.
    111113        if ( '' !== $this->options->get( 'cgb_clist_args' ) ) {
     
    136138        }
    137139        // Print comments.
    138         wp_list_comments( $args );
     140        return wp_list_comments( $args );
    139141    }
    140142
     
    186188
    187189    /**
    188      * Show the navigation bar
     190     * Get the navigation bar html
    189191     *
    190192     * @param string $location The position where the navigation bar should be displayed.
    191193     *
    192      * @return void
     194     * @return string
    193195     */
    194196    public function show_nav_html( $location ) {
    195197        if ( get_comment_pages_count() > 1 && (bool) get_option( 'page_comments' ) ) {
    196198            $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 ) . '">';
    198200
    199201            if ( '' !== $this->options->get( 'cgb_clist_num_pagination' ) ) {
    200202                // 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(
    203205                    array(
     206                        'echo'      => false,
    204207                        'prev_text' => $this->nav_label_prev,
    205208                        'next_text' => $this->nav_label_next,
     
    207210                    )
    208211                );
    209                 echo '</div>';
     212                $out .= '</div>';
    210213            } else {
    211214                // Only previous and next links.
    212215                // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- $this->get_comment_nav_label is already escaped.
    213216                // 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>
    215218                    <div class="nav-previous">' . $this->get_comment_nav_label( true ) . '</div>
    216219                    <div class="nav-next">' . $this->get_comment_nav_label() . '</div>';
     
    218221            }
    219222
    220             echo '</nav>';
    221         }
     223            $out .= '</nav>';
     224            return $out;
     225        }
     226        return '';
    222227    }
    223228
     
    231236     */
    232237    private function get_comment_nav_label( $previous = false ) {
    233         ob_start();
    234238        if ( $previous ) {
    235             previous_comments_link( $this->nav_label_prev );
     239            return get_previous_comments_link( $this->nav_label_prev );
    236240        } 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
    248248     *
    249249     * @param string $location The location where the comment form shall be displayed.
    250250     *
    251      * @return void
     251     * @return string
    252252     */
    253253    public function show_comment_form_html( $location ) {
    254         // Print custom form styles.
     254        $out = '';
     255        // Custom form styles.
    255256        if ( ! (bool) $this->num_forms ) {
    256257            $styles = $this->options->get( 'cgb_form_styles' );
     
    269270            // Print styles.
    270271            if ( '' !== $styles ) {
    271                 echo '
     272                $out .= '
    272273                    <style>
    273274                        ' . esc_html( $styles ) . '
     
    276277        }
    277278        $this->num_forms ++;
    278         // Show form.
     279        // Comment form.
    279280        if ( ( 'above_comments' === $location && '' !== $this->options->get( 'cgb_form_above_comments' ) )
    280281            || ( 'below_comments' === $location && '' !== $this->options->get( 'cgb_form_below_comments' ) )
     
    283284            // Add required parts for foldable comment form.
    284285            if ( 'false' !== $this->options->get( 'cgb_form_expand_type' ) ) {
    285                 echo '
     286                $out .= '
    286287                    <a class="form-link" id="show-form-' . esc_attr( strval( $this->num_forms ) ) . '" href="#show-form-' . esc_attr( strval( $this->num_forms ) ) . '">' .
    287288                        esc_html( $this->options->get( 'cgb_form_expand_link_text' ) ) . '</a>
     
    289290            }
    290291            // 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();
    292296            if ( 'false' !== $this->options->get( 'cgb_form_expand_type' ) ) {
    293                 echo '</div>';
    294             }
    295         }
     297                $out .= '</div>';
     298            }
     299        }
     300        return $out;
    296301    }
    297302
  • comment-guestbook/trunk/includes/comments-template.php

    r2381922 r2406957  
    1818
    1919global $wp_query;
    20 $cgb_in_page = ! isset( $wp_query->comments );
    2120
    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).
     22if ( ( '' === $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'] ) ) ) {
    3324    echo '
    3425            <div id="comments">';
    35 
    3626    // 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' );
    3829
    3930    // Is a password required?
     
    5243
    5344    // Are comments available?
    54     if ( have_comments() ) {
     45    if ( count( $wp_query->comments ) ) {
    5546        // Print custom list styles.
    5647        $cgb_styles = $cgb_options->get( 'cgb_clist_styles' );
     
    6758        }
    6859        // 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' );
    7062        echo '<ol class="commentlist cgb-commentlist">';
    71         $cgb_func->list_comments();
     63        echo $cgb_func->list_comments();
    7264        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
    7467    }
    7568
    7669    // 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' );
    7872    echo '
    7973            </div><!-- #comments -->';
  • comment-guestbook/trunk/includes/options.php

    r2381922 r2406957  
    6363     */
    6464    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 );
    6667        add_action( 'admin_init', array( &$this, 'register' ) );
    6768    }
  • comment-guestbook/trunk/includes/shortcode.php

    r2381922 r2406957  
    7676             */
    7777            ob_start();
    78                 include CGB_PATH . 'includes/comments-template.php';
     78                $GLOBALS['cgb_comment_template_in_page'] = true;
     79                comments_template();
    7980                $out = strval( ob_get_contents() );
    8081            ob_end_clean();
     82            unset( $GLOBALS['cgb_comment_template_in_page'] );
    8183            return $out;
    8284        } elseif ( '' !== $this->options->get( 'cgb_form_in_page' ) && ( '' === $this->options->get( 'cgb_form_above_comments' ) || '' === $this->options->get( 'cgb_adjust_output' ) ) ) {
     
    8688             */
    8789            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' );
    9391        } else {
    9492            /**
  • comment-guestbook/trunk/readme.txt

    r2381922 r2406957  
    44Tags: comment, guestbook, site, comments, integrated, shortcode, modify, list, form
    55Requires at least: 4.5
    6 Tested up to: 5.5
     6Tested up to: 5.6
    77Requires PHP: 5.2
    8 Stable tag: 0.7.4
     8Stable tag: 0.7.5
    99Plugin URI: https://wordpress.org/plugins/comment-guestbook/
    1010Licence: GPLv2
     
    9191== Changelog ==
    9292
     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
    9397= 0.7.4 (2020-09-15) =
    9498* complete code rewrite:
Note: See TracChangeset for help on using the changeset viewer.