You are here

function _xbbcode_custom_eval in Extensible BBCode 8

Same name and namespace in other branches
  1. 8.2 xbbcode.module \_xbbcode_custom_eval()
  2. 7 xbbcode.module \_xbbcode_custom_eval()

Rendering callback for dynamic custom tags (PHP evaluated).

1 string reference to '_xbbcode_custom_eval'
xbbcode_xbbcode_info in ./xbbcode.module
Implements hook_xbbcode_info().

File

./xbbcode.module, line 233
The main module file containing hook implementations.

Code

function _xbbcode_custom_eval($tag_data, $xbbcode_filter) {
  if (module_exists('php')) {
    global $tag;
    $tag = $tag_data;
    module_load_include('inc', 'xbbcode', 'xbbcode.crud');

    // Insert the $tag variable into the evaluated code's scope.
    $code = '<?php global $tag; ?>' . xbbcode_custom_tag_load($tag->name)->markup;
    $output = php_eval($code);
    unset($tag);
    return $output;
  }
}