Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:18:24+00:00 2026-06-08T15:18:24+00:00

Okay I have installed a theme in wordpress that returns a few errors. Warning:

  • 0

Okay I have installed a theme in wordpress that returns a few errors.

Warning: Invalid argument supplied for foreach() in /home/mvprop/public_html/wp-content/themes/yoo_vox_wp/warp/systems/wordpress.3.0/helpers/system.php on line 339

This problem is resolved on these forums

but I can’t understand what the last post is about. The guy posts a bunch of random code that solves the problem. He doesn’t specify where it’s from or where to put it. Just pastes code that doesn’t seem to have to do with anything.

line 334 to the end of the file

function getWidgets($position = null) {

    if (empty($this->widgets)) {
        foreach (wp_get_sidebars_widgets() as $pos => $ids) {
            $this->widgets[$pos] = array();
            foreach ($ids as $id) {
                $this->widgets[$pos][$id] = $this->getWidget($id);
            }
        }
    }

    if (!is_null($position)) {
        return isset($this->widgets[$position]) ? $this->widgets[$position] : array();
    }

    return $this->widgets;
}

/*
    Function: displayWidget
        Checks if a widget should be displayed

    Returns:
        Boolean
*/
function displayWidget($widget) {
    if (!isset($widget->options['display']) || in_array('*', $widget->options['display'])) return true;

    foreach ($this->getQuery() as $q) {
        if (in_array($q, $widget->options['display'])) {
            return true;
        }
    }

    return false;
}

/*
    Function: overrideConfig
        Overrides default config based on page

    Returns:
        Void
*/
function overrideConfig() {
    if (!count($this->config_overrides)) return;

    foreach ($this->getQuery() as $q) {
        if (isset($this->config_overrides[$q])) {
            $this->warp->config->parseString($this->config_overrides[$q]);
        }
    }
}

/*
    Function: isBlog

    Returns:
        Boolean
*/
function isBlog() {
    return true;
}

/*
    Function: isPreview
        Checks for default widgets in theme preview 

    Returns:
        Boolean
*/
function isPreview($position) {

    // preview postions
    $positions = array('logo', 'right');

    return is_preview() && in_array($position, $positions);
}

/*
    Function: ajaxSearch
        Ajax search callback

    Returns:
        String
*/
function ajaxSearch(){
    global $wp_query;

    $result = array('results' => array());
    $query  = isset($_REQUEST['s']) ? $_REQUEST['s']:"";

    if (strlen($query)>=3) {

        $wp_query->query_vars['s'] = $query;
        $wp_query->is_search = true;

        foreach ($wp_query->get_posts() as $post) {

            $content = !empty($post->post_excerpt) ? strip_tags(do_shortcode($post->post_excerpt)) : strip_tags(do_shortcode($post->post_content));

            if (strlen($content) > 255) {
                $content = substr($content, 0, 254).'...';
            }

            $result['results'][] = array(
                'title' => $post->post_title,
                'text'  => $content,
                'url'   => get_permalink($post->ID)
            );
        }
    }

    die(json_encode($result));
}

/*
    Function: _adminInit
        Admin init actions

    Returns:
        Void
*/
function _adminInit() {

    if ((defined('DOING_AJAX') && DOING_AJAX) && isset($_POST['warp-ajax-save'])) {

        // update option values
        foreach ($_POST as $option => $value) {
            if (preg_match('/^(warp_|'.preg_quote($this->prefix, '/').')/', $option)) {
                update_option($option, $value);
            }
        }

        die();
    }

    wp_enqueue_script('warp-admin', rtrim(get_bloginfo('template_url'),'/').'/warp/systems/wordpress.3.0/js/wp-admin.js', false, '1.0');
    add_action('wp_ajax_save_nav_settings', array($this,'_save_nav_settings'));
    add_action('wp_ajax_get_nav_settings', array($this,'_get_nav_settings'));
}

/*
    Function: _adminHead
        Admin head actions

    Returns:
        Void
*/
function _adminHead() {

    // init vars
    $path =& $this->getHelper('path'); 

    $head[] = '<link rel="stylesheet" href="'.$path->url('warp:systems/wordpress.3.0/css/admin.css').'" type="text/css" />';
    $head[] = '<script type="text/javascript" src="'.$path->url('warp:systems/wordpress.3.0/js/admin.js').'"></script>';

    echo implode("\n", $head);
}

/*
    Function: _adminMenu
        Admin menu actions

    Returns:
        Void
*/
function _adminMenu() {

    // init vars
    $path =& $this->getHelper('path');
    $name = $this->xml->document->getElement('name');
    $icon = $path->url('warp:systems/wordpress.3.0/images/yoo_icon_16.png');

    if (function_exists('add_object_page')) {
        add_object_page('', $name->data(), 8, 'warp', false, $icon);
    } else {
        add_menu_page('', $name->data(), 8, 'warp', false, $icon); 
    }

    add_submenu_page('warp', 'Theme Options', 'Theme Options', 8, 'warp', array($this, '_adminThemeOptions'));
    add_submenu_page('warp', 'Widget Options', 'Widget Options', 8, 'warp_widget', array($this, '_adminWidgetOptions'));
}

