I am able to use Toolset and Oxygen 3.7 - 3.8 no problems (apart from the usual oxygen builder debug log bloat)
I am also able to use Toolset types 3.4.10 and wpgridbuilder 1.5.8
but if I try to add a grid to oxygen with Toolset Types installed I get some critical errors (I don't get the same thing using CPT UI.
...I am raising ticket with wpgridbuilder and oxygen, so please let me know if you think this is a toolset issue or not.
I tried many older version of toolset and oxygen and wpgridbuilder - always the same result
sample from log
Stack trace:
#0 /sites/ox37.izu.io/files/wp-content/plugins/types/vendor/toolset/toolset-common/inc/toolset.css.component.class.php(69): Toolset_CssComponent->is_allowed_page()
#1 /sites/ox37.izu.io/files/wp-includes/class-wp-hook.php(292): Toolset_CssComponent->admin_enqueue_scripts()
#2 /sites/ox37.izu.io/files/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters()
#3 /sites/ox37.izu.io/files/wp-includes/plugin.php(484): WP_Hook->do_action()
#4 /sites/ox37.izu.io/files/wp-includes/functions.wp-scripts.php(95): do_action()
#5 /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php(904): wp_print_scripts()
#6 /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/single.template.php(44): OxygenElement->ajax_render_callback()
#7 /sites/ox37.izu.io/files/wp-i in /sites/ox37.izu.io/files/wp-content/plugins/types/vendor/toolset/toolset-common/inc/toolset.css.component.class.php on line 261
[07-Jul-2021 12:40:00 UTC] PHP Notice: Trying to get property 'ID' of non-object in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/component-init.php on line 610
[07-Jul-2021 12:40:06 UTC] PHP Notice: Undefined variable: show_gradient in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/toolbar/views/background.view.php on line 167
[07-Jul-2021 12:40:22 UTC] PHP Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /sites/ox37.izu.io/files/wp-includes/functions.php on line 4757
[07-Jul-2021 12:40:22 UTC] PHP Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /sites/ox37.izu.io/files/wp-includes/functions.php on line 4757
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: html_template in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 297
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: html_template in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 297
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: inlineJS in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 318
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: inlineJS in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 319
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: html_template in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 297
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: inlineJS in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 318
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: inlineJS in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 319
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined property: OxygenElement::$registeredSelectors in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 350
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: html_template in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 297
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: inlineJS in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 318
[07-Jul-2021 12:40:22 UTC] PHP Notice: Undefined index: inlineJS in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 319
[07-Jul-2021 12:40:26 UTC] PHP Notice: Undefined index: queryOptions in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/single.template.php on line 20
[07-Jul-2021 12:40:26 UTC] PHP Notice: Undefined index: children in /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php on line 876
[07-Jul-2021 12:40:26 UTC] PHP Fatal error: Uncaught Error: Call to undefined function get_current_screen() in /sites/ox37.izu.io/files/wp-content/plugins/types/vendor/toolset/toolset-common/inc/toolset.css.component.class.php:261
Stack trace:
#0 /sites/ox37.izu.io/files/wp-content/plugins/types/vendor/toolset/toolset-common/inc/toolset.css.component.class.php(69): Toolset_CssComponent->is_allowed_page()
#1 /sites/ox37.izu.io/files/wp-includes/class-wp-hook.php(292): Toolset_CssComponent->admin_enqueue_scripts()
#2 /sites/ox37.izu.io/files/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters()
#3 /sites/ox37.izu.io/files/wp-includes/plugin.php(484): WP_Hook->do_action()
#4 /sites/ox37.izu.io/files/wp-includes/functions.wp-scripts.php(95): do_action()
#5 /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/oxygen.element.class.php(904): wp_print_scripts()
#6 /sites/ox37.izu.io/files/wp-content/plugins/oxygen/component-framework/api/single.template.php(44): OxygenElement->ajax_render_callback()
#7 /sites/ox37.izu.io/files/wp-i in /sites/ox37.izu.io/files/wp-content/plugins/types/vendor/toolset/toolset-common/inc/toolset.css.component.class.php on line 261
Hello,
Since it is a compatibility issue, please provide a copy of your website, you can put the package files in your own google drive disk, share the link only, also point out the problem page URLs, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/
Thanks for the details, I can duplicate the same problem with your package file.
1) Toolset Types plugin do check if it is in WP admin side with WP function is_admin(), see the source code of Types plugin file "
/types/vendor/toolset/toolset-common/inc/toolset.css.component.class.php", line 257~261:
if ( is_admin() ) {
$screen_id = '';
$screen_base = '';
$screen = get_current_screen();
More help:
https://developer.wordpress.org/reference/functions/is_admin/
2) The problem is in another plugin "WP Grid Builder - Oxygen", file "wp-grid-builder-oxygen\includes\elements\class-grid.php", line 135~137:
if ( ! defined( 'WP_ADMIN' ) ) {
define( 'WP_ADMIN', true );
}
It forces to define as WP administrative interface page, and conducts the problem, you will need to check it with the plugin author of "WP Grid Builder - Oxygen"
Hello,
This line of code is normal and only happens when a request is for an administrative interface page.
And, this is a case when making an Ajax request to the backend in order to enqueue assests in the editor.
Checking is_admin() does not guarantee the existence of the get_current_screen() function.
Because this function my be declared later depending on the order of execution of the code.
Regards,
Loïc Blascos
Please have a look to the document I mentioned above:
https://developer.wordpress.org/reference/functions/is_admin/
WP function is_admin() will check if it is inside WordPress administration interface, and if it is inside WordPress administration interface, the function get_current_screen() should work without any problem:
https://developer.wordpress.org/reference/classes/wp_screen/
Core class used to implement an admin screen API.
It is the plugin "WP Grid Builder - Oxygen" define it as inside WordPress administration interface forcedly, even it is in frontend side, and conducts the problem.
There is nothing we can do here, you will need to check it with the plugin author of "WP Grid Builder - Oxygen".
From Loïc - the developer of wpgridbuilder:
The code pointed by Toolset team in WP Grid Builder - Oxygen add-on is only executed in the backend from an Ajax request made by Oxygen builder in the editor.
is_admin() function does not guarantee the existence of the get_current_screen() function. That's for this reason there is a fatal error in Toolset code.
get_current_screen() function is not always loaded even if is_admin() returns true.
Loïc suggests that the fix might be simple:
Toolset could check if the function exists before calling it., as there isn't any error or issue from WP Grid Builder.
WP Grid Builder - Oxygen add-on is an oxygen builder integration so I imagine that's why WordPress administration interface is being forced.
what do you think ?
thanks again
Hi,
Thank you for sharing these details.
Luo is on vacation this week, so I'll be following up on this ticket.
I've shared these details and the response from the WP Grid Builder - Oxygen plugin, with the concerned team for further review.
I'll update you once I'll hear back from them.
regards,
Waqar
Thanks Waqar, good to hear from you again.
Thank you for waiting and I've heard back from our concerned team.
We've run some tests and even if we make some adjustments in the Toolset code to make the detection of admin pages check more precise, it won't solve the actual issue.
The WP function 'get_current_screen()' is only available on the back-end admin pages. It’s correct that 'is_admin()' can be true during front-end ajax requests, so we could make this more watertight by adding a check for ajax requests as well with 'wp_doing_ajax()'. However, it’s actually redundant here because the code under review isn’t run during ajax requests.
But the error still occurs if we make that change.
Why? Because the WP Grid Builder – Oxygen plugin breaks the core WP function 'is_admin()' by setting the WP_ADMIN constant to true, even when *not* on back-end admin pages. Of course, this is likely to have side effects, not just with Toolset plugins but with other plugins and themes, which use the 'is_admin()' function to detect the back-end admin pages.
It still clears the (! wp_doing_ajax hurdle) in ours tests because the WP Grid Builder plugin doesn’t use the normal WordPress API for ajax and instead uses a bespoke system.
So, in sum, the error occurs because editing with Oxygen happens on a front-end page but this plugin tricks WordPress into thinking it is on a back-end admin page.
We don’t know exactly why they do it like this, but our recommendation would be that they find some alternative that does not depend on breaking core WordPress functionality. We won’t add redundant function_exists checks for core WP functions throughout our codebase to cover such unexpected scenarios.
Waqar,
thank you and level2 for putting in so much effort, it is truly appreciated.
I want to pass the comments on to Loïc and see what happens if we can keep this open for a few days
regards
bryan
I have marked this ticket as "Waiting for feedback" status, you can update here if you still need assistance for it.
From Loïc - the developer of wpgridbuilder:
First of all, the request is not made by WP Grid Builder but by Oxygen plugin in the editor.
Checking is_admin() or wp_doing_ajax() does not ensure that WordPress has included all helpers (including screen functions).
For this reason, it is important to check the existence of the function before using it:
if ( function_exists( 'get_current_screen' ) ) { ... }
Some WordPress functions may not exist in certain contexts and need to be included or checked before calling them. The most important thing to understand is that when a fatal error occurs it is due to the logic of the code where it occurs (lack of checks, syntax problems, etc.).
his conclusion:
Expecting that a function exists and calling it when it doesn't is a coding error.
let me know what you think !
thanks
Please check the above answer from our 2nd tier supporters:
We won’t add redundant function_exists checks for core WP functions throughout our codebase to cover such unexpected scenarios.