www.webdeveloper.com
Results 1 to 9 of 9

Thread: Please Help! Invalid Argument issue

  1. #1
    Join Date
    Nov 2012
    Posts
    5

    Please Help! Invalid Argument issue

    hi friends i use wordpress but when in active yoo theme its show error but i don't know about this error please help

    error show
    Code:
    Warning:  Invalid argument supplied for foreach() in /public_html/wp-content/themes/yoo_catalyst/warp/systems/wordpress.3.0/helpers/widgets.php on line 107
    code

    PHP Code:
     <?php
    /**
    * @package   Warp Theme Framework
    * @author    YOOtheme http://www.yootheme.com
    * @copyright Copyright (C) YOOtheme GmbH
    * @license   YOOtheme Proprietary Use License (http://www.yootheme.com/license)
    */

    /*
        Class: WidgetsWarpHelper
            Wordpress widget helper class, provides simplyfied access to wordpress widgets
    */
    class WidgetsWarpHelper extends WarpHelper {

        
    /* widgets */
        
    public $widgets;
        
        
    /* options */
        
    public $options;

        
    /*
            Function: Constructor
                Class Constructor.
        */
        
    public function __construct() {
            
    parent::__construct();

            
    // set options
            
    $this->options get_option('warp_widget_options', array());
        }

        
    /*
            Function: get
                Retrieve a widget by id

            Parameters:
                $id - Widget ID

            Returns:
                Object
        */
        
    public function get($id) {
            global 
    $wp_registered_widgets;
            
            
    $widget null;

            if (isset(
    $wp_registered_widgets[$id]) && ($data $wp_registered_widgets[$id])) {
                
    $widget = new stdClass();
                
                foreach (array(
    'id''name''classname''description') as $var) {
                    
    $widget->$var = isset($data[$var]) ? $data[$var] : null;
                }

                if (isset(
    $data['callback']) && is_array($data['callback']) && ($object current($data['callback']))) {
                    if (
    is_a($object'WP_Widget')) {

                        
    $widget->type $object->id_base;

                        if (isset(
    $data['params'][0]['number'])) {

                            
    $number $data['params'][0]['number'];
                            
    $params get_option($object->option_name);

                            if (
    false === $params && isset($object->alt_option_name)) {
                                
    $params get_option($object->alt_option_name);
                            }

                            if (isset(
    $params[$number])) {
                                
    $widget->params $params[$number];
                            }
                        }
                    }
                } else if (
    $id == 'nav_menu-0') {
                    
    $widget->type 'nav_menu';
                }
                
                if (empty(
    $widget->name)) {
                    
    $widget->name ucfirst($widget->type);
                }

                if (empty(
    $widget->params)) {
                    
    $widget->params = array();
                }

                
    $widget->options = isset($this->options[$id]) ? $this->options[$id] : array();
                
    $widget->display $this->_display($widget);
            }
            
            return 
    $widget;
        }

        
    /*
            Function: getWidgets
                Retrieve widgets

            Parameters:
                $position - Position

            Returns:
                Array
        */
        
    public 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->get($id);
                    }
                }
            }

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

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

            Returns:
                Boolean
        */
        
    protected function _display($widget) {
            if (!isset(
    $widget->options['display']) || in_array('*'$widget->options['display'])) return true;
            
            
    $query $this['system']->getQuery();

            foreach (
    $query as $q) {
                  
               if (
    in_array($q$widget->options['display'])) {
                    
                    switch(
    $q) {
                        case 
    "page":
                            
                            if(
    is_home()) {
                                return 
    in_array('home'$widget->options['display']);
                            }

                            if(
    is_front_page()) {
                                return 
    in_array('front_page'$widget->options['display']);
                            }

                        default:
                            return 
    true;
                    }
                }
            }

            return 
    false;
        }

    }

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    22,332
    It's telling you that on that line, $ids is not an array. As to why not, that would take some debugging to find out the call to wp_get_sidebars_widgets() is actually returning -- my guess is that it's returning Boolean false. You could try to debug with something like:
    PHP Code:
        public function getWidgets($position null) {

            if (empty(
    $this->widgets)) {
                
    $sideBarWidgets wp_get_sidebar_widgets();
                foreach (
    $sideBarWidgets as $pos => $ids) {
                    if( ! 
    is_array($ids)) {
                        die(
    "<pre>Not an array:\n".var_export($sideBarWidgetstrue)."</pre>");
                    }
                    
    $this->widgets[$pos] = array();
                    foreach (
    $ids as $id) {
                        
    $this->widgets[$pos][$id] = $this->get($id);
                    }
                }
            } 
    Or you could try contacting the theme creator, or see if there is a new version of the theme.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Nov 2012
    Posts
    5
    thanks for reply sir but now this error show
    Code:
    Fatal error: Call to undefined function wp_get_sidebar_widgets() in /home/semdr786/public_html/wp-content/themes/yoo_catalyst/warp/systems/wordpress.3.0/helpers/widgets.php on line 105

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    22,332
    That's because I made a typo, and "sidebars" should be plural.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  5. #5
    Join Date
    Nov 2012
    Posts
    5
    what do?

  6. #6
    Join Date
    Nov 2012
    Posts
    5
    please help me

  7. #7
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    22,332
    Code:
    $sideBarWidgets = wp_get_sidebars_widgets();
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  8. #8
    Join Date
    Nov 2012
    Posts
    5
    now show this
    Not an array:
    array (
    'wp_inactive_widgets' =>
    array (
    0 => 'meta-2',
    1 => 'categories-2',
    2 => 'search-4',
    3 => 'search-3',
    ),
    'general' =>
    array (
    0 => 'search-2',
    1 => 'text-2',
    2 => 'recent-posts-2',
    3 => 'recent-comments-2',
    4 => 'pages-2',
    5 => 'archives-2',
    6 => 'text-3',
    ),
    'slider' =>
    array (
    ),
    'homepage' =>
    array (
    ),
    'post' =>
    array (
    ),
    'page' =>
    array (
    ),
    'blog' =>
    array (
    ),
    'contact' => NULL,
    'portfolio' => NULL,
    'other' =>
    array (
    ),
    'footer-1' => NULL,
    'footer-2' => NULL,
    'footer-3' => NULL,
    )

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    22,332
    So, it looks like some elements are arrays and some are simple scalars with NULL values. I'm hesitant to suggest a final solution, since I don't really know what all this is supposed to do, nor how critical it is, but the simple solution to avoid the error might be something like:
    PHP Code:
        public function getWidgets($position null) {

            if (empty(
    $this->widgets)) {
                
    $sideBarWidgets wp_get_sidebar_widgets();
                foreach (
    $sideBarWidgets as $pos => $ids) {
                    if( ! 
    is_array($ids)) {
                        continue; 
    // just skip this item
                    
    }
                    
    $this->widgets[$pos] = array();
                    foreach (
    $ids as $id) {
                        
    $this->widgets[$pos][$id] = $this->get($id);
                    }
                }
            } 
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13028 seconds
  • Memory Usage 3,002KB
  • Queries Executed 13 (?)
More Information
Template Usage (35):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (9)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates