PHP warnings with ACF Pro
-
I am getting two warnings in the Apache error log that are caused by treating ACF Pro fields as strings, which they sometimes are not, apparently.
Warning #1:
PHP message: PHP Warning: strpos() expects parameter 1 to be string, array given in /wp-content/plugins/prismatic/inc/resources-enqueue.php on line 353
Line 353 looks like this:
if (strpos($value, $cls) !== false) {
The following crude fix seems to work, but there might be more elegant solutions:
if (is_string($value) && strpos($value, $cls) !== false) {
Warning #2:
PHP message: PHP Warning: preg_split() expects parameter 2 to be string, array given in /wp-content/plugins/prismatic/inc/prismatic-core.php on line 28
Line 28 looks like this:
$split = preg_split("/(<code[^>]*>.*<\/code>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
I am guessing this happens when
$text
holds an ACF Pro field value.
- The topic ‘PHP warnings with ACF Pro’ is closed to new replies.