Title: [PATCH] Various warnings
Last modified: August 21, 2016

---

# [PATCH] Various warnings

 *  [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * (@flynsarmy)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/patch-various-warnings/)
 * In WP 3.6.1 with WP_DEBUG turned on your plugin throws various warnings. Here
   are the fixes.
 * > Undefined index: post_status in /path/to/wp-content/plugins/featured-post/featured-
   > post.php on line 157
 * change
 *     ```
       if ( is_admin() && $_GET[ 'post_status' ] == 'featured' ) {
       ```
   
 * to
 *     ```
       if ( is_admin() && isset($_GET[ 'post_status' ]) && $_GET[ 'post_status' ] == 'featured' ) {
       ```
   
 * Next
 * > Undefined index: post_status in /path/to/wp-content/plugins/featured-post/featured-
   > post.php on line 74
 * Change
 *     ```
       $class               = $_GET[ 'post_status' ] == 'featured' ? "current" : '';
       ```
   
 * to
 *     ```
       $class               = isset($_GET[ 'post_status' ]) && $_GET[ 'post_status' ] == 'featured' ? "current" : '';
       ```
   
 * Next
 * > Notice: Undefined index: title in /path/to/wp-content/plugins/featured-post/
   > featured-post.php on line 201-203
 * Change
 *     ```
       function form( $instance )
       {
       	global $SovitFeaturedPost;
       	$title      = esc_attr( $instance[ 'title' ] );
       	$type       = esc_attr( $instance[ 'post_type' ] );
       	$num        = (int) esc_attr( $instance[ 'num' ] );
       	$post_types = get_post_types( array(
       		 'publicly_queryable' => true
       	), 'objects' );
       ```
   
 * to
 *     ```
       function get_default_post_type( $post_types )
       {
       	global $SovitFeaturedPost;
   
       	// Grab a default post type
       	$default = '';
       	foreach ( $post_types as $key => $post_type )
       	{
       		if ( !in_array( $key, $SovitFeaturedPost->ignore_post_type ) )
       		{
       			$default = $key;
       			break;
       		}
       	}
   
       	// None found - assume 'post'
       	if ( empty($default) )
       		$default = 'post';
   
       	return $default;
       }
   
       function form( $instance )
       {
       	$post_types = get_post_types( array(
       		 'publicly_queryable' => true
       	), 'objects' );
   
       	// Apply default settings
       	$instance = wp_parse_args($instance, array(
       		'title' => '',
       		'post_type' => $this->get_default_post_type($post_types),
       		'num' => 0,
       	));
   
       	global $SovitFeaturedPost;
       	$title      = esc_attr( $instance[ 'title' ] );
       	$type       = esc_attr( $instance[ 'post_type' ] );
       	$num        = (int) esc_attr( $instance[ 'num' ] );
       ```
   
 * [http://wordpress.org/plugins/featured-post/](http://wordpress.org/plugins/featured-post/)

The topic ‘[PATCH] Various warnings’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/featured-post.svg)
 * [Featured Post](https://wordpress.org/plugins/featured-post/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/featured-post/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/featured-post/)
 * [Active Topics](https://wordpress.org/support/plugin/featured-post/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/featured-post/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/featured-post/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/patch-various-warnings/)
 * Status: not resolved