Unexpected CASE (T_CASE)

Asked

Viewed 774 times

0

Okay guys, I’m really lost here, I’m with a case error and I have no idea how to solve the code I’m putting down, thanks in advance.

Parse error: syntax error, Unexpected 'case' (T_CASE) in /var/www/wordpress/wp-content/themes/joy_theme/single.php on line 370

line 370 case 'blog': ( and if i remove the error comes to next line)
line 371 case '':

<?php get_header(); require('keys.php'); ?>
<!-- breadcrumb -->
<div class="breadcrumb">
    <?php seobreadcrumbs();?>
    
    <span style="float:right; margin:-15px 0 0 0;"><?php edit_post_link('Editar');?></span>
</div>
<!-- fim breadcrumb -->

<div class="doble-dote" style="margin:0 0 20px 0;"></div>


<!-- esquerda -->
<div class="esquerda">

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); 
    setPostViews($post->ID);
    /* ----  TIPO POST  ---- */
    $tipo_post = get_post_meta($post->ID, 'tipo_post', true);

    if($tipo_post == 'video') {
        /* ----  THUMBNAIL  ---- */
        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'post_capa');
    
        
        /* ----  INFO VIDEO  ---- */
        $esconder_capa_video = get_post_meta($post->ID, 'esconder_capa_video', true);
        $capa = get_post_meta($post->ID, 'capa', true);
        $tempo = get_post_meta($post->ID, 'tempo', true);
        $lancamento = get_post_meta($post->ID, 'lancamento', true);
        $audio = get_post_meta($post->ID, 'audio', true);
        $trailer = get_post_meta($post->ID, 'trailer', true);
        $esconder_trailer = get_post_meta($post->ID,'esconder_trailer_rodape', true);
        
        /* ----  DOWN LINKS  ---- */
        $esconder_download = get_post_meta($post->ID, 'esconder_lista_download', true);
        $servidor_download = get_post_meta($post->ID, 'servidor_download', true);
        
        
        /* ----  VIDEO EMBEDS  ---- */
        $esconder_assistir = get_post_meta($post->ID, 'esconder_lista_assistir', true);
        $servidor_assistir = get_post_meta($post->ID, 'servidor_assistir', true);
    }
?>


