Custom sidebars and BuddyMedia conflict

When both Custom Sidebars Pro and BuddyMedia are active, add sidebar button doesn't work. it keeps spinning endlessly
The plugin GitHub link: https://github.com/WebDevStudios/WDS-BP-Media.

  • Mahlamusa

    Hello Hitt-Girl

    I hope you are doing great today. I am sorry for the inconvenience caused by the conflict between the plugins. I have downloaded and installed both plugins on my test website with the intention to replicate this issue.

    I was able to replicate this issue on my test, after reviewing the code of the BuddyMedia plugin I was able to find a fix for this. The issue is that the BuddyMedia plugin was hijacking the Ajax Requests of the Custom Sidebars Pro plugin. This plugin can cause some other issue not only on Custom Sidebars Pro because it was written to check for a general ajax request and do something with the data or response of the request, it does not check for its own Ajax requests but hijacks any running one on the page.

    What I did to resolve this was to change one line inside the file:

    includes/js/bp-media.js

    I changed:

    if( !str )
    	       return false;

    To :

    if( !str || typeof str != "string" || typeof str === "object")
    	       return false;

    So the function looks like this:

    function get_var_in_query( item,  str ){
    	   var items;
    	   if( !str || typeof str != "string" || typeof str === "object")
    	       return false;
    
    	   var data_fields = str.split('&');
    	   for( var i=0; i< data_fields.length; i++ ){
    
    	       items = data_fields[i].split('=');
    	       if( items[0] == item )
    	           return items[1];
    		}
    
    	    return false;
    	}

    After that, I tested the process of creating a custom sidebar and it works as expected. I did this because the function

    get_var_in_query(item, str)

    Is used to grab the response of the running Ajax Request and do some splitting, it expects this to be a string but Custom Sidebars Pro returns an object, so the function fails as it can't split an object, that is why it hangs up after failing.

    You should contact the developer of the BuddyMedia plugin and let them know about this issue, they should only manipulate their own Ajax Requests not any running request. They should write their code to do the checks before manipulating any responses.

    I hope this helps.

    Cheers,
    Mahlamusa