我在下面的代码中遇到意外的文件错误结束

时间:2017-08-04 11:25:38

标签: php

<?php // Get current user ID
$user_id = get_current_user_id();

// Check if the user is member of the plan 'gold'
if ( wc_memberships_is_user_active_member( $user_id, 'premium_lidmaatschap' ) ) {
if ((!vlog_get_option('open_videos_inplay') && is_single()) || (!is_single())): ?>
    <a class="vlog-cover" href="javascript: void(0);" data-action="video"
       data-id="<?php echo esc_attr(get_the_ID()); ?>">
        <?php echo vlog_get_featured_image('vlog-cover-full', false, false, true); ?>
        <?php echo vlog_post_format_action('large'); ?>
    </a><?php
    endif;

    if ($video = hybrid_media_grabber(array('type' => 'video', 'split_media' => true))): ?>
    <div class="vlog-format-content"><?php if (vlog_get_option('open_videos_inplay') && is_single()) {
            echo '<div class="vlog-popup-wrapper">' . $video . '</div>';
        } ?></div>
<?php endif; 

} 

else {
get_template_part("template-parts/child.membership");

if ((!vlog_get_option('open_videos_inplay') && is_single()) || (!is_single())): ?>
    <a class="vlog-cover" href="javascript: void(0);" data-action="video"
       data-id="<?php echo esc_attr(get_the_ID()); ?>">
        <?php echo vlog_get_featured_image('vlog-cover-full', false, false, true); ?>
        <?php echo vlog_post_format_action('large'); ?>
    </a>
<?php endif; ?>
}

?>

这是我为客户编写的代码。第一位有效,但当站点调用else语句时,会出现上述错误。

4 个答案:

答案 0 :(得分:1)

更改此代码

<?php endif; ?>
}

?>

<?php endif; 
}
?>

答案 1 :(得分:0)

只需复制我的以下代码并尝试

<?php // Get current user ID
$user_id = get_current_user_id();

// Check if the user is member of the plan 'gold'
if ( wc_memberships_is_user_active_member( $user_id, 'premium_lidmaatschap' ) ) {
if ((!vlog_get_option('open_videos_inplay') && is_single()) || (!is_single())): ?>
    <a class="vlog-cover" href="javascript: void(0);" data-action="video"
       data-id="<?php echo esc_attr(get_the_ID()); ?>">
        <?php echo vlog_get_featured_image('vlog-cover-full', false, false, true); ?>
        <?php echo vlog_post_format_action('large'); ?>
    </a><?php
    endif;

    if ($video = hybrid_media_grabber(array('type' => 'video', 'split_media' => true))): ?>
    <div class="vlog-format-content"><?php if (vlog_get_option('open_videos_inplay') && is_single()) {
            echo '<div class="vlog-popup-wrapper">' . $video . '</div>';
        } ?></div>
<?php endif; 

} 

else {
get_template_part("template-parts/child.membership");

if ((!vlog_get_option('open_videos_inplay') && is_single()) || (!is_single())): ?>
    <a class="vlog-cover" href="javascript: void(0);" data-action="video"
       data-id="<?php echo esc_attr(get_the_ID()); ?>">
        <?php echo vlog_get_featured_image('vlog-cover-full', false, false, true); ?>
        <?php echo vlog_post_format_action('large'); ?>
    </a>
<?php endif; } ?>


?>

答案 2 :(得分:0)

我已编辑代码,请按原样上传:

<?php // Get current user ID
$user_id = get_current_user_id();
// Check if the user is member of the plan 'gold'
if ( wc_memberships_is_user_active_member( $user_id, 'premium_lidmaatschap' ) ) {
    if ((!vlog_get_option('open_videos_inplay') && is_single()) || (!is_single())): ?>
    <a class="vlog-cover" href="javascript: void(0);" data-action="video"
       data-id="<?php echo esc_attr(get_the_ID()); ?>">
        <?php echo vlog_get_featured_image('vlog-cover-full', false, false, true); ?>
        <?php echo vlog_post_format_action('large'); ?>
    </a>
    <?php
    endif;
    if ($video = hybrid_media_grabber(array('type' => 'video', 'split_media' => true))): ?>
    <div class="vlog-format-content">
        <?php if (vlog_get_option('open_videos_inplay') && is_single()) {
            echo '<div class="vlog-popup-wrapper">'.$video.'</div>';
        } ?></div>
    <?php endif; 
} else {
get_template_part("template-parts/child.membership");
if ((!vlog_get_option('open_videos_inplay') && is_single()) || (!is_single())): ?>
    <a class="vlog-cover" href="javascript: void(0);" data-action="video"
       data-id="<?php echo esc_attr(get_the_ID()); ?>">
        <?php echo vlog_get_featured_image('vlog-cover-full', false, false, true); ?>
        <?php echo vlog_post_format_action('large'); ?>
    </a>
<?php endif; 
}
?>

答案 3 :(得分:0)

在你的代码的最后一段 取代

<?php endif; ?>
}

?>
with
<?php endif;
}

?>