<?php switch($tipo_post) {
    case 'video': ?>
    
    <!--
    /* ---------------------------------------------------------
        /   VIDEO   /
    --------------------------------------------------------- */
    -->
    
    <article>
    <!-- videos servidores -->
    <div class="tabs">   
        <!-- embed videos -->
        <div class="embeds-servidores">
        <?php
        if(is_array($servidor_assistir)) {
        $i = 1; foreach ($servidor_assistir as $embed) {
            
            if($embed != '') {
            
            echo '<div class="embeds-video">';
            echo do_shortcode($embed);
            echo '</div>';
            $i++;
            
            }
        }
        }
        ?>
        </div>
        <!-- fim embed videos -->
        
        <?php if($esconder_assistir != 1) {?>
        <!-- title -->
        <div class="clear"></div>
        <?php if(is_array($servidor_assistir)) {?>
        <span class="assistir-title play-ico open-sans">
            Assistir Filme
        </span>
        <?php }?>
        <!-- fim title -->
        
       
        <div class="clear"></div>
       
        <!-- links servidores -->
        <ul class="links-servidores">
        <?php 
        if(is_array($servidor_assistir)) {
        $i = 1; foreach ($servidor_assistir as $servidor) {
            
            if($servidor != '') {
            
            if($i==1) {
            echo '<li class="active">';    
            } else {
            echo '<li>';    
            }
            echo '<span name="tabs-'.$i.'" class="link-servidor pfregular block">Assistir Server '.$i.'<span class="arrow-assistir"></span></span>';
            echo '</li>';
            $i++;
            
            }
        }
        }
        ?>
        </ul>
        <!-- fim links servidores -->
        <?php }?>
    </div>
    <!-- fim videos servidores -->
    
    <?php if(is_array($servidor_assistir)) {?>
    <div class="clear"></div>
    <div class="doble-dote" style="margin:0 0 15px 0;"></div>
    <?php }?>
    
    
    <?php if($esconder_download != 1) {?>
    <!-- baixar links -->
    <div class="baixar-links">
       <!-- title -->
       <?php if(is_array($servidor_download)) {?>
       <span class="assistir-title down-ico open-sans">
       BAIXAR FILME
       </span>
       <?php }?>
       <!-- fim title -->
       
       <div class="clear"></div>
       
       <!-- links download -->
       <ul class="links-servidores download-lista">
       <?php
        if(is_array($servidor_download)) {
        $i = 1; 
        foreach ($servidor_download as $servidor) {
            if($servidor != '') {
            
            $url = $servidor;
            $parse = parse_url($url);
            
            echo '<li class="tooltip2" title="'.$parse['host'].'">';    
            echo '<a href="'.$servidor.'" target="_blank"><span name="tabs-'.$i.'" class="link-servidor pfregular block">Servidor '.$i.'<span class="arrow-assistir"></span></span></a>';
            echo '</li>';
    
            $i++;
            
            }
        }
        } 
        ?>
        </ul> 
        <!-- fim links download -->
    </div>
    <!-- links baixar -->
    
    
    <div class="clear"></div>
    <div class="doble-dote" style="margin:30px 0 10px 0;"></div>
    <?php }?>
    
    <!-- infos video -->
    <?php if($tempo) {?>
    <span class="info-video open-sans tempo-video">
        <strong>Tempo:</strong> <?php echo $tempo;?>
    </span>
    <?php }?>
    
    <?php if($lancamento) {?>
    <span class="info-video open-sans lancamento-video">
        <strong>Lançamento:</strong> <?php echo $lancamento;?>
    </span>
    <?php }?>
    
    <?php if($audio) {?>
    <span class="info-video open-sans audio-video">
        <strong>Áudio:</strong> <?php echo $audio;?>
    </span>
    <?php }?>
    
    <span class="info-video open-sans visitas-video">
        <strong>Visitas:</strong> <?php echo getPostViews(get_the_ID());?>
    </span>
    <!-- infos video -->
    
    
    <div class="clear"></div>
    <div class="doble-dote" style="margin:10px 0 15px 0;"></div>
    
    
    <?php if($esconder_capa_video != 1) {?>
    <!-- capa single -->
    <div class="capa-single">
        <img src="<?php if(has_post_thumbnail()) { echo $thumbnail[0]; } elseif($capa) { echo $capa;} else {?><?php bloginfo('template_directory');?>/images/capa.jpg<?php }?>" alt="<?php the_title();?>" />
    </div>
    <!-- fim capa single -->
    <?php }?>
    
    <!-- content single -->
    <div class="content content-single">
        <?php the_content();?>
    </div>
    <!-- fim content single -->
    
    
    <?php /* mostar compartilhamento */ if($mostrar_compartilhamento == 'true') {?>
        <div class="clear"></div>
        <div class="doble-dote" style="margin:15px 0 15px 0;"></div>
        
        <span style="float:left; margin:0 10px 0 0;">
        Compartilhar Post: 
        </span>
        
        <?php if($mostrar_facebook_share == 'true') {?>
        <span style="float:left; margin:0 10px 0 0;">
        <div class="fb-like" data-href="<?php the_permalink();?>" data-width="110" data-layout="button_count" data-show-faces="false" data-send="false"></div>
        </span>
        <?php }?>
        
        <?php if($mostrar_twitter_share == 'true') {?>
        <span style="float:left; margin:0 10px 0 0;">
        <a href="<?php the_permalink();?>" class="twitter-share-button" data-text="<?php the_title();?>" data-via="<?php echo $twitter;?>" data-lang="pt">Tweetar</a>
        </span>
        <?php }?>
        
        <?php if($mostrar_google_share == 'true') {?>
        <span style="float:left; margin:0 10px 0 0;">
        <g:plusone size="medium" href="<?php the_permalink();?>"></g:plusone>
        </span>
        <?php }?>
    
    <?php }?>
    
    <div class="clear"></div>
    <div class="doble-dote" style="margin:15px 0 10px 0;"></div>
    
    <!-- infos video -->
    <span class="info-video open-sans categoria-video">
        <strong>Categorias:</strong> <?php the_category(', ');?>
    </span>
    
    <span class="info-video open-sans tag-video">
        <?php the_tags('<strong>Tags:</strong> ', ', ');?>
    </span>
    <!-- infos video -->
    </article>
    
    <div class="clear"></div>
    <div class="doble-dote" style="margin:10px 0 35px 0;"></div>
    
    
    <!-- relacionados -->
    <div <?php if($esconder_trailer != 1 && $trailer) { echo 'class="coll-relacionados-trailer"';}?>>
        <span class="assistir-title open-sans" style="border-bottom:1px solid #2f2f2f; padding:0 0 5px 0px; margin:0 0 15px 0; display:block;">
            <span class="relacionados-icon"></span>RELACIONADOS
        </span>
    
    
        <!-- relacionados lista -->
        <div class="flexslider <?php if($esconder_trailer != 1 && $trailer) { echo 'slider-relacionados'; } else { echo 'slider-relacionados-full'; }?>">
        <?php 
        $orig_post = $post;
        global $post;
        $categories = get_the_category($post->ID);
        
        if ($categories) {
            $category_ids = array();
            foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
        
            $args=array(
                'category__in' => $category_ids,
                'post__not_in' => array($post->ID),
                'posts_per_page'=> 10, 
                'caller_get_posts'=>1,
                'orderby' => 'rand',
                'meta_key' => 'tipo_post',
                'meta_value' => 'video',
            );
        
            $my_query = new wp_query( $args );
            if( $my_query->have_posts() ) {
                $i=0;
                echo '<ul class="slides lista-filmes" style="background:none;">';
                while( $my_query->have_posts() ) {
                    $my_query->the_post();
                    
                    $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'post_capa');
                    $capa = get_post_meta($post->ID, 'capa', true);
                    ?>
        <li style=" <?php if($esconder_trailer != 1 && $trailer) { echo 'margin:0 10px 0 0;'; } else { echo 'margin:0 15px 0 0;'; }?> ">
            <!-- titulo box -->
            <div class="titulo-box open-sans">
                <h2 class="titulo-box-link">
                <a href="<?php the_permalink();?>" title="<?php the_title();?>" <?php if (strlen($post->post_title) > 21) {echo 'class="tooltip"'; }?>><?php if (strlen($post->post_title) > 21) {echo substr(the_title($before = '', $after = '', FALSE), 0, 21) . '...'; } else {the_title();} ?></a>
                </h2>
            </div>
            <!-- fim titulo box -->
            
            <div class="clear"></div>
            
            <!-- capa -->
            <div class="capa">
            <a href="<?php the_permalink();?>" class="absolute-capa no-text"><?php the_title();?></a>
            <img src="<?php if(has_post_thumbnail()) { echo $thumbnail[0]; } elseif($capa) { echo $capa;} else {?><?php bloginfo('template_directory');?>/images/capa.jpg<?php }?>" alt="<?php the_title();?>" />
            </div>
            <!-- fim capa -->
            
            <div class="clear"></div>
            
            <!-- views -->
            <div class="views">
            <?php echo getPostViews(get_the_ID());?> visitas
            </div>
            <!-- fim views -->
            
            <!-- balao comentario -->
            <div class="balao-comentario">
            <?php comments_popup_link('0','1', '%', '','-'); ?>
            </div>
            <!-- fim balao comentario -->
            
        </li>
        <? $i++;
            }
                echo '</ul>';
            }
        }
        $post = $orig_post;
        wp_reset_query(); 
        ?>
        </div>
        <!-- relacionados lista -->
    </div>
    <!-- fim relacionados -->
    
    
    
    <?php if($esconder_trailer != 1 && $trailer) {?>
    <!-- trailer -->
    <div class="coll-relacionados-trailer" style="float:right;">
    
        <span class="assistir-title trailer-ico open-sans" style="border-bottom:1px solid #2f2f2f; padding:0 0 5px 30px; margin:0 0 15px 0; display:block;">
        Trailer
        </span>
    
        <!-- embed trailer -->
        <div class="embed-trailer">
        <?php echo stripslashes($trailer);?>
        </div>
        <!-- fim embed trailer -->
    
    </div>
    <!-- fim trailer -->
    <?php }?>
