css-element-queries icon indicating copy to clipboard operation
css-element-queries copied to clipboard

Element queries not working when Gravatar Hovercards from Jetpack for WordPress is being used

Open enventa opened this issue 8 years ago • 2 comments
trafficstars

Hi @marcj

I have noticed that Element Queries don't work when "Gravatar Hovercards" functionality from Jetpack for WordPress plugin is ON. If I deactivate that functionality, Element Queries work fine again.

In fact, it is this piece of javascript code the one to blaim:

/* global WPGroHo:true, Gravatar */
WPGroHo = jQuery.extend( {
	my_hash: '',
	data: {},
	renderers: {},
	syncProfileData: function( hash, id ) {
		if ( !WPGroHo.data[hash] ) {
			WPGroHo.data[hash] = {};
			jQuery( 'div.grofile-hash-map-' + hash + ' span' ).each( function() {
				WPGroHo.data[hash][this.className] = jQuery( this ).text();
			} );
		}

		WPGroHo.appendProfileData( WPGroHo.data[hash], hash, id );
	},
	appendProfileData: function( data, hash, id ) {
		for ( var key in data ) {
			if ( jQuery.isFunction( WPGroHo.renderers[key] ) ) {
				return WPGroHo.renderers[key]( data[key], hash, id, key );
			}

			jQuery( '#' + id ).find( 'h4' ).after( jQuery( '<p class="grav-extra ' + key + '" />' ).html( data[key] ) );
		}
	}
}, WPGroHo );

jQuery( document ).ready( function() {
	if ( 'undefined' === typeof Gravatar ) {
		return;
	}

	Gravatar.profile_cb = function( h, d ) {
		WPGroHo.syncProfileData( h, d );
	};

	Gravatar.my_hash = WPGroHo.my_hash;
	Gravatar.init( 'body', '#wpadminbar' );
} );

Do you see what the incompatibility issue may come from? Anything suspect in the code above that could be the cause of the issue?

Thanks!

Regards, Víctor

enventa avatar Aug 22 '17 09:08 enventa

In fact, making just some trials, I found out that is the last line (Gravatar.init( 'body', '#wpadminbar' );) the one to blame.

Anyone knows what does it do exactly?

enventa avatar Aug 22 '17 10:08 enventa

Actually no idea. Maybe you should post the code behind Gravatar.init to get more insights.

marcj avatar Aug 22 '17 13:08 marcj