-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating selective refresh script. Partial completion of issue #1, re…
…renders the plugin however it is hidden
- Loading branch information
1 parent
add24f7
commit 1071daf
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
jQuery( function() { | ||
// Short-circuit selective refresh events if not in customizer preview or pre-4.5. | ||
if ( 'undefined' === typeof wp || ! wp.customize || ! wp.customize.selectiveRefresh ) { | ||
return; | ||
} | ||
|
||
// Re-load Facebook Page Plugin when a partial is rendered. | ||
wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { | ||
if ( placement.container ) { | ||
if( placement.container.find('.cameronjonesweb_facebook_page_plugin') ) { | ||
var wrapper = placement.container.find('.cameronjonesweb_facebook_page_plugin'); | ||
var containerId = wrapper.attr('id'); | ||
var container = wrapper.children('.fb-page'); | ||
var url = container.data('href'); | ||
container.load( url, function() { | ||
FB.XFBML.parse(document.getElementById( containerId ), | ||
function() { | ||
container.fadeIn( "slow" ); | ||
} | ||
); | ||
}); | ||
} | ||
} | ||
} ); | ||
|
||
// Refresh a moved partial containing a Facebook Page Plugin, since it has to be re-built. | ||
wp.customize.selectiveRefresh.bind( 'partial-content-moved', function( placement ) { | ||
if ( placement.container && placement.container.find( '.cameronjonesweb_facebook_page_plugin' ).length ) { | ||
placement.partial.refresh(); | ||
} | ||
} ); | ||
} ); |