\WP_Stager_Integration\Shortcodes::callback_wpstager_event_page_component(array $atts = array(), string $content = ''): string

Description

Callback for [wpstager_event_page_component] shortcode.

Maps the shortcode type attribute to the corresponding \WP_Stager_Integration\Component rendering method.

Parameters:

ParameterTypeDescription
$atts array Shortcode attributes.
$content string Shortcode content.

Returns:

string Shortcode output HTML.

Information

Fileclass-shortcodes.php line 504

Full Code

/**
 * Callback for <code>[wpstager_event_page_component]</code> shortcode.
 *
 * Maps the shortcode <code>type</code> attribute to the corresponding
 * <code>\WP_Stager_Integration\Component</code> rendering method.
 *
 * @param array  $atts   Shortcode attributes.
 * @param string $content Shortcode content.
 *
 * @return string Shortcode output HTML.
 */
public static function callback_wpstager_event_page_component( $atts = array(), $content = '' ) {

    $methods = array(
        'featured_image'  => 'render_event_featured_image',
        'name'            => 'render_event_name',
        'subtitle'        => 'render_event_subtitle',
        'labels'          => 'render_event_labels',
        'meta_table'      => 'render_event_meta_table',
        'content'         => 'render_event_content',
        'tickets'         => 'render_event_tickets',
        'location'        => 'render_event_location',
        'regular_urls'    => 'render_event_regular_urls',
        'program'         => 'render_event_program',
        'spotify_artists' => 'render_event_spotify_artists',
        'gallery'         => 'render_event_gallery',
        'videos'          => 'render_event_videos',
        'audio'           => 'render_event_audio',
    );

    // Type casting
    $atts = (array) $atts;

    // Get data
    $type   = (string) ( $atts[ 'type' ] ?? '' );
    $method = (string) ( $methods[ $type ] ?? '' );

    // Bail if method is not set or not callable
    if ( ! $method || ! is_callable( array( Component::class, $method ) ) ) {
        return '';
    }

    ob_start();
    Component::$method();
    return ob_get_clean();
}

💡 If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration

🎁 Limited offer: Use code WELCOME26 to get your first month for free!