Ahto
Forum Replies Created
-
@rose18 basically I have setup like this: https://developers.elementor.com/add-javascript-to-elementor-widgets/
and instead of
wp_register_script
in the class__construct()
method you could put the mentioned action hook.I opted to use the other method and I just tested that it does not matter whether you include the
'elementor-frontend'
last of first. This just makes sure that the frontend script gets enqueued, even if no other widget on the page requests it. The widget’s script is anyway wrapped into:
jQuery( window ).on( ‘elementor/frontend/init’, () => { /* class and attachHandler sfuff */ });
and if the script loads before'elementor-frontend'
on the page it does not really matter, atleast for my usecase.I encountered the same issue on Elementor v3.24.7 (with Pro v3.24.4). It seems that when custom widgets use
'elementor-frontend'
as a script dependency, it causes a loading order conflict that results in the error.I was able to resolve the issue by delaying the registration of the script, ensuring it loads later in the script order.
Instead of registering the script directly in the widget constructor like this:
wp_register_script('handle', '/script.js', ['elementor-frontend'], '1.0.0', true);
I moved the registration into an action hook with a higher priority:
add_action( 'wp_enqueue_scripts', function() { wp_register_script('handle', '/script.js', ['elementor-frontend'], '1.0.0', true); }, 999);
This still changes the loading order of the
elementor-frontend
script, but not as much and prevents the error.Another option that I found was to not specify the dependancy when registering script and then used
get_script_depends()
to include'elementor-frontend'
.- This reply was modified 5 months, 1 week ago by Ahto. Reason: Additional findings
The change resolved my issue. Thank you.
Forum: Plugins
In reply to: [Subpages Extended] Plugin breaks WP admin panelsEncountered the same fatal error and tracked it down to line 38 in ‘subpages-extended/subpages-extended-util-dropdown-pages.php’ (plugin version 1.6.4).
Line 38 content:
$output = apply_filters( 'wp_dropdown_pages', $output );
This filter should have 3 arguments instead of one (source: https://developer.www.ads-software.com/reference/hooks/wp_dropdown_pages/)
Adding missing arguments solved the fatal error problem for me:
$output = apply_filters( 'wp_dropdown_pages', $output, $r, $pages );
- This reply was modified 4 years, 10 months ago by Ahto. Reason: improve readability