Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/widgets
File: customizer-utils.js
/* global gapi, FB, twttr, PaypalExpressCheckout */
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Utilities to work with widgets in Customizer.
[3] Fix | Delete
*/
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Checks whether this Customizer supports partial widget refresh.
[7] Fix | Delete
* @return {boolean}
[8] Fix | Delete
*/
[9] Fix | Delete
wp.customizerHasPartialWidgetRefresh = function () {
[10] Fix | Delete
return (
[11] Fix | Delete
'object' === typeof wp &&
[12] Fix | Delete
'function' === typeof wp.customize &&
[13] Fix | Delete
'object' === typeof wp.customize.selectiveRefresh &&
[14] Fix | Delete
'object' === typeof wp.customize.widgetsPreview &&
[15] Fix | Delete
'function' === typeof wp.customize.widgetsPreview.WidgetPartial
[16] Fix | Delete
);
[17] Fix | Delete
};
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Verifies that the placed widget ID contains the widget name.
[21] Fix | Delete
* @param {object} placement
[22] Fix | Delete
* @param {string} widgetName
[23] Fix | Delete
* @return {*|boolean}
[24] Fix | Delete
*/
[25] Fix | Delete
wp.isJetpackWidgetPlaced = function ( placement, widgetName ) {
[26] Fix | Delete
return placement.partial.widgetId && 0 === placement.partial.widgetId.indexOf( widgetName );
[27] Fix | Delete
};
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Bind events for selective refresh in Customizer.
[31] Fix | Delete
*/
[32] Fix | Delete
( function ( $ ) {
[33] Fix | Delete
$( document ).ready( function () {
[34] Fix | Delete
if ( wp && wp.customize && wp.customizerHasPartialWidgetRefresh() ) {
[35] Fix | Delete
// Refresh widget contents when a partial is rendered.
[36] Fix | Delete
wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function ( placement ) {
[37] Fix | Delete
if ( placement.container ) {
[38] Fix | Delete
// Refresh Google+
[39] Fix | Delete
if (
[40] Fix | Delete
wp.isJetpackWidgetPlaced( placement, 'googleplus-badge' ) &&
[41] Fix | Delete
'object' === typeof gapi &&
[42] Fix | Delete
gapi.person &&
[43] Fix | Delete
'function' === typeof gapi.person.go
[44] Fix | Delete
) {
[45] Fix | Delete
gapi.person.go( placement.container[ 0 ] );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
// Refresh Facebook XFBML
[49] Fix | Delete
else if (
[50] Fix | Delete
wp.isJetpackWidgetPlaced( placement, 'facebook-likebox' ) &&
[51] Fix | Delete
'object' === typeof FB &&
[52] Fix | Delete
'object' === typeof FB.XFBML &&
[53] Fix | Delete
'function' === typeof FB.XFBML.parse
[54] Fix | Delete
) {
[55] Fix | Delete
FB.XFBML.parse( placement.container[ 0 ], function () {
[56] Fix | Delete
var $fbContainer = $( placement.container[ 0 ] ).find( '.fb_iframe_widget' ),
[57] Fix | Delete
fbWidth = $fbContainer.data( 'width' ),
[58] Fix | Delete
fbHeight = $fbContainer.data( 'height' );
[59] Fix | Delete
$fbContainer.find( 'span' ).css( { width: fbWidth, height: fbHeight } );
[60] Fix | Delete
setTimeout( function () {
[61] Fix | Delete
$fbContainer
[62] Fix | Delete
.find( 'iframe' )
[63] Fix | Delete
.css( { width: fbWidth, height: fbHeight, position: 'relative' } );
[64] Fix | Delete
}, 1 );
[65] Fix | Delete
} );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
// Refresh Twitter
[69] Fix | Delete
else if (
[70] Fix | Delete
wp.isJetpackWidgetPlaced( placement, 'twitter_timeline' ) &&
[71] Fix | Delete
'object' === typeof twttr &&
[72] Fix | Delete
'object' === typeof twttr.widgets &&
[73] Fix | Delete
'function' === typeof twttr.widgets.load
[74] Fix | Delete
) {
[75] Fix | Delete
twttr.widgets.load( placement.container[ 0 ] );
[76] Fix | Delete
} else if ( wp.isJetpackWidgetPlaced( placement, 'eu_cookie_law_widget' ) ) {
[77] Fix | Delete
// Refresh EU Cookie Law
[78] Fix | Delete
if ( $( '#eu-cookie-law' ).hasClass( 'top' ) ) {
[79] Fix | Delete
$( '.widget_eu_cookie_law_widget' ).addClass( 'top' );
[80] Fix | Delete
} else {
[81] Fix | Delete
$( '.widget_eu_cookie_law_widget' ).removeClass( 'top' );
[82] Fix | Delete
}
[83] Fix | Delete
placement.container.fadeIn();
[84] Fix | Delete
} else if ( wp.isJetpackWidgetPlaced( placement, 'jetpack_simple_payments_widget' ) ) {
[85] Fix | Delete
// Refresh Simple Payments Widget
[86] Fix | Delete
try {
[87] Fix | Delete
var buttonId = $( '.jetpack-simple-payments-button', placement.container )
[88] Fix | Delete
.attr( 'id' )
[89] Fix | Delete
.replace( '_button', '' );
[90] Fix | Delete
PaypalExpressCheckout.renderButton( null, null, buttonId, null );
[91] Fix | Delete
} catch {
[92] Fix | Delete
// PaypalExpressCheckout may fail.
[93] Fix | Delete
// For the same usage, see also:
[94] Fix | Delete
// https://github.com/Automattic/jetpack/blob/6c1971e6bed7d3df793392a7a58ffe0afaeeb5fe/modules/simple-payments/simple-payments.php#L111
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
}
[98] Fix | Delete
} );
[99] Fix | Delete
[100] Fix | Delete
// Refresh widgets when they're moved.
[101] Fix | Delete
wp.customize.selectiveRefresh.bind( 'partial-content-moved', function ( placement ) {
[102] Fix | Delete
if ( placement.container ) {
[103] Fix | Delete
// Refresh Twitter timeline iframe, since it has to be re-built.
[104] Fix | Delete
if (
[105] Fix | Delete
wp.isJetpackWidgetPlaced( placement, 'twitter_timeline' ) &&
[106] Fix | Delete
placement.container.find( 'iframe.twitter-timeline:not([src]):first' ).length
[107] Fix | Delete
) {
[108] Fix | Delete
placement.partial.refresh();
[109] Fix | Delete
} else if ( wp.isJetpackWidgetPlaced( placement, 'jetpack_simple_payments_widget' ) ) {
[110] Fix | Delete
// Refresh Simple Payments Widget
[111] Fix | Delete
placement.partial.refresh();
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
} );
[115] Fix | Delete
}
[116] Fix | Delete
} );
[117] Fix | Delete
} )( jQuery );
[118] Fix | Delete
[119] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function