From 291b4e67a1b233cca6b95963e7c14bf8319b8f72 Mon Sep 17 00:00:00 2001 From: shridhamdeveloper <38998323+shridhamdeveloper@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:55:34 +0530 Subject: [PATCH 1/7] #415 --- admin/class-adsforwp-admin-settings.php | 3 +-- admin/control-center.php | 2 +- output/class-adsforwp-output-functions.php | 21 ++++++++++++--------- public/assets/js/adsforwp.js | 3 ++- public/assets/js/adsforwp.min.js | 2 +- view/class-adsforwp-view-ad-groups.php | 5 +++-- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/admin/class-adsforwp-admin-settings.php b/admin/class-adsforwp-admin-settings.php index 716d735..71d2d1d 100644 --- a/admin/class-adsforwp-admin-settings.php +++ b/admin/class-adsforwp-admin-settings.php @@ -674,10 +674,9 @@ public function adsforwp_import_callback() { } public function adsforwp_ad_blocker_notice_opt_callback() { $settings = adsforwp_defaultSettings(); - $notice_type = esc_attr( $settings['notice_type'] ); + $notice_type = isset( $settings['notice_type'] ) ? esc_attr( $settings['notice_type'] ) : ''; $notice_title = esc_attr( $settings['notice_title'] ); $notice_description = esc_html( $settings['notice_description'] ); - $notice_close_btn = esc_attr( $settings['notice_close_btn'] ); $btn_txt = esc_attr( $settings['btn_txt'] ); $notice_bg_color = sanitize_hex_color( $settings['notice_bg_color'] ); $notice_txt_color = sanitize_hex_color( $settings['notice_txt_color'] ); diff --git a/admin/control-center.php b/admin/control-center.php index d60bf12..f2e4788 100644 --- a/admin/control-center.php +++ b/admin/control-center.php @@ -127,7 +127,7 @@ function adsforwp_reset_all_settings() { $result = ''; // Deleting Settings - update_option( 'adsforwp_settings', array() ); // Security: Permission and nonce verified + delete_option( 'adsforwp_settings' ); // Security: Permission and nonce verified // Deleting Ads $allposts = get_posts( diff --git a/output/class-adsforwp-output-functions.php b/output/class-adsforwp-output-functions.php index 269d015..bf86d01 100644 --- a/output/class-adsforwp-output-functions.php +++ b/output/class-adsforwp-output-functions.php @@ -1401,20 +1401,23 @@ public function adsforwp_display_ads( $content ) { $p_number = $paragraph_id; foreach ( $paragraphs as $index => $paragraph ) { + + if ( ! empty( $paragraph ) ) { - if ( trim( $paragraph ) ) { - $paragraphs[ $index ] .= $closing_p; - } + if ( trim( $paragraph ) ) { + $paragraphs[ $index ] .= $closing_p; + } - if ( $every_paragraphs == 1 ) { + if ( $every_paragraphs == 1 ) { + + if ( $paragraph_id == $index + 1 ) { + $paragraphs[ $index ] .= $ad_code; + $paragraph_id += $p_number; + } + } elseif ( $paragraph_id == $index + 1 ) { - if ( $paragraph_id == $index + 1 ) { $paragraphs[ $index ] .= $ad_code; - $paragraph_id += $p_number; } - } elseif ( $paragraph_id == $index + 1 ) { - - $paragraphs[ $index ] .= $ad_code; } } diff --git a/public/assets/js/adsforwp.js b/public/assets/js/adsforwp.js index f4aa176..bf53c26 100644 --- a/public/assets/js/adsforwp.js +++ b/public/assets/js/adsforwp.js @@ -12,6 +12,7 @@ nextId = jQuery(this).parents("tbody").find("tr").length; selectrow = selectrow.replace(/\[0\]/g, "["+nextId+"]"); selectrow = selectrow.replace(/\[group-0\]/g, "[group-"+group_index+"]"); + selectrow = selectrow.replace(/afw-select-post-type 0/g, "afw-select-post-type "+nextId); jQuery(this).parents("tr").after(selectrow);adsforwpremoveHtml();adsforwpclone(); }); } @@ -906,7 +907,7 @@ jQuery( document ).ready(function($) { window.history.pushState("", "", href); return false; }); - $('#adsforwp_ad_expire_from, #adsforwp_ad_expire_to').datepicker({ + $('#adsforwp_ad_expire_from').datepicker({ dateFormat: "yy-mm-dd", minDate: 0, onSelect: function(selected){ diff --git a/public/assets/js/adsforwp.min.js b/public/assets/js/adsforwp.min.js index c42d33f..f302308 100644 --- a/public/assets/js/adsforwp.min.js +++ b/public/assets/js/adsforwp.min.js @@ -1 +1 @@ -var e=document.createElement("div");e.id="adsforwp-hidden-block",e.style.display="none",document.body.appendChild(e);var adsforwpclone=function(){jQuery(".placement-row-clone").off("click").click(function(){var t=jQuery(this).closest(".afw-placement-group").attr("data-id"),a=jQuery(document).find("#call_html_template_afw").html();nextId=jQuery(this).parents("tbody").find("tr").length,a=(a=a.replace(/\[0\]/g,"["+nextId+"]")).replace(/\[group-0\]/g,"[group-"+t+"]"),jQuery(this).parents("tr").after(a),adsforwpremoveHtml(),adsforwpclone()})},adsforwpremoveHtml=function(){jQuery(".placement-row-delete").off("click").click(function(){1==jQuery(".afw-placement-group").length?jQuery(this).parents("tbody").find("tr").length>1&&jQuery(this).parents("tr").remove():1==jQuery(this).parents("tbody").find("tr").length?jQuery(this).parents(".afw-placement-group").remove():jQuery(this).parents("tr").remove()})};function taxonomyDataCall(){jQuery("select.ajax-output").change(function(){if("ef_taxonomy"==jQuery(this).closest("tr").find(".afw-select-post-type").val()){parentSelector=jQuery(this).parents("td").find(".afw-insert-ajax-select");var t=jQuery(this).val(),a=jQuery(this).attr("name").split("[")[1].replace("]",""),o=$("#adsforwp_select_name_nonce").val();parentSelector.find(".afw-ajax-output-child").remove(),parentSelector.find(".spinner").attr("style","visibility:visible"),parentSelector.children(".spinner").addClass("show");var i=adsforwp_localize_data.ajax_url,n=jQuery(this).closest(".afw-placement-group").attr("data-id");jQuery.ajax({url:i,method:"POST",data:{action:"adsforwp_ajax_select_taxonomy",id:t,number:a,group_number:n,adsforwp_call_nonce:o},beforeSend:function(){},success:function(t){parentSelector.find(".afw-ajax-output-child").remove(),parentSelector.children(".spinner").removeClass("show"),parentSelector.find(".spinner").attr("style","visibility:hidden").hide(),parentSelector.append(t)},error:function(t){console.log("Failed Ajax Request"),console.log(t)}})}})}var adsforwpvisitorclone=function(){jQuery(".adsforwp-visitor-condition-row-clone").off("click").click(function(){var t=jQuery(this).closest(".adsforwp-visitor-condition-group").attr("data-id"),a=jQuery(document).find("#adsforwp_visitor_condition_html_template").html(),o=jQuery(this).parents("tbody").find("tr").length;a=(a=a.replace(/\[0\]/g,"["+o+"]")).replace(/\[group-0\]/g,"[group-"+t+"]"),jQuery(this).parents("tr").after(a),adsforwpvisitorremoveHtml(),adsforwpvisitorclone()})},adsforwpvisitorremoveHtml=function(){jQuery(".adsforwp-visitor-condition-row-delete").off("click").click(function(t){var a;1==jQuery(".adsforwp-visitor-condition-group").length?jQuery(this).parents("tbody").find("tr").length>1?jQuery(this).parents("tr").remove():(jQuery(this).parents(".adsforwp_visitor_condition_group").find(".adsforwp-visitor-condition-div").length<1?(jQuery('
User Targeting

