\WP_Stager_Integration\Shortcodes::callback_wpstager_ticket_shop_widget(array $atts = array(), string $content = ''): string
\WP_Stager_Integration\Shortcodes::callback_wpstager_ticket_shop_widget(array $atts = array(), string $content = ''): stringDescription
Callback for [wpstager_ticket_shop_widget] shortcode.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$atts | array | Shortcode attributes. |
$content | string | Shortcode content. |
Returns:
string Shortcode output HTML.
Information
| File | class-shortcodes.php line 410 |
|---|---|
| See also |
Full Code
/**
* Callback for <code>[wpstager_ticket_shop_widget]</code> shortcode.
*
* @param array $atts Shortcode attributes.
* @param string $content Shortcode content.
*
* @return string Shortcode output HTML.
*
* @see \WP_Stager_Integration\Component::render_ticket_shop_widget_event()
* @see \WP_Stager_Integration\Component::render_ticket_shop_widget_basket()
* @see \WP_Stager_Integration\Component::render_ticket_shop_widget_order()
*/
public static function callback_wpstager_ticket_shop_widget( $atts = array(), $content = '' ) {
// Get data
$has_feature_ticket_shops = (bool) Options::has_ticket_shops();
// Bail if feature is not enabled
if ( ! $has_feature_ticket_shops ) {
return;
}
// Parse args with defaults matching block.json
$args = wp_parse_args( $atts, array(
'integration_type' => 'advanced',
'render_type' => 'basket',
'initial_load_page' => 'events',
'cookie_banner_enabled' => true,
'cookie_banner_render_type' => 'default',
'width' => '',
'height' => '',
'auto_scaling' => true,
'event_id' => 0,
'shop_id' => 0,
'basket_button_enabled' => true,
'basket_button_label' => '',
'order_button_enabled' => true,
'order_button_label' => '',
) );
// Get data
$widget_type = (string) ( $args[ 'type' ] ?? 'basket' );
// Remove 'type' from args since it's not needed downstream
unset( $args[ 'type' ] );
// Set integration type based on widget type
if ( 'basic' === $widget_type || 'basic' === $args[ 'integration_type' ] ) {
$args[ 'widget_type' ] = 'basic';
$args[ 'integration_type' ] = 'basic';
} else {
$args[ 'integration_type' ] = 'advanced';
}
// Define attributes that should be passed directly in args (not under widget_options key)
$direct_args_attributes = array(
'basket_button_enabled',
'basket_button_label',
'order_button_enabled',
'order_button_label',
);
// Convert snake_case attributes to camelCase since Stager JS expects camelCase
$direct_args = array();
$widget_options = array();
foreach ( $args as $key => $value ) {
// Skip direct args attributes
if ( in_array( $key, $direct_args_attributes ) ) {
$direct_args[ $key ] = $value;
continue;
}
// If key contains an underscore, convert to camelCase
if ( strpos( $key, '_' ) !== false ) {
// Convert snake_case to camelCase
$camel_key = lcfirst( str_replace( ' ', '', ucwords( str_replace( '_', ' ', $key ) ) ) );
$widget_options[ $camel_key ] = $value;
} else {
// Keep as is if no underscore
$widget_options[ $key ] = $value;
}
}
// Parse attributes into args structure (includes widget_type determination)
$parsed_args = Ticket_Shop::parse_widget_attributes( $widget_options );
$widget_type = $parsed_args[ 'widget_type' ];
ob_start();
Ticket_Shop::render_widget_type( $widget_type, $parsed_args );
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!

