}> */ public static function get_layouts() { /** * Filter: aha_orbit_testimonials_layouts * * Returns the list of available orbit layouts for the Layout selector. * Built-in layouts (default, grid, carousel) are registered via * aha_orbit_testimonials_register_builtin_layouts() in the main plugin file. * * Add your own layout by hooking into this filter: * * add_filter( 'aha_orbit_testimonials_layouts', function( $layouts ) { * $layouts['my_layout'] = array( * 'label' => __( 'My Layout', 'my-plugin' ), * 'template' => plugin_dir_path( __FILE__ ) . 'templates/my-layout.php', * 'supported_fields' => array( 'video_url' ), * ); * return $layouts; * } ); * * @since 1.0.0 * @param array $layouts */ return apply_filters( 'aha_orbit_testimonials_layouts', array() ); } /** * Get the layouts that support a given settings field dynamically. * * @since 1.1.1 * @param string $setting_name The name of the setting field. * @param string[] $default_layouts The default layout slugs supporting this setting. * @return string[] Layout slugs. */ public static function get_setting_layouts( $setting_name, $default_layouts = array() ) { return apply_filters( 'aha_orbit_testimonials_setting_layouts', $default_layouts, $setting_name ); } /** * Get the list of available card styles. * * @since 1.2.0 * @param string $layout Active layout slug. * @return array */ public static function get_card_styles( $layout = '' ) { $styles = array( 'default' => array( 'label' => __( 'Default', 'aha-orbit-testimonials' ), ), ); return apply_filters( 'aha_orbit_testimonials_card_styles', $styles, $layout ); } /** * Get the configuration for all testimonial fields. * * @return array */ public static function get_testimonial_fields() { return apply_filters( 'aha_orbit_testimonials_fields', array( 'name' => array( 'type' => 'text', 'label' => __( 'Name', 'aha-orbit-testimonials' ), 'required' => true, 'core' => true, 'sanitize_cb' => 'sanitize_text_field', ), 'role' => array( 'type' => 'text', 'label' => __( 'Role', 'aha-orbit-testimonials' ), 'required' => true, 'core' => true, 'sanitize_cb' => 'sanitize_text_field', ), 'text' => array( 'type' => 'textarea', 'label' => __( 'Text', 'aha-orbit-testimonials' ), 'required' => true, 'core' => true, 'sanitize_cb' => 'sanitize_textarea_field', ), 'image' => array( 'type' => 'image', 'label' => __( 'Image URL', 'aha-orbit-testimonials' ), 'description' => __( 'Optional. If left empty, the avatar will display the initials of the first and last name.', 'aha-orbit-testimonials' ), 'required' => false, 'core' => true, 'sanitize_cb' => 'esc_url_raw', ), 'company_logo' => array( 'type' => 'image', 'label' => __( 'Company Logo URL', 'aha-orbit-testimonials' ), 'description' => __( 'Optional. Displayed below the reviewer name if provided (displayed at 30px max height).', 'aha-orbit-testimonials' ), 'required' => false, 'core' => true, 'sanitize_cb' => 'esc_url_raw', ), 'rating' => array( 'type' => 'rating', 'label' => __( 'Star Rating', 'aha-orbit-testimonials' ), 'required' => false, 'core' => true, 'sanitize_cb' => 'floatval', ), 'pos_left' => array( 'type' => 'manual_pos', 'label' => __( 'X (Left %)', 'aha-orbit-testimonials' ), 'placeholder' => 'e.g. 20%', 'required' => false, 'core' => true, 'sanitize_cb' => 'sanitize_text_field', 'wrapper_class' => 'aha-orbit-col-half', 'show_if_layout_mode' => 'manual', ), 'pos_top' => array( 'type' => 'manual_pos', 'label' => __( 'Y (Top %)', 'aha-orbit-testimonials' ), 'placeholder' => 'e.g. 80%', 'required' => false, 'core' => true, 'sanitize_cb' => 'sanitize_text_field', 'wrapper_class' => 'aha-orbit-col-half', 'show_if_layout_mode' => 'manual', ), 'social_network' => array( 'type' => 'select', 'label' => __( 'Social Network', 'aha-orbit-testimonials' ), 'required' => false, 'core' => true, 'options' => array( '' => __( '— None —', 'aha-orbit-testimonials' ), 'facebook' => 'Facebook', 'instagram' => 'Instagram', 'linkedin' => 'LinkedIn', 'twitter' => 'X (Twitter)', 'youtube' => 'YouTube', 'tiktok' => 'TikTok', 'google' => 'Google', 'trustpilot' => 'Trustpilot', ), 'description' => __( 'If selected, a small social network badge will appear on the avatar.', 'aha-orbit-testimonials' ), 'sanitize_cb' => 'sanitize_key', ), 'social_link' => array( 'type' => 'url', 'label' => __( 'Social Profile Link', 'aha-orbit-testimonials' ), 'description' => __( 'Optional. If provided, the social badge on the avatar will be clickable.', 'aha-orbit-testimonials' ), 'required' => false, 'core' => true, 'sanitize_cb' => 'esc_url_raw', ), ) ); } /** * Add Meta Boxes. */ public function add_meta_boxes() { add_meta_box( 'aha_orbit_settings', __( 'Slider Settings', 'aha-orbit-testimonials' ), array( $this, 'render_settings_metabox' ), 'aha_orbit', 'normal', 'high' ); add_meta_box( 'aha_orbit_testimonials', __( 'Testimonials', 'aha-orbit-testimonials' ), array( $this, 'render_testimonials_metabox' ), 'aha_orbit', 'normal', 'high' ); } /** * Render Settings Metabox. * * @param WP_Post $post Post object. */ public function render_settings_metabox( $post ) { wp_nonce_field( 'aha_orbit_save_settings', 'aha_orbit_settings_nonce' ); $settings = get_post_meta( $post->ID, '_aha_orbit_settings', true ); $settings = wp_parse_args( (array) $settings, array( 'layout' => 'default', 'layoutMode' => 'auto', 'showArrows' => 'yes', 'showDots' => 'yes', 'autoplay' => 'yes', 'interval' => 5000, 'transitionSpeed' => 800, 'animationDelay' => 150, 'grayscale' => 'yes', 'draggable' => 'yes', 'containerHeight' => 450, 'grid_columns' => 3, 'carousel_columns' => 1, 'card_style' => 'default', 'audio_card_effect' => 'flip', // Default colour palette. 'card_bg' => '#ffffff', 'text_color' => '#1e293b', 'name_color' => '#3b82f6', 'role_color' => '#64748b', 'quote_color' => '#64748b', 'arrow_color' => '#64748b', 'bullet_color' => '#64748b', 'bullet_active_color' => '#3b82f6', ) ); $available_layouts = self::get_layouts(); ?>

/>

/>

/>

/>

/>

__( 'Card Background', 'aha-orbit-testimonials' ), 'text_color' => __( 'Testimonial Text', 'aha-orbit-testimonials' ), 'name_color' => __( 'Name', 'aha-orbit-testimonials' ), 'role_color' => __( 'Role / Function', 'aha-orbit-testimonials' ), 'quote_color' => __( 'Quote Icon', 'aha-orbit-testimonials' ), 'arrow_color' => __( 'Navigation Arrows', 'aha-orbit-testimonials' ), 'bullet_color' => __( 'Dot Indicators', 'aha-orbit-testimonials' ), 'bullet_active_color' => __( 'Active Dot', 'aha-orbit-testimonials' ), ); foreach ( $colour_fields as $key => $label ) : $field_id = 'aha_orbit_settings_' . $key; ?>
ID, $settings ); ?>
array of layout slugs. */ private static function render_field_html( $field_key, $config, $index_str, $item_data, $field_layout_map ) { $supported_layouts = ''; if ( empty( $config['core'] ) ) { $supported = $field_layout_map[ $field_key ] ?? array(); if ( empty( $supported ) ) { return; // No layout supports this field, skip it. } $supported_layouts = implode( ',', $supported ); } $layout_mode = ! empty( $config['show_if_layout_mode'] ) ? $config['show_if_layout_mode'] : ''; $value = isset( $item_data[ $field_key ] ) ? $item_data[ $field_key ] : ''; $custom_class = ! empty( $config['wrapper_class'] ) ? ' ' . $config['wrapper_class'] : ''; echo '
'; if ( 'image' === $config['type'] ) { echo '
'; echo '
'; $display = empty( $value ) && '{{INDEX}}' !== $index_str ? 'display:none;' : ''; if ( '{{INDEX}}' === $index_str ) { $display = 'display:none;'; } echo ''; echo '
'; $class_name = 'image' === $field_key ? 'aha-orbit-image-url' : 'aha-orbit-company-logo-url'; echo '
'; echo ''; echo ''; echo '
'; } elseif ( 'textarea' === $config['type'] ) { echo '
'; echo ''; } elseif ( 'rating' === $config['type'] ) { echo '
'; echo ''; } elseif ( 'select' === $config['type'] ) { echo '
'; echo ''; } elseif ( 'url' === $config['type'] ) { $placeholder = ! empty( $config['placeholder'] ) ? $config['placeholder'] : ''; echo '
'; echo ''; } else { // Default text input. (Including manual_pos) $placeholder = ! empty( $config['placeholder'] ) ? $config['placeholder'] : ''; echo '
'; echo ''; } if ( ! empty( $config['description'] ) ) { echo '

' . wp_kses_post( $config['description'] ) . '

'; } echo '
'; } /** * Render Testimonials Repeater Metabox. * * @param WP_Post $post Post object. */ public function render_testimonials_metabox( $post ) { $testimonials = get_post_meta( $post->ID, '_aha_orbit_testimonials_data', true ); if ( ! is_array( $testimonials ) ) { $testimonials = array(); } $fields = self::get_testimonial_fields(); $layouts = self::get_layouts(); $field_layout_map = array(); foreach ( $layouts as $slug => $data ) { if ( ! empty( $data['supported_fields'] ) ) { foreach ( $data['supported_fields'] as $fk ) { $field_layout_map[ $fk ][] = $slug; } } } ?>
sanitize_key( $settings_raw['layout'] ?? 'default' ), 'layoutMode' => sanitize_text_field( $settings_raw['layoutMode'] ?? 'auto' ), 'showArrows' => isset( $settings_raw['showArrows'] ) ? 'yes' : 'no', 'showDots' => isset( $settings_raw['showDots'] ) ? 'yes' : 'no', 'autoplay' => isset( $settings_raw['autoplay'] ) ? 'yes' : 'no', 'interval' => absint( $settings_raw['interval'] ?? 5000 ), 'transitionSpeed' => absint( $settings_raw['transitionSpeed'] ?? 800 ), 'animationDelay' => absint( $settings_raw['animationDelay'] ?? 150 ), 'grayscale' => isset( $settings_raw['grayscale'] ) ? 'yes' : 'no', 'draggable' => isset( $settings_raw['draggable'] ) ? 'yes' : 'no', 'containerHeight' => absint( $settings_raw['containerHeight'] ?? 450 ), 'grid_columns' => absint( $settings_raw['grid_columns'] ?? 3 ) ?: 3, 'carousel_columns' => absint( $settings_raw['carousel_columns'] ?? 1 ) ?: 1, 'card_style' => sanitize_key( $settings_raw['card_style'] ?? 'default' ), 'audio_card_effect' => sanitize_key( $settings_raw['audio_card_effect'] ?? 'flip' ), ), $colours ); update_post_meta( $post_id, '_aha_orbit_settings', $settings_sanitized ); } // Save Testimonials if ( isset( $_POST['aha_orbit_testimonials'] ) && is_array( $_POST['aha_orbit_testimonials'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- values are sanitized individually below. $testimonials_raw = wp_unslash( $_POST['aha_orbit_testimonials'] ); $testimonials_sanitized = array(); $fields = self::get_testimonial_fields(); foreach ( $testimonials_raw as $item ) { // Base check for required fields $has_required = true; foreach ( $fields as $key => $config ) { if ( ! empty( $config['required'] ) && empty( $item[ $key ] ) ) { $has_required = false; break; } } if ( $has_required ) { $sanitized_item = array(); foreach ( $fields as $key => $config ) { $raw_val = isset( $item[ $key ] ) ? $item[ $key ] : ''; $sanitize_cb = $config['sanitize_cb'] ?? 'sanitize_text_field'; if ( is_callable( $sanitize_cb ) ) { $sanitized_item[ $key ] = call_user_func( $sanitize_cb, $raw_val ); } else { $sanitized_item[ $key ] = sanitize_text_field( $raw_val ); } } $testimonials_sanitized[] = $sanitized_item; } } update_post_meta( $post_id, '_aha_orbit_testimonials_data', $testimonials_sanitized ); } else { delete_post_meta( $post_id, '_aha_orbit_testimonials_data' ); } } }