• Resolved suckkids

    (@suckkids)


    Hi everyone, I want to make a shortcode for calling a few post from X category. This’s my code :

    /*-----------------------------------------------------------------------------------*/
    /* Category - shortcode
    /*-----------------------------------------------------------------------------------*/
    function shortcode_category($atts, $content = null) {
    		extract(shortcode_atts(array(
    			"categ_id" => '',
    			"show" => '3',
    			"title" => '',
    		), $atts));
    
    		global $wp_query;
    
    		$temp = $wp_query;
    		$wp_query = null;
    		$wp_query = new WP_Query();
    
    				$query .= '&cat='.$categ_id;
    
    				$query .= '&showposts='.$show;
    
    				$query .= $query;
    
    			$wp_query->query($query);
    			ob_start();
    
    ?>
    
    	<span class="divider2"><span><?php echo $title; ?></span></span><!--DIVIDER-->
    	<div class="row-fluid">
    			<div class="content">
    				<div class="span12">
    					<div class="row-fluid">
    
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); $do_not_duplicate = $post->ID; ?>
    
    	<div class="span4 recent_blog">
    	<div class="recent-img">
    									<?php the_post_thumbnail('single_image'); ?>
    									<div class="caption">
    										<?php if ( has_post_format( 'video' )) {
    											?>
    
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    
    <img src="<?php bloginfo('stylesheet_directory'); ?>/img/iconsweet/format-video.png" alt="Video Format" />	
    
    </a>									<?php
    	}
    										else if ( has_post_format( 'image' )) {
    									?>
    
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    
    <img src="<?php bloginfo('stylesheet_directory'); ?>/img/iconsweet/format-images.png" alt="Image Format" />
    
    </a>
    									<?php
    	}
    	?>
    
    </div>
    								</div>
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><h4><?php the_title(); ?></h4></a>
    <div class="date"><?php the_time("F jS, Y");?> <?php _e('|','');?> <?php comments_number('No Comments', 'One Comment', '% Comments'); ?></div>
    
    <?php wpe_excerpt('wpe_excerptlength_index_sc', ''); ?>	
    
    <div class="mores"><a href="<?php the_permalink(); ?>"><?php _e('More &rarr;','');?> </a></div>	
    
    </div>
    <?php endwhile; ?>
    <div class="clearfix"></div>
    
    </div>
    
    </div>
    <div class="clearfix"></div>
    </div>
    </div>
    
    	<?php $wp_query = null; $wp_query = $temp;
    	$content = ob_get_contents();
    	ob_end_clean();
    	return $content;  
    
    }
    
    add_shortcode ('categories', 'shortcode_category');

    The question is:
    my code is secure? or my code contains code that prohibited and dangerous?

    Thank you everyone.

The topic ‘Is dangerous using ob_start on shortcode??’ is closed to new replies.