|string $atts Attributes. * @return string */ public function render_shortcode( $atts ) { if ( ! aha_hero_slider_should_render_slider_output() ) { return ''; } if ( ! aha_hero_slider_is_cpt_enabled() ) { return ''; } $atts = AHA_Hero_Slider_Shortcode_Attributes::parse( $atts ); $transition_mode = aha_hero_slider_sanitize_transition_mode( (string) $atts['transition'] ); $progress_mode = aha_hero_slider_sanitize_progress_mode( (string) $atts['progress'] ); $infinite_raw = strtolower( trim( (string) $atts['infinite'] ) ); $infinite_mode = 'loop'; if ( in_array( $infinite_raw, array( 'no', '0', 'false', 'off' ), true ) ) { $infinite_mode = 'finite'; } elseif ( 'seamless' === $infinite_raw ) { $infinite_mode = 'seamless'; } wp_enqueue_style( 'aha-hero-slider-main' ); wp_enqueue_script( AHA_Hero_Slider_Assets::SCRIPT_MAIN ); $global_css = aha_hero_slider_get_global_styles_css(); if ( $global_css ) { wp_add_inline_style( 'aha-hero-slider-main', wp_strip_all_tags( $global_css ) ); } $query_args = array(); if ( isset( $atts['group'] ) && trim( (string) $atts['group'] ) !== '' ) { $query_args['group'] = $atts['group']; } $posts = aha_hero_slider_get_cpt_slides( $query_args ); $slides = array(); foreach ( $posts as $p ) { if ( $p instanceof WP_Post ) { $slides[] = aha_hero_slider_slide_from_post( $p ); } } /** * Filter slides for shortcode output. * * @since 1.0.0 * * @param array> $slides Slides. */ $slides = apply_filters( 'aha_hero_slider_shortcode_slides', $slides ); if ( empty( $slides ) ) { return ''; } $instance_css_vars = aha_hero_slider_instance_css_vars_from_shortcode_atts( $atts ); $slider_id = ! empty( $atts['id'] ) ? sanitize_html_class( 'aha-hero-slider-' . $atts['id'] ) : 'aha-hero-slider-' . wp_unique_id(); $config = array( 'autoplay_speed' => max( 0, (int) $atts['autoplay_speed'] ), 'show_arrows' => $atts['arrows'] === 'yes', 'border_radius' => max( 0, min( 100, (int) $atts['radius'] ) ), 'transition' => $transition_mode, 'infinite' => $infinite_mode, 'progress' => $progress_mode, 'title_tag' => (string) $atts['title_tag'], 'instance_css_vars' => $instance_css_vars, ); /** * Filter slider render config (per shortcode instance). * * Core keys are normalized; add-ons may merge extra keys for templates or scripts. * * @since 1.0.0 * * @param array $config Render config. * @param array $atts Parsed shortcode attributes. * @param array> $slides Slide data. */ $config = apply_filters( 'aha_hero_slider_render_config', $config, $atts, $slides ); ob_start(); aha_hero_slider_render( $slides, $slider_id, $config ); return (string) ob_get_clean(); } }