From d04bd6e0a15a03c592aa66c84bd221cf6a97e420 Mon Sep 17 00:00:00 2001 From: Bastien Ho <b@stienho.fr> Date: Tue, 24 Apr 2018 18:07:26 +0200 Subject: [PATCH] Do not parse shortcodes in REST context for PUT, POST and DELETE methods Signed-off-by: Kevin Cristiano <kcristiano@tadpole.cc> --- includes/civicrm.shortcodes.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/civicrm.shortcodes.php b/includes/civicrm.shortcodes.php index 556660919e..26e1b163cb 100644 --- a/includes/civicrm.shortcodes.php +++ b/includes/civicrm.shortcodes.php @@ -246,6 +246,16 @@ class CiviCRM_For_WordPress_Shortcodes { * @return string HTML for output */ public function render_single( $atts ) { + // Do not parse shortcodes in REST context for PUT, POST and DELETE methods + if(defined('REST_REQUEST') && REST_REQUEST && (isset($_PUT) || isset($_POST) || isset($_DELETE)) ){ + // Return the original shortcode + $shortcode = '[civicrm'; + foreach($atts as $att=>$val){ + $shortcode.=' '.$att.'="'.$val.'"'; + } + $shortcode.=']'; + return $shortcode; + } // check if we've already parsed this shortcode global $post; -- GitLab