WordPress.org

Plugin Directory

jetpack

Opened 4 years ago

Closed 4 years ago

#1979 closed defect (duplicate)

Widget visibility: code assumes the a -number on the end of the widget name

Reported by: pbearne Owned by: tmoorewp
Priority: normal Severity: normal
Plugin: jetpack Keywords: widget-visibility has-patch
Cc: pbearne, richard@…, westonruter, jeremy+wp@…

Description

Undefined offset: 1 at /jetpack/modules/widget-visibility/widget-conditions.php line 251

This is the line that is erroring
list( $basename, $suffix ) = explode( "-", $widget_id, 2 );

The problem is that it assumes the a -number on the end of the widget name

This is not safe as you can widget names like
icl_lang_sel_widget
recent-comments-2

I added this horrible code to stop the errors
if(!stripos( $widget_id, "-" ) )
$widget_id = $widget_id.'-';
$basenames = preg_split( "/-.{0,3}$/", $widget_id );
$basename = $basenames[0];
$suffix = str_replace($basename.'-',, $widget_id );
list( $basename, $suffix ) = array( $basename, $suffix );

it need the authors TLC to sort.

Attachments (1)

widget-conditions.php.patch (1.5 KB) - added by westonruter 4 years ago.
Add support for old-style single (non-multi) widgets

Download all attachments as: .zip

Change History (7)

comment:1 @richardmtl4 years ago

  • Cc richard@… added
  • Component changed from not-listed to jetpack
  • Owner set to tmoorewp

comment:2 @jeherve4 years ago

  • Summary changed from code assumes the a -number on the end of the widget name to Widget visibility: code assumes the a -number on the end of the widget name

@westonruter4 years ago

Add support for old-style single (non-multi) widgets

comment:3 @westonruter4 years ago

  • Keywords has-patch added

comment:4 @westonruter4 years ago

  • Cc westonruter added

comment:6 @jeherve4 years ago

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.