Home » Topics » Priority Support » acf-widgets.js change request

acf-widgets.js change request

ACF Widgets Support Priority Support acf-widgets.js change request

This topic contains 6 replies, has 2 voices, and was last updated by  Daron Spence 2 years, 11 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #82492

    Przemek Cichoń
    Participant

    Hi Daron,

    Recently I have installed MailPoet plugin on two websites where I am using both ACF Widget and the former one and on one of them I am having an issue with the MailPoet interface where I am to create an email newsletter.

    I guess that the problem is that there is some script not related to ACF Widget which does not allow DOM to load completely. In result (if I understand that correctly) the way the DOM ready event is implemented in acf-widget.js script makes all other scripts freeze. What I did was following this instruction: http://gregfranko.com/blog/jquery-best-practices/ and modified acf-widget.js so that end result is the following:
    `
    (function ($, window, document ) {

    function acfw(){
    var el = $(“div[id*=’_acf_widget_’] .acf-field”);
    var num = 0;
    var body = $(‘body’);
    num = el.length;
    if ( num > 0 ){
    var remove = el.siblings(‘.acfw-no-acf’);
    remove.attr(‘data-display’, ‘none’);
    }
    }

    function acfw_remove_fields(){
    $(‘.widget .acf-field’).remove();
    }

    $( acfw );

    }( jQuery, window, document ) );
    `

    Again if I got it right it removes this dependency which is causing the MailPoet interface freeze.

    Would you be able to consider changing the acf-widget.js accordingly (perhaps it is not completely right, I am not a javascript expert) in future releases?

    I have mentioned that I am using both plugins on two site but I’m faceing this issue only on one of them probably because the original issue is somewhere else and is not related to either of the two plugins.

    Best regards,
    Przemek

    #82497

    Daron Spence
    Keymaster

    Good lord that is embarrassing! Remember how people talk about going back to look at old code and cringing? That just happened!

    I’ll be sure to update this and get a fix pushed out before Monday hopefully. I’m moving across the country in a few weeks so things are a little crazy at home 🙂

    In the meantime, you can modify the script and the changes will be overwritten when I push the update.

    Which Mailpoet plugin were you using exactly? Just want to double check before I do push anything.

    Cheers! Thanks for catching that! (this is so embarrassing)

    #82498

    Przemek Cichoń
    Participant

    Hey,

    no worries 🙂 really your plugin saves a lot of my time.

    Here is the plugin that I am using for newsletter: https://wordpress.org/plugins/wysija-newsletters/.

    regards,
    Przemek

    #82499

    Przemek Cichoń
    Participant

    However if you are asking me which extension to Mailpoet do I use, then none 🙂 When I was writing Mailpoet plugin I meant Mailpoet not a plugin to Mailpoet. Probably it’s just my English issue 😉

    #82716

    Daron Spence
    Keymaster

    Hey Przemek, finally got some time to work on this. Sorry!

    Would you mind testing out this configuration instead for the JS file?

    function acfw(){
    	var el = jQuery("div[id*='_acf_widget_'] .acf-field");
    	var num = 0;
    	var body = jQuery('body');
    	num = el.length;
    	if ( num > 0 ){
    		var remove = el.siblings('.acfw-no-acf');
    		remove.attr('data-display', 'none');
    	}
    }
    function acfw_remove_fields(){ 
    	jQuery('.widget .acf-field').remove(); 
    }
    jQuery(document).ready( acfw );
    

    Unfortunately, I need to keep the acfw() function available for plugin to use and wrapping it in an anonymous function makes it inaccessible to anything after it runs once.

    Let me know if that works for you. If it doesn’t I would greatly appreciate a screen-shot of the error so I can debug the conflict.

    Thanks!

    #83198

    Przemek Cichoń
    Participant

    Hey Daron,

    Yep, I can confirm that if I replace the original code with the code above all is working fine.

    Thank you,
    Przemek

    #83206

    Daron Spence
    Keymaster

    Thanks. I will get this pushed tonight.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘acf-widgets.js change request’ is closed to new replies.