Created
June 14, 2018 13:58
-
-
Save BramEsposito/636560d90b88940c4bb5286410b8afec to your computer and use it in GitHub Desktop.
patch Events Manager Wordpress plugin to allow [gallery] shortcode overrides
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
From 5ad8723a1b7acb8b04bbe38824f00b930b703293 Mon Sep 17 00:00:00 2001 | |
From: Bram Esposito <[email protected]> | |
Date: Tue, 5 Jun 2018 14:22:00 +0200 | |
Subject: [PATCH] patch events manager wrt gallery issues | |
--- | |
wp-content/plugins/events-manager/classes/em-event.php | 12 +++++++++++- | |
1 file changed, 11 insertions(+), 1 deletion(-) | |
diff --git a/wp-content/plugins/events-manager/classes/em-event.php b/wp-content/plugins/events-manager/classes/em-event.php | |
index c91b1a06..32cd6ef4 100644 | |
--- a/wp-content/plugins/events-manager/classes/em-event.php | |
+++ b/wp-content/plugins/events-manager/classes/em-event.php | |
@@ -3104,6 +3104,8 @@ if ( is_object($GLOBALS['wp_embed']) ){ | |
*/ | |
function em_event_gallery_override( $attr = array() ){ | |
global $post; | |
+ | |
+ global $old_gallery; | |
if( $post->post_type == EM_POST_TYPE_EVENT && empty($attr['id']) && empty($attr['ids']) ){ | |
//no id specified, so check if it's recurring and override id with recurrence template post id | |
$EM_Event = em_get_event($post->ID, 'post_id'); | |
@@ -3111,9 +3113,17 @@ function em_event_gallery_override( $attr = array() ){ | |
$attr['id'] = $EM_Event->get_event_recurrence()->post_id; | |
} | |
} | |
- return gallery_shortcode($attr); | |
+ if ($old_gallery != "") { | |
+ return call_user_func($old_gallery, $attr); | |
+ } else { | |
+ return gallery_shortcode($attr); | |
+ } | |
} | |
function em_event_gallery_override_init(){ | |
+ global $shortcode_tags; | |
+ global $old_gallery; | |
+ | |
+ $old_gallery = $shortcode_tags['gallery']; | |
remove_shortcode('gallery'); | |
add_shortcode('gallery', 'em_event_gallery_override'); | |
} | |
-- | |
2.16.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment