WordPress.org

Ready to get started?Download WordPress

Forums

AVH Extended Categories Widgets
[PATCH] More undefined offsets (1 post)

  1. flynsarmy
    Member
    Posted 11 months ago #

    I'm getting a bunch of warnings that break the widgets list page in admin and make all widgets below undraggable.

    Because that's a huge amount of change, here's the updated version that you can do a diff on http://pastebin.com/PxAMf0ss

    In /plugins/extended-categories-widget/3.3/class/avh-ec.widgets.php WP_Widget_AVH_ExtendedCategories_Normal::form() (around line 255):

    Change

    $selected_cats = ($instance['post_category'] != '') ? unserialize($instance['post_category']) : FALSE;

    to

    $selected_cats = (isset($instance['post_category']) && $instance['post_category'] != '') ? unserialize($instance['post_category']) : FALSE;

    Change all instances of

    (bool) $instance['...']

    to

    !empty($instance['...'])

    Change the 3 instances from

    ..., $options, $instance['...']);

    to

    ..., $options, @$instance['...']);

    or preferrably

    ..., $options, isset($instance['...']) ? $instance['...'] : '');

    Now down in WP_Widget_AVH_ExtendedCategories_Category_Group::form() (around line 748) do the same thing but also here's an updated version of the 'Prepare data for display' section which had generated heaps of warnings:

    // Prepare data for display
    		$title = esc_attr($instance['title']);
    		$count = !empty($instance['count']);
    		$hierarchical = !empty($instance['hierarchical']);
    		$hide_empty = !empty($instance['hide_empty']);
    		$use_desc_for_title = !empty($instance['use_desc_for_title']);
    		$sort_id = (isset($instance['sort_column']) && $instance['sort_column'] == 'ID') ? ' SELECTED' : '';
    		$sort_name = (isset($instance['sort_column']) && $instance['sort_column'] == 'name') ? ' SELECTED' : '';
    		$sort_count = (isset($instance['sort_column']) && $instance['sort_column'] == 'count') ? ' SELECTED' : '';
    		$sort_order_a = (isset($instance['sort_order']) && $instance['sort_order'] == 'asc') ? ' SELECTED' : '';
    		$sort_order_d = (isset($instance['sort_order']) && $instance['sort_order'] == 'desc') ? ' SELECTED' : '';
    		$style_list = (isset($instance['sort_column']) && $instance['style'] == 'list') ? ' SELECTED' : '';
    		$style_drop = (isset($instance['sort_column']) && $instance['style'] == 'drop') ? ' SELECTED' : '';
    		$rssfeed = !empty($instance['rssfeed']);
    		$rssimage = esc_attr($instance['rssimage']);
    
    		$selected_cats = (isset($instance['post_group_category']) && $instance['post_group_category'] != '') ? unserialize($instance['post_group_category']) : FALSE;

    Back up in WP_Widget_AVH_ExtendedCategories_Top::form (around line 457) same thing again but also change

    if (! $amount = (int) $instance['amount']) {

    to

    if (!isset($instance['amount']) || !($amount = (int) $instance['amount']) ) {

    I would actually recommend you create a get_instance_var() method so you can call
    $this->get_instance_var($instance, 'hierarchical', false) and it'll handle isset() and stuff for you. something like:

    public function get_instance_var( $instance, $key, $default=NULL )
    {
    	if ( !is_array($instance) || !array_key_exists($instance, $key) )
    		return $default;
    
    	return $instance[$key];
    }

    http://wordpress.org/plugins/extended-categories-widget/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.