Exemplo n.º 1
0
function do_shortcode_php($content)
{
    if (strpos($content, '{{php}}') === false) {
        return $content;
    }
    global $config, $speak;
    return preg_replace_callback('#(?<!`)\\{\\{php\\}\\}(?!`)([\\s\\S]*?)(?<!`)\\{\\{\\/php\\}\\}(?!`)#', function ($matches) use($config, $speak) {
        return Converter::phpEval($matches[1], array('config' => $config, 'speak' => $speak));
    }, $content);
}
Exemplo n.º 2
0
            $key = preg_replace_callback('#%\\\\\\[(.*?)\\\\\\]#', function ($matches) {
                return '(' . str_replace(',', '|', $matches[1]) . ')';
            }, $key);
        }
        // %s: accept any values without line breaks
        // %S: accept any values with/without line breaks
        // %i: accept integer numbers
        // %f: accept float numbers
        // %b: accept boolean values
        $key = str_replace(array('%s', '%S', '%i', '%f', '%b'), array('(.+?)', '([\\s\\S]+?)', '(\\d+?)', '((?:\\d*\\.)?\\d+?)', '\\b(TRUE|FALSE|YES|NO|ON|OFF|true|false|yes|no|on|off|1|0)\\b'), $key);
        $value = str_replace(array('\\n', '\\r', '\\t'), array("\n", "\r", "\t"), $value);
        $content = preg_replace('#(?<!`)' . $key . '(?!`)#', $value, $content);
    }
    if (strpos($content, '{{php}}') !== false) {
        $content = preg_replace_callback('#(?<!`)\\{\\{php\\}\\}(?!`)([\\s\\S]*?)(?<!`)\\{\\{\\/php\\}\\}(?!`)#', function ($matches) {
            return Converter::phpEval($matches[1]);
        }, $content);
    }
    return $content;
}, 20);
// YOU ARE HERE! -- You can specify your own shortcode priority to be greater
// than the default shortcode file priority, but lesser than the shortcode
// deactivation priority by determining the shortcode priority between 20 - 30
Filter::add('shortcode', function ($content) {
    if (strpos($content, '`{{') === false) {
        return $content;
    }
    return str_replace(array('`{{', '}}`'), array('{{', '}}'), $content);
}, 30);
/**
 * Other(s)