User Targeting conditions to limit the number of users who can see your ad.

').insertBefore(jQuery(".adsforwp-visitor-condition-groups")),jQuery("#adsforwp_v_condition_enable").val(""),jQuery(".adsforwp-visitor-condition-div").show(),jQuery(".adsforwp-visitor-condition-groups").addClass("afw_hide")):(jQuery(".adsforwp-visitor-condition-div").show(),jQuery(".adsforwp-visitor-condition-groups").addClass("afw_hide"),jQuery("#adsforwp_v_condition_enable").val("")),jQuery(".device-type-notice").hide()):1==jQuery(this).parents("tbody").find("tr").length?jQuery(this).parents(".adsforwp-visitor-condition-group").remove():jQuery(this).parents("tr").remove()})};function adsforwp_field_val_check(t){if("checkbox"===document.getElementById(t).type.toLowerCase()){if(jQuery("#"+t).is(":checked"))var a=jQuery("#"+t).val();else var a=0}else var a=jQuery("#"+t).val();return a}function adsforwp_get_adtype(t){r=t.value,p=t.name,"checkbox"==t.type&&(r=t.checked?t.value:0),"sticky"!=jQuery("#wheretodisplay option:selected").val()&&("ad_image"!=r||"doubleclick"!=r)&&jQuery("#wheretodisplay option[value='sticky']").remove();var a=jQuery("#wheretodisplay option:selected").val();for(var o in"doubleclick"==r&&"sticky"!=a&&jQuery("#wheretodisplay option[value='custom_target']").after(''),"ad_image"==r&&"sticky"!=a&&jQuery("#wheretodisplay option[value='custom_target']").after(''),"select_adtype"==p&&jQuery(".afw_pointer").attr("id","afw_"+r+"_pointer"),jQuery("#"+p).parent().find("p").remove(),adtype_metafields){var i=adtype_metafields[o];if(i.notice&&jQuery.each(i.notice,function(a,o){r==a&&p==i.id&&(amp_story_ads_feature.amp_story_ad,jQuery(t).parent().append(o))}),i.metaboxes&&jQuery.each(i.metaboxes,function(t,a){r==t&&p==i.id&&jQuery.each(a,function(t,a){"all"==a?jQuery("#display-metabox,#adsforwp-location,#setexpiredate,#adsforwp_visitor_condition_metabox,#adsforwp_placement_metabox").show():jQuery("#"+a).hide()})}),i.required){var n=i.required.type;switch(n){case"and":var s=[];jQuery.each(i.required.fields,function(t,a){"object"==typeof a?-1!==a.indexOf(adsforwp_field_val_check(t))?s.push(!0):s.push(!1):p==t&&r==a?s.push(!0):adsforwp_field_val_check(t)==a?s.push(!0):s.push(!1)}),1==(s=s.filter(function(t,a,o){return o.indexOf(t)===a})).length&&!0==s[0]?jQuery("#"+i.id).parents("tr").show():jQuery("#"+i.id).parents("tr").hide();break;case"or":var r,p,s=[];jQuery.each(i.required.fields,function(t,a){"object"==typeof a?-1!==a.indexOf(adsforwp_field_val_check(t))?s.push(!0):s.push(!1):p==t&&r==a?s.push(!0):adsforwp_field_val_check(t)==a?s.push(!0):s.push(!1)}),-1!=(s=s.filter(function(t,a,o){return o.indexOf(t)===a})).indexOf(!0)?jQuery("#"+i.id).parents("tr").show():jQuery("#"+i.id).parents("tr").hide()}}}}function adsforwp_get_display_metafields(t){p=t.value,d=t.name,"checkbox"==t.type&&(p=t.checked?t.value:0);var a=jQuery("#select_adtype").val();jQuery(".adsforwp-advance-option-click").hide();var o=jQuery("#adposition").val();for(var i in"number_of_paragraph"==o?jQuery(".adsforwp-advance-option-click").show():"50_of_the_content"==o&&jQuery(".adsforwp-advance-option-click").hide(),"wheretodisplay"==d&&"sticky"!=p&&("ad_image"==a||"doubleclick"==a||jQuery("#"+d+" option[value='sticky']").remove()),display_metafields){var n=display_metafields[i];if(n.required){var s=n.required.type;switch(s){case"and":var r=[];jQuery.each(n.required.fields,function(t,a){"object"==typeof a?-1!==a.indexOf(adsforwp_field_val_check(t))?r.push(!0):r.push(!1):d==t&&p==a?r.push(!0):adsforwp_field_val_check(t)==a?r.push(!0):r.push(!1)}),1==(r=r.filter(function(t,a,o){return o.indexOf(t)===a})).length&&!0==r[0]?jQuery("#"+n.id).parents("tr").show():jQuery("#"+n.id).parents("tr").hide();break;case"or":var p,d,r=[];jQuery.each(n.required.fields,function(t,a){"object"==typeof a?-1!==a.indexOf(adsforwp_field_val_check(t))?r.push(!0):r.push(!1):d==t&&p==a?r.push(!0):adsforwp_field_val_check(t)==a?r.push(!0):r.push(!1)}),-1!=(r=r.filter(function(t,a,o){return o.indexOf(t)===a})).indexOf(!0)?jQuery("#"+n.id).parents("tr").show():jQuery("#"+n.id).parents("tr").hide()}}}}function adsforwpGetParamByName(t,a){a||(a=window.location.href);var o=RegExp("[?&]"+(t=t.replace(/[\[\]]/g,"\\$&"))+"(=([^&#]*)|&|#|$)").exec(a);return o?o[2]?decodeURIComponent(o[2].replace(/\+/g," ")):"":null}function adsforwp_pointer(t,a,o){$("#"+t).pointer({content:a,position:{edge:"top"},show:function(t,a){a.pointer.css({right:"95px",left:"auto"})},close:function(){}}).pointer(o)}function adsforwp_pointer_hover(t,a){var o="default";switch(t){case"afw_adsforwp_ad_floating_pointer":o="

