comments_open example


function _oembed_filter_feed_content( $content ) {
    return str_replace( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"', '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"', $content );
}

/** * Prints the necessary markup for the embed comments button. * * @since 4.4.0 */
function print_embed_comments_button() {
    if ( is_404() || ! ( get_comments_number() || comments_open() ) ) {
        return;
    }
    ?> <div class="wp-embed-comments"> <a href="<?php comments_link(); ?>" target="_top"> <span class="dashicons dashicons-admin-comments"></span> <?php             printf(
                /* translators: %s: Number of comments. */
                _n(
                    '%s <span class="screen-reader-text">Comment</span>',
                    
esc_html__( 'Older comments', 'twentytwentyone' )
                ),
                'next_text'          => sprintf(
                    '<span class="nav-next-text">%s</span> %s',
                    esc_html__( 'Newer comments', 'twentytwentyone' ),
                    is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' )
                ),
            )
        );
        ?> <?php if ( ! comments_open() ) : ?> <p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'twentytwentyone' ); ?></p> <?php endif; ?> <?php endif; ?> <?php     comment_form(
        array(
            'title_reply'        => esc_html__( 'Leave a comment', 'twentytwentyone' ),
            'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">',
            'title_reply_after'  => '</h2>',
        )
    );
'%1$s Comments<span class="screen-reader-text"> on %2$s</span>',
            $comments_number
        );
        $more = sprintf( $morenumber_format_i18n( $comments_number )$post_title );
    }

    if ( false === $none ) {
        /* translators: %s: Post title. */
        $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' )$post_title );
    }

    if ( 0 == $comments_number && ! comments_open() && ! pings_open() ) {
        printf(
            '<span%1$s>%2$s</span>',
            ! empty( $css_class ) ? ' class="' . esc_attr( $css_class ) . '"' : '',
            $none
        );
        return;
    }

    if ( post_password_required() ) {
        _e( 'Enter your password to view comments.' );
        return;
    }
<?php         atom_enclosure();

        /** * Fires at the end of each Atom feed item. * * @since 2.0.0 */
        do_action( 'atom_entry' );

        if ( get_comments_number() || comments_open() ) :
            ?> <link rel="replies" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php the_permalink_rss(); ?>#comments" thr:count="<?php echo get_comments_number(); ?>" /> <link rel="replies" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( 0, 'atom' ) ); ?>" thr:count="<?php echo get_comments_number(); ?>" /> <thr:total><?php echo get_comments_number(); ?></thr:total> <?php endif; ?> </entry> <?php endwhile; ?> </feed>
'<span class="screen-reader-text">' . get_the_title() . '</span>'
                    ),
                    '<span class="edit-link">',
                    '</span><br>'
                );
            }
            ?> </footer><!-- .entry-footer --> </article><!-- #post-<?php the_ID(); ?> --> <?php     // If comments are open or there is at least one comment, load up the comment template.     if ( comments_open() || get_comments_number() ) {
        comments_template();
    }
} // End the loop.
get_footer();

    do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' );

    /* * Allow the Discussion meta box to show up if the post type supports comments, * or if comments or pings are open. */
    if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
        add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
    }

    $stati = get_post_stati( array( 'public' => true ) );
    if ( empty( $stati ) ) {
        $stati = array( 'publish' );
    }
    $stati[] = 'private';

    if ( in_array( get_post_status( $post )$stati, true ) ) {
        /* * If the post type support comments, or the post has comments, * allow the Comments meta box. */

    do_action( 'rss2_head' );

    while ( have_posts() ) :
        the_post();
        ?> <item> <title><?php the_title_rss(); ?></title> <link><?php the_permalink_rss(); ?></link> <?php if ( get_comments_number() || comments_open() ) : ?> <comments><?php comments_link_feed(); ?></comments> <?php endif; ?> <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator> <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> <?php the_category_rss( 'rss2' ); ?> <guid isPermaLink="false"><?php the_guid(); ?></guid> <?php if ( get_option( 'rss_use_excerpt' ) ) : ?> <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php else : ?>
// If not IE, use the standard stylesheet.         wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style.css', array()wp_get_theme()->get( 'Version' ) );
    }

    // RTL styles.     wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );

    // Print styles.     wp_enqueue_style( 'twenty-twenty-one-print-style', get_template_directory_uri() . '/assets/css/print.css', array()wp_get_theme()->get( 'Version' ), 'print' );

    // Threaded comment reply styles.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

    // Register the IE11 polyfill file.     wp_register_script(
        'twenty-twenty-one-ie11-polyfills-asset',
        get_template_directory_uri() . '/assets/js/polyfills.js',
        array(),
        wp_get_theme()->get( 'Version' ),
        true
    );

    
if ( is_attachment() ) {
        // Parent post navigation.         the_post_navigation(
            array(
                /* translators: %s: Parent post link. */
                'prev_text' => sprintf( __( '<span class="meta-nav">Published in</span><span class="post-title">%s</span>', 'twentytwentyone' ), '%title' ),
            )
        );
    }

    // If comments are open or there is at least one comment, load up the comment template.     if ( comments_open() || get_comments_number() ) {
        comments_template();
    }

    // Previous/next post navigation.     $twentytwentyone_next = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' );
    $twentytwentyone_prev = is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' );

    $twentytwentyone_next_label     = esc_html__( 'Next post', 'twentytwentyone' );
    $twentytwentyone_previous_label = esc_html__( 'Previous post', 'twentytwentyone' );

    the_post_navigation(
        
<?php wp_list_comments(); ?> </ol> <div class="navigation"> <div class="alignleft"><?php previous_comments_link(); ?></div> <div class="alignright"><?php next_comments_link(); ?></div> </div> <?php else : // This is displayed if there are no comments so far. ?> <?php if ( comments_open() ) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // Comments are closed. ?> <!-- If comments are closed. --> <p class="nocomments"><?php _e( 'Comments are closed.' ); ?></p> <?php endif; ?> <?php endif; ?> <?php comment_form(); ?>


get_header();

/* Start the Loop */
while ( have_posts() ) :
    the_post();
    get_template_part( 'template-parts/content/content-page' );

    // If comments are open or there is at least one comment, load up the comment template.     if ( comments_open() || get_comments_number() ) {
        comments_template();
    }
endwhile; // End of the loop.
get_footer();


    // get_post_status() will get the parent status for attachments.     $status = get_post_status( $post );

    if ( ( 'private' === $status ) && ! current_user_can( 'read_post', $comment_post_id ) ) {
        return new WP_Error( 'comment_id_not_found' );
    }

    $status_obj = get_post_status_object( $status );

    if ( ! comments_open( $comment_post_id ) ) {

        /** * Fires when a comment is attempted on a post that has comments closed. * * @since 1.5.0 * * @param int $comment_post_id Post ID. */
        do_action( 'comment_closed', $comment_post_id );

        return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 );

    }

        }

        if ( ! $this->check_read_post_permission( $post$request ) ) {
            return new WP_Error(
                'rest_cannot_read_post',
                __( 'Sorry, you are not allowed to read the post for this comment.' ),
                array( 'status' => rest_authorization_required_code() )
            );
        }

        if ( ! comments_open( $post->ID ) ) {
            return new WP_Error(
                'rest_comment_closed',
                __( 'Sorry, comments are closed for this item.' ),
                array( 'status' => 403 )
            );
        }

        return true;
    }

    /** * Creates a comment. * * @since 4.7.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or error object on failure. */
        $full_page = get_extended( $page->post_content );
        $link      = get_permalink( $page->ID );

        // Get info the page parent if there is one.         $parent_title = '';
        if ( ! empty( $page->post_parent ) ) {
            $parent       = get_post( $page->post_parent );
            $parent_title = $parent->post_title;
        }

        // Determine comment and ping settings.         $allow_comments = comments_open( $page->ID ) ? 1 : 0;
        $allow_pings    = pings_open( $page->ID ) ? 1 : 0;

        // Format page date.         $page_date     = $this->_convert_date( $page->post_date );
        $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date );

        // Pull the categories info together.         $categories = array();
        if ( is_object_in_taxonomy( 'page', 'category' ) ) {
            foreach ( wp_get_post_categories( $page->ID ) as $cat_id ) {
                $categories[] = get_cat_name( $cat_id );
            }

        $show_post_comments_feed = apply_filters( 'feed_links_extra_show_post_comments_feed', $show_comments_feed );

        if ( $show_post_comments_feed && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) {
            $title = sprintf(
                $args['singletitle'],
                get_bloginfo( 'name' ),
                $args['separator'],
                the_title_attribute( array( 'echo' => false ) )
            );

            $feed_link = get_post_comments_feed_link( $post->ID );

            if ( $feed_link ) {
                $href = $feed_link;
            }
Home | Imprint | This part of the site doesn't use cookies.