feat(wpmc S3): Helpers::alt_get_field with do_shortcode + filter
Implements alt_get_field(): applies wpmc_alt_get_field_post_id filter for
post_id remapping, guards against missing ACF, runs do_shortcode on string
results, passes arrays/null through unchanged. 4 new tests; full suite
22 tests / 58 assertions green.
Note: Brain Monkey FunctionStub::__construct calls function_exists()
internally; expect() calls must precede when('function_exists')->alias()
in each test to avoid the alias intercepting the stub-creation check and
causing eval redeclaration errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -72,4 +72,14 @@ final class Helpers
|
||||
$parts = array_values(array_filter(explode('/', $path), static fn(string $p) => $p !== ''));
|
||||
return $parts[0] ?? null;
|
||||
}
|
||||
|
||||
public static function alt_get_field(string $selector, $post_id = false, bool $format_value = true)
|
||||
{
|
||||
$post_id = \apply_filters('wpmc_alt_get_field_post_id', $post_id, $selector);
|
||||
if (!\function_exists('get_field')) {
|
||||
return null;
|
||||
}
|
||||
$value = \get_field($selector, $post_id, $format_value);
|
||||
return is_string($value) ? \do_shortcode($value) : $value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user