0
votes

After I dragged a widget (lets say "Search") into the widget area "Footer" I am getting an error: "Warning: sprintf(): Argument number must be greater than zero in C:\xampp\apps\wordpress\htdocs\wp-includes\widgets.php on line 1199".

This line in widgets.php of WP-core is determing the before-widgets arguments. I use custom widget areas which I included with register_sidebar within "functions.php" in the main root folder of my theme.

I did not have this problems before, I imported the whole folder with the theme data from a MAC. I know that APACHE makes several security checks but that should not involve data within a theme folder.

I use the newest Wordpress version 4.1. Why do I get this error?

EDIT: Here is the code in functions.php which generates the widget areas:

function vidaneo_widgets_init() {
if ( function_exists('register_sidebar') ) {

  register_sidebar(array(
    'name' => 'Header',
    'description' => 'Header mit Logo, Navigation und Banner',
    'before_widget' => '<div class="header">',
    'after_widget' => '</div>',
    'after_title' => '</h6>',
    ));

  register_sidebar( array(
    'name'          => 'Hauptbereich (links)',
    'id'            => 'sidebar-content',
    'description'   => 'Hauptbereich links',
    'class'         => 'content',
    'before_widget' => '<div class="widget"',
    'after_widget'  => '</div>',
    'before_title'  => '<h3 class="content-title">',
    'after_title'   => '</h3>',
  ));

  register_sidebar(array('name' => 'Sidebar rechts',
    'id' => 'sidebar-right',
    'description' => 'Seitenbereich rechts',
    'before_widget' => '<div id="%1$s" class="widget %$s"',
    'after_widget' => '</div>',
    'before_title' => '<h6>',
    'after_title' => '</h6>',
    ));

  register_sidebar(array(
    'name' => 'Footer',
    'description' => 'Container für Footer-Widgets',
    'before_widget' => '<div id="%1$s" class="widget %$s"',
    'after_widget' => '</div>',
    'before_title' => '<h6>',
    'after_title' => '</h6>',
    ));
  }
}
1
Can you include the code from your functions.php that you use to register the sidebar?Cal Evans
Ok, I just added this code. I cannot see any errors in it.Pille

1 Answers

2
votes

I think I see the problem.

'before_widget' => '<div id="%1$s" class="widget %$s"',

Specifically class="widget %$s". the $ is used in sprintf for parameter swapping. It requires that you precede it a number. Since there are only 2 parameters being passed in, this should work just fine:

'before_widget' => '<div id="%s" class="widget %s"',

Or, if you want to keep the $ in there.

'before_widget' => '<div id="%s" class="widget %2$s"',

Here's the sprintf page for reference:

http://php.net/sprintf

HTH,

=C=