Last active
February 20, 2020 18:05
-
-
Save bordoni/1a81670f0cdd66bb1ed437c05a0337a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: The Events Calendar Extension: Missing Events Single JSON-LD | |
* Plugin URI: https://theeventscalendar.com/extensions/---the-extension-article-url---/ | |
* GitHub Plugin URI: https://github.com/mt-support/tribe-ext-extension-template | |
* Description: Makes sure JSON-LD is present on Single Event for V2. | |
* Version: 1.0.0 | |
* Author: Modern Tribe, Inc. | |
* Author URI: http://m.tri.be/1971 | |
* License: GPL version 3 or any later version | |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html | |
* Text Domain: tribe-ext-v2-single-event-json-ld | |
* | |
* This plugin is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* any later version. | |
* | |
* This plugin is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
*/ | |
add_action( 'wp', function() { | |
if ( ! class_exists( 'Tribe__Events__JSON_LD__Event' ) ) { | |
return; | |
} | |
if ( ! class_exists( 'Tribe__Events__Main' ) ) { | |
return; | |
} | |
// Check if we are in a single page. | |
if ( ! is_singular( Tribe__Events__Main::POSTTYPE ) ) { | |
return; | |
} | |
$context = tribe_context(); | |
// One more check for our Post Type. | |
if ( ! $context->is( 'tec_post_type' ) ) { | |
return; | |
} | |
// Bail when that action already exists. | |
if ( has_action( 'wp_head', [ Tribe__Events__JSON_LD__Event::instance(), 'markup' ] ) ) { | |
return; | |
} | |
// Print JSON-LD markup on the`wp_head` | |
add_action( 'wp_head', [ Tribe__Events__JSON_LD__Event::instance(), 'markup' ] ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download Extension Link:
https://s3.theeventscalendar.com/uploads/2020/02/tribe-ext-v2-single-event-json-ld.1.0.0.zip