\WP_Stager_Integration\Event::output_structured_data(array $event = null): void
\WP_Stager_Integration\Event::output_structured_data(array $event = null): voidDescription
Outputs structured data as a JSON-LD script element.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$event | array | (Optional) The raw Stager event data. Defaults to the event data of the currently viewed event page. |
Returns:
void
Information
| File | class-event.php line 1476 |
|---|
Full Code
/**
* Outputs structured data as a JSON-LD script element.
*
* @param array $event (Optional) The raw Stager event data. Defaults to the event data of the currently viewed event page.
*
* @return void
*/
public static function output_structured_data( $event = null ) {
/**
* Filters whether to output structured data.
*
* Allows users to disable the output of structured data by returning <code>false</code>.
*
* @param bool $output Whether to output structured data.
*
* @return bool Whether to output structured data.
*/
$output = (bool) apply_filters( 'wpstagerintegration_output_structured_data', true );
// Bail if output is disabled
if ( ! $output ) {
return;
}
// Get data
$feature_enabled_seo_features = (bool) Feature::has_feature_seo_features();
// Bail if feature is not enabled
if ( ! $feature_enabled_seo_features ) {
return;
}
// Fallback to event data of currently viewed event page
if ( null == $event ) {
$event = (array) self::get_single_event_data();
} else {
// Type casting
$event = (array) $event;
}
// Generate structured data
$structured_data = (array) (self::generate_structured_data( $event ) ?: array());
// Bail if no structured data was generated
if ( ! $structured_data ) {
return;
}
// Output schema
echo '<script type="application/ld+json">' . Utility::esc_json_encode( $structured_data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) . '</script>';
}💡 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!