"+adsforwp_localize_data.pointer_help+'

Enabling the option will make the ad float on content scroll, please Click Here for more info.

';break;case"afw_adsense_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.adsense_pointer+"

";break;case"afw_media_net_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.media_net_pointer+"

";break;case"afw_ad_now_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.ad_now_pointer+"

";break;case"afw_revcontent_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.revcontent_pointer+"

";break;case"afw_mgid_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.mgid_pointer+"

";break;case"afw_contentad_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.contentad_pointer+"

";break;case"afw_infolinks_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.infolinks_pointer+"

";break;case"afw_ad_image_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.ad_image_pointer+"

";break;case"afw_custom_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.custom_pointer+"

";break;case"afw_doubleclick_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.doubleclick_pointer+"

";break;case"afw_ad_background_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.ad_background_pointer+"

";break;case"afw_ezoic_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.ezoic_pointer+"

";break;case"afw_engageya_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.engageya_pointer+"

";break;case"afw_mantis_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.mantis_pointer+"

";break;case"afw_outbrain_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.outbrain_pointer+"

";break;case"afw_mediavine_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.mediavine_pointer+"

";break;case"afw_taboola_pointer":o="

"+adsforwp_localize_data.pointer_help+"

"+adsforwp_localize_data.taboola_pointer+"

