array( $this, 'render_callback' ), ) ); } public function get_label() { return __( 'Post Slider', 'getwid' ); } public function render_callback( $attributes, $content ) { $query_args = getwid_build_custom_post_type_query( $attributes ); $q = new \WP_Query( $query_args ); $use_template = false; $template_part_content = ''; if ( isset( $attributes['postTemplate'] ) && '' !== $attributes['postTemplate'] ) { $template_post = get_post( $attributes['postTemplate'], ARRAY_A ); if ( ! is_null( $template_post ) && '' !== $template_post['post_content'] ) { $use_template = true; $template_part_content = $template_post['post_content']; } } $block_name = 'wp-block-getwid-post-slider'; $post_type = isset( $attributes['postType'] ) ? $attributes['postType'] : 'post'; $extra_attr = array( 'block_name' => $block_name, 'back_end' => getwid_is_block_editor(), ); $class = $block_name; $class .= ' custom-post-type-' . $post_type; if ( isset( $attributes['align'] ) ) { $class .= ' align' . $attributes['align']; } if ( isset( $attributes['className'] ) ) { $class .= ' ' . $attributes['className']; } $content_class = $block_name . '__content'; $slide_style = ''; if ( isset( $attributes['minHeight'] ) ) { $slide_style .= 'min-height:' . $attributes['minHeight'] . ';'; } $class .= ' has-arrows-' . $attributes['sliderArrows']; $class .= ' has-dots-' . $attributes['sliderDots']; $slider_data = array( 'getwid_fade_effect' => $attributes['sliderAnimationEffect'], 'getwid_autoplay' => $attributes['sliderAutoplay'], 'getwid_pause_on_hover' => $attributes['sliderPauseOnHover'], 'getwid_autoplay_speed' => intval( $attributes['sliderAutoplaySpeed'] ), 'getwid_infinite' => $attributes['sliderInfinite'], 'getwid_animation_speed' => intval( $attributes['sliderAnimationSpeed'] ), 'getwid_arrows' => $attributes['sliderArrows'], 'getwid_dots' => $attributes['sliderDots'], ); $slider_options = wp_json_encode( $slider_data ); ob_start(); ?>
have_posts() ) { while ( $q->have_posts() ) : $q->the_post(); ?>
blocksManager()->addBlock( new PostSlider() );