Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/advanced.../modules/gadsense/admin/assets/js
File: adsense.js
/**
[0] Fix | Delete
* actually this method was moved inside the ad network class.
[1] Fix | Delete
* however the responsive addon depends on it, so i made it global again.
[2] Fix | Delete
* this makes it downward compatible (with an older version of responsive),
[3] Fix | Delete
* but you should probably adjust the responsive plugin to make use of
[4] Fix | Delete
* the static method (AdvancedAdsNetworkAdsense.gadsenseFormatAdContent)
[5] Fix | Delete
*
[6] Fix | Delete
* in case you come across a missing method originating from the deleted new-ad.js,
[7] Fix | Delete
* please just make the methods static and create a wrapper function like the one below
[8] Fix | Delete
*/
[9] Fix | Delete
window.gadsenseFormatAdContent = function () {
[10] Fix | Delete
AdvancedAdsNetworkAdsense.gadsenseFormatAdContent();
[11] Fix | Delete
};
[12] Fix | Delete
[13] Fix | Delete
class AdvancedAdsNetworkAdsense extends AdvancedAdsAdNetwork {
[14] Fix | Delete
constructor( codes ) {
[15] Fix | Delete
super( 'adsense' );
[16] Fix | Delete
this.name = 'adsense';
[17] Fix | Delete
this.codes = codes;
[18] Fix | Delete
this.parseCodeBtnClicked = false;
[19] Fix | Delete
this.preventCloseAdSelector = false;
[20] Fix | Delete
// this.adUnitName = null;
[21] Fix | Delete
// the legacy code of gadsense executes a script inside a php template and will may not have been executed
[22] Fix | Delete
// at this stage. the AdvancedAdsAdNetwork class already knows the publisher id, so we will overwrite
[23] Fix | Delete
// the field in gadsenseData to be up to date at all times.
[24] Fix | Delete
// TODO: the use of gadsenseData.pubId could be removed from this class in favor of this.vars.pubId
[25] Fix | Delete
gadsenseData.pubId = this.vars.pubId;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Legacy method
[30] Fix | Delete
*
[31] Fix | Delete
* Format the post content field
[32] Fix | Delete
*/
[33] Fix | Delete
static gadsenseFormatAdContent() {
[34] Fix | Delete
const slotId = jQuery( '#ad-parameters-box #unit-code' ).val();
[35] Fix | Delete
const unitType = jQuery( '#ad-parameters-box #unit-type' ).val();
[36] Fix | Delete
const publisherId = jQuery( '#advads-adsense-pub-id' ).val() ? jQuery( '#advads-adsense-pub-id' ).val() : gadsenseData.pubId;
[37] Fix | Delete
let adContent = {
[38] Fix | Delete
slotId: slotId,
[39] Fix | Delete
unitType: unitType,
[40] Fix | Delete
pubId: publisherId
[41] Fix | Delete
};
[42] Fix | Delete
if ( unitType === 'responsive' ) {
[43] Fix | Delete
let resize = jQuery( '#ad-parameters-box #ad-resize-type' ).val();
[44] Fix | Delete
if ( resize === '0' ) {
[45] Fix | Delete
resize = 'auto';
[46] Fix | Delete
}
[47] Fix | Delete
adContent.resize = resize;
[48] Fix | Delete
}
[49] Fix | Delete
if ( unitType === 'in-feed' ) {
[50] Fix | Delete
adContent.layout_key = jQuery( '#ad-parameters-box #ad-layout-key' ).val();
[51] Fix | Delete
}
[52] Fix | Delete
if ( typeof adContent.resize !== 'undefined' && adContent.resize !== 'auto' ) {
[53] Fix | Delete
jQuery( document ).trigger( 'gadsenseFormatAdResponsive', [adContent] );
[54] Fix | Delete
}
[55] Fix | Delete
jQuery( document ).trigger( 'gadsenseFormatAdContent', [adContent] );
[56] Fix | Delete
[57] Fix | Delete
if ( typeof window.gadsenseAdContent !== 'undefined' ) {
[58] Fix | Delete
adContent = window.gadsenseAdContent;
[59] Fix | Delete
delete( window.gadsenseAdContent );
[60] Fix | Delete
}
[61] Fix | Delete
jQuery( '#advads-ad-content-adsense' ).val( JSON.stringify( adContent, false, 2 ) );
[62] Fix | Delete
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
openSelector() {
[66] Fix | Delete
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
closeAdSelector() {
[70] Fix | Delete
if ( this.preventCloseAdSelector ) {
[71] Fix | Delete
return;
[72] Fix | Delete
}
[73] Fix | Delete
AdvancedAdsAdmin.AdImporter.closeAdSelector();
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
getSelectedId() {
[77] Fix | Delete
const pubId = gadsenseData.pubId || false;
[78] Fix | Delete
const slotId = jQuery( '#unit-code' ).val().trim();
[79] Fix | Delete
return pubId && slotId ? 'ca-' + pubId + ':' + slotId : null;
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
selectAdFromList( slotId ) {
[83] Fix | Delete
this.preventCloseAdSelector = true;
[84] Fix | Delete
this.onSelectAd( slotId );
[85] Fix | Delete
AdvancedAdsAdmin.AdImporter.openExternalAdsList();
[86] Fix | Delete
[87] Fix | Delete
const report = Advanced_Ads_Adsense_Report_Helper.getReportObject();
[88] Fix | Delete
if ( report ) {
[89] Fix | Delete
report.filter = slotId.split( ':' )[1];
[90] Fix | Delete
report.updateHtmlAttr();
[91] Fix | Delete
report.refresh();
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
updateAdFromList( slotId ) {
[96] Fix | Delete
this.getRemoteCode( slotId );
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
getRefreshAdsParameters() {
[100] Fix | Delete
return {
[101] Fix | Delete
nonce: AdsenseMAPI.nonce,
[102] Fix | Delete
action: 'advanced_ads_get_ad_units_adsense',
[103] Fix | Delete
account: gadsenseData.pubId,
[104] Fix | Delete
inactive: ! this.hideIdle
[105] Fix | Delete
};
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
onManualSetup() {
[109] Fix | Delete
jQuery( '.advads-adsense-code' ).css( 'display', 'none' );
[110] Fix | Delete
jQuery( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
[111] Fix | Delete
this.undoReadOnly();
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Parse the code of an adsense ad and adjust the GUI
[116] Fix | Delete
* call it, when an ad unit was selected.
[117] Fix | Delete
* returns the parsed obj or false, when the ad code could not be parsed
[118] Fix | Delete
*/
[119] Fix | Delete
processAdCode( code ) {
[120] Fix | Delete
const parsed = this.parseAdContentFailsafe( code );
[121] Fix | Delete
if ( parsed ) {
[122] Fix | Delete
this.undoReadOnly();
[123] Fix | Delete
this.setDetailsFromAdCode( parsed );
[124] Fix | Delete
this.makeReadOnly();
[125] Fix | Delete
jQuery( '#remote-ad-code-error' ).hide();
[126] Fix | Delete
jQuery( '#remote-ad-unsupported-ad-type' ).hide();
[127] Fix | Delete
this.closeAdSelector();
[128] Fix | Delete
} else {
[129] Fix | Delete
jQuery( '#remote-ad-code-error' ).show();
[130] Fix | Delete
}
[131] Fix | Delete
return parsed;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
/**
[135] Fix | Delete
* Clone of legacy method
[136] Fix | Delete
*
[137] Fix | Delete
* @param slotID
[138] Fix | Delete
*/
[139] Fix | Delete
onSelectAd( slotID ) {
[140] Fix | Delete
if ( typeof this.codes[slotID] !== 'undefined' ) {
[141] Fix | Delete
this.getSavedDetails( slotID );
[142] Fix | Delete
} else {
[143] Fix | Delete
this.getRemoteCode( slotID );
[144] Fix | Delete
}
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Legacy method
[149] Fix | Delete
*
[150] Fix | Delete
* @param slotID
[151] Fix | Delete
*/
[152] Fix | Delete
getSavedDetails( slotID ) {
[153] Fix | Delete
if ( typeof this.codes[slotID] !== 'undefined' ) {
[154] Fix | Delete
const parsed = this.processAdCode( this.codes[slotID] );
[155] Fix | Delete
if ( parsed !== false ) {
[156] Fix | Delete
jQuery( '#remote-ad-unsupported-ad-type' ).css( 'display', 'none' );
[157] Fix | Delete
this.closeAdSelector();
[158] Fix | Delete
this.preventCloseAdSelector = false;
[159] Fix | Delete
}
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
/**
[164] Fix | Delete
* Legacy method
[165] Fix | Delete
*
[166] Fix | Delete
* @param slotID
[167] Fix | Delete
*/
[168] Fix | Delete
getRemoteCode( slotID ) {
[169] Fix | Delete
if ( slotID === '' ) {
[170] Fix | Delete
return;
[171] Fix | Delete
}
[172] Fix | Delete
jQuery( '#mapi-loading-overlay' ).css( 'display', 'block' );
[173] Fix | Delete
const self = this;
[174] Fix | Delete
jQuery.ajax( {
[175] Fix | Delete
type: 'post',
[176] Fix | Delete
url: ajaxurl,
[177] Fix | Delete
data: {
[178] Fix | Delete
nonce: AdsenseMAPI.nonce,
[179] Fix | Delete
action: 'advads_mapi_get_adCode',
[180] Fix | Delete
unit: slotID
[181] Fix | Delete
},
[182] Fix | Delete
success: function ( response ) {
[183] Fix | Delete
jQuery( '#mapi-loading-overlay' ).css( 'display', 'none' );
[184] Fix | Delete
if ( typeof response.code !== 'undefined' ) {
[185] Fix | Delete
jQuery( '#remote-ad-code-msg' ).empty();
[186] Fix | Delete
if ( self.processAdCode( response.code ) !== false ) {
[187] Fix | Delete
self.codes[slotID] = response.code;
[188] Fix | Delete
AdvancedAdsAdmin.AdImporter.unitIsSupported( slotID );
[189] Fix | Delete
}
[190] Fix | Delete
AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList();
[191] Fix | Delete
jQuery( '[data-slotid="' + slotID + '"]' ).children( '.unittype' ).text( response.type );
[192] Fix | Delete
self.closeAdSelector();
[193] Fix | Delete
[194] Fix | Delete
} else {
[195] Fix | Delete
if ( typeof response.raw !== 'undefined' ) {
[196] Fix | Delete
jQuery( '#remote-ad-code-msg' ).html( response.raw );
[197] Fix | Delete
} else if ( typeof response.msg !== 'undefined' ) {
[198] Fix | Delete
if ( typeof response.reload !== 'undefined' ) {
[199] Fix | Delete
AdvancedAdsAdmin.AdImporter.emptyMapiSelector( response.msg );
[200] Fix | Delete
} else {
[201] Fix | Delete
if ( response.msg === 'doesNotSupportAdUnitType' ) {
[202] Fix | Delete
AdvancedAdsAdmin.AdImporter.unitIsNotSupported( slotID );
[203] Fix | Delete
} else {
[204] Fix | Delete
jQuery( '#remote-ad-code-msg' ).html( response.msg );
[205] Fix | Delete
}
[206] Fix | Delete
}
[207] Fix | Delete
if ( typeof response.raw !== 'undefined' ) {
[208] Fix | Delete
console.log( response.raw );
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
}
[212] Fix | Delete
},
[213] Fix | Delete
error: function () {
[214] Fix | Delete
jQuery( '#mapi-loading-overlay' ).css( 'display', 'none' );
[215] Fix | Delete
[216] Fix | Delete
}
[217] Fix | Delete
} );
[218] Fix | Delete
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
/**
[222] Fix | Delete
* Legacy method
[223] Fix | Delete
*
[224] Fix | Delete
* Parse ad content.
[225] Fix | Delete
*
[226] Fix | Delete
* @return {!Object}
[227] Fix | Delete
*/
[228] Fix | Delete
parseAdContent( content ) {
[229] Fix | Delete
const rawContent = typeof content !== 'undefined' ? content.trim() : '';
[230] Fix | Delete
const theContent = jQuery( '<div />' ).html( rawContent );
[231] Fix | Delete
const adByGoogle = theContent.find( 'ins' );
[232] Fix | Delete
let theAd = {};
[233] Fix | Delete
theAd.slotId = adByGoogle.attr( 'data-ad-slot' ) || '';
[234] Fix | Delete
if ( typeof adByGoogle.attr( 'data-ad-client' ) !== 'undefined' ) {
[235] Fix | Delete
theAd.pubId = adByGoogle.attr( 'data-ad-client' ).substr( 3 );
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
if ( theAd.slotId !== undefined && theAd.pubId !== '' ) {
[239] Fix | Delete
theAd.display = adByGoogle.css( 'display' );
[240] Fix | Delete
theAd.format = adByGoogle.attr( 'data-ad-format' );
[241] Fix | Delete
theAd.layout = adByGoogle.attr( 'data-ad-layout' ); // for In-feed and In-article
[242] Fix | Delete
theAd.layout_key = adByGoogle.attr( 'data-ad-layout-key' ); // for InFeed
[243] Fix | Delete
theAd.style = adByGoogle.attr( 'style' ) || '';
[244] Fix | Delete
[245] Fix | Delete
// Normal ad.
[246] Fix | Delete
if ( typeof theAd.format === 'undefined' && theAd.style.indexOf( 'width' ) !== - 1 ) {
[247] Fix | Delete
theAd.type = 'normal';
[248] Fix | Delete
theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
[249] Fix | Delete
theAd.height = adByGoogle.css( 'height' ).replace( 'px', '' );
[250] Fix | Delete
} else if ( typeof theAd.format !== 'undefined' && theAd.format === 'auto' ) {
[251] Fix | Delete
// Responsive ad, auto resize.
[252] Fix | Delete
theAd.type = 'responsive';
[253] Fix | Delete
} else if ( typeof theAd.format !== 'undefined' && theAd.format === 'link' ) {
[254] Fix | Delete
// Older link unit format; for new ads the format type is no longer needed; link units are created through the AdSense panel
[255] Fix | Delete
if ( theAd.style.indexOf( 'width' ) !== - 1 ) {
[256] Fix | Delete
// Is fixed size.
[257] Fix | Delete
theAd.width = adByGoogle.css( 'width' ).replace( 'px', '' );
[258] Fix | Delete
theAd.height = adByGoogle.css( 'height' ).replace( 'px', '' );
[259] Fix | Delete
theAd.type = 'link';
[260] Fix | Delete
} else {
[261] Fix | Delete
// Is responsive.
[262] Fix | Delete
theAd.type = 'link-responsive';
[263] Fix | Delete
}
[264] Fix | Delete
} else if ( typeof theAd.format !== 'undefined' && theAd.format === 'autorelaxed' ) {
[265] Fix | Delete
// Responsive Matched Content
[266] Fix | Delete
theAd.type = 'matched-content';
[267] Fix | Delete
} else if ( typeof theAd.format !== 'undefined' && theAd.format === 'fluid' ) {
[268] Fix | Delete
// In-article & In-feed ads.
[269] Fix | Delete
if ( typeof theAd.layout !== 'undefined' && theAd.layout === 'in-article' ) {
[270] Fix | Delete
// In-article.
[271] Fix | Delete
theAd.type = 'in-article';
[272] Fix | Delete
} else {
[273] Fix | Delete
// In-feed.
[274] Fix | Delete
theAd.type = 'in-feed';
[275] Fix | Delete
}
[276] Fix | Delete
}
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
/**
[280] Fix | Delete
* Synchronous code
[281] Fix | Delete
*/
[282] Fix | Delete
if ( rawContent.indexOf( 'google_ad_slot' ) !== - 1 ) {
[283] Fix | Delete
const adClient = rawContent.match( /google_ad_client ?= ?["']([^'"]+)/ );
[284] Fix | Delete
const adSlot = rawContent.match( /google_ad_slot ?= ?["']([^'"]+)/ );
[285] Fix | Delete
const adFormat = rawContent.match( /google_ad_format ?= ?["']([^'"]+)/ );
[286] Fix | Delete
const adWidth = rawContent.match( /google_ad_width ?= ?([\d]+)/ );
[287] Fix | Delete
const adHeight = rawContent.match( /google_ad_height ?= ?([\d]+)/ );
[288] Fix | Delete
[289] Fix | Delete
theAd = {};
[290] Fix | Delete
theAd.pubId = adClient[1].substr( 3 );
[291] Fix | Delete
[292] Fix | Delete
if ( adSlot !== null ) {
[293] Fix | Delete
theAd.slotId = adSlot[1];
[294] Fix | Delete
}
[295] Fix | Delete
if ( adFormat !== null ) {
[296] Fix | Delete
theAd.format = adFormat[1];
[297] Fix | Delete
}
[298] Fix | Delete
if ( adWidth !== null ) {
[299] Fix | Delete
theAd.width = parseInt( adWidth[1] );
[300] Fix | Delete
}
[301] Fix | Delete
if ( adHeight !== null ) {
[302] Fix | Delete
theAd.height = parseInt( adHeight[1] );
[303] Fix | Delete
}
[304] Fix | Delete
if ( typeof theAd.format === 'undefined' ) {
[305] Fix | Delete
theAd.type = 'normal';
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
if ( theAd.slotId === '' && gadsenseData.pubId && gadsenseData.pubId !== '' ) {
[311] Fix | Delete
theAd.type = jQuery( '#unit-type' ).val();
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
// Page-Level ad.
[315] Fix | Delete
if ( rawContent.indexOf( 'enable_page_level_ads' ) !== - 1 || /script[^>]+data-ad-client=/.test( rawContent ) ) {
[316] Fix | Delete
theAd = {'parse_message': 'pageLevelAd'};
[317] Fix | Delete
} else if ( ! theAd.type ) {
[318] Fix | Delete
// Unknown ad.
[319] Fix | Delete
theAd = {'parse_message': 'unknownAd'};
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
jQuery( document ).trigger( 'gadsenseParseAdContent', [theAd, adByGoogle] );
[323] Fix | Delete
return theAd;
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
parseAdContentFailsafe( code ) {
[327] Fix | Delete
if ( typeof code === 'string' ) {
[328] Fix | Delete
try {
[329] Fix | Delete
code = JSON.parse( code );
[330] Fix | Delete
} catch ( e ) {
[331] Fix | Delete
return this.parseAdContent( code );
[332] Fix | Delete
}
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
return code;
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
/**
[339] Fix | Delete
* Handle result of parsing content.
[340] Fix | Delete
*
[341] Fix | Delete
* Legacy method
[342] Fix | Delete
*/
[343] Fix | Delete
handleParseResult( parseResult ) {
[344] Fix | Delete
jQuery( '#pastecode-msg' ).empty();
[345] Fix | Delete
switch ( parseResult.parse_message ) {
[346] Fix | Delete
case 'pageLevelAd' :
[347] Fix | Delete
advads_show_adsense_auto_ads_warning();
[348] Fix | Delete
break;
[349] Fix | Delete
case 'unknownAd' :
[350] Fix | Delete
// Not recognized ad code.
[351] Fix | Delete
if ( this.parseCodeBtnClicked && 'post-new.php' === gadsenseData.pagenow ) {
[352] Fix | Delete
// do not show if just after switching to AdSense ad type on ad creation.
[353] Fix | Delete
jQuery( '#pastecode-msg' ).append( jQuery( '<p />' ).css( 'color', 'red' ).html( gadsenseData.msg.unknownAd ) );
[354] Fix | Delete
}
[355] Fix | Delete
break;
[356] Fix | Delete
default:
[357] Fix | Delete
this.setDetailsFromAdCode( parseResult );
[358] Fix | Delete
if ( typeof AdsenseMAPI !== 'undefined' && typeof AdsenseMAPI.hasToken !== 'undefined' && AdsenseMAPI.pubId === parseResult.pubId ) {
[359] Fix | Delete
const content = jQuery( '#advanced-ads-ad-parameters input[name="advanced_ad[content]"]' ).val();
[360] Fix | Delete
this.mapiSaveAdCode( content, parseResult.slotId );
[361] Fix | Delete
this.makeReadOnly();
[362] Fix | Delete
}
[363] Fix | Delete
jQuery( '.advads-adsense-code' ).hide();
[364] Fix | Delete
jQuery( '.advads-adsense-show-code' ).show();
[365] Fix | Delete
jQuery( '.mapi-insert-code' ).show();
[366] Fix | Delete
const customInputs = this.getCustomInputs();
[367] Fix | Delete
customInputs.show();
[368] Fix | Delete
}
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Legacy method
[373] Fix | Delete
*
[374] Fix | Delete
* Set ad parameters fields from the result of parsing ad code
[375] Fix | Delete
*/
[376] Fix | Delete
setDetailsFromAdCode( theAd ) {
[377] Fix | Delete
this.undoReadOnly();
[378] Fix | Delete
jQuery( '#unit-code' ).val( theAd.slotId );
[379] Fix | Delete
jQuery( '#advads-adsense-pub-id' ).val( theAd.pubId );
[380] Fix | Delete
if ( theAd.type === 'normal' ) {
[381] Fix | Delete
jQuery( '#unit-type' ).val( 'normal' );
[382] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( theAd.width );
[383] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( theAd.height );
[384] Fix | Delete
} else if ( theAd.type === 'responsive' ) {
[385] Fix | Delete
jQuery( '#unit-type' ).val( 'responsive' );
[386] Fix | Delete
jQuery( '#ad-resize-type' ).val( 'auto' );
[387] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
[388] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
[389] Fix | Delete
} else if ( theAd.type === 'link') {
[390] Fix | Delete
jQuery( '#unit-type' ).val( 'link' );
[391] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( theAd.width );
[392] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( theAd.height );
[393] Fix | Delete
} else if ( theAd.type === 'link-responsive' ) {
[394] Fix | Delete
jQuery( '#unit-type' ).val( 'link-responsive' );
[395] Fix | Delete
jQuery( '#ad-resize-type' ).val( 'auto' );
[396] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
[397] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
[398] Fix | Delete
} else if ( theAd.type === 'matched-content' ) {
[399] Fix | Delete
jQuery( '#unit-type' ).val( 'matched-content' );
[400] Fix | Delete
jQuery( '#ad-resize-type' ).val( 'auto' );
[401] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
[402] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
[403] Fix | Delete
} else if ( theAd.type === 'in-article' ) {
[404] Fix | Delete
jQuery( '#unit-type' ).val( 'in-article' );
[405] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
[406] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
[407] Fix | Delete
} else if ( theAd.type === 'in-feed' ) {
[408] Fix | Delete
jQuery( '#unit-type' ).val( 'in-feed' );
[409] Fix | Delete
jQuery( '#ad-layout-key' ).val( theAd.layout_key );
[410] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]' ).val( '' );
[411] Fix | Delete
jQuery( '#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]' ).val( '' );
[412] Fix | Delete
}
[413] Fix | Delete
const storedPubId = gadsenseData.pubId;
[414] Fix | Delete
[415] Fix | Delete
if ( storedPubId !== '' && theAd.pubId !== storedPubId && theAd.slotId !== '' ) {
[416] Fix | Delete
jQuery( '#adsense-ad-param-error' ).text( gadsenseData.msg.pubIdMismatch );
[417] Fix | Delete
} else {
[418] Fix | Delete
jQuery( '#adsense-ad-param-error' ).empty();
[419] Fix | Delete
}
[420] Fix | Delete
jQuery( document ).trigger( 'this.setDetailsFromAdCode', [theAd] );
[421] Fix | Delete
jQuery( '#unit-type' ).trigger( 'change' );
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
/**
[425] Fix | Delete
* Legacy method
[426] Fix | Delete
*/
[427] Fix | Delete
updateAdsenseType() {
[428] Fix | Delete
const $ = jQuery;
[429] Fix | Delete
const type = $( '#unit-type' ).val();
[430] Fix | Delete
const layout = $( '.advads-adsense-layout' );
[431] Fix | Delete
const layoutKey = $( '.advads-adsense-layout-key' );
[432] Fix | Delete
const size = $( '#advanced-ads-ad-parameters-size' );
[433] Fix | Delete
const width = $( '[name="advanced_ad\[width\]"]' );
[434] Fix | Delete
const height = $( '[name="advanced_ad\[height\]"]' );
[435] Fix | Delete
[436] Fix | Delete
layout.hide().next( 'div' ).hide();
[437] Fix | Delete
layoutKey.hide().next( 'div' ).hide();
[438] Fix | Delete
[439] Fix | Delete
jQuery( '.advads-ad-notice-in-feed-add-on' ).hide();
[440] Fix | Delete
if ( type === 'responsive' || type === 'link-responsive' || type === 'matched-content' ) {
[441] Fix | Delete
size.hide().prev( '.label' ).hide();
[442] Fix | Delete
size.next( '.hr' ).hide();
[443] Fix | Delete
$( '.clearfix-before' ).show();
[444] Fix | Delete
} else if ( type === 'in-feed' ) {
[445] Fix | Delete
layout.hide().next( 'div' ).hide();
[446] Fix | Delete
layoutKey.show().next( 'div' ).show();
[447] Fix | Delete
size.hide().prev( '.label' ).hide();
[448] Fix | Delete
size.next( '.hr' ).hide();
[449] Fix | Delete
[450] Fix | Delete
// show add-on notice
[451] Fix | Delete
$( '.advads-ad-notice-in-feed-add-on' ).show();
[452] Fix | Delete
$( '.clearfix-before' ).show();
[453] Fix | Delete
} else if ( type === 'in-article' ) {
[454] Fix | Delete
size.hide().prev( '.label' ).hide();
[455] Fix | Delete
size.next( '.hr' ).hide();
[456] Fix | Delete
$( '.clearfix-before' ).show();
[457] Fix | Delete
} else if ( type === 'normal' || type === 'link' ) {
[458] Fix | Delete
size.show().prev( '.label' ).show();
[459] Fix | Delete
size.next( '.hr' ).show();
[460] Fix | Delete
$( '.clearfix-before' ).hide();
[461] Fix | Delete
[462] Fix | Delete
if ( ! width.val() ) {
[463] Fix | Delete
width.val( '300' );
[464] Fix | Delete
}
[465] Fix | Delete
if ( ! height.val() ) {
[466] Fix | Delete
height.val( '250' );
[467] Fix | Delete
}
[468] Fix | Delete
}
[469] Fix | Delete
$( document ).trigger( 'gadsenseUnitChanged' );
[470] Fix | Delete
AdvancedAdsNetworkAdsense.gadsenseFormatAdContent();
[471] Fix | Delete
[472] Fix | Delete
this.show_float_warnings( type );
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* Legacy method
[477] Fix | Delete
*
[478] Fix | Delete
* Show / hide position warning.
[479] Fix | Delete
*/
[480] Fix | Delete
show_float_warnings( unit_type ) {
[481] Fix | Delete
const resize_type = jQuery( '#ad-resize-type' ).val();
[482] Fix | Delete
const position = jQuery( 'input[name="advanced_ad[output][position]"]:checked' ).val();
[483] Fix | Delete
[484] Fix | Delete
if (
[485] Fix | Delete
( ['link-responsive', 'matched-content', 'in-article', 'in-feed'].indexOf( unit_type ) !== - 1
[486] Fix | Delete
|| ( unit_type === 'responsive' && resize_type !== 'manual' )
[487] Fix | Delete
)
[488] Fix | Delete
&& ( position.startsWith( 'left' ) || position.startsWith( 'right' ) )
[489] Fix | Delete
) {
[490] Fix | Delete
jQuery( '#ad-parameters-box-notices .advads-ad-notice-responsive-position' ).show();
[491] Fix | Delete
} else {
[492] Fix | Delete
jQuery( '#ad-parameters-box-notices .advads-ad-notice-responsive-position' ).hide();
[493] Fix | Delete
}
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
/**
[497] Fix | Delete
* Legacy method - adds readonly to relevant inputs
[498] Fix | Delete
*/
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function