Warning sprintf() function.sprintf too few argumen

2019-09-07 05:29发布

问题:

I have a WordPress script but the menu disappears when the url includes non-latin characters. Example: www.site.com/بحث

I Get:

warning sprintf() function.sprintf too few arguments in nav-menu-template.php

At this line:

$nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items );

回答1:

Sometimes its a problem if you have arabian characters in your url.

http://istizada.com/understanding-arabic-url-uri-structure-encoding-for-arabic-sites/

This is a cool post what happen when you have such a URL.

But normally this error means, that you have more placeholders as strings to replace. I think when you have such characters in your URL its transformed to UTF-8 URL encoding.

%D9%86 = ن

Then you have something like this and when you put that directly to your sprintf you have some new placeholders and such errors.

Try rawurldecode to change that characters back.

http://php.net/manual/de/function.rawurldecode.php



标签: php wordpress