Support » Plugin: Category Posts Widget » [Plugin: Category Posts Widget] no defaults = undefined index

  • Resolved Franz Josef Kaiser

    (@f-j-kaiser)


    When you got (production environment) set WP_DEBUG to true in wp-config.php, you get a lot of undefined index, because the widget ain’t got any default values. A fast hack is adding the following lines to form() function at between line 139 & 140. Btw: Every Widget should have defaults imho.

    // defaults
    	if(!isset($instance["title"])) { $instance["title"] = 'insert title here'; }
    	if(!isset($instance["cat"])) { $instance["cat"] = 'allgemein'; }
    	if(!isset($instance["num"])) { $instance["cat"] = '5'; }
    	if(!isset($instance["title_link"])) { $instance["title_link"] = false; }
    	if(!isset($instance["excerpt"])) { $instance["excerpt"] = false; }
    	if(!isset($instance["excerpt_length"])) { $instance["excerpt_length"] = '25'; }
    	if(!isset($instance["comment_num"])) { $instance["comment_num"] = false; }
    	if(!isset($instance["date"])) { $instance["date"] = false; }
    	if(!isset($instance["thumb"])) { $instance["thumb"] = false; }
    	if(!isset($instance["thumb_w"])) { $instance["thumb_w"] = '40'; }
    	if(!isset($instance["thumb_h"])) { $instance["thumb_h"] = '30'; }

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Category Posts Widget] no defaults = undefined index’ is closed to new replies.