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
파일: PostTest.php 프로젝트: jgrossi/corcel
 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');
 }