Polylang 1.2 beta is ready for tests
-
More informations are available on blog post.
You can report bugs here.
-
Hi,
The ‘language’ part of pretty permalinks for the home page is not being removed for the default language.
It’s always like: example.com/language/en/
However, the other language works fine: example.com/fr/Checking the option: “Hide URL language information for default language” removes all language information from the pretty permalink for the home page, but that’s not what I want.
I have WordPress 3.6.1 and Polylang 1.2dev47 with these settings:
When the front page is visited, set the language according to the browser preference (checked).
The language is set from content. Posts, pages, categories and tags urls are not modified.
Remove /language/ in pretty permalinks.
Hide URL language information for default language (NOT checked).
Default Language: English@ahspw
Thank you very much for your tests and your bug report. I uploaded anew version (1.2dev49) which should correct this.I’m with 1.2dev50 right now.
Subdomains and domains were a great adition.
I’m having a bug and it comes at least since 1.2dev45 which is:
When using the option to set the language from e.g. “/en/”, querying custom post types taxonomies it returns the language instead the term. It doesn’t happen for regular posts.
This doesn’t happen either when using the language selection from content.
Sorry, my explanation above isn’t clear enough.
The result listing of custom post types by terms is right, so the query is being done right.
The problem is that the language is displayed at the listing title and meta title.
Thanks. This should now be corrected in 1.2dev52.
Hello Chouby,
I downloaded the 1.2 beta version today and began testing.
My server is logging an invalid argument warning. I’m including a “trace” for this error below:
/* Trail starts when WordPress processes the navigation menu for the twentytwelve theme*/ /* ...themes/twentytwelve/header.php */ <body <?php body_class(); ?>> <div id="page" class="hfeed site"> <header id="masthead" class="site-header" role="banner"> <hgroup> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2> </hgroup> <nav id="site-navigation" class="main-navigation" role="navigation"> <h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3> <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?> /* calls the wp_nav_menu function */ . . . /* .../wp-includes/nav-menu-template.php line 147 */ function wp_nav_menu( $args = array() ) { static $menu_id_slugs = array(); $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'depth' => 0, 'walker' => '', 'theme_location' => '' ); /* <-- menu == NULL */ $args = wp_parse_args( $args, $defaults ); $args = apply_filters( 'wp_nav_menu_args', $args ); $args = (object) $args; // Get the nav menu based on the requested menu $menu = wp_get_nav_menu_object( $args->menu ); /* <-- $menu == false */ // Get the nav menu based on the theme_location if ( ! $menu && $args->theme_location && ( $locations = get_nav_menu_locations() ) /* <-- calls get_nav_menu_location() next */ && isset( $locations[ $args->theme_location ] ) ) $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] ); . . . /* ...wp-includes/nav-menu.php line 129 */ function get_nav_menu_locations() { $locations = get_theme_mod( 'nav_menu_locations' ); /* evaluates get_theme_mod() next */ return ( is_array( $locations ) ) ? $locations : array(); } /* ...wp-includes/theme.php line 776 */ function get_theme_mod( $name, $default = false ) { /* $name == 'nav_menu_location', $default == false */ $mods = get_theme_mods(); /* evaluates get_theme mods() next */ . . . /* ...wp-includes/theme.php line 746 */ function get_theme_mods() { $theme_slug = get_option( 'stylesheet' ); /* $theme_slug == 'twentytwelve-dark'; (my twentytwelve based child theme) */ if ( false === ( $mods = get_option( "theme_mods_$theme_slug" ) ) ) { /* value from db cache == a:2:{i:0;b:0;s:18:"nav_menu_locations";N;} */ $theme_name = get_option( 'current_theme' ); if ( false === $theme_name ) $theme_name = wp_get_theme()->get('Name'); $mods = get_option( "mods_$theme_name" ); // Deprecated location. if ( is_admin() && false !== $mods ) { update_option( "theme_mods_$theme_slug", $mods ); delete_option( "mods_$theme_name" ); } } return $mods; /* $mods == array ( [0] => false, [nav_menu_locations] => NULL )*/ } /* returns to get_theme_mod() next */ /* ...wp-includes/theme.php line 776 */ function get_theme_mod( $name, $default = false ) { $mods = get_theme_mods(); if ( isset( $mods[ $name ] ) ) /* $mods['nav_menu_location'] == NULL */ return apply_filters( "theme_mod_$name", $mods[ $name ] ); if ( is_string( $default ) ) /* $default is boolean */ $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); return apply_filters( "theme_mod_$name", $default ); /* this filter is applied with $default == false */ } /* ...wp-includes/plugin.php line 137 */ function apply_filters($tag, $value) { /* $tag == theme_mod_nav_menu_locations, $value == false */ . . . do { foreach( (array) current($wp_filter[$tag]) as $the_ ) /* the_ == array ( [0] ==> 'PLL_Frontend_Nav_Menu' , [1] ==> 'nav_menu_locations' ) */ if ( !is_null($the_['function']) ){ $args[1] = $value; /* $args == array ([0] ==> 'theme_mod_nav_menu_locations', [1] ==> false ) */ $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); } } while ( next($wp_filter[$tag]) !== false ); . . . /* ...polylang/frontend/frontend-nav-menu.php line 157 */ public function nav_menu_locations($menus) { /* $menus = false */ $curlang = pll_current_language(); foreach ($menus as $loc => $menu) { /* <-- $menus == false --> Server Error Log: PHP Warning: Invalid argument supplied for foreach() in ...polylang/frontend/frontend-nav-menu.php on line 160 */ if (($pos = strpos($loc, '___')) && substr($loc, $pos+3) == $curlang) $arr[substr($loc, 0, $pos)] = $menu; } return empty($arr) ? $menus : array_merge($menus, $arr); } /* returns false to nav-menu.php next */
I figured that I can condition the foreach cycle to be processed if $menus is not boolean, but I don’t know if there are any repercussions for Polylang due to this error later on.
Fatal error: Call to undefined method stdClass::set_flag() in C:\wamp\www\wordpress\wp-content\plugins\polylang\include\model.php on line 150
Polylang 1.2dev52, PHP 5.4.12, WordPress 3.6.1
@reactorshop
I will fix that in the next upload@anas Sulaiman
I can easily fix it but I fear that this error is hiding something else. What are the circumstances? (in particular, I would like to know if it is after an upgrade from 1.1.6 or a fresh install)It was working until I updated from 1.2dev4? to 1.2dev52.
I’ve just noticed that it’s working fine on my other setup, where PHP version is 5.3.3.And before that. Has your site run any stable version of Polylang?
I believe that your DB is lacking some essential data fo Polylang to correctly work. These data are new in Polylang 1.2 and created when you add a new language (or at upgrade from 1.1.x to 1.2).
I’ve just enabled errors debug.
I got these:
Notice: Undefined index: file in wp-content/plugins/polylang/include/base.php on line 72
Notice: Undefined index: line in wp-content/plugins/polylang/include/base.php on line 72
Notice: get_home_url was called incorrectly: use $polylang->links->get_home_url() instead of $polylang->get_home_url() in on line Error handler in wp-content/plugins/polylang/include/base.php on line 73
@chouby
I understand.
It seems this an error on my side, please don’t mind it, I’ll check my setup and see what happens.@anas Sulaiman
I will modify my code to avoid an inelegant fatal error. But this will lead to an empty list of languages.@miguelcortereal
The 3rd notice is intentionnaly emitted by Polylang because I added backward compatibility for call to $polylang->get_home_url which in 1.2 should be $polylang->links->get_home_url but this should display the file and the line of this call (which I get from the debug_backtrace function).The two first notices appear because the debug_backtrace does not return the file name and line (or at least not the way I expect them). I will remake a test with two different versions of PHP to see if PHP versions could explain that these indexes are not as expected.
Anyway I found one bad call in Polylang (in WPML API), so I will correct it in the next upload.
In any case, it does not prevent Polylang to work correctly.
Thank you, Chouby,
To continue testing, here’s my temporary fix to that find:
/* .../polylang/frontend/frontend-nav-menu.php line 157*/ public function nav_menu_locations($menus) { $curlang = pll_current_language(); if(!is_bool($menus)) // Added an if to only enter the foreach loop if $menus is not bool. foreach ($menus as $loc => $menu) { if (($pos = strpos($loc, '___')) && substr($loc, $pos+3) == $curlang) $arr[substr($loc, 0, $pos)] = $menu; } return empty($arr) ? $menus : array_merge($menus, $arr); }
And here’s another find:
If the last time you loaded your website was on a language different than english, or if, for example, you type:
https://www.mywebsite.com/es/ (or any other slug that is not /en/)
The website will load using the last language stored in your cookie or as the permalink requests (both as expected), but the language switcher will always show English (the first entry in the switcher list).
I traced the situation to this function:
/* ...polylang/include/walker-dropdown.php line 18 */ function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) { $value = isset($args['value']) && $args['value'] ? $args['value'] : 'slug'; $output .= sprintf( "\t".'<option value="%s"%s>%s</option>'."\n", esc_attr($element->$value), isset($args['selected']) && $args['selected'] == $element->$value ? ' selected="selected"' : '', esc_html($element->name) ); }
At first glance, I couldn’t find any instance of $args[‘selected’] being set throughout Polylang’s plugin files.
In order to continue testing, I fixed it like this:
function start_el( &$output, $element, $depth = 0, $args = array(), $current_object_id = 0 ) { $value = isset($args['value']) && $args['value'] ? $args['value'] : 'slug'; // Add to $args['selected'] the language slug value if $element matches current // language to preselect it in the widget language switcher. if(pll_current_language() == $element->slug) { $args['selected'] = $element->$value; } else { if(isset($args['selected'])) { unset($args['selected']); // They don't exist. } } $output .= sprintf( "\t".'<option value="%s"%s>%s</option>'."\n", esc_attr($element->$value), isset($args['selected']) && $args['selected'] == $element->$value ? ' selected="selected"' : '', esc_html($element->name) ); }
And now the widget’s selected language updates and switches languages as expected.
I’ll continue testing to see what other findings I can contribute.
Thank you, Chouby!
Again thanks a lot for all the testing you are doing.
I just uploaded a new version (1.2dev54) which should fix this.
- The topic ‘Polylang 1.2 beta is ready for tests’ is closed to new replies.