Skip navigation
Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 -
- 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 -

Часовой пояс сторонника: Europe/Vienna (GMT+01:00)

Эта тема содержит 0 ответов, имеет 1 голос.

Последнее обновление: johnS-9 4 месяца, 2 недели назад.

При содействии: Bigul.

Автор Записи
28 июня, 2024 на 12:56 пп #15851987

johnS-9

Background of the issue:
I am trying to use a Menu item based language switcher.

I am also using LearnDash LMS, which runs has_shortcode() on menu item descriptions.

Because WPML's WPML_LS_Menu_Item has the $description set to null, it causes a deprecation warning.

Symptoms:
WPML_LS_Menu_Item throwing - Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated.

Questions:
Is it possible to apply this patch to WPML to improve the compatibility with LearnDash? Setting a better default will not cause the deprecation warning.

diff --git a/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-menu-item.php b/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-menu-item.php
--- a/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-menu-item.php (revision 62e2aa2b89fe4476033df2ecf81f112ef12ea707)
+++ b/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-menu-item.php (revision d56f60b8f00090029253e361ff702859a11e137d)
@@ -50,6 +50,7 @@
$this->title = $item_content;
$this->post_title = $item_content;
$this->url = isset( $lang['url'] ) ? $lang['url'] : null;
+ $this->description = '';

if ( isset( $lang['css_classes'] ) ) {
$this->classes = $lang['css_classes'];

Тема '[Закрытые] WPML_LS_Menu_Item throwing — Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of…' закрыта для новых ответов.