1
votes

i'm getting this warning in apache logs each time i visit my wordpress site:

[error] [client myiphere] PHP Warning: implode(): Invalid arguments passed in /var/www/mysitepath/wp-content/themes/mytheme/noscript/views/list-view.php on line 16, referer: http://www.example.com/

Here is a part of list-view.php:

<?php
$mytheme = mytheme::getInstance();
$currentContentLayout = $mytheme->WPData['currentContentLayout'];
$contentLayout = $mytheme->settings->contentLayouts->{$currentContentLayout};
$headerClasses = array();
if('no' == $contentLayout->metaPosition){
    $headerClasses = 'no-meta';
} else {
    $headerClasses[] = 'meta-' . $contentLayout->metaPosition;
}
?>
<div class="mytheme-list-view row">
    <div class="large-12 columns">
        <?php while(have_posts()){ the_post();?>
        <article id="post-<?php the_ID();?>" <?php post_class();?> data-mytheme-post-from-id="<?php the_ID();?>">
            <header class="entry-header <?php echo implode(' ', $headerClasses);?>">
...
...

Is there anything wrong with the code? Thanks

2

2 Answers

5
votes

You need to change this line:

$headerClasses = 'no-meta';

To this:

$headerClasses[] = 'no-meta';

The problem occurs when $headerClasses is a string, as implode() takes an array as the second argument.

1
votes

implode function requires array as parameter while in if condition you are passing simple string . You shuld use like this

if('no' == $contentLayout->metaPosition){
    $headerClasses[] = 'no-meta';              // this should be pass into array
} else {
    $headerClasses[] = 'meta-' . $contentLayout->metaPosition;
}

second one . you can check on impload like this

<?php echo is_array($headerClasses)? implode(' ', $headerClasses):$headerClasses;?>