carousel_id = 'appw-carousel-' . self::$instance_id ;
$this->carousel_inner_items = '' ;
$this->number_of_inner_items = 0 ;
$this->carousel_indicators = '' ;
$this->slide_to_index = 0 ;
self::$instance_id++;
}
public function add_post_markup( $post_markup ) {
$this->append_post_markup_to_inner_items( $post_markup ) ;
$this->append_to_carousel_indicators() ;
$this->number_of_inner_items++ ;
}
private function append_post_markup_to_inner_items( $post_markup ) {
$is_active = (0 == $this->slide_to_index ) ? 'active' : '' ;
$this->carousel_inner_items .=
"
{$post_markup}
\n" ;
}
private function append_to_carousel_indicators(){
$is_active = (0 == $this->slide_to_index ) ? 'active' : '' ;
$this->carousel_indicators .=
"" ;
$this->slide_to_index++ ;
}
private function maybe_get_controls() {
if ( $this->number_of_inner_items > 1 ) {
return "
" ;
}
}
private function maybe_get_indicators() {
if ( $this->number_of_inner_items > 1 ) {
return "
{$this->carousel_indicators}
\n" ;
}
}
public function get() {
$controls = $this->maybe_get_controls() ;
$indicators = $this->maybe_get_indicators() ;
return "
{$indicators}
{$this->carousel_inner_items}
{$controls}
\n" ;
}
}