Corcel\Post::addShortcode PHP Метод

addShortcode() публичный статический Метод

Add a shortcode handler
public static addShortcode ( string $tag, function $function )
$tag string the shortcode tag
$function function the shortcode handling function
    public static function addShortcode($tag, $function)
    {
        self::$shortcodes[$tag] = $function;
    }

Usage Example

Пример #1
0
 public function testAddShortcode()
 {
     Post::addShortcode('gallery', function (ShortcodeInterface $s) {
         return $s->getName() . '.' . $s->getParameter('id') . '.' . $s->getParameter('size');
     });
     $post = Post::find(123);
     $this->assertEquals($post->content, 'test gallery.123.medium shortcodes');
 }