Skip to content

Commit

Permalink
Fix issues with field, hasfield, isfield post ID parsing
Browse files Browse the repository at this point in the history
Switching to is_numeric to identify ID values from strings, since the blade template is always parsed as a string and is_string wasn't catching IDs.

Fixes Log1x#44
Fixes Log1x#63
  • Loading branch information
EHLOVader committed Nov 3, 2021
1 parent d4461df commit 374c00b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Directives/ACF.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

if (! empty($expression->get(2)) && ! is_string($expression->get(2))) {
if (! empty($expression->get(2)) && is_numeric($expression->get(2))) {
return "<?= get_field({$expression->get(0)}, {$expression->get(2)})[{$expression->get(1)}]; ?>";
}

if (! is_string($expression->get(1))) {
if (is_numeric($expression->get(1))) {
return "<?= get_field({$expression->get(0)}, {$expression->get(1)}); ?>";
}

Expand All @@ -79,11 +79,11 @@
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

if (! empty($expression->get(2)) && ! is_string($expression->get(2))) {
if (! empty($expression->get(2)) && is_numeric($expression->get(2))) {
return "<?php if (get_field({$expression->get(0)}, {$expression->get(2)})[{$expression->get(1)}]) : ?>";
}

if (! is_string($expression->get(1))) {
if (is_numeric($expression->get(1))) {
return "<?php if (get_field({$expression->get(0)}, {$expression->get(1)})) : ?>";
}

Expand All @@ -97,15 +97,15 @@
if (Str::contains($expression, ',')) {
$expression = Util::parse($expression);

if (! empty($expression->get(3)) && ! is_string($expression->get(2))) {
if (! empty($expression->get(3)) && is_numeric($expression->get(2))) {
return "<?php if (get_field({$expression->get(0)}, {$expression->get(3)})[{$expression->get(1)}] === {$expression->get(2)}) : ?>"; // phpcs:ignore
}

if (! empty($expression->get(2)) && ! is_string($expression->get(2))) {
if (! empty($expression->get(2)) && is_numeric($expression->get(2))) {
return "<?php if (get_field({$expression->get(0)}, {$expression->get(2)}) === {$expression->get(1)}) : ?>"; // phpcs:ignore
}

if (! empty($expression->get(2)) && is_string($expression->get(2))) {
if (! empty($expression->get(2)) && ! is_numeric($expression->get(2))) {
return "<?php if (get_field({$expression->get(0)})[{$expression->get(2)}] === {$expression->get(1)}) : ?>"; // phpcs:ignore
}

Expand Down

0 comments on commit 374c00b

Please sign in to comment.