Advertisement
Guest User

apiki

a guest
May 15th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. /**
  2.      * Reads the shortcode and show FAQs
  3.      *
  4.      * @since 1.0
  5.      * @param array $args Params
  6.      */
  7.     public function shortcode( $args )
  8.     {
  9.         ob_start();
  10.         echo $this->display_faq($args);
  11.  
  12.         $output_string = ob_get_contents();
  13.         ob_end_clean();
  14.         return $output_string;
  15.     }
  16.    
  17.     /**
  18.      * Show FAQ
  19.      *
  20.      * @since 1.0
  21.      * @param array $args Options
  22.      * @return void
  23.      */
  24.     public function display_faq( $args = array() )
  25.     {
  26.         $faq = $this->get_faq( $args );
  27.  
  28.         extract( $args, EXTR_SKIP );
  29.        
  30.         $thiscat = '';
  31.         $categories = get_terms( $this->category_taxonomy, 'hide_empty=0' );
  32.         foreach ( (array)$categories as $cat )
  33.         {
  34.              if( $cat->slug == $category )
  35.                   $thiscat = $cat->name;
  36.         }
  37.  
  38.         $output = '<h2>' . $thiscat . ' FAQ</h2><div class="apiki-wp-faq-show">';
  39.        
  40.         if( empty( $faq ) || is_wp_error( $faq ) ) :
  41.             $output .= __( 'No FAQ found.', $this->text_domain );
  42.         else :
  43.             $output .= '<ul>';
  44.        
  45.             foreach( (array)$faq as $_faq )
  46.                 $output .= sprintf( '<li><a href="%1$s" title="%2$s">%2$s</a></li>', get_permalink( $_faq->ID ), $_faq->post_title );
  47.            
  48.             $output .= '</ul>';
  49.         endif;
  50.        
  51.         $output .= '</div>';
  52.        
  53.         return $output;
  54.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement