[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' ] );
- The topic ‘[PATCH] Various warnings’ is closed to new replies.