/*
    Function: _adminThemeOptions
        Render admin theme options layout

    Returns:
        Void
*/  
function _adminThemeOptions() {

    // init vars
    $path  =& $this->getHelper('path');
    $xml   =& $this->getHelper('xml');
    $http  =& $this->getHelper('http');
    $check =& $this->getHelper('checksum');

    // get warp xml
    $warp_xml = $xml->load($path->path('warp:warp.xml'), 'xml', true);

    // update check
    $update = null;
    if ($url = $warp_xml->document->getElement('updateUrl')) {

        // get template info
        $template = get_template();
        $version  = $this->xml->document->getElement('version');
        $url      = sprintf('%s?application=%s&version=%s&format=raw', $url->data(), $template, $version->data());

        // only check once a day 
        if (get_option($this->prefix.'update_check') != date('Y-m-d').' '.$version->data()) {
            if ($request = $http->get($url)) {
                update_option($this->prefix.'update_check', date('Y-m-d').' '.$version->data());
                update_option($this->prefix.'update_data', $request['body']);
            }
        }

        // decode update response
        $update = json_decode(get_option($this->prefix.'update_data'));
    }

    // verify theme files
    if (($checksums = $path->path('template:checksums')) && filesize($checksums)) {
        $check->verify($path->path('template:'), $log);
    } else {
        $log = false;
    }

    echo $this->warp->template->render('admin/theme_options', array('xml' => $this->xml, 'warp_xml' => $warp_xml, 'update' => $update, 'checklog' => $log));
}

/*
    Function: _adminWidgetOptions
        Render admin widget options layout

    Returns:
        Void
*/  
function _adminWidgetOptions() {

    // get position settings
    $position_settings = $this->warp->config->get('warp.positions');

    // get module settings
    $module_settings = array();
    $settings = $this->xml->document->getElement('modulesettings');

    foreach ($settings->children() as $setting) {
        $module_settings[$setting->attributes('name')] = $setting;
    }

    echo $this->warp->template->render('admin/widget_options', compact('position_settings', 'module_settings'));
}

/*
    Function: getMenuItemOptions
        Retrieve menu by id

    Parameters:
        $id - Menu Item ID

    Returns:
        Array
*/
function getMenuItemOptions($id) {

    $menu_settings = array(
        'columns'     => 1,
        'columnwidth' => -1,
        'image'       => ''
    );

    if (isset($this->menu_item_options[$id])) {
        $menu_settings = array_merge($menu_settings, $this->menu_item_options[$id]);
    }

    return $menu_settings;
}


/*
    Function: _save_nav_settings
        Saves menu item settings

    Returns:
        Void
*/  
function _save_nav_settings() {

    if (isset($_POST['menu-item'])) {

        $menu_item_settings = $this->menu_item_options;

        foreach ($_POST['menu-item'] as $itemId=>$settings){
            $menu_item_settings[$itemId] = $settings;
        }

        update_option($this->prefix.'menu-items', $menu_item_settings);
        $this->menu_item_options = $menu_item_settings;
    }

    die();
}

/*
    Function: _get_nav_settings
        Returns menu item settings as json

    Returns:
        Boolean
*/
function _get_nav_settings() {
    die(json_encode($this->menu_item_options));
    }

}

    /*
        Function: mb_strpos
            mb_strpos function for servers not using the multibyte string extension
    */
    if (!function_exists('mb_strpos')) {
        function mb_strpos($haystack, $needle, $offset = 0) {
            return strpos($haystack, $needle, $offset);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:18:26+00:00Added an answer on June 8, 2026 at 3:18 pm

    Basically what this warning message tells you is that the variable you’re passing into your foreach is not an array or object. Make sure your variable is valid by testing it ( is_array($var) or is_object($var) ) or placing this block of code in a try-catch.

    If $var is supposed to be an array, you should also initialize it just to be certain.

    $var = Array();
    .
    . // code that may change the data type of $var
    .
    if (is_array($var)) {
        foreach($var as $v) {
            //code here
        }
    }
    

    From the manual at http://php.net/manual/en/control-structures.foreach.php:

    The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I have a large CRUD app that uses tabs with Forms embedded in
I'm using Mercurial for revision control of few projects. I have Mercurial installed both
Okay, I have a page on a Drupal install that has multiple divs. I
Okay - I have a dilemma. So far my script converts page titles into
okay i have been trying to understand this for hours i am learning VB
Okay I have a series of objects based on a base class which are
okay i have found the way to run a video in a image.... the
Okay I have updated my code quite a bit. I am getting a new
Okay I have updated my code a little, but I am still not exactly
Okay i have two models: posts and comments. as you can think comments has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.