Support » Plugin: Custom Meta Widget » Undefined offset notice

  • Resolved timholz

    (@timholz)


    Hi
    To solve the notice add the following in customMeta.php (line 61):

    $options = array();
    	foreach( $values as $slug => $sub_values ) {
    		$temp = array();
    		for( $i=0; $i<5; $i++ )
    			if (isset($sub_values[$i])){ //new
    			$temp[$keys[$i]] = $sub_values[$i];
    			$options[$slug] = $temp;
    		} //new
    	}
    	return $options;
    }

    The notice is gone in the backend.
    regards
    theo

    • This topic was modified 2 years, 2 months ago by timholz.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Luke Mlsna

    (@bitacre)

    Is this still happening in the latest version?

    Hi, no, i’ve had no notices in the latest version.
    regards theo

    Plugin Author Luke Mlsna

    (@bitacre)

    Cool. Thank you for the detailed report, just wanted to make sure it was fixed.

    Dear Luke,

    I found a simple plugin you made a while back that is exactly what I need but it does not work in the newest version of WordPress. If it’s okay, could I get you to have a quick look at it?

    https://wordpress.org/plugins/count-posts-in-a-category/

    Sorry for posting here. I just saw your name and remembered it from when I was testing different plugins.

    I guess this code needs an update:

    if( !empty( $slug ) ) { $field = 'slug'; $value = $slug; }
    	elseif( !empty( $id ) ) { $field = 'id'; $value = $id; }
    	elseif( !empty( $name ) ) { $field = 'name'; $value = $name; }
    	else return 0; // nothing specified

    Maybe to this:

    if( $slug !== '' ) { $field = 'slug'; $value = $slug; }
    	elseif( $id !== '' ) { $field = 'id'; $value = $id; }
    	elseif( $name !== '' ) { $field = 'name'; $value = $name; }
    	else return 0;

    But I’m not sure what happens here:

    $term = get_term_by( $field, $value, $taxonomy ); // get term object
    	if( isset( $term->count ) ) return $term->count;
    	else return 10;
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Undefined offset notice’ is closed to new replies.