*/ function aha_hero_slider_get_templates() { $templates = array( 'default' => array( 'slug' => 'default', 'label' => __( 'Default', 'aha-hero-slider' ), 'description' => __( 'Text content with buttons over a background image.', 'aha-hero-slider' ), 'icon' => 'dashicons-editor-alignleft', ), 'image_only' => array( 'slug' => 'image_only', 'label' => __( 'Image only', 'aha-hero-slider' ), 'description' => __( 'Full background image with an optional link.', 'aha-hero-slider' ), 'icon' => 'dashicons-format-image', ), ); /** * Filter the registered slide templates. * * Add-ons can register new templates by adding entries to the array. * Each entry must include at least `slug` and `label`. * * @since 1.0.0 * * @param array $templates Registered templates keyed by slug. */ return apply_filters( 'aha_hero_slider_templates', $templates ); } /** * Get all valid layout slugs. * * @since 1.0.0 * * @return string[] */ function aha_hero_slider_get_valid_layouts() { return array_keys( aha_hero_slider_get_templates() ); } /** * Check whether a layout slug is registered. * * @since 1.0.0 * * @param string $slug Layout slug. * @return bool */ function aha_hero_slider_is_valid_layout( $slug ) { return in_array( $slug, aha_hero_slider_get_valid_layouts(), true ); } /** * Normalize a layout slug: returns the slug if valid, otherwise 'default'. * * @since 1.0.0 * * @param string $raw Raw layout value. * @return string */ function aha_hero_slider_normalize_layout( $raw ) { return aha_hero_slider_is_valid_layout( $raw ) ? $raw : 'default'; } /** * Which slide meta box sections are visible for a layout (IDs without the `aha-hero-section-` prefix). * * Add-ons extend via {@see 'aha_hero_slider_layout_meta_section_ids'}. * * @since 1.0.0 * * @param string $layout_slug Registered layout slug. * @return string[] */ function aha_hero_slider_get_layout_meta_section_ids( $layout_slug ) { $layout_slug = is_string( $layout_slug ) ? $layout_slug : ''; $map = array( 'default' => array( 'texts', 'buttons', 'mobile', 'media', 'advanced' ), 'image_only' => array( 'links-image-only', 'media', 'advanced' ), ); $ids = isset( $map[ $layout_slug ] ) ? $map[ $layout_slug ] : array(); /** * Filter section keys shown in the slide meta box for a layout. * * Core keys: `texts`, `buttons`, `mobile`, `links-image-only`, `media`, `advanced`. * Pro adds: `pro-video`, `pro-video-full-extra`. * * @since 1.0.0 * * @param string[] $ids Section keys (may be empty for unknown layouts). * @param string $layout_slug Layout slug. */ $ids = apply_filters( 'aha_hero_slider_layout_meta_section_ids', $ids, $layout_slug ); if ( $ids === array() && aha_hero_slider_is_valid_layout( $layout_slug ) ) { return array( 'media', 'advanced' ); } return is_array( $ids ) ? array_values( array_unique( array_filter( array_map( 'strval', $ids ) ) ) ) : array(); } /** * Mobile image hint variant for the slide editor (`default` vs `image-only` strips). * * @since 1.0.0 * * @param string $layout_slug Layout slug. * @return string `default` or `image-only`. */ function aha_hero_slider_get_layout_meta_mobile_hint( $layout_slug ) { $layout_slug = is_string( $layout_slug ) ? $layout_slug : ''; $map = array( 'image_only' => 'image-only', 'video_full' => 'image-only', ); $hint = isset( $map[ $layout_slug ] ) ? $map[ $layout_slug ] : 'default'; /** * Filter mobile hint variant for the slide meta box. * * @since 1.0.0 * * @param string $hint `default` or `image-only`. * @param string $layout_slug Layout slug. */ $hint = (string) apply_filters( 'aha_hero_slider_layout_meta_mobile_hint', $hint, $layout_slug ); return in_array( $hint, array( 'default', 'image-only' ), true ) ? $hint : 'default'; }