Incompatibility with latest WPML version
-
Hi,
I manage a website that uses your plugin that works fine even with the latest version of WP (5.3.2).This website also uses the WPML plugin and your plugin is not compatible with the latest version of WPML Multilingual CMS (v4.3.6) with the “Different languages in directories” setting. After updating the WPML plugin to this version, the English language of my website was no longer working (example: mywebsite.com/en).
PHP Fatal error: Uncaught Error: Call to a member function using_permalinks() on null in .../public_html/wp-content/plugins/add-any-extension-to-pages/add-any-extension-to-pages.php:110 Stack trace: #0 .../public_html/wp-includes/class-wp-hook.php(288): aaetp_no_page_trailing_slash('/en', '') #1 .../public_html/wp-includes/plugin.php(206): WP_Hook->apply_filters('/en', Array) #2 .../public_html/wp-content/plugins/sitepress-multilingual-cms/classes/utilities/class-wpml-slash-management.php(82): apply_filters('user_trailingsl...', '/en', '') #3 .../public_html/wp-content/plugins/sitepress-multilingual-cms/classes/utilities/class-wpml-slash-management.php(52): WPML_Slash_Management->user_trailingslashit('/en')
I opened a ticket with WPML support and they have indicated that the following function used by your plugin is the one that generates the error.
The issue here mainly comes from the call to using_permalinks() which when its first called returns NULL.
function aaetp_no_page_trailing_slash($string, $type) { global $wp_rewrite; if ( $wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes == true && $type == 'page' ){ return untrailingslashit( $string ); } else { return $string; } } add_filter( 'user_trailingslashit', 'aaetp_no_page_trailing_slash', 66, 2 );
WPML support suggested me the following fix:
# 1. Edit add-any-extension-to-pages.php
# 2. Move Line 117 one line up adding the add_filter() within the function as shown below.function aaetp_no_page_trailing_slash($string, $type) { global $wp_rewrite; if ( $wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes == true && $type == 'page' ){ return untrailingslashit( $string ); } else { return $string; } add_filter( 'user_trailingslashit', 'aaetp_no_page_trailing_slash', 66, 2 ); }
This fix solved the problem.
I hope this report can be useful for the next release of your plugin.
- The topic ‘Incompatibility with latest WPML version’ is closed to new replies.