<!--
/* ---------------------------------------------------------
    /    FIM VÍDEO   /
--------------------------------------------------------- */
-->
    
    <?php break;
    case 'blog':
    case '': ?>
    
    <!-- content blog -->
    <div class="content content-blog">
    <?php the_content();?>
    </div>    
    <!-- fim content blog -->
    
    <?php /* mostar compartilhamento */ if($mostrar_compartilhamento == 'true') {?>
        <div class="clear"></div>
        <div class="doble-dote" style="margin:15px 0 15px 0;"></div>
        
        <span style="float:left; margin:0 10px 0 0;">
        Compartilhar Post: 
        </span>
        
        <?php if($mostrar_facebook_share == 'true') {?>
        <span style="float:left; margin:0 10px 0 0;">
        <div class="fb-like" data-href="<?php the_permalink();?>" data-width="110" data-layout="button_count" data-show-faces="false" data-send="false"></div>
        </span>
        <?php }?>
        
        <?php if($mostrar_twitter_share == 'true') {?>
        <span style="float:left; margin:0 10px 0 0;">
        <a href="<?php the_permalink();?>" class="twitter-share-button" data-text="<?php the_title();?>" data-via="<?php echo $twitter;?>" data-lang="pt">Tweetar</a>
        </span>
        <?php }?>
        
        <?php if($mostrar_google_share == 'true') {?>
        <span style="float:left; margin:0 10px 0 0;">
        <g:plusone size="medium" href="<?php the_permalink();?>"></g:plusone>
        </span>
        <?php }?>
    
    <?php }?>
    
    <div class="clear"></div>
    <div class="doble-dote" style="margin:15px 0 10px 0;"></div>
    
    <!-- infos video -->
    <span class="info-video open-sans categoria-video">
        <strong>Categorias:</strong> <?php the_category(', ');?>
    </span>
    
    <span class="info-video open-sans tag-video">
        <?php the_tags('<strong>Tags:</strong> ', ', ');?>
    </span>
    <!-- infos video -->
    <div class="clear"></div>
    <div class="doble-dote" style="margin:10px 0 35px 0;"></div>
    
        
    <?php break;
}?>

