block_name = 'thumbnail-slider'; $this->scripts = array( 'pcp_swiper', 'sp_smart_post_blocks_script_js' ); $this->styles = array( 'pcp_swiper', 'sp_smart_post_blocks_css', 'sp_smart_post_blocks_social_icons_style', 'sp_smart_post_blocks_google_fonts' ); $this->editor_scripts = array( 'sp_smart_post_blocks_index_js' ); $this->editor_styles = array( 'sp_smart_post_blocks_editor_style' ); $this->keywords = array( 'Smart post', 'Slider', 'Thumbnails Slider' ); } /** * Render Thumbnail Slider block. * * @param array $attributes Block attributes. * @param string $content Block content. * @param array $blocks Inner blocks. * @return $content. */ public function render_block( $attributes, $content = '', $blocks = array() ) { if ( Helper::is_editor_page() ) { return $content; } // Setup and sanitize attributes. $attributes['page_id'] = get_the_ID(); $unique_id = $attributes['uniqueId'] ?? ''; $sp_block_id = $attributes['spBlockId'] ?? ''; // Not changeable id. $block_name = $attributes['blockName'] ?? ''; $align = $attributes['align'] ?? ''; $additional_class = $attributes['additionalCssClass'] ?? ''; $animation_effect = $attributes['postThumbnailAnimationEffect'] ?? ''; $layout = $attributes['thumbnailSliderLayout'] ?? ''; $carousel_data = $attributes['carouselData'] ?? ''; $thumbnails_data = $attributes['thumbnailsData'] ?? ''; $arrow_on_hover = $attributes['navArrowVisibilityOnHover'] ?? ''; $arrow_style = $attributes['carouselArrowStyle'] ?? ''; $pagination_style = $attributes['carouselPaginationStyle'] ?? ''; $show_pagination = $attributes['carouselPaginationDot'] ?? false; $post_thumbnail_pos = $attributes['postThumbnailPosition'] ?? ''; $category_position = $attributes['catTabCategoryPosition'] ?? ''; $preloader_enable = $attributes['preloaderEnable'] ?? false; $post_not_found = ! empty( $attributes['noResultFoundResult'] ) ? $attributes['noResultFoundResult'] : 'No post found'; $preloader_svg = SP_PC_URL . 'public/assets/img/preloader.svg'; // Clean up unnecessary attributes. unset( $attributes['dynamicCss'], $attributes['fontListsEditPage'], $attributes['fontLists'] ); // Fetch posts. $query_attr = ( ! empty( $attributes['postQuery'] ) && isset( $attributes['postQuery'] ) ) ? (array) json_decode( $attributes['postQuery'] ) : $attributes; $post_query = $this->get_cached_post_query_result( $query_attr, $unique_id, $sp_block_id ); $post_query = $post_query[0]; // Layout class condition. $background_layout_class = ! in_array( $layout, array( 'thumbnail-slider-layout-three', 'thumbnail-slider-layout-four' ), true ) ? 'sp-smart-post-background-layout' : ''; $align_class = isset( $align ) ? 'align' . $align : ''; // Start output buffering. ob_start(); ?>