Mecha CMS

Mecha CMS blog and documentation.

Disabling the {{php}} Shortcode

Updated: Sunday, 07 August 2016

How to disable the {{php}} shortcode?

The {{php}} shortcode that is prone to be misused should be regulated so that it does not harm you, especially if you have multiple users in one website. If you ever need to turn off the feature, you can use this filter to remove the shortcode pattern before it is being executed:

Filter::add('content_raw', function($content) {
    return str_replace(array('{{php}}', '{{/php}}'), "", $content);
}, 1);

This is the way to disable the shortcode for all users except admin:

if(Guardian::happy() && Guardian::get('user') !== 'admin') {
    Filter::add('content_raw', function($content) {
        return str_replace(array('{{php}}', '{{/php}}'), "", $content);
    }, 1);
}
Donation and Email Subscription