Conflict with Smart Slider 3 and code improvement suggestion
-
Hi @modcodingcom,
I’m the developer of Smart Slider 3. We use ob_start function like you do in your plugin. I started to collection usage of output buffering examples in different plugins and it seems like you use different method. Here you can check my collection: https://github.com/nextend/wp-ob-plugins-themes/blob/master/README.md
As you can see all of the popular plugins use template_redirect action to start their output buffers. Using template_include instead will result plugin conflict with other plugins.
Your original code:
function mcgfuidgen_head(){ @ob_start(); } function mcgfuidgen_footer(){ $s = @ob_get_clean(); $form_id = 0; if ($ar = mcgfuidgen_GetStringBetweenTags("gform_fields_","'",$s)) $form_id = (int)@$ar[0]; if ($form_id > 0) { // some form rendered $GLOBALS['MCGF_FRONT_INIT'] = 1; // render required scripts for front view of submission pages of the form mcgfuidgen_post_paging(array("id" => $form_id),1,1); } echo $s; } add_action('init', 'mcgfuidgen_head', 0); add_action('wp_footer', 'mcgfuidgen_footer', PHP_INT_MAX);
You just need to use
template_redirect
action with high priority instead of the init action, so the suggested code:function mcgfuidgen_head(){ @ob_start(); } function mcgfuidgen_footer(){ $s = @ob_get_clean(); $form_id = 0; if ($ar = mcgfuidgen_GetStringBetweenTags("gform_fields_","'",$s)) $form_id = (int)@$ar[0]; if ($form_id > 0) { // some form rendered $GLOBALS['MCGF_FRONT_INIT'] = 1; // render required scripts for front view of submission pages of the form mcgfuidgen_post_paging(array("id" => $form_id),1,1); } echo $s; } add_action('template_redirect', 'mcgfuidgen_head', PHP_INT_MAX ); add_action('wp_footer', 'mcgfuidgen_footer', PHP_INT_MAX);
- The topic ‘Conflict with Smart Slider 3 and code improvement suggestion’ is closed to new replies.