echo $manager->doShortcode('[nest]My email is [mail address=test@test.com], and the date is [d/][/mail][/nest]', 'nest|d', true) . '<br><br>'; /* * Let's get rid of 'm' and use it for something else * */ echo $manager->deregister('m')->register(new SimpleShortcode('m', null, function () { return 'M is pretty fantastic'; }))->doShortcode('My opinion on the letter "M": [m]') . '<br><br>'; /* * Let's go even further * Let's deregister the original [date] shortcode, but keep its alias * The second parameter allows us to prevent deregistration of a given shortcode's aliases * */ echo $manager->deregister('date', false)->doShortcode('Today is [d], not "[date]"') . '<br><br>'; /* * There are also a few shorthand methods! * Registration and Deregistration may be performed using the manager's ArrayAccess Implementation * There is also a doShortcode method for Shortcode Classes that will allow you to run the manager against only that particular shortcode and its aliases * Aliasing is also availble to SimpleShortcode, and Shortcodes that implement AliasInterface * */ $bold = new SimpleShortcode('bold', null, function ($content) { return sprintf('<strong>%s</strong>', $content); }); $manager[] = $bold; //Shorthand register $bold->alias('b'); //Register an alias directly on a shortcode echo $bold->doShortcode('[nest][bold]Bold Text[/bold] [b]More Bold Text[/b][/nest]') . '<br><br>'; //Run doShortocde directly on a Shortcode and its aliases unset($manager['bold']); //Deregister a shortcode and all of its aliases echo $bold->doShortcode('[nest][bold]Not so bold text[/bold], [b]or this[/b][/nest]') . '<br><br>';
/** * @expectedException \Maiorano\Shortcodes\Exceptions\RegisterException * @expectedExceptionMessage No shortcode with identifier 'test' has been registered */ public function testShorthandError() { $test = new Library\SimpleShortcode('test'); $test->doShortcode('[test]'); }