Skip to content

Commit

Permalink
enhance(directives): Add support for customizing the @field format …
Browse files Browse the repository at this point in the history
…value (Fixes #43)
  • Loading branch information
Log1x committed Jul 29, 2023
1 parent 3e15669 commit 261ac55
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Directives/Acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,26 @@
$expression = Util::parse($expression);

if (Util::isIdentifier($expression->get(2))) {
return "<?php echo get_field({$expression->get(0)}, {$expression->get(2)})[{$expression->get(1)}]; ?>";
if (empty($expression->get(3))) {
$expression->put(3, 'true');
}

return "<?php echo get_field({$expression->get(0)}, {$expression->get(2)}, {$expression->get(3)})[{$expression->get(1)}]; ?>";
}

if (Util::isIdentifier($expression->get(1))) {
return "<?php echo get_field({$expression->get(0)}, {$expression->get(1)}); ?>";
if (empty($expression->get(2))) {
$expression->put(2, 'true');
}

return "<?php echo get_field({$expression->get(0)}, {$expression->get(1)}, {$expression->get(2)}); ?>";
}

if (empty($expression->get(2))) {
$expression->put(2, 'true');
}

return "<?php echo get_field({$expression->get(0)})[{$expression->get(1)}]; ?>";
return "<?php echo get_field({$expression->get(0)}, null, {$expression->get(2)})[{$expression->get(1)}]; ?>";
}

return "<?php echo get_field({$expression}); ?>";
Expand Down

0 comments on commit 261ac55

Please sign in to comment.