【问题标题】:Wordpress - Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING)Wordpress - 解析错误:语法错误,意外的“函数”(T_FUNCTION),需要标识符(T_STRING)
【发布时间】:2017-08-07 10:29:51
【问题描述】:

使用 Woo-Commerce 和 Storefront 主题的 Wordpress 出现以下错误。

错误是 - 解析错误:语法错误、意外的“函数”(T_FUNCTION)、需要标识符 (T_STRING)

有人可以帮忙吗?

这是主题的标准代码。没有编辑。它刚刚开始不起作用。

这是第 31 行的函数:

    <?php
if ( ! function_exists( 'storefront_display_comments' ) ) {

    function storefront_display_comments() {
        // If comments are open or we have at least one comment, load up the comment template.
        if ( comments_open() || '0' != get_comments_number() ) :
            comments_template();
        endif;
    }
}

if ( ! function_exists( 'storefront_comment' ) ) {

    function storefront_comment( $comment, $args, $depth ) {
        if ( 'div' == $args['style'] ) {
            $tag = 'div';
            $add_below = 'comment';
        } else {
            $tag = 'li';
            $add_below = 'div-comment';
        }
        ?>
        <<?php echo esc_attr( $tag ); ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
        <div class="comment-body">
        <div class="comment-meta commentmetadata">
            <div class="comment-author vcard">
            <?php echo get_avatar( $comment, 128 ); ?>
            <?php printf( wp_kses_post( '<cite class="fn">%s</cite>', 'storefront' ), get_comment_author_link() ); ?>
            </div>
            <?php if ( '0' == $comment->comment_approved ) : ?>
                <em class="comment-awaiting-moderation"><?php esc_attr_e( 'Your comment is awaiting moderation.', 'storefront' ); ?></em>
                <br />
            <?php endif; ?>

            <a href="<?php echo esc_url( htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ); ?>" class="comment-date">
                <?php echo '<time datetime="' . get_comment_date( 'c' ) . '">' . get_comment_date() . '</time>'; ?>
            </a>
        </div>
        <?php if ( 'div' != $args['style'] ) : ?>
        <div id="div-comment-<?php comment_ID() ?>" class="comment-content">
        <?php endif; ?>
        <div class="comment-text">
        <?php comment_text(); ?>
        </div>
        <div class="reply">
        <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
        <?php edit_comment_link( __( 'Edit', 'storefront' ), '  ', '' ); ?>
        </div>
        </div>
        <?php if ( 'div' != $args['style'] ) : ?>
        </div>
        <?php endif; ?>
    <?php
    }
}

【问题讨论】:

标签: php wordpress parsing syntax


【解决方案1】:

自己找到了答案。 进入文件并删除了一个不合适的 hr 标签,它解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-21
    • 2015-05-26
    • 2021-09-13
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多