Tribe__Tickets__JSON_LD__Type::markup( mixed|null $post = null, array $args = array() )
Function called by the wp_head hook to attach the markup into the page if that’s the case, once does the setup calls the parent method to do the work to generate the script.
Contents
Parameters
- $post
-
(mixed|null) (Optional) The ID of the post or array of posts
Default value: null
- $args
-
(array) (Optional) The arguments used to register the data on this type
Default value: array()
Return
(mixed|void)
Source
File: src/Tribe/JSON_LD/Type.php
public function markup( $post = null, $args = array() ) {
// Is not a the single view of a post type
if ( ! is_singular() ) {
return;
}
$post_type = get_post_type();
// The post type is the Event type so this is done already not need to be done for this type
if ( class_exists( 'Tribe__Events__Main' ) && $post_type === Tribe__Events__Main::POSTTYPE ) {
return;
}
// Does this post has tickets?
if ( ! tribe_events_has_tickets( get_the_ID() ) ) {
return;
}
/**
* This will allow you to change the type for the Rich Snippet, by default it will use the type Product for
* any Post type or Page. If this is runs in a book post type the filter becomes something like.
*
* @example tribe_events_json_ld_book_type
*
* @see http://schema.org/Product
*
* @see https://developers.google.com/structured-data/rich-snippets/
*
* @since 4.7.1
*
* @param string $post_type The name fo the registered post type
*/
$this->type = apply_filters( "tribe_tickets_json_ld_{$post_type}_type", 'Product' );
parent::markup();
}
Changelog
| Version | Description |
|---|---|
| 4.7.1 | Introduced. |