<?php endwhile; ?>

<div class="clear"></div>

<!-- comentarios -->
<div class="comentarios">
    <?php comments_template();?>
</div>
<!-- fim comentarios -->


<?php else : endif; ?>
    
</div>
<!-- fim esquerda -->


<!-- direita -->
<div class="direita">
<?php require('sidebar.php');?>
</div>
<!-- fim direita -->

<?php get_footer();?>
  • The 370 line would be which? could put it in the spotlight?

  • i specified in the topic the line 370 is "case 'blog':"

  • By your comment, maybe it’s a lock key that’s in the wrong place

  • With this indentation will be a little difficult to find the keys closing remaining. (but there is fault the way wordpress works...)

1 answer

1

The problem is that:

case 'blog':
case '':

doesn’t work that way. If your goal is to set the 'blog' option to default if no option is given, use the method default, thus:

case 'blog':
default:
    // seu código aqui
    break;

theoretically, the default is the last option of switch, then you wouldn’t even have to use the break; but you can use it if you want.

  • 1

    I don’t know how I missed that..

  • Walter I understood what you said, but the error is in the case 'blog' line she is unexpected soon something before this could happen this error, no? i already made the changes with the default and still persists the errors, first say that endwhile is unexpected after Else and finally 'unexpected code ending', I’m still trying here kkk, if I get some result I comment!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.