"}adsforwp_pointer(t,o,a)}!function(t){t("#display-metabox,#adsforwp-location,#setexpiredate,#adsforwp_visitor_condition_metabox,#adsforwp_placement_metabox").show(),t("#select_adtype").trigger("change"),t("#adsense_type").trigger("change"),t("#wheretodisplay").trigger("change"),jQuery(".afw_display_pointer").attr("id","afw_adsforwp_ad_floating_pointer")}(jQuery),afw_amp_status=jQuery("#ads-for-wp_amp_compatibilty").val(),function(t){t("#select_adtype").change(function(){t(this).find("option:selected").each(function(){var a=t(this).attr("value");if(t(this).html().toLowerCase())switch(t(".afw-amp-support").addClass("afw_hide"),t(".afw-amp-support").addClass("afw_hide"),t(".afw-amp-support span").text(""),t("#afw-amp-status-display").text(afw_amp_status),t(".afw-amp-edit-post-status").show(),t("#ads-for-wp_amp_compatibilty").val(afw_amp_status),a){case"ad_background":t("#ad_background_image").attr("readonly",!0);break;case"ad_now":t(".afw-amp-support").removeClass("afw_hide"),t(".afw-amp-support span").text(adsforwp_localize_data.adnow_note),t("#afw-amp-status-display").text("disable"),t(".afw-amp-edit-post-status").hide(),t("#ads-for-wp_amp_compatibilty").val("disable");break;case"infolinks":t(".afw-amp-support").removeClass("afw_hide"),t(".afw-amp-support span").text(adsforwp_localize_data.infolinks_note),t("#afw-amp-status-display").text("disable"),t(".afw-amp-edit-post-status").hide(),t("#ads-for-wp_amp_compatibilty").val("disable");break;case"ad_image":t("#adsforwp_ad_image").attr("readonly",!0)}})}).change()}(jQuery),jQuery(document).ready(function(t){if(t(".adsforwp-upgrade-to-pro").parent().attr({href:"https://www.adsforwp.com/pricing/#pricings",target:"_blank"}),adsforwp_localize_data.do_tour){var a,o="

You are awesome for using Ads for WP

";o+="

Do you want the latest on Ads update before others and some best resources on monetization in a single email? - Free just for users of ADS!

",o+='",o+='
',o+='
',o+='
',o+='
',o+='',o+='',o+='',o+='',o+="
",o+='
',o+='',o+='',o+="
",o+='',o+='',o+="
",o+="
";var i={content:o+="
",position:{edge:"top",align:"left"}};i=t.extend(i,{buttons:function(t,a){return button=jQuery(''+adsforwp_localize_data.button1+""),button_2=jQuery("#pointer-close.button"),button.bind("click.pointer",function(){a.element.pointer("close")}),button_2.on("click",function(){a.element.pointer("close")}),button},close:function(){t.post(adsforwp_localize_data.ajax_url,{pointer:"adsforwp_subscribe_pointer",action:"dismiss-wp-pointer"})},show:function(t,a){a.pointer.css({left:"170px",top:"160px"})}}),a=function(){t(adsforwp_localize_data.displayID).pointer(i).pointer("open"),adsforwp_localize_data.button2&&(jQuery("#pointer-close").after(''+adsforwp_localize_data.button2+""),jQuery("#pointer-primary").click(function(){adsforwp_localize_data.function_name}),jQuery("#pointer-close").click(function(){t.post(adsforwp_localize_data.ajax_url,{pointer:"adsforwp_subscribe_pointer",action:"dismiss-wp-pointer"})}))},i.position&&i.position.defer_loading?t(window).bind("load.wp-pointers",a):a()}jQuery("#ad-forwp-subscribe-newsletter-form").on("submit",function(t){t.preventDefault(),jQuery(".mc-newsletter-sent").val("Sending...");var a=jQuery(this),o=a.find('input[name="name"]').val(),i=a.find('input[name="email"]').val(),n=a.find('input[name="company"]').val(),n=a.find('input[name="company"]').val();jQuery.post(adsforwp_localize_data.ajax_url,{action:"adsforwp_subscribe_newsletter",adsforwp_security_nonce:adsforwp_localize_data.adsforwp_security_nonce,name:o,email:i,website:n},function(t){jQuery.post(adsforwp_localize_data.ajax_url,{pointer:"adsforwp_subscribe_pointer",action:"dismiss-wp-pointer"},function(){jQuery(".mc-newsletter-sent").val("Subscribe"),location.reload()})})}),t(".afw_pointer").mouseover(function(){adsforwp_pointer_hover(t(this).attr("id"),"open")}),t(".afw_display_pointer").mouseover(function(){adsforwp_pointer_hover(t(this).attr("id"),"open")}),t(document).on("change",".adsforwp-visitor-condition-ajax-output",function(){var a=t(this).val();t(this).parent().find(".adsforwp_user_agent_custom").addClass("afw_hide"),t(this).parent().find(".adsforwp_browser_width_custom").addClass("afw_hide"),t(this).parent().find(".adsforwp_url_custom").addClass("afw_hide"),"url_custom"==a&&t(this).parent().find(".adsforwp_url_custom").removeClass("afw_hide"),"user_agent_custom"==a&&t(this).parent().find(".adsforwp_user_agent_custom").removeClass("afw_hide"),"browser_width_custom"==a&&t(this).parent().find(".adsforwp_browser_width_custom").removeClass("afw_hide")}),t(".adsforwp-visitor-condition-or-group").on("click",function(a){a.preventDefault();var o="",o=t(".adsforwp-visitor-condition-group").length,i=jQuery(document).find("#adsforwp_visitor_condition_html_template").html();i=i.replace(/\[group-0\]/g,"[group-"+o+"]");var n="";n+='',n+=i,n+="
";var s="";s+='
',s+='Or',s+=n,s+="
",t(".adsforwp-visitor-condition-group[data-id="+(o-1)+"]").after(s),o++,adsforwpvisitorclone(),adsforwpvisitorremoveHtml()});var n=t("#adsforwp_visitor_condition_metabox").find("table.widefat tr").html();t("body").append("