Kevin Barsotti
Forum Replies Created
-
Forum: Plugins
In reply to: [Blog Manager Light] Featured images won’t showI know that I am not the plugin developer, but I came upon this same issue and was able to resolve it by adding an additional line to the otw_dispatcher.php script referenced in the warning message. It seems to be a compatibility issue related to PHP 7.0.
Lines 192 and 193 of otw_dispatcher.php look like this:
$postMetaData['media_type'] = 'wp-native'; $postMetaData['featured_img'] = $postAttachement;
To correct the issue, I prepended (that is to say, inserted before) an additional line of script before the problem lines. My fixed version (now lines 192, 193, and 194) looks like this:
$postMetaData = array(); $postMetaData['media_type'] = 'wp-native'; $postMetaData['featured_img'] = $postAttachement;
For some reason, after transitioning to a hosted environment running PHP7, the above block of logic stopped automagically assuming an array when those two values were assigned, almost as if the script had spontaneously developed stronger typing. By explicitly declaring it as an array just prior to assignment things started working again.
In the latest release I found that the warning can be eliminated by replacing this code block (beginning on
line 56 of frontend/class-frontend.php
):if ( isset( $this->options['ignore_users'] ) ) { if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) { return false; } }
With the following code block:
if ( isset( $this->options['ignore_users'] ) ) { if ( is_array( $this->options['ignore_users'] ) ) { if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) { return false; } } }
What is going on here is that the expected value of
$this->options['ignore_users']
Is an array (the data type) while the actual value is “
array
” (the 5-character string). There is no case set up to handle the variable in question being instantiated but not containing array-type data.A quick and dirty fix (that doesn’t involve commenting out potentially functional logic) would be replacing the following code block (starting at line 56 of
wp-content/plugins/google-analytics-for-wordpress/frontend/class-frontend.php)
:if ( isset( $this->options['ignore_users'] ) ) { if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) { return false; } else { return true; } } else { return true; }
With this code-block:
if ( isset( $this->options['ignore_users'] ) ) { if ( is_array($this->options['ignore_users'] ) ) { if ( ! empty( $current_user->roles ) && in_array( $current_user->roles[0], $this->options['ignore_users'] ) ) { return false; } else { return true; } } else { return true; } } else { return true; }
Which causes it to not only check if
$this->options['ignore_users']
is set, but also if it contains proper array-format data.It should be noted that the aforementioned fix entirely bypasses deeper questions of what’s causing the faulty data in the variable.