Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 4 replies, has 2 voices.

Last updated by jerisscloudcenter 11 months, 2 weeks ago.

Assisted by: Bruno Kos.

Author Posts
May 17, 2023 at 5:39 pm #13667139

jerisscloudcenter

https://wpml.org/documentation/getting-started-guide/sticky-links/#handling-links-inside-shortcode-content

Your documentation provides the below code (which goes into Theme > Functions.php) :

global $WPML_Sticky_Links;
if ( method_exists( $WPML_Sticky_Links, 'show_permalinks' ) ) {
add_filter( 'do_shortcode_tag', [ $WPML_Sticky_Links, 'show_permalinks' ], 0 );
}

However, there are cases when I need to disable WPML plugins for debugging. And the issue is that if I disable WPML plugins BUT I keep the above shortcode on my Functions.php, the site crashes.

Therefore, you need to adjust your shortcode so that it avoids crashing the site if WPML plugins are being disabled (because it can happen, like for debugging for instance). So you need to make sure your code detects if WPML plugins are activated or not, if not then the code should not fire itself.

Uncaught TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given in wp-content/themes/THEME/functions.php:3
Stack trace:
#0 wp-content/themes/THEME/functions.php(33): method_exists()
#1 wp-settings.php(591): include('/home/DOMAIN...')
#2 wp-config.php(92): require_once('/home/DOMAIN...')
#3 wp-load.php(50): require_once('/home/DOMAIN...')
#4 wp-admin/admin.php(34): require_once('/home/DOMAIN...')
#5 wp-admin/theme-editor.php(10): require_once('/home/DOMAIN...')
#6 {main}
thrown

CAPTURE.png
May 18, 2023 at 2:07 pm #13672679

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

Can you try with this?

if ( class_exists( 'WPML_Sticky_Links' ) ) {
	global $WPML_Sticky_Links;
    add_filter( 'do_shortcode_tag', [ $WPML_Sticky_Links, 'show_permalinks' ], 0 );
}

Regards,
Bruno Kos

May 18, 2023 at 2:53 pm #13672825

jerisscloudcenter

It seems to work better now. Would you adjust your documentation with this new code? Thanks

May 19, 2023 at 5:52 am #13675845

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

We created an internal ticket to adjust this in the documentation as well.

Regards,
Bruno Kos

May 19, 2023 at 7:30 am #13676303

jerisscloudcenter

Ok great thanks!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.