Skip to content

Commit

Permalink
feat: Add {{#evt}} function
Browse files Browse the repository at this point in the history
As `{{#ev}}` already supports named args, the `evt` hook is just an alias for `ev`
  • Loading branch information
octfx committed Oct 17, 2023
1 parent 979bacf commit 15062e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions EmbedVideo.i18n.magic.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

$magicWords['en'] = [
'ev' => [ 0, 'ev' ],
'evt' => [ 0, 'evt' ],
'evu' => [ 0, 'evu' ],
'evl' => [ 0, 'evl' ],
'vlink' => [ 0, 'vlink' ],
Expand Down
4 changes: 2 additions & 2 deletions includes/EmbedVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ private function parseArgs( array $args, bool $fromTag ): array {

$keys = array_keys( $supportedArgs );

$serviceName = array_shift( $args );
$serviceName = str_replace( 'service=', '', array_shift( $args ) ?? '' );

$counter = 0;

Expand Down Expand Up @@ -387,7 +387,7 @@ private function parseArgs( array $args, bool $fromTag ): array {
++$counter;
}

$supportedArgs['service'] = $serviceName ?? false;
$supportedArgs['service'] = empty( $serviceName ) ? false : $serviceName;

// An intentional weak check
if ( $supportedArgs['autoresize'] == true ) {
Expand Down
6 changes: 6 additions & 0 deletions includes/EmbedVideoHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ public function onParserFirstCallInit( $parser ): void {
Parser::SFH_OBJECT_ARGS
);

$parser->setFunctionHook(
'evt',
[ EmbedVideo::class, 'parseEV' ],
Parser::SFH_OBJECT_ARGS
);

$parser->setFunctionHook(
'evu',
[ EmbedVideo::class, 'parseEVU' ],
Expand Down

0 comments on commit 15062e2

Please sign in to comment.