This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're experiencing a warning message about an undefined property in the Astra theme's extras.php file while configuring WPML, specifically related to stdClass::$menu_id on lines 508 and 546.
Solution:
We recommend checking if the menu_id property exists in the $args object using isset() to avoid the error when the property is undefined. You can temporarily update the following lines in the /wp-content/themes/astra/inc/extras.php file:
if (isset($args->menu_id) && in_array($args->menu_id, $astra_menu_locations)) {
on line 513
and
$is_special_menu = isset($args->menu_id) && in_array($args->menu_id, $special_menu_ids);
on line 536.
This solution might be irrelevant if it's outdated or not applicable to your case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at WPML support forum.
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.
Tagged: Bug, Compatibility
This topic contains 26 replies, has 3 voices.
Last updated by Marcel 1 month, 1 week ago.
Assisted by: Marcel.
Author | Posts |
---|---|
October 2, 2024 at 3:59 pm #16246654 | |
samM-20 |
I set up a redirect.php in the domain's main directory with the only content <?php But WPML seems not to accept that as an html default page in language settings, neither by entering redirect.php nor by /redirect.php. |
October 2, 2024 at 4:02 pm #16246659 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, Please refer to this link for more details: WPML Language Setup. The root page as a WordPress page doesn't have built-in styling options, so all styling must be applied manually via code. You can add the necessary HTML file to the root directory of your installation without making any changes to the theme folder. Best regards, |
October 3, 2024 at 12:57 pm #16250083 | |
samM-20 |
I really appreciate your support and I feel terribly sorry for being still stuck. The option with the WP page seems not to work since I can not select a template in the page settings. Maybe because of Astra theme? The html file option seems not to work – I placed a file with the content you specified, but only got a different error message. Any more hints or ideas? (Feeling so stupid.) |
October 3, 2024 at 12:59 pm #16250127 | |
samM-20 |
Here's the error message shown on the website's root: Warning: include(/redirect.php): Failed to open stream: No such file or directory in /home/httpd/vhosts/***.com/***.com/wp-content/plugins/sitepress-multilingual-cms/classes/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php on line 45 Warning: include(/redirect.php): Failed to open stream: No such file or directory in /home/httpd/vhosts/***.com/***.com/wp-content/plugins/sitepress-multilingual-cms/classes/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php on line 45 Warning: include(): Failed opening '/redirect.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/httpd/vhosts/***.com/***.com/wp-content/plugins/sitepress-multilingual-cms/classes/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php on line 45 |
October 3, 2024 at 2:17 pm #16250614 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, No worries! It looks like the procedure wasn't quite right, but you can try the following steps: 1) Create a file named "root-page.html" and save it in the root folder of your server (the same location as the redirect.php file). Make sure there are no empty spaces, so the file is starting on line 1. 2) Open the WPML settings and simply enter "root-page.html" without adding a forward slash ("/"). You can see a screenshot of this step hidden link redirect.png">here. 3) Lastly, resave your WordPress permalinks (WPML will prompt you to do this and provide a link). Best Regards, |
October 3, 2024 at 3:07 pm #16250936 | |
samM-20 |
That finally worked. Thanks so much for your support and being patient! |
October 3, 2024 at 3:12 pm #16250946 | |
samM-20 |
By the way: we now have a root page, so the front end works properly. But the original issue was still not solved. We still see the error message at > WPML > languages Warning: Undefined property: stdClass::$menu_id in /home/httpd/vhosts/***.com/***.com/wp-content/themes/astra/inc/extras.php on line 508 Warning: Undefined property: stdClass::$menu_id in /home/httpd/vhosts/***.com/***.com/wp-content/themes/astra/inc/extras.php on line 546 Warning: Undefined property: stdClass::$menu_id in /home/httpd/vhosts/***.com/***.com/wp-content/themes/astra/inc/extras.php on line 508 Warning: Undefined property: stdClass::$menu_id in /home/httpd/vhosts/variaduna.com/***.com/wp-content/themes/astra/inc/extras.php on line 546 |
October 3, 2024 at 5:37 pm #16251628 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Hi, Could you please provide a Duplicator copy of your site for further debugging? This will help us investigate why, despite all requirements being met now, the Astra theme is still causing an error on our GUI endpoint. Thanks! Best regards, |
October 8, 2024 at 2:43 pm #16266018 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Thank you! You can go ahead and remove the file now. This was helpful in allowing me to reproduce the issue from scratch and escalate it to our compatibility team, who will contact the theme authors to get it resolved in their code. In the meantime, I’ve found a temporary workaround you can apply. By checking if the menu_id property exists in the $args object using isset(), we can avoid the error when the property is undefined. You can temporarily update the following lines in the /wp-content/themes/astra/inc/extras.php file: Line 513: if ( isset( $args->menu_id ) && in_array( $args->menu_id, $astra_menu_locations ) ) { Line 536: $is_special_menu = isset( $args->menu_id ) && in_array( $args->menu_id, $special_menu_ids ); Best Regards, |
October 8, 2024 at 3:11 pm #16266135 | |
samM-20 |
Since we know it's treated by you: if there is only the admin user interface issue we'll be fine with it for the moment. Do you see any potential frontend side effects we should catch with the two code lines? |
October 8, 2024 at 3:14 pm #16266137 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Currently, I haven't noticed any side effects. I’ve tested it locally, but it might be best to wait a few more days until our compatibility team contacts Astra, as they may resolve the issue quickly. Best regards, |
October 8, 2024 at 3:14 pm #16266153 | |
Marcel Supporter
Languages: English (English ) German (Deutsch ) Timezone: Europe/Madrid (GMT+01:00) |
Currently, I haven't noticed any side effects. I’ve tested it locally, but it might be best to wait a few more days until our compatibility team contacts Astra, as they may resolve the issue quickly. Best regards, |