Bug: Undefined index: widget_title/widget_text & attribute_escape is deprecated
-
With
define('WP_DEBUG', true);
inwp-config.php
some errors can be observed on WordPress Widgets page if plugin widget is used:Notice: Undefined index: widget_title in /../wp-content/plugins/wp-email-capture/inc/widget.php on line 55
Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead in /../wp-includes/functions.php on line 2841
[..]
Notice: Undefined index: widget_text in /../wp-content/plugins/wp-email-capture/inc/widget.php on line 56
Notice: attribute_escape is deprecated since version 2.8! Use esc_attr() instead in /../wp-includes/functions.php on line 2841Reasons are wrong indexes
title
andtext
in default-array in filewp-email-capture/inc/widget.php
, line 48Wrong:
$default = array( 'title' => __('Subscribe!','WPEC'), 'text' => __('Subscribe to my blog for updates','WPEC') );
Suggested fix:
$default = array( 'widget_title' => __('Subscribe!','WPEC'), 'widget_text' => __('Subscribe to my blog for updates','WPEC') );
and deprecated use of attribute_escape() call in file
wp-email-capture/inc/widget.php
, starting at line 55Wrong:
echo "\r\n".'<p><label for="'.$title_id.'">'.__('Widget title:','WPEC').': <input type="text" class="widefat" id="'.$title_id.'" name="'.$title_name.'" value="'.attribute_escape( $instance['widget_title'] ).'" /><label></p>'; echo "\r\n".'<p><label for="'.$text_id.'">'.__('Widget text:','WPEC').': <input type="text" class="widefat" id="'.$text_id.'" name="'.$text_name .'" value="'.attribute_escape( $instance['widget_text'] ).'" /><label></p>';
Suggested fix:
echo "\r\n".'<p><label for="'.$title_id.'">'.__('Widget title:','WPEC').': <input type="text" class="widefat" id="'.$title_id.'" name="'.$title_name.'" value="'.esc_attr( $instance['widget_title'] ).'" /><label></p>'; echo "\r\n".'<p><label for="'.$text_id.'">'.__('Widget text:','WPEC').': <input type="text" class="widefat" id="'.$text_id.'" name="'.$text_name .'" value="'.esc_attr( $instance['widget_text'] ).'" /><label></p>';
- The topic ‘Bug: Undefined index: widget_title/widget_text & attribute_escape is deprecated’ is closed to new replies.