Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #995131

    I just spent several hours tracing this issue to Enfold. In short, I’ve got a site using the Pods CPT framework to make a frontend form for users to update various profile fields. A recent-ish update to Pods switched them to a new script for handling select fields/media uploads, etc. which was broken on our site. That script has the WordPress core “media-views” as a dependency, which in turn has “wp-mediaelement” as a dependency.

    In Enfold’s functions.php, starting at line 417 we have:

    		//load mediaelement js
    		$condition  = !( isset($options['disable_mediaelement']) && $options['disable_mediaelement'] == "disable_mediaelement" ) && av_video_assets_required();
    		$condition2 = ( version_compare( get_bloginfo( 'version' ), '4.9', '>=' ) ) && $condition;
    		avia_enqueue_script_conditionally( $condition , 'wp-mediaelement');
    		avia_enqueue_style_conditionally( $condition2 , 'wp-mediaelement'); //With WP 4.9 we need to load the stylesheet seperately
    

    If we look into the avia_enqueue_script_conditionally and avia_enqueue_style_conditionally in function-set-avia-frontend.php, we see that these functions’ default option is to deregister scripts when the condition is false and the optional argument “deregister” is true. I’ve updated the function to

    		//load mediaelement js
    		$condition  = !( isset($options['disable_mediaelement']) && $options['disable_mediaelement'] == "disable_mediaelement" ) && av_video_assets_required();
    		$condition2 = ( version_compare( get_bloginfo( 'version' ), '4.9', '>=' ) ) && $condition;
    		avia_enqueue_script_conditionally( $condition , 'wp-mediaelement', '', array(), false, false, false);
    		avia_enqueue_style_conditionally( $condition2 , 'wp-mediaelement', '', array(), false, 'all', false); //With WP 4.9 we need to load the stylesheet seperately
    

    Which fixes my issue. Enfold probably shouldn’t be deregistering WordPress core scripts, since other plugins might expect them to exist. Is this something that can be fixed in future versions of Enfold?

    #995136

    Hey ianrmcnair!

    Yes the next update will introduce a new filter so you don’t need to hack the theme files ( https://kriesi.at/support/topic/wp_enqueue_media-not-working-on-frontend-after-latest-update/#post-993991 )

    You can then use following code in your child theme functions.php to set the condition to true and to always load wp-mediaelement:

    
    add_filter( 'avf_enqueue_wp_mediaelement', 'avia_always_load_mediaelement', 10, 2);
    function avia_always_load_mediaelement($condition, $options)
    {
    	$condition = true;
    	return $condition;
    }
    

    (this is just an example – of course you could also set it with __return_true: https://codex.wordpress.org/Function_Reference/_return_true ).

    Cheers!
    Peter

    #995140

    Ah excellent, thank you. I searched before posting, but I guess I glossed over that thread. I’ll keep an eye out for that next update.

    • This reply was modified 6 years, 3 months ago by ianrmcnair.
    #995248

    Hi,

    Thanks for the feedback. Please let us know if you should need any further help on the topic.

    Best regards,
    Rikard

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.