'', ), $attributes, 'post-carousel' ) ); $post_id = $attributes['id']; $pc_number_of_total_posts = intval( get_post_meta( $post_id, 'pc_number_of_total_posts', true ) ); $pc_number_of_column = intval( get_post_meta( $post_id, 'pc_number_of_column', true ) ); $pc_number_of_column_desktop = intval( get_post_meta( $post_id, 'pc_number_of_column_desktop', true ) ); $pc_number_of_column_tablet = intval( get_post_meta( $post_id, 'pc_number_of_column_tablet', true ) ); $pc_number_of_column_mobile = intval( get_post_meta( $post_id, 'pc_number_of_column_mobile', true ) ); $pc_auto_play_speed = get_post_meta( $post_id, 'pc_auto_play_speed', true ); $pc_nav_arrow_color = get_post_meta( $post_id, 'pc_nav_arrow_color', true ); $pc_nav_arrow_bg = get_post_meta( $post_id, 'pc_nav_arrow_bg', true ); $pc_pagination_color = get_post_meta( $post_id, 'pc_pagination_color', true ); $pc_pagination_active_color = get_post_meta( $post_id, 'pc_pagination_active_color', true ); $pc_scroll_speed = get_post_meta( $post_id, 'pc_scroll_speed', true ); $pc_post_title_color = get_post_meta( $post_id, 'pc_post_title_color', true ); $pc_post_title_hover_color = get_post_meta( $post_id, 'pc_post_title_hover_color', true ); $pc_post_content_color = get_post_meta( $post_id, 'pc_post_content_color', true ); $pc_post_meta_color = get_post_meta( $post_id, 'pc_post_meta_color', true ); $pc_post_meta_hover_color = get_post_meta( $post_id, 'pc_post_meta_hover_color', true ); $pc_carousel_title_color = get_post_meta( $post_id, 'pc_carousel_title_color', true ); $pc_themes = get_post_meta( $post_id, 'pc_themes', true ); $pc_auto_play = $this->get_meta( $post_id, 'pc_auto_play', 'true' ); $pc_pause_on_hover = $this->get_meta( $post_id, 'pc_pause_on_hover', 'true' ); $pc_show_navigation = $this->get_meta( $post_id, 'pc_show_navigation', 'true' ); $pc_show_pagination_dots = $this->get_meta( $post_id, 'pc_show_pagination_dots', 'true' ); $pc_touch_swipe = $this->get_meta( $post_id, 'pc_touch_swipe', 'true' ); $pc_mouse_draggable = $this->get_meta( $post_id, 'pc_mouse_draggable', 'true' ); $pc_rtl = $this->get_meta( $post_id, 'pc_rtl', 'true' ); $pc_post_title = $this->get_meta( $post_id, 'pc_post_title', 'true' ); $pc_post_content = $this->get_meta( $post_id, 'pc_post_content', 'true' ); $pc_post_author = $this->get_meta( $post_id, 'pc_post_author', 'true' ); $pc_post_date = $this->get_meta( $post_id, 'pc_post_date', 'true' ); $pc_carousel_title = $this->get_meta( $post_id, 'pc_carousel_title', 'true' ); $args = array( 'post_type' => 'post', 'orderby' => get_post_meta( $post_id, 'pc_posts_order_by', true ), 'order' => get_post_meta( $post_id, 'pc_posts_order', true ), 'posts_per_page' => $pc_number_of_total_posts, ); $que = new WP_Query( $args ); $outline = ''; $outline .= ' '; $outline .= ''; if ( $pc_themes == 'carousel_one' ) { $outline .= '
'; if ( $pc_carousel_title == 'true' ) { $outline .= '

' . get_the_title( $post_id ) . '

'; } $outline .= '
'; if ( $que->have_posts() ) { while ( $que->have_posts() ) : $que->the_post(); $outline .= '
'; if ( has_post_thumbnail( $que->post->ID ) ) { $outline .= '
'; $outline .= '' . get_the_post_thumbnail( $que->post->ID, 'large', array( 'class' => 'sp-pc-post-img' ) ) . ''; $outline .= '
'; } if ( $pc_post_title == 'true' ) { $outline .= '

'; $outline .= '' . get_the_title() . ''; $outline .= '

'; } if ( $pc_post_author == 'true' || $pc_post_date == 'true' ) { $outline .= ''; } if ( 'hide' !== $pc_post_content ) { $trimexcerpt = get_the_content(); $shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 30, $more = '' ); if ( 'full_content' == $pc_post_content ) { $outline .= "

" . do_shortcode( $trimexcerpt ) . '

'; } else { $outline .= "

" . do_shortcode( $shortexcerpt ) . '

'; } } $outline .= '
'; // sp-pc-post. endwhile; } else { $outline .= '

' . __( 'No posts found', 'post-carousel' ) . '

'; } $outline .= '
'; $outline .= '
'; // sp-post-carousel-section. } elseif ( $pc_themes == 'carousel_two' ) { $outline .= '
'; if ( $pc_carousel_title == 'true' ) { $outline .= '

' . get_the_title( $post_id ) . '

'; } $outline .= '
'; if ( $que->have_posts() ) { while ( $que->have_posts() ) : $que->the_post(); $outline .= '
'; $outline .= '
'; if ( has_post_thumbnail( $que->post->ID ) ) { $outline .= '
'; $outline .= '' . get_the_post_thumbnail( $que->post->ID, 'large', array( 'class' => 'sp-pc-post-img' ) ) . ''; $outline .= '
'; } if ( $pc_post_title == 'true' ) { $outline .= '

'; $outline .= '' . get_the_title() . ''; $outline .= '

'; } if ( $pc_post_author == 'true' || $pc_post_date == 'true' ) { $outline .= ''; } if ( 'hide' !== $pc_post_content ) { $trimexcerpt = get_the_content(); $shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 30, $more = '' ); if ( 'full_content' == $pc_post_content ) { $outline .= "

" . do_shortcode( $trimexcerpt ) . '

'; } else { $outline .= "

" . do_shortcode( $shortexcerpt ) . '

'; } } $outline .= '
'; // sp-pc-post-box. $outline .= '
'; // sp-pc-post. endwhile; } else { $outline .= '

' . __( 'No posts found', 'post-carousel' ) . '

'; } $outline .= '
'; $outline .= '
'; // sp-post-carousel-section. } wp_reset_query(); return $outline; } /** * Get post meta by id and key * * @param $post_id * @param $key * @param $default * * @return string|void */ public function get_meta( $post_id, $key, $default = null ) { $meta = get_post_meta( $post_id, $key, true ); if ( empty( $meta ) && $default ) { $meta = $default; } if ( $meta == 'zero' ) { $meta = '0'; } if ( $meta == 'on' ) { $meta = 'true'; } if ( $meta == 'off' ) { $meta = 'false'; } return esc_attr( $meta ); } } new SP_PC_ShortCode();