• Resolved vlad13

    (@vlad13)


    Hi there,
    I tried posting this to another thread, however it is marked resolved and I am not sure if you happened to notice the request, so here’s a repost:

    Can you implement a change that would allow having php code inside HTML fragments?

    All you need to do is replace the following block of code inside the “gcb” function:

    if($entry['type']!="php") {
    	return apply_filters('gcb_block_output', do_shortcode($content));//make sure we also run the shortcodes in here
    }
    else
    {
    	//execute the php code
    	ob_start();
    	$result = eval(" ".$content);
    	$output = ob_get_contents();
    	ob_end_clean();
    	return apply_filters('gcb_block_output', do_shortcode($output . $result));//run the shortcodes as well
    }

    with

    if($entry['type'] == "php") {
        //execute the php code
        ob_start();
        $result = eval(" ".$content);
        $output = ob_get_contents();
        ob_end_clean();
        return apply_filters('gcb_block_output', do_shortcode($output . $result));//run the shortcodes as well
    }
    elseif($entry['type'] == "html") {   // alloyphoto: enable PHP code in < ?php ... ? > tags inside blocks
        ob_start();
        eval("?>$content<?php ");
        $output = ob_get_contents();
        ob_end_clean();
        return apply_filters('gcb_block_output', do_shortcode($output));//run the shortcodes as well
    }
    else
    {
        return apply_filters('gcb_block_output', do_shortcode($content));//make sure we also run the shortcodes in here
    }

    Thanks!

    https://www.ads-software.com/plugins/global-content-blocks/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP code inside HTML blocks’ is closed to new replies.