AdSense Plugin WP QUADS - Version 1.4.4

Version Description

  • Fix: Undefined variable if WP QUADS PRO beta version is used with more than 3 AdSebse paragraph AdSebse spots
  • Fix: Deactivate License button not working
  • Fix: Admin notice if AdSense codes are empty
  • Fix: PHP Warning when AdSense ad codes are empty
  • Fix: Not more than 3 AdSense widgets are shown at the same time
Download this release

Release Info

Developer ReneHermi
Plugin Icon 128x128 AdSense Plugin WP QUADS
Version 1.4.4
Comparing to
See all releases

Code changes from version 1.4.1 to 1.4.4

assets/css/quads-admin.css CHANGED
@@ -795,3 +795,11 @@ li.quads-tabs {
795
  min-height: 25px;
796
  }
797
 
 
 
 
 
 
 
 
 
795
  min-height: 25px;
796
  }
797
 
798
+
799
+ #quads-validate{
800
+ margin-top: -20px;
801
+ display: block;
802
+ margin-left: 2px;
803
+ margin-bottom: 20px;
804
+ font-weight: bold;
805
+ }
assets/css/quads-admin.min.css CHANGED
@@ -1 +1 @@
1
- .quads-share-button-container{margin:5px 0}.quads-share-button-container p{margin:0 0 10px}.quads-share-button{display:inline-block}.quads-share-button a{text-decoration:none}.quads-share-button .quads-share{font-family:sans-serif;font-weight:700;text-decoration:none;text-align:center;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;color:#FFF;display:inline;font-size:16px;width:40px;padding:4px 8px}.quads-share-button-twitter .quads-share{background-color:#00ABF0}.quads-share-button-facebook .quads-share{background-color:#3b5998}.quads-share-button-googleplus .quads-share{background-color:#F53424}.quads-share-button-facebook .share:active,.quads-share-button-googleplus .share:active,.quads-share-button-twitter .share:active{background-color:#353535}@media (max-width:925px){.quads-share-button .quads-share{font-size:15px;padding:8px 16px}}.quads-richeditor{font-size:11px}#quads-add-ons h2{margin:0 0 15px}#quads-add-ons .quadsshare-addons{float:left;margin:0 15px 15px 0;background:#f0f0f0;border:1px solid #ccc;width:320px;padding:8px;height:315px;position:relative}#quads-add-ons .quadsshare-addons h3{margin:0 0 8px;font-size:13px}#quads-add-ons .quadsshare-addons .button-secondary{position:absolute;bottom:8px;left:8px}#quads-add-ons .quadsshare-addons .third-party{display:none}#system-info-textarea{width:580px;height:400px;font-family:Menlo,Monaco,monospace;background:0 0;white-space:pre;overflow:auto;display:block}.quads-select-chosen{width:300px}input.large-text,textarea.large-text{max-width:600px}input.medium-text,textarea.medium-text{min-width:190px}#quads_tab_container ul{list-style:none;margin:0;padding:0;background:#fff;float:left}#quads_tab_container ul li:first-child.selected-tab{border-top:none}#quads_tab_container ul li a.selected-tab{font-weight:700;text-decoration:none}#quads_tab_container .quads-row{padding-top:12px;padding-bottom:12px}#quads_tab_container .quads-row label strong,#tab_container .quads-row strong{font-weight:700}.quads-tabs a{padding:5px;color:#a1a1a1;text-transform:uppercase}.quads-tabs a strong{font-weight:700}li.quads-tabs{float:left;margin-left:0;background-color:#e5e5e5}#quads_tab_container>ul>li.quads-tabs.active{background-color:#fff}#quads_tab_container>ul>li.quads-tabs.active a{color:#83c11f}#quads_tab_container .quads-panel-container{background:#FFF;padding:20px;overflow:auto;text-align:left;margin-bottom:10px;max-width:640px;float:left;clear:both}.form-table{margin-top:-20px}#quads_tab_container .form-table th{vertical-align:top;text-align:left;padding:20px 10px 20px 0;line-height:1.3;font-weight:700;font-size:14px;color:#484848;width:30%}#quads_tab_container .form-table tr{border-bottom:1px solid #E7E7E7}#quads_tab_container span.description{display:block;font-weight:400;font-style:normal;font-size:13px;margin-top:7px;color:#484848}#quads_tab_container .col-title{font-size:18px;color:#484848}@media only screen and (max-width:680px){#quads_tab_container ul{float:none;background:#fff}#quads_tab_container .form-table tr>th{width:100%}#quads_tab_container span.description{font-size:14px}#quads_tab_container .form-table tr>th,#tab_container .form-table tr>td{padding:10px}#quads_tab_container .quads-tabs a{text-align:left}#quads_tab_container li.quads-tabs{float:none;margin-left:0}}#quads_tab_container ul li.quads-tabs{margin-bottom:0}#quads_tab_container ul li.quads-tabs a{display:block;padding:10px;text-decoration:none;font-weight:700}#quads_tab_container ul li.quads-tabs a:hover{color:#383838}#quads_tab_container ul li.quads-tabs a.active{text-decoration:underline}#quads_tab_container table tbody tr:nth-child(1)>th>div{font-size:20px}#quadstabcontainer>.quadstabs{background-color:#fff}#quadstabcontainer ul .active{background-color:#00adef;color:#fff;border-bottom-color:#0098D2}#quadstabcontainer ul .active:hover{background-color:#00A4E2;color:#fff;border-bottom-color:#0098D2}#quadstabcontainer ul li a{padding:10px 14px;background-color:#f3f3f3}#quadstabcontainer .quadstab-container{border:0 solid #ececec}.quads-quote-docs{font-family:Courier New,Courier,Fixed;color:#050}.quads-desc{display:block;font-style:italic;padding-top:10px}.quads-postbox{padding:10px;position:relative;min-width:255px;border:1px solid #e5e5e5;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff;margin-bottom:20px}.nav-tab-active{background-color:#fff;border-bottom:0}#quads-add-ons{padding:20px}.quads-toggle{position:absolute;right:0;top:0}.quads-box-close .quads-close-open-icon{background-position:0 -38px}.quads-close-open-icon{width:38px;height:38px;background:url(../images/arrow-close.png) repeat-y #f4f4f4}.quads-ad-toggle-header{position:relative;background-color:#f4f4f4;margin-bottom:2px;padding:10px 10px 10px 15px;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none;cursor:pointer!important}.quads-ad-toggle-container{padding:20px;background-color:#f4f4f4}.quads-toogle-title{font-size:16px;font-weight:700}.adsense-size-title,.quads-advanced-description label{font-weight:600;font-size:12px;text-transform:uppercase;float:left}.quads-advanced-description label{width:215px}.quads-advanced-ad-box{clear:both;margin-top:20px;margin-bottom:20px}.adsense-size-title{margin-right:0;line-height:32px;margin-left:14px;min-width:100px}.quads-select-style-overwrite{border:1px solid #e6e6e6;width:150px;overflow:hidden;background:url(../images/box_arrow.png) 120px 0 repeat-y #fff;margin:0 0 5px}.quads-select-style-overwrite select{width:150px}.quads-size-input{position:relative;top:-1px;width:110%;border:none;box-shadow:none;background:0 0;-webkit-appearance:none;font-family:'Open Sans',arial,sans-serif;color:#555;font-size:12px}.quads-pro-overlay{height:200px}.quads-license-error-notice,.quads-license-expires-soon-notice{background-color:#fff;padding:10px;overflow:auto;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);border:1px solid #ECECEC;border-radius:3px}.quads-license-error-notice a{color:#0097df;text-decoration:underline}.quads-license-error-notice{border-left:4px solid #dd3d36}.quads-license-expiration-date-notice,.quads-license-lifetime-notice,.quads-license-null{padding:0}.quads-license-expiration-date-notice .quads-license-data p,.quads-license-lifetime-notice .quads-license-data p{color:#666;font-size:14px;font-style:italic;margin:4px 0 0}#quads_settingslicenses_header-nav{display:none}#quads_settingslicenses_header{max-width:640px}#quads_settingslicenses_header .quads-row.th{min-width:250px}.quads-notice{background:#fff;border-left:4px solid #46b450;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 15px 2px;padding:1px 12px}.quads_admin h2.nav-tab-wrapper{border:0}.quads_admin .nav-tab{border:0;text-transform:uppercase;color:#a1a1a1;font-weight:700}.quads-h1{margin-bottom:1.35rem;font-size:2.5em;line-height:3.68rem;letter-spacing:normal}.quads-h2{margin-top:0;margin-bottom:1.2rem;font-size:30px;line-height:2.5rem}.quads-heading-pro{color:#83c11f;font-weight:700}.quads-button.green{display:inline-block;background-color:#83c11f;padding:10px;min-width:170px;color:#fff;font-size:16px;text-decoration:none;text-align:center;margin-top:20px}#quads-add-ons .quads-footer{clear:both;margin-top:20px;font-style:italic}#quads-add-ons li{font-size:18px;line-height:29px;position:relative;padding-left:23px;list-style:none!important}#quads-add-ons li:before{width:1em;height:100%;background:url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;background-size:contain;content:"";position:absolute;top:0;left:0;color:#77b227}.adsense_admin_header{font-size:14px;font-weight:500}#quads-adsense-bg-div{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.65);z-index:250000}#quads-adsense-container{text-align:center;width:480px;margin:85px auto 0;background-color:#fff;padding:2%;border-radius:2px}#quads-adsense-container h3{margin-top:0}#quads-adsense-container textarea,.quads-ad-toggle-container textarea{width:100%}.quads-ad-toggle-container input{margin-top:7px;margin-bottom:10px}.quads-adsense-code label,input{margin-right:2px}#quads_settings\5b ad2\5d \5b g_data_ad_client\5d{width:200px}.quads-ad-toggle-container label{display:inline-block;margin-right:2px;margin-top:-3px}.quads_adsense_code .quads-add-adsense{margin:20px 5px 20px 0}.quads-label-left{min-width:71px}#quads-label-Type{min-width:67px}.quads-medium-size{width:110px}#quads-msg{display:none;margin:5px;background-color:#c55c5c;color:#fff}.quads-loader,.quads-success-modal{display:block;position:fixed;top:45%;left:25%;width:200px;height:auto;padding:5px 20px;z-index:1002;overflow:auto}.quads-form-table{width:100%}.quads-left-box{width:45%;min-height:100px;float:left;line-height:35px;min-width:300px}@media screen and (max-width:700px){.adsense-size-title{margin-left:0}.quads-left-box{width:45%;min-height:100px;float:none;line-height:35px;min-width:300px}.quads-style img{max-width:50px}}.adsense_admin_header ul li{margin-top:2px;margin-left:20px;list-style-type:square}.quads-general-helper,.quads-helper{background-color:#83c11f;width:15px;display:inline-block;top:4px;cursor:pointer;margin-left:2px}.quads-helper{border-radius:50%;border:2px solid #fff;height:15px;position:relative;margin-top:-4px}.quads-general-helper:after,.quads-helper:after{height:20px;font-family:sans-serif;content:"?";font-size:11px;font-weight:700;left:4px;position:absolute;color:#fff}.quads-helper:after{margin-top:-10px}.quads-general-helper:after{margin-top:-2px}.quads-general-helper{border-radius:50%;border:2px solid #fff;height:15px;position:relative;margin-top:-4px}.quads-message{padding:10px;border:1px solid #FBFBFB;border-radius:2px;background-color:#F8F8F8;position:absolute;max-width:500px;z-index:9999;display:none;box-shadow:0 0 5px rgba(0,0,0,.2);font-weight:400;line-height:20px;text-transform:none;font-size:14px}#quads-pro-hover{background-color:#83c11f;padding:20px;min-width:150px;color:#fff;display:block;position:relative;margin-top:-100px;margin-left:50%}#quads-pro-hover-background{width:100%;height:100%;background:rgba(0,0,0,.6)}#quads-open-toggle{clear:both;float:left;margin-top:10px}#quads_settingsadsense_header input[type=number].small-text{width:55px}.quads_adsense_code input.quads-bggrey{background-color:#f5f5f5;color:#939393}.quads-amp-code{color:#939393;height:130px}.quads-chosen-select .chosen-choices li.search-field input{min-height:25px}
1
+ .quads-share-button-container{margin:5px 0}.quads-share-button-container p{margin:0 0 10px}.quads-share-button{display:inline-block}.quads-share-button a{text-decoration:none}.quads-share-button .quads-share{font-family:sans-serif;font-weight:700;text-decoration:none;text-align:center;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;color:#FFF;display:inline;font-size:16px;width:40px;padding:4px 8px}.quads-share-button-twitter .quads-share{background-color:#00ABF0}.quads-share-button-facebook .quads-share{background-color:#3b5998}.quads-share-button-googleplus .quads-share{background-color:#F53424}.quads-share-button-facebook .share:active,.quads-share-button-googleplus .share:active,.quads-share-button-twitter .share:active{background-color:#353535}@media (max-width:925px){.quads-share-button .quads-share{font-size:15px;padding:8px 16px}}.quads-richeditor{font-size:11px}#quads-add-ons h2{margin:0 0 15px}#quads-add-ons .quadsshare-addons{float:left;margin:0 15px 15px 0;background:#f0f0f0;border:1px solid #ccc;width:320px;padding:8px;height:315px;position:relative}#quads-add-ons .quadsshare-addons h3{margin:0 0 8px;font-size:13px}#quads-add-ons .quadsshare-addons .button-secondary{position:absolute;bottom:8px;left:8px}#quads-add-ons .quadsshare-addons .third-party{display:none}#system-info-textarea{width:580px;height:400px;font-family:Menlo,Monaco,monospace;background:0 0;white-space:pre;overflow:auto;display:block}.quads-select-chosen{width:300px}input.large-text,textarea.large-text{max-width:600px}input.medium-text,textarea.medium-text{min-width:190px}#quads_tab_container ul{list-style:none;margin:0;padding:0;background:#fff;float:left}#quads_tab_container ul li:first-child.selected-tab{border-top:none}#quads_tab_container ul li a.selected-tab{font-weight:700;text-decoration:none}#quads_tab_container .quads-row{padding-top:12px;padding-bottom:12px}#quads_tab_container .quads-row label strong,#tab_container .quads-row strong{font-weight:700}.quads-tabs a{padding:5px;color:#a1a1a1;text-transform:uppercase}.quads-tabs a strong{font-weight:700}li.quads-tabs{float:left;margin-left:0;background-color:#e5e5e5}#quads_tab_container>ul>li.quads-tabs.active{background-color:#fff}#quads_tab_container>ul>li.quads-tabs.active a{color:#83c11f}#quads_tab_container .quads-panel-container{background:#FFF;padding:20px;overflow:auto;text-align:left;margin-bottom:10px;max-width:640px;float:left;clear:both}.form-table{margin-top:-20px}#quads_tab_container .form-table th{vertical-align:top;text-align:left;padding:20px 10px 20px 0;line-height:1.3;font-weight:700;font-size:14px;color:#484848;width:30%}#quads_tab_container .form-table tr{border-bottom:1px solid #E7E7E7}#quads_tab_container span.description{display:block;font-weight:400;font-style:normal;font-size:13px;margin-top:7px;color:#484848}#quads_tab_container .col-title{font-size:18px;color:#484848}@media only screen and (max-width:680px){#quads_tab_container ul{float:none;background:#fff}#quads_tab_container .form-table tr>th{width:100%}#quads_tab_container span.description{font-size:14px}#quads_tab_container .form-table tr>th,#tab_container .form-table tr>td{padding:10px}#quads_tab_container .quads-tabs a{text-align:left}#quads_tab_container li.quads-tabs{float:none;margin-left:0}}#quads_tab_container ul li.quads-tabs{margin-bottom:0}#quads_tab_container ul li.quads-tabs a{display:block;padding:10px;text-decoration:none;font-weight:700}#quads_tab_container ul li.quads-tabs a:hover{color:#383838}#quads_tab_container ul li.quads-tabs a.active{text-decoration:underline}#quads_tab_container table tbody tr:nth-child(1)>th>div{font-size:20px}#quadstabcontainer>.quadstabs{background-color:#fff}#quadstabcontainer ul .active{background-color:#00adef;color:#fff;border-bottom-color:#0098D2}#quadstabcontainer ul .active:hover{background-color:#00A4E2;color:#fff;border-bottom-color:#0098D2}#quadstabcontainer ul li a{padding:10px 14px;background-color:#f3f3f3}#quadstabcontainer .quadstab-container{border:0 solid #ececec}.quads-quote-docs{font-family:Courier New,Courier,Fixed;color:#050}.quads-desc{display:block;font-style:italic;padding-top:10px}.quads-postbox{padding:10px;position:relative;min-width:255px;border:1px solid #e5e5e5;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff;margin-bottom:20px}.nav-tab-active{background-color:#fff;border-bottom:0}#quads-add-ons{padding:20px}.quads-toggle{position:absolute;right:0;top:0}.quads-box-close .quads-close-open-icon{background-position:0 -38px}.quads-close-open-icon{width:38px;height:38px;background:url(../images/arrow-close.png) repeat-y #f4f4f4}.quads-ad-toggle-header{position:relative;background-color:#f4f4f4;margin-bottom:2px;padding:10px 10px 10px 15px;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none;cursor:pointer!important}.quads-ad-toggle-container{padding:20px;background-color:#f4f4f4}.quads-toogle-title{font-size:16px;font-weight:700}.adsense-size-title,.quads-advanced-description label{font-weight:600;font-size:12px;text-transform:uppercase;float:left}.quads-advanced-description label{width:215px}.quads-advanced-ad-box{clear:both;margin-top:20px;margin-bottom:20px}.adsense-size-title{margin-right:0;line-height:32px;margin-left:14px;min-width:100px}.quads-select-style-overwrite{border:1px solid #e6e6e6;width:150px;overflow:hidden;background:url(../images/box_arrow.png) 120px 0 repeat-y #fff;margin:0 0 5px}.quads-select-style-overwrite select{width:150px}.quads-size-input{position:relative;top:-1px;width:110%;border:none;box-shadow:none;background:0 0;-webkit-appearance:none;font-family:'Open Sans',arial,sans-serif;color:#555;font-size:12px}.quads-pro-overlay{height:200px}.quads-license-error-notice,.quads-license-expires-soon-notice{background-color:#fff;padding:10px;overflow:auto;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);border:1px solid #ECECEC;border-radius:3px}.quads-license-error-notice a{color:#0097df;text-decoration:underline}.quads-license-error-notice{border-left:4px solid #dd3d36}.quads-license-expiration-date-notice,.quads-license-lifetime-notice,.quads-license-null{padding:0}.quads-license-expiration-date-notice .quads-license-data p,.quads-license-lifetime-notice .quads-license-data p{color:#666;font-size:14px;font-style:italic;margin:4px 0 0}#quads_settingslicenses_header-nav{display:none}#quads_settingslicenses_header{max-width:640px}#quads_settingslicenses_header .quads-row.th{min-width:250px}.quads-notice{background:#fff;border-left:4px solid #46b450;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 15px 2px;padding:1px 12px}.quads_admin h2.nav-tab-wrapper{border:0}.quads_admin .nav-tab{border:0;text-transform:uppercase;color:#a1a1a1;font-weight:700}.quads-h1{margin-bottom:1.35rem;font-size:2.5em;line-height:3.68rem;letter-spacing:normal}.quads-h2{margin-top:0;margin-bottom:1.2rem;font-size:30px;line-height:2.5rem}.quads-heading-pro{color:#83c11f;font-weight:700}.quads-button.green{display:inline-block;background-color:#83c11f;padding:10px;min-width:170px;color:#fff;font-size:16px;text-decoration:none;text-align:center;margin-top:20px}#quads-add-ons .quads-footer{clear:both;margin-top:20px;font-style:italic}#quads-add-ons li{font-size:18px;line-height:29px;position:relative;padding-left:23px;list-style:none!important}#quads-add-ons li:before{width:1em;height:100%;background:url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;background-size:contain;content:"";position:absolute;top:0;left:0;color:#77b227}.adsense_admin_header{font-size:14px;font-weight:500}#quads-adsense-bg-div{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.65);z-index:250000}#quads-adsense-container{text-align:center;width:480px;margin:85px auto 0;background-color:#fff;padding:2%;border-radius:2px}#quads-adsense-container h3{margin-top:0}#quads-adsense-container textarea,.quads-ad-toggle-container textarea{width:100%}.quads-ad-toggle-container input{margin-top:7px;margin-bottom:10px}.quads-adsense-code label,input{margin-right:2px}#quads_settings\5b ad2\5d \5b g_data_ad_client\5d{width:200px}.quads-ad-toggle-container label{display:inline-block;margin-right:2px;margin-top:-3px}.quads_adsense_code .quads-add-adsense{margin:20px 5px 20px 0}.quads-label-left{min-width:71px}#quads-label-Type{min-width:67px}.quads-medium-size{width:110px}#quads-msg{display:none;margin:5px;background-color:#c55c5c;color:#fff}.quads-loader,.quads-success-modal{display:block;position:fixed;top:45%;left:25%;width:200px;height:auto;padding:5px 20px;z-index:1002;overflow:auto}.quads-form-table{width:100%}.quads-left-box{width:45%;min-height:100px;float:left;line-height:35px;min-width:300px}@media screen and (max-width:700px){.adsense-size-title{margin-left:0}.quads-left-box{width:45%;min-height:100px;float:none;line-height:35px;min-width:300px}.quads-style img{max-width:50px}}.quads-general-helper,.quads-helper{background-color:#83c11f;width:15px;display:inline-block;top:4px;cursor:pointer}.adsense_admin_header ul li{margin-top:2px;margin-left:20px;list-style-type:square}.quads-helper{border-radius:50%;border:2px solid #fff;height:15px;position:relative;margin-top:-4px;margin-left:2px}.quads-general-helper:after,.quads-helper:after{height:20px;font-family:sans-serif;content:"?";font-size:11px;font-weight:700;left:4px;position:absolute;color:#fff}.quads-helper:after{margin-top:-10px}.quads-general-helper:after{margin-top:-2px}.quads-general-helper{border-radius:50%;border:2px solid #fff;height:15px;position:relative;margin-top:-4px;margin-left:2px}.quads-message{padding:10px;border:1px solid #FBFBFB;border-radius:2px;background-color:#F8F8F8;position:absolute;max-width:500px;z-index:9999;display:none;box-shadow:0 0 5px rgba(0,0,0,.2);font-weight:400;line-height:20px;text-transform:none;font-size:14px}#quads-pro-hover{background-color:#83c11f;padding:20px;min-width:150px;color:#fff;display:block;position:relative;margin-top:-100px;margin-left:50%}#quads-pro-hover-background{width:100%;height:100%;background:rgba(0,0,0,.6)}#quads-open-toggle{clear:both;float:left;margin-top:10px}#quads_settingsadsense_header input[type=number].small-text{width:55px}.quads_adsense_code input.quads-bggrey{background-color:#f5f5f5;color:#939393}.quads-amp-code{color:#939393;height:130px}.quads-chosen-select .chosen-choices li.search-field input{min-height:25px}#quads-validate{margin-top:-20px;display:block;margin-left:2px;margin-bottom:20px;font-weight:700}
assets/css/quads-plugins-admin.min.css CHANGED
@@ -32,6 +32,7 @@
32
  margin:5px;
33
  }
34
 
 
35
  @media screen and (max-width:400px){
36
  #quick-adsense-reloaded-feedback-content {
37
  padding:0px;
32
  margin:5px;
33
  }
34
 
35
+
36
  @media screen and (max-width:400px){
37
  #quick-adsense-reloaded-feedback-content {
38
  padding:0px;
assets/js/ads.js ADDED
@@ -0,0 +1 @@
 
1
+ var wpquads_adblocker_check = true;
assets/js/quads-admin.js CHANGED
@@ -145,7 +145,8 @@ jQuery(document).ready(function ($) {
145
 
146
  // Check current url / settings page
147
  var url = window.location.search;
148
- var search = url.search("page=quads-settings&tab=imexport");
 
149
 
150
  jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
151
  jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
@@ -166,8 +167,8 @@ jQuery(document).ready(function ($) {
166
  jQuery('#quads-save-result').hide('fast');
167
  }
168
  });
169
- // Do not preventDefault on import/export tab
170
- if ( search === -1 ){
171
  return false;
172
  }
173
  });
145
 
146
  // Check current url / settings page
147
  var url = window.location.search;
148
+ var tab_imexport = url.search("page=quads-settings&tab=imexport");
149
+ var tab_licenses = url.search("page=quads-settings&tab=licenses");
150
 
151
  jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
152
  jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
167
  jQuery('#quads-save-result').hide('fast');
168
  }
169
  });
170
+ // Do not use ajax saving on import/export and licenses tab
171
+ if ( tab_imexport === -1 && tab_licenses ===-1 ){
172
  return false;
173
  }
174
  });
includes/admin/admin-notices.php CHANGED
@@ -29,6 +29,22 @@ function quads_admin_messages() {
29
  quads_theme_notice();
30
 
31
  quads_update_notice();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  //quads_plugin_deactivated_notice();
34
 
@@ -233,8 +249,82 @@ function quads_update_notice() {
233
  <?php
234
  }
235
  }
236
-
 
 
237
  function quads_hide_notice(){
238
  update_option ('quads_show_update_notice', 'no');
239
  }
240
  add_action('quads_hide_update_notice', 'quads_hide_notice', 10);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  quads_theme_notice();
30
 
31
  quads_update_notice();
32
+
33
+ if (!quads_is_any_ad_activated() && quads_is_admin_page() ){
34
+ echo '<div class="notice notice-warning">'.sprintf(__('<strong>No ads are activated!</strong> You need to assign at least 1 ad to an ad spot. Fix this in <a href="%s">General Settings</a>! Alternatively you need to use a shortcode in your posts or no ads are shown at all.', 'quick-adsense-reloaded'), admin_url().'admin.php?page=quads-settings#quads_settingsgeneral_header').'</div>';
35
+ }
36
+
37
+ if (quads_get_active_ads() === 0 && quads_is_admin_page() ){
38
+ echo '<div class="notice notice-warning">'.sprintf(__('<strong>No ads defined!</strong> You need to create at least one ad code. Fix this in <a href="%s">ADSENSE CODE</a>.', 'quick-adsense-reloaded'), admin_url().'admin.php?page=quads-settings#quads_settingsadsense_header').'</div>';
39
+ }
40
+
41
+ if (!quads_is_post_type_activated() && quads_is_admin_page() ){
42
+ echo '<div class="notice notice-warning">'.sprintf(__('<strong>No ads are shown - No post types selected</strong> You need to select at least 1 post type like <i>blog</i> or <i>page</i>. Fix this in <a href="%s">General Settings</a> or no ads are shown at all.', 'quick-adsense-reloaded'), admin_url().'admin.php?page=quads-settings#quads_settingsgeneral_header').'</div>';
43
+ }
44
+
45
+ if (isset($_GET['quads-action']) && $_GET['quads-action'] === 'validate' && quads_is_admin_page() && quads_is_any_ad_activated() && quads_is_post_type_activated() && quads_get_active_ads() > 0 ){
46
+ echo '<div class="notice notice-success">' . sprintf(__('<strong>No errors detected in WP QUADS settings.</strong> If ads are still not shown read the <a href="%s" target="_blank">troubleshooting guide</a>'), 'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=toplink') . '</div>';
47
+ }
48
 
49
  //quads_plugin_deactivated_notice();
50
 
249
  <?php
250
  }
251
  }
252
+ /**
253
+ * Hide Notice and update db option quads_hide_notice
254
+ */
255
  function quads_hide_notice(){
256
  update_option ('quads_show_update_notice', 'no');
257
  }
258
  add_action('quads_hide_update_notice', 'quads_hide_notice', 10);
259
+
260
+ /**
261
+ * Check if any ad is activated and assigned in general settings
262
+ *
263
+ * @global array $quads_options
264
+ * @return boolean
265
+ */
266
+ function quads_is_any_ad_activated() {
267
+ global $quads_options;
268
+
269
+ // Check if custom positions location_settings is empty or does not exists
270
+ $check = array();
271
+ if( isset( $quads_options['location_settings'] ) ) {
272
+ foreach ( $quads_options['location_settings'] as $location_array ) {
273
+ if( isset( $location_array['status'] ) ) {
274
+ $check[] = $location_array['status'];
275
+ }
276
+ }
277
+ }
278
+ //wp_die(print_r($check));
279
+
280
+ if( count( $check ) === 0 &&
281
+ !isset( $quads_options['pos1']['BegnAds'] ) &&
282
+ !isset( $quads_options['pos2']['MiddAds'] ) &&
283
+ !isset( $quads_options['pos3']['EndiAds'] ) &&
284
+ !isset( $quads_options['pos4']['MoreAds'] ) &&
285
+ !isset( $quads_options['pos5']['LapaAds'] ) &&
286
+ !isset( $quads_options['pos6']['Par1Ads'] ) &&
287
+ !isset( $quads_options['pos7']['Par2Ads'] ) &&
288
+ !isset( $quads_options['pos8']['Par3Ads'] ) &&
289
+ !isset( $quads_options['pos9']['Img1Ads'] ) ) {
290
+ return false;
291
+ }
292
+ return true;
293
+ }
294
+
295
+ /**
296
+ * Check if any post type is enabled
297
+ *
298
+ * @global array $quads_options
299
+ * @return boolean
300
+ */
301
+ function quads_is_post_type_activated(){
302
+ global $quads_options;
303
+
304
+ if (empty($quads_options['post_types'])){
305
+ return false;
306
+ }
307
+ return true;
308
+ }
309
+
310
+ /**
311
+ * Check if ad codes are populated
312
+ *
313
+ * @global array $quads_options
314
+ * @return booleantrue if ads are empty
315
+ */
316
+ function quads_ads_empty() {
317
+ global $quads_options;
318
+
319
+ $check = array();
320
+
321
+ for ( $i = 1; $i <= 10; $i++ ) {
322
+ if( !empty( $quads_options['ad' . $i]['code'] ) ) {
323
+ $check[] = 'true';
324
+ }
325
+ }
326
+ if( count( $check ) === 0 ) {
327
+ return true;
328
+ }
329
+ return false;
330
+ }
includes/admin/settings/display-settings.php CHANGED
@@ -1,344 +1,349 @@
1
- <?php
2
- /**
3
- * Admin Options Page
4
- *
5
- * @package QUADS
6
- * @subpackage Admin/Settings
7
- * @copyright Copyright (c) 2015, René Hermenau
8
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since 1.0
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) exit;
14
-
15
- /* Returns list elements for jQuery tab navigation
16
- * based on header callback
17
- *
18
- * @since 2.1.2
19
- * @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be much faster?
20
- * @return string
21
- */
22
-
23
- function quads_get_tab_header($page, $section){
24
- global $quads_options;
25
- global $wp_settings_fields;
26
-
27
- if (!isset($wp_settings_fields[$page][$section]))
28
- return;
29
-
30
- echo '<ul>';
31
- foreach ((array) $wp_settings_fields[$page][$section] as $field) {
32
- $sanitizedID = str_replace('[', '', $field['id'] );
33
- $sanitizedID = str_replace(']', '', $sanitizedID );
34
- if ( strpos($field['callback'],'header') !== false && !quads_is_excluded(array('help', 'licenses') ) ) {
35
- echo '<li class="quads-tabs"><a href="#' . $sanitizedID . '">' . $field['title'] .'</a></li>';
36
- }
37
- }
38
- echo '</ul>';
39
- }
40
-
41
- /**
42
- * Check if current page is excluded
43
- *
44
- * @param array $pages
45
- * @return boolean
46
- */
47
- function quads_is_excluded($pages){
48
- if (isset($_GET['tab'])){
49
- $currentpage = $_GET['tab'];
50
- if (isset($currentpage) && in_array($currentpage, $pages))
51
- return true;
52
- }
53
- }
54
-
55
- /**
56
- * Print out the settings fields for a particular settings section
57
- *
58
- * Part of the Settings API. Use this in a settings page to output
59
- * a specific section. Should normally be called by do_settings_sections()
60
- * rather than directly.
61
- *
62
- * @global $wp_settings_fields Storage array of settings fields and their pages/sections
63
- * @return string
64
- *
65
- * @since 2.1.2
66
- *
67
- * @param string $page Slug title of the admin page who's settings fields you want to show.
68
- * @param section $section Slug title of the settings section who's fields you want to show.
69
- *
70
- * Copied from WP Core 4.0 /wp-admin/includes/template.php do_settings_fields()
71
- * We use our own function to be able to create jQuery tabs with easytabs()
72
- *
73
- * We dont use tables here any longer. Are we stuck in the nineties?
74
- * @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be faster?
75
- * @todo some media queries for better responisbility
76
- */
77
- function quads_do_settings_fields($page, $section) {
78
- global $wp_settings_fields;
79
- $header = false;
80
- $firstHeader = false;
81
-
82
- if (!isset($wp_settings_fields[$page][$section]))
83
- return;
84
-
85
- // Check first if any callback header registered
86
- foreach ((array) $wp_settings_fields[$page][$section] as $field) {
87
- strpos($field['callback'],'header') !== false ? $header = true : $header = false;
88
-
89
- if ($header === true)
90
- break;
91
- }
92
-
93
- foreach ((array) $wp_settings_fields[$page][$section] as $field) {
94
-
95
- $sanitizedID = str_replace('[', '', $field['id'] );
96
- $sanitizedID = str_replace(']', '', $sanitizedID );
97
-
98
- // Check if header has been created previously
99
- if (strpos($field['callback'],'header') !== false && $firstHeader === false) {
100
-
101
- echo '<div id="' . $sanitizedID . '">';
102
- echo '<table class="quads-form-table"><tbody>';
103
- $firstHeader = true;
104
-
105
- } elseif (strpos($field['callback'],'header') !== false && $firstHeader === true) {
106
- // Header has been created previously so we have to close the first opened div
107
- echo '</table></div><div id="' . $sanitizedID . '">';
108
- echo '<table class="quads-form-table"><tbody>';
109
- }
110
-
111
- if (!empty($field['args']['label_for']) && !quads_is_excluded_title( $field['args']['id'] )){
112
- echo '<tr class="quads-row">';
113
- echo '<td class="quads-row th">';
114
- echo '<label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label>';
115
- echo '</td></tr>';
116
- }else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) && !empty($field['args']['helper-desc'])){
117
- echo '<tr class="quads-row">';
118
- echo '<td class="quads-row th">';
119
- echo '<div class="col-title">' . $field['title'] . '<a class="quads-general-helper" href="#"></a><div class="quads-message">' . $field['args']['helper-desc']. '</div></div>';
120
- echo '</td></tr>';
121
- }else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) ){
122
- echo '<tr class="quads-row">';
123
- echo '<td class="quads-row th">';
124
- echo '<div class="col-title">' . $field['title'] . '</div>';
125
- echo '</td></tr>';
126
- }
127
-
128
- else {
129
- echo '';
130
- }
131
-
132
-
133
- echo '<tr><td>';
134
- call_user_func($field['callback'], $field['args']);
135
- echo '<tr><td>';
136
-
137
-
138
-
139
- }
140
- echo '</tbody></table>';
141
- if ($header === true){
142
- echo '</div>';
143
- }
144
- }
145
-
146
- /**
147
- * If title is one of these entries do not show it
148
- */
149
- function quads_is_excluded_title($string){
150
- $haystack = array('ad1','ad2','ad3','ad4','ad5','ad6','ad7','ad8','ad9','ad10',
151
- 'ad1_widget',
152
- 'ad2_widget',
153
- 'ad3_widget',
154
- 'ad4_widget',
155
- 'ad5_widget',
156
- 'ad6_widget',
157
- 'ad7_widget',
158
- 'ad8_widget',
159
- 'ad9_widget',
160
- 'ad10_widget'
161
- );
162
-
163
- if (in_array($string, $haystack)){
164
- return true;
165
- }
166
- return false;
167
- }
168
-
169
- /**
170
- * Options Page
171
- *
172
- * Renders the options page contents.
173
- *
174
- * @since 1.0
175
- * @global $quads_options Array of all the QUADS Options
176
- * @return void
177
- */
178
- function quads_options_page() {
179
- global $quads_options;
180
-
181
- $active_tab = isset( $_GET[ 'tab' ] ) && array_key_exists( $_GET['tab'], quads_get_settings_tabs() ) ? $_GET[ 'tab' ] : 'general';
182
-
183
- ob_start();
184
- ?>
185
- <div class="wrap quads_admin">
186
- <h1 style="text-align:center;"> <?php echo QUADS_NAME . ' ' . QUADS_VERSION; ?></h1>
187
- <div class="about-text" style="font-weight: 400;line-height: 1.6em;text-align:center;">
188
- <div class='quads-share-button-container'>
189
- <div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
190
- <div clas='box'>
191
- <a href="https://twitter.com/share?url=http://wpquads.com&text=WPQUADS+-+The quickest+and+most+easiest+way+to+integrate+AdSense+into+WordPress+websites+@wpquads" target='_blank'>
192
- <span class='quads-share'><?php echo __('Shout out a tweet','quick-adsense-reloaded'); ?></span>
193
- </a>
194
- </div>
195
- </div>
196
- <div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
197
- <div class="box">
198
- <a href="https://www.facebook.com/sharer/sharer.php?u=http://wpquads.com" target="_blank">
199
- <span class='quads-share'><?php echo __('Share on Facebook','quick-adsense-reloaded'); ?></span>
200
- </a>
201
- </div>
202
- </div>
203
- </div>
204
- </div>
205
- <h2 class="nav-tab-wrapper">
206
- <?php
207
- foreach( quads_get_settings_tabs() as $tab_id => $tab_name ) {
208
-
209
- $tab_url = esc_url(add_query_arg( array(
210
- 'settings-updated' => false,
211
- 'tab' => $tab_id
212
- ) ));
213
-
214
- $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
215
-
216
- echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
217
- echo esc_html( $tab_name );
218
- echo '</a>';
219
- }
220
- ?>
221
- </h2>
222
- <div id="quads_tab_container" class="quads_tab_container">
223
- <?php quads_get_tab_header( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab ); ?>
224
- <div class="quads-panel-container"> <!-- new //-->
225
- <form method="post" action="options.php" id="quads_settings">
226
-
227
- <?php
228
- settings_fields( 'quads_settings' );
229
- quads_do_settings_fields( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab );
230
- ?>
231
- <!--</table>-->
232
-
233
- <?php settings_errors(); ?>
234
- <?php
235
- // do not show save button on add-on page
236
- if ($active_tab !== 'addons'){
237
- $other_attributes = array( 'id' => 'quads-submit-button' );
238
- submit_button(null, 'primary', 'quads-save-settings' , true, $other_attributes );
239
- }
240
- ?>
241
- </form>
242
- <?php
243
- echo sprintf( __( '<strong>If you like this plugin please do us a BIG favor and give us a 5 star rating <a href="%s" target="_blank">here</a> . If you`re not happy, please open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
244
- 'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/#new-post',
245
- 'http://wpquads.com/support/'
246
- );
247
- echo '<p>' . sprintf( __( '<strong>Ads are not showing? Read the <a href="%s" target="_blank">troubleshooting guide</a> to find out how to resolve this issue.', 'quick-adsense-reloaded' ),
248
- 'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=bottomlink'
249
- );
250
- ?>
251
- </div> <!-- new //-->
252
- <?php quads_get_advertising(); ?>
253
- </div><!-- #tab_container-->
254
- <div id="quads-save-result"></div>
255
- <div class="quads-admin-debug"><?php echo quads_get_debug_messages(); ?></div>
256
- <?php echo quads_render_adsense_form(); ?>
257
- </div><!-- .wrap -->
258
- <?php
259
- echo ob_get_clean();
260
- }
261
-
262
- function quads_get_debug_messages(){
263
- global $quads_options;
264
-
265
- if (isset($quads_options['debug_mode'])){
266
- echo '<pre style="clear:both;">';
267
- var_dump($quads_options);
268
- echo '</pre>';
269
- }
270
- }
271
-
272
- /**
273
- * Render ad and return it when plugin is not pro version
274
- * @return string
275
- */
276
- function quads_get_advertising() {
277
-
278
- if ( quads_is_advanced() ){
279
- return '';
280
- }
281
- ob_start();
282
- ?>
283
- <div class="quads-panel-sidebar" style="float:left;min-width: 301px;margin-left: 1px;margin-top:0px;">
284
- <a href="http://wpquads.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-quads&utm_campaign=wpquads" target="_blank">
285
- <img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/quads_banner_250x521_buy.png'; ?>">
286
- </a>
287
- <br>
288
- <a style="display:block;" href="http://demo.clickfraud-monitoring.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-cfm&utm_campaign=wpquads" target="_blank">
289
- <img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/banner_250x296-cfm.png'; ?>">
290
- </a>
291
- </div>
292
- <?php
293
- echo ob_get_clean();
294
- }
295
-
296
- /**
297
- * Render social buttons
298
- *
299
- * @return void
300
- */
301
- function quads_render_social(){
302
- ob_start()?>
303
-
304
- <div class='quads-share-button-container'>
305
- <div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
306
- <div clas='box'>
307
- <a href="https://twitter.com/share?url=https://wordpress.org/plugins/quick-adsense-reloaded&text=Quick%20AdSense%20reloaded%20-%20a%20brand%20new%20fork%20of%20the%20popular%20AdSense%20Plugin%20Quick%20Adsense!" target='_blank'>
308
- <span class='quads-share'><?php echo __('Tweet','quick-adsense-reloaded'); ?></span>
309
- </a>
310
- </div>
311
- </div>
312
-
313
- <div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
314
- <div class="box">
315
- <a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/plugins/quick-adsense-reloaded" target="_blank">
316
- <span class='quads-share'><?php echo __('Share','quick-adsense-reloaded'); ?></span>
317
- </a>
318
- </div>
319
- </div>
320
- </div>
321
-
322
- <?php
323
- echo ob_get_clean();
324
- }
325
-
326
-
327
- /**
328
- * Render AdSense Form
329
- */
330
- function quads_render_adsense_form(){
331
-
332
- ?>
333
- <div id="quads-adsense-bg-div" style="display: none;">
334
- <div id="quads-adsense-container">
335
- <h3><?php _e( 'Copy ad code from AdSense account and paste it here', 'quick-adsense-reloaded' ); ?></h3>
336
- <textarea rows="15" cols="55" id="quads-adsense-form"></textarea><hr />
337
- <button class="button button-primary" id="quads-paste-button"><?php _e( 'Get Code', 'quick-adsense-reloaded' ); ?></button>&nbsp;&nbsp;
338
- <button class="button button-secondary" id="quads-close-button"><?php _e( 'Close', 'quick-adsense-reloaded' ); ?></button>
339
- <div id="quads-msg"></div>
340
- <input type="hidden" id="quads-adsense-id" value="">
341
- </div>
342
- </div>
343
- <?php
344
- }
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Options Page
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Settings
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /* Returns list elements for jQuery tab navigation
16
+ * based on header callback
17
+ *
18
+ * @since 2.1.2
19
+ * @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be much faster?
20
+ * @return string
21
+ */
22
+
23
+ function quads_get_tab_header($page, $section){
24
+ global $quads_options;
25
+ global $wp_settings_fields;
26
+
27
+ if (!isset($wp_settings_fields[$page][$section]))
28
+ return;
29
+
30
+ echo '<ul>';
31
+ foreach ((array) $wp_settings_fields[$page][$section] as $field) {
32
+ $sanitizedID = str_replace('[', '', $field['id'] );
33
+ $sanitizedID = str_replace(']', '', $sanitizedID );
34
+ if ( strpos($field['callback'],'header') !== false && !quads_is_excluded(array('help', 'licenses') ) ) {
35
+ echo '<li class="quads-tabs"><a href="#' . $sanitizedID . '">' . $field['title'] .'</a></li>';
36
+ }
37
+ }
38
+ echo '</ul>';
39
+ }
40
+
41
+ /**
42
+ * Check if current page is excluded
43
+ *
44
+ * @param array $pages
45
+ * @return boolean
46
+ */
47
+ function quads_is_excluded($pages){
48
+ if (isset($_GET['tab'])){
49
+ $currentpage = $_GET['tab'];
50
+ if (isset($currentpage) && in_array($currentpage, $pages))
51
+ return true;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Print out the settings fields for a particular settings section
57
+ *
58
+ * Part of the Settings API. Use this in a settings page to output
59
+ * a specific section. Should normally be called by do_settings_sections()
60
+ * rather than directly.
61
+ *
62
+ * @global $wp_settings_fields Storage array of settings fields and their pages/sections
63
+ * @return string
64
+ *
65
+ * @since 2.1.2
66
+ *
67
+ * @param string $page Slug title of the admin page who's settings fields you want to show.
68
+ * @param section $section Slug title of the settings section who's fields you want to show.
69
+ *
70
+ * Copied from WP Core 4.0 /wp-admin/includes/template.php do_settings_fields()
71
+ * We use our own function to be able to create jQuery tabs with easytabs()
72
+ *
73
+ * We dont use tables here any longer. Are we stuck in the nineties?
74
+ * @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be faster?
75
+ * @todo some media queries for better responisbility
76
+ */
77
+ function quads_do_settings_fields($page, $section) {
78
+ global $wp_settings_fields;
79
+ $header = false;
80
+ $firstHeader = false;
81
+
82
+ if (!isset($wp_settings_fields[$page][$section]))
83
+ return;
84
+
85
+ // Check first if any callback header registered
86
+ foreach ((array) $wp_settings_fields[$page][$section] as $field) {
87
+ strpos($field['callback'],'header') !== false ? $header = true : $header = false;
88
+
89
+ if ($header === true)
90
+ break;
91
+ }
92
+
93
+ foreach ((array) $wp_settings_fields[$page][$section] as $field) {
94
+
95
+ $sanitizedID = str_replace('[', '', $field['id'] );
96
+ $sanitizedID = str_replace(']', '', $sanitizedID );
97
+
98
+ // Check if header has been created previously
99
+ if (strpos($field['callback'],'header') !== false && $firstHeader === false) {
100
+
101
+ echo '<div id="' . $sanitizedID . '">';
102
+ echo '<table class="quads-form-table"><tbody>';
103
+ $firstHeader = true;
104
+
105
+ } elseif (strpos($field['callback'],'header') !== false && $firstHeader === true) {
106
+ // Header has been created previously so we have to close the first opened div
107
+ echo '</table></div><div id="' . $sanitizedID . '">';
108
+ echo '<table class="quads-form-table"><tbody>';
109
+ }
110
+
111
+ if (!empty($field['args']['label_for']) && !quads_is_excluded_title( $field['args']['id'] )){
112
+ echo '<tr class="quads-row">';
113
+ echo '<td class="quads-row th">';
114
+ echo '<label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label>';
115
+ echo '</td></tr>';
116
+ }else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) && !empty($field['args']['helper-desc'])){
117
+ echo '<tr class="quads-row">';
118
+ echo '<td class="quads-row th">';
119
+ echo '<div class="col-title">' . $field['title'] . '<a class="quads-general-helper" href="#"></a><div class="quads-message">' . $field['args']['helper-desc']. '</div></div>';
120
+ echo '</td></tr>';
121
+ }else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) ){
122
+ echo '<tr class="quads-row">';
123
+ echo '<td class="quads-row th">';
124
+ echo '<div class="col-title">' . $field['title'] . '</div>';
125
+ echo '</td></tr>';
126
+ }
127
+
128
+ else {
129
+ echo '';
130
+ }
131
+
132
+
133
+ echo '<tr><td>';
134
+ call_user_func($field['callback'], $field['args']);
135
+ echo '<tr><td>';
136
+
137
+
138
+
139
+ }
140
+ echo '</tbody></table>';
141
+ if ($header === true){
142
+ echo '</div>';
143
+ }
144
+ }
145
+
146
+ /**
147
+ * If title is one of these entries do not show it
148
+ */
149
+ function quads_is_excluded_title($string){
150
+ $haystack = array('ad1','ad2','ad3','ad4','ad5','ad6','ad7','ad8','ad9','ad10',
151
+ 'ad1_widget',
152
+ 'ad2_widget',
153
+ 'ad3_widget',
154
+ 'ad4_widget',
155
+ 'ad5_widget',
156
+ 'ad6_widget',
157
+ 'ad7_widget',
158
+ 'ad8_widget',
159
+ 'ad9_widget',
160
+ 'ad10_widget'
161
+ );
162
+
163
+ if (in_array($string, $haystack)){
164
+ return true;
165
+ }
166
+ return false;
167
+ }
168
+
169
+ /**
170
+ * Options Page
171
+ *
172
+ * Renders the options page contents.
173
+ *
174
+ * @since 1.0
175
+ * @global $quads_options Array of all the QUADS Options
176
+ * @return void
177
+ */
178
+ function quads_options_page() {
179
+ global $quads_options;
180
+
181
+ $active_tab = isset( $_GET[ 'tab' ] ) && array_key_exists( $_GET['tab'], quads_get_settings_tabs() ) ? $_GET[ 'tab' ] : 'general';
182
+
183
+ ob_start();
184
+ ?>
185
+ <div class="wrap quads_admin">
186
+ <h1 style="text-align:center;"> <?php echo QUADS_NAME . ' ' . QUADS_VERSION; ?></h1>
187
+ <div class="about-text" style="font-weight: 400;line-height: 1.6em;text-align:center;">
188
+ <div class='quads-share-button-container'>
189
+ <div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
190
+ <div clas='box'>
191
+ <a href="https://twitter.com/share?url=http://wpquads.com&text=WPQUADS+-+The quickest+and+most+easiest+way+to+integrate+AdSense+into+WordPress+websites+@wpquads" target='_blank'>
192
+ <span class='quads-share'><?php echo __('Shout out a tweet','quick-adsense-reloaded'); ?></span>
193
+ </a>
194
+ </div>
195
+ </div>
196
+ <div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
197
+ <div class="box">
198
+ <a href="https://www.facebook.com/sharer/sharer.php?u=http://wpquads.com" target="_blank">
199
+ <span class='quads-share'><?php echo __('Share on Facebook','quick-adsense-reloaded'); ?></span>
200
+ </a>
201
+ </div>
202
+ </div>
203
+ </div>
204
+ </div>
205
+ <h2 class="nav-tab-wrapper">
206
+ <?php
207
+ foreach( quads_get_settings_tabs() as $tab_id => $tab_name ) {
208
+
209
+ $tab_url = esc_url(add_query_arg( array(
210
+ 'settings-updated' => false,
211
+ 'tab' => $tab_id
212
+ ) ));
213
+
214
+ $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
215
+
216
+ echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
217
+ echo esc_html( $tab_name );
218
+ echo '</a>';
219
+ }
220
+ ?>
221
+ </h2>
222
+ <div id="quads_tab_container" class="quads_tab_container">
223
+ <?php quads_get_tab_header( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab ); ?>
224
+ <div class="quads-panel-container"> <!-- new //-->
225
+ <form method="post" action="options.php" id="quads_settings">
226
+
227
+ <?php
228
+ settings_fields( 'quads_settings' );
229
+ quads_do_settings_fields( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab );
230
+ ?>
231
+ <!--</table>-->
232
+
233
+ <?php settings_errors(); ?>
234
+ <?php
235
+ // do not show save button on add-on page
236
+ if ($active_tab !== 'addons'){
237
+ $other_attributes = array( 'id' => 'quads-submit-button' );
238
+ submit_button(null, 'primary', 'quads-save-settings' , true, $other_attributes );
239
+ ?>
240
+ <a href="<?php echo admin_url() . '/admin.php?page=quads-settings&quads-action=validate'; ?> " id="quads-validate"><?php _e('Validate Settings','quick-adsense-reloaded')?></a>
241
+ <?php
242
+ }
243
+ ?>
244
+ </form>
245
+ <?php
246
+ if ($active_tab !== 'addons' && $active_tab !== 'licenses'){
247
+ echo sprintf( __( '<strong>If you like this plugin please do us a BIG favor and give us a 5 star rating <a href="%s" target="_blank">here</a> . If you`re not happy, please open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
248
+ 'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/#new-post',
249
+ 'http://wpquads.com/support/'
250
+ );
251
+ echo '<p>' . sprintf( __( '<strong>Ads are not showing? Read the <a href="%s" target="_blank">troubleshooting guide</a> to find out how to resolve this issue.', 'quick-adsense-reloaded' ),
252
+ 'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=bottomlink'
253
+ );
254
+ }
255
+ ?>
256
+ </div> <!-- new //-->
257
+ <?php quads_get_advertising(); ?>
258
+ </div><!-- #tab_container-->
259
+ <div id="quads-save-result"></div>
260
+ <div class="quads-admin-debug"><?php echo quads_get_debug_messages(); ?></div>
261
+ <?php echo quads_render_adsense_form(); ?>
262
+ </div><!-- .wrap -->
263
+ <?php
264
+ echo ob_get_clean();
265
+ }
266
+
267
+ function quads_get_debug_messages(){
268
+ global $quads_options;
269
+
270
+ if (isset($quads_options['debug_mode'])){
271
+ echo '<pre style="clear:both;">';
272
+ var_dump($quads_options);
273
+ echo '</pre>';
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Render ad and return it when plugin is not pro version
279
+ * @return string
280
+ */
281
+ function quads_get_advertising() {
282
+
283
+ if ( quads_is_advanced() ){
284
+ return '';
285
+ }
286
+ ob_start();
287
+ ?>
288
+ <div class="quads-panel-sidebar" style="float:left;min-width: 301px;margin-left: 1px;margin-top:0px;">
289
+ <a href="http://wpquads.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-quads&utm_campaign=wpquads" target="_blank">
290
+ <img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/quads_banner_250x521_buy.png'; ?>">
291
+ </a>
292
+ <br>
293
+ <a style="display:block;" href="http://demo.clickfraud-monitoring.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-cfm&utm_campaign=wpquads" target="_blank">
294
+ <img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/banner_250x296-cfm.png'; ?>">
295
+ </a>
296
+ </div>
297
+ <?php
298
+ echo ob_get_clean();
299
+ }
300
+
301
+ /**
302
+ * Render social buttons
303
+ *
304
+ * @return void
305
+ */
306
+ function quads_render_social(){
307
+ ob_start()?>
308
+
309
+ <div class='quads-share-button-container'>
310
+ <div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
311
+ <div clas='box'>
312
+ <a href="https://twitter.com/share?url=https://wordpress.org/plugins/quick-adsense-reloaded&text=Quick%20AdSense%20reloaded%20-%20a%20brand%20new%20fork%20of%20the%20popular%20AdSense%20Plugin%20Quick%20Adsense!" target='_blank'>
313
+ <span class='quads-share'><?php echo __('Tweet','quick-adsense-reloaded'); ?></span>
314
+ </a>
315
+ </div>
316
+ </div>
317
+
318
+ <div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
319
+ <div class="box">
320
+ <a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/plugins/quick-adsense-reloaded" target="_blank">
321
+ <span class='quads-share'><?php echo __('Share','quick-adsense-reloaded'); ?></span>
322
+ </a>
323
+ </div>
324
+ </div>
325
+ </div>
326
+
327
+ <?php
328
+ echo ob_get_clean();
329
+ }
330
+
331
+
332
+ /**
333
+ * Render AdSense Form
334
+ */
335
+ function quads_render_adsense_form(){
336
+
337
+ ?>
338
+ <div id="quads-adsense-bg-div" style="display: none;">
339
+ <div id="quads-adsense-container">
340
+ <h3><?php _e( 'Copy ad code from AdSense account and paste it here', 'quick-adsense-reloaded' ); ?></h3>
341
+ <textarea rows="15" cols="55" id="quads-adsense-form"></textarea><hr />
342
+ <button class="button button-primary" id="quads-paste-button"><?php _e( 'Get Code', 'quick-adsense-reloaded' ); ?></button>&nbsp;&nbsp;
343
+ <button class="button button-secondary" id="quads-close-button"><?php _e( 'Close', 'quick-adsense-reloaded' ); ?></button>
344
+ <div id="quads-msg"></div>
345
+ <input type="hidden" id="quads-adsense-id" value="">
346
+ </div>
347
+ </div>
348
+ <?php
349
+ }
includes/admin/settings/register-settings.php CHANGED
@@ -124,7 +124,7 @@ function quads_get_registered_settings() {
124
  'general' => apply_filters( 'quads_settings_general', array(
125
  array(
126
  'id' => 'general_header',
127
- 'name' => '<strong>' . __( 'General Settings', 'quick-adsense-reloaded' ) . '</strong>',
128
  'desc' => __( '', 'quick-adsense-reloaded' ),
129
  'type' => 'header'
130
  ),
@@ -145,6 +145,7 @@ function quads_get_registered_settings() {
145
  7 => '7',
146
  8 => '8',
147
  9 => '9',
 
148
  11 => '11',
149
  12 => '12',
150
  13 => '13',
@@ -159,7 +160,7 @@ function quads_get_registered_settings() {
159
  ),
160
  array(
161
  'id' => 'ad_position',
162
- 'name' => __( 'Position', 'quick-adsense-reloaded' ),
163
  'desc' => __( 'Assign and activate ads on specific ad places', 'quick-adsense-reloaded' ),
164
  'type' => 'ad_position'
165
  ),
@@ -357,21 +358,26 @@ function quads_get_registered_settings() {
357
  'priority' => array(
358
  'id' => 'priority',
359
  'name' => __( 'Load Priority', 'quick-adsense-reloaded' ),
360
- 'desc' => __( 'Do not change this if everything is working fine. It could result in non showing ads! A lower value loads WP QUADS earlier than other Plugins. Use a higher value for loading WP QUADS later. Try to lower the value to a value less than 10 if not all ads are shown. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
 
361
  'type' => 'number',
362
  'size' => 'small',
363
  'std' => 20
364
  ),
365
  'create_settings' => array(
366
  'id' => 'create_settings',
367
- 'name' => __( 'Settings link', 'quick-adsense-reloaded' ),
368
- 'desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong> This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
 
 
369
  'type' => 'checkbox',
370
  ),
371
  'uninstall_on_delete' => array(
372
  'id' => 'uninstall_on_delete',
373
- 'name' => __( 'Remove Data on Uninstall?', 'quick-adsense-reloaded' ),
374
- 'desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
 
 
375
  'type' => 'checkbox'
376
  ),
377
  )
124
  'general' => apply_filters( 'quads_settings_general', array(
125
  array(
126
  'id' => 'general_header',
127
+ 'name' => '<strong>' . __( 'General & Position', 'quick-adsense-reloaded' ) . '</strong>',
128
  'desc' => __( '', 'quick-adsense-reloaded' ),
129
  'type' => 'header'
130
  ),
145
  7 => '7',
146
  8 => '8',
147
  9 => '9',
148
+ 10 => '10',
149
  11 => '11',
150
  12 => '12',
151
  13 => '13',
160
  ),
161
  array(
162
  'id' => 'ad_position',
163
+ 'name' => __( 'Position - Default Ads', 'quick-adsense-reloaded' ),
164
  'desc' => __( 'Assign and activate ads on specific ad places', 'quick-adsense-reloaded' ),
165
  'type' => 'ad_position'
166
  ),
358
  'priority' => array(
359
  'id' => 'priority',
360
  'name' => __( 'Load Priority', 'quick-adsense-reloaded' ),
361
+ //'desc' => __( 'Do not change this until you know what you are doing. Usually the default value 20 is working fine. Changing this value can lead to unexpected results like ads not showing or loaded on wrong order. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
362
+ 'helper-desc' => __( 'Do not change this until you know what you are doing. Usually the default value 20 is working fine. Changing this value can lead to unexpected results like ads not showing or loaded on wrong order. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
363
  'type' => 'number',
364
  'size' => 'small',
365
  'std' => 20
366
  ),
367
  'create_settings' => array(
368
  'id' => 'create_settings',
369
+ 'name' => __( 'Remove Menue Button', 'quick-adsense-reloaded' ),
370
+ //'desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
371
+ 'desc' => __('Remove'),
372
+ 'helper-desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
373
  'type' => 'checkbox',
374
  ),
375
  'uninstall_on_delete' => array(
376
  'id' => 'uninstall_on_delete',
377
+ 'name' => __( 'Delete Data on Uninstall?', 'quick-adsense-reloaded' ),
378
+ //'desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
379
+ 'helper-desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
380
+ 'desc' => 'Delete',
381
  'type' => 'checkbox'
382
  ),
383
  )
includes/admin/upgrades/upgrade-functions.php CHANGED
@@ -132,7 +132,8 @@ function quads_is_advanced_1_2_7() {
132
  }
133
 
134
  /**
135
- * Convert all post/page setting to new post_type global options array
 
136
  * @global array $quads_options
137
  * @return true if success
138
  */
132
  }
133
 
134
  /**
135
+ * Convert all previous post/page settings to the new post_type global options array which has been introduced in 1.4.0
136
+ *
137
  * @global array $quads_options
138
  * @return true if success
139
  */
includes/api.php CHANGED
@@ -34,7 +34,7 @@
34
 
35
 
36
  /**
37
- * Return ad locations HTML based on new API.
38
  *
39
  * @param $html
40
  * @return string Locations HTML
@@ -120,12 +120,14 @@ function quads_has_ad( $location ) {
120
  return apply_filters( 'quads_has_ad', $result, $location );
121
  }
122
  /**
123
- * Display an ad
124
  *
125
  * @param array $args Displaying options
126
  * @return string|void Ad code or none if echo set to true
127
  */
128
  function quads_ad( $args ) {
 
 
129
  $defaults = array(
130
  'location' => '',
131
  'echo' => true,
@@ -133,14 +135,18 @@ function quads_ad( $args ) {
133
  $args = wp_parse_args( $args, $defaults );
134
  $code = '';
135
 
 
 
 
 
 
136
  if ( quads_has_ad( $args['location'] ) ) {
137
  global $quads_options;
138
 
139
- quads_set_ad_count_custom(); // increase amount of shortcode ads
140
 
141
  $location_settings = quads_get_ad_location_settings( $args['location'] );
142
  $code .= "\n".'<!-- WP QUADS Custom Ad v. ' . QUADS_VERSION .' -->'."\n";
143
- //$code .= $quads_options[ 'ad' . $location_settings['ad'] ]['code'];
144
  $code .= '<div class="quads-location quads-ad' .$location_settings['ad']. '" id="quads-ad' .$location_settings['ad']. '">'."\n";
145
  $code .= quads_render_ad( 'ad' . $location_settings['ad'], $quads_options[ 'ad' . $location_settings['ad'] ]['code'] );
146
  $code .= '</div>';
34
 
35
 
36
  /**
37
+ * Return ad locations HTML based on new API in general settings
38
  *
39
  * @param $html
40
  * @return string Locations HTML
120
  return apply_filters( 'quads_has_ad', $result, $location );
121
  }
122
  /**
123
+ * Display a custom ad
124
  *
125
  * @param array $args Displaying options
126
  * @return string|void Ad code or none if echo set to true
127
  */
128
  function quads_ad( $args ) {
129
+ global $post;
130
+
131
  $defaults = array(
132
  'location' => '',
133
  'echo' => true,
135
  $args = wp_parse_args( $args, $defaults );
136
  $code = '';
137
 
138
+ // All ads are deactivated via post meta settings
139
+ if( quads_check_meta_setting( 'NoAds' ) === '1' ){
140
+ return false;
141
+ }
142
+
143
  if ( quads_has_ad( $args['location'] ) ) {
144
  global $quads_options;
145
 
146
+ quads_set_ad_count_custom(); // increase amount of Custom ads
147
 
148
  $location_settings = quads_get_ad_location_settings( $args['location'] );
149
  $code .= "\n".'<!-- WP QUADS Custom Ad v. ' . QUADS_VERSION .' -->'."\n";
 
150
  $code .= '<div class="quads-location quads-ad' .$location_settings['ad']. '" id="quads-ad' .$location_settings['ad']. '">'."\n";
151
  $code .= quads_render_ad( 'ad' . $location_settings['ad'], $quads_options[ 'ad' . $location_settings['ad'] ]['code'] );
152
  $code .= '</div>';
includes/conditionals.php CHANGED
@@ -70,9 +70,11 @@ function quads_get_total_ad_count(){
70
  $shortcode = isset($visibleShortcodeAds) ? (int)$visibleShortcodeAds : 0;
71
  $content = isset($visibleContentAdsGlobal) ? (int)$visibleContentAdsGlobal : 0;
72
  $custom = isset($ad_count_custom) ? (int)$ad_count_custom : 0;
73
- $widget = isset($ad_count_widget) ? (int)$ad_count_widget : 0;
74
-
75
- //wp_die($ad_count_widget);
 
 
76
  return $shortcode + $content + $custom + $widget;
77
  }
78
 
@@ -89,6 +91,10 @@ function quads_ad_reach_max_count(){
89
  global $quads_options;
90
 
91
  $maxads = isset($quads_options['maxads']) ? $quads_options['maxads'] : 10;
 
 
 
 
92
  if ( quads_get_total_ad_count() >= $maxads ){
93
  return true;
94
  }
70
  $shortcode = isset($visibleShortcodeAds) ? (int)$visibleShortcodeAds : 0;
71
  $content = isset($visibleContentAdsGlobal) ? (int)$visibleContentAdsGlobal : 0;
72
  $custom = isset($ad_count_custom) ? (int)$ad_count_custom : 0;
73
+ //$widget = isset($ad_count_widget) ? (int)$ad_count_widget : 0;
74
+ $widget = quads_get_number_widget_ads();
75
+
76
+ //wp_die($widget);
77
+ //wp_die( $shortcode + $content + $custom + $widget);
78
  return $shortcode + $content + $custom + $widget;
79
  }
80
 
91
  global $quads_options;
92
 
93
  $maxads = isset($quads_options['maxads']) ? $quads_options['maxads'] : 10;
94
+ $maxads = $maxads - quads_get_number_widget_ads();
95
+
96
+ //echo 'Total ads: '. quads_get_total_ad_count() . ' maxads: '. $maxads . '<br>';
97
+
98
  if ( quads_get_total_ad_count() >= $maxads ){
99
  return true;
100
  }
includes/frontend-checks.php ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Helper Functions
4
+ *
5
+ * @package QUADS
6
+ * @subpackage INCLUDES
7
+ * @copyright Copyright (c) 2016, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @author René Hermenau
10
+ * @author Thank you Thomas Maier (advanced ads) for that great inspiration. I borrowed some code. Hope you dont mind:)
11
+ * @since 1.4.3
12
+ */
13
+ // Exit if accessed directly
14
+ if( !defined( 'ABSPATH' ) )
15
+ exit;
16
+
17
+ function quads_frontend_checks_init() {
18
+ if( !is_admin() && is_admin_bar_showing() && current_user_can( 'update_plugins' )
19
+ ) {
20
+ add_action( 'admin_bar_menu', 'quads_add_admin_bar_menu', 1000 );
21
+ add_filter( 'the_content', 'quads_check_the_content_filter' );
22
+ add_filter( 'wp_footer', 'quads_check_adblocker', -101 );
23
+ add_filter( 'quads-ad-output', 'after_ad_output', 10, 2 );
24
+ }
25
+ }
26
+
27
+ add_action( 'init', 'quads_frontend_checks_init' );
28
+
29
+ /**
30
+ * Create WP QUADS List possible error cases in the admin-bar.
31
+ *
32
+ * @param obj $wp_admin_bar WP_Admin_Bar
33
+ */
34
+ function quads_add_admin_bar_menu( $wp_admin_bar ) {
35
+ global $quads_options, $wp_the_query, $post, $wp_scripts, $the_content;
36
+
37
+ $error = false;
38
+
39
+ $wp_admin_bar->add_node( array(
40
+ 'id' => 'quads_ad_check',
41
+ 'title' => __( 'Ad Check', 'quick-adsense-reloaded' ),
42
+ ) );
43
+
44
+ // Hidden by default
45
+ $wp_admin_bar->add_node( array(
46
+ 'parent' => 'quads_ad_check',
47
+ 'id' => 'quads_ad_check_jquery',
48
+ 'title' => __( '- JavaScript / jQuery error', 'quick-adsense-reloaded' ),
49
+ 'href' => 'http://wpquads.com/docs/javascript-issues-breaking-adsense-ads/',
50
+ 'meta' => array(
51
+ 'class' => 'quads-hidden quads_ad_check_warning',
52
+ 'target' => '_blank'
53
+ )
54
+ ) );
55
+
56
+ // Hidden by default
57
+ $wp_admin_bar->add_node( array(
58
+ 'parent' => 'quads_ad_check',
59
+ 'id' => 'quads_ad_check_adblocker_enabled',
60
+ 'title' => __( '- Ad blocker enabled', 'quick-adsense-reloaded' ),
61
+ 'meta' => array(
62
+ 'class' => 'quads-hidden quads_ad_check_warning',
63
+ 'target' => '_blank'
64
+ )
65
+ ) );
66
+ // Hidden by default
67
+ if( $wp_the_query->is_singular() ) {
68
+ // Check if the_content filter is available
69
+ if( !$the_content ) {
70
+ $wp_admin_bar->add_node( array(
71
+ 'parent' => 'quads_ad_check',
72
+ 'id' => 'quads_ad_check_the_content_not_invoked',
73
+ 'title' => __( '- <em>the_content</em> filter does not exist', 'quick-adsense-reloaded' ),
74
+ 'href' => 'http://wpquads.com/docs/the_content-filter-missing/',
75
+ 'meta' => array(
76
+ 'class' => 'quads_ad_check_warning',
77
+ 'target' => '_blank'
78
+ )
79
+ ) );
80
+ $error = true;
81
+ }
82
+ // Hidden by default
83
+ if( !empty( $post->ID ) ) {
84
+ $ad_settings = get_post_meta( $post->ID, '_quads_config_visibility', true );
85
+
86
+ if( !empty( $ad_settings['NoAds'] ) ) {
87
+ $wp_admin_bar->add_node( array(
88
+ 'parent' => 'quads_ad_check',
89
+ 'id' => 'quads_ad_check_disabled_on_page',
90
+ 'title' => __( '- All Ads are disabled on this page', 'quick-adsense-reloaded' ),
91
+ 'href' => get_edit_post_link( $post->ID ) . '#quads-ad-settings',
92
+ 'meta' => array(
93
+ 'class' => 'quads_ad_check_warning',
94
+ 'target' => '_blank'
95
+ )
96
+ ) );
97
+ $error = true;
98
+ }
99
+ if( !empty( $ad_settings['OffDef'] ) ) {
100
+ $wp_admin_bar->add_node( array(
101
+ 'parent' => 'quads_ad_check',
102
+ 'id' => 'quads_ad_check_disabled_in_content',
103
+ 'title' => __( '- Default Ads disabled in content of this page', 'quick-adsense-reloaded' ),
104
+ 'href' => get_edit_post_link( $post->ID ) . '#quads-ad-settings',
105
+ 'meta' => array(
106
+ 'class' => 'quads_ad_check_warning',
107
+ 'target' => '_blank'
108
+ )
109
+ ) );
110
+ $error = true;
111
+ }
112
+ } else {
113
+ $wp_admin_bar->add_node( array(
114
+ 'parent' => 'quads_ad_check',
115
+ 'id' => 'quads_ad_check_post_zero',
116
+ 'title' => __( '- Current post ID is 0 ', 'quick-adsense-reloaded' ),
117
+ 'href' => 'https://wpadvancedads.com/manual/known-plugin-conflicts/#frontend-issue-post-id-empty',
118
+ 'meta' => array(
119
+ 'class' => 'quads_ad_check_warning',
120
+ 'target' => '_blank'
121
+ )
122
+ ) );
123
+ $error = true;
124
+ }
125
+ }
126
+
127
+ if( $wp_the_query->is_404() && !empty( $quads_options['disabled-ads']['404'] ) ) {
128
+ $wp_admin_bar->add_node( array(
129
+ 'parent' => 'quads_ad_check',
130
+ 'id' => 'quads_ad_check_no_404',
131
+ 'title' => __( 'Ads are disabled on 404 pages', 'quick-adsense-reloaded' ),
132
+ 'href' => admin_url( 'admin.php?page=quads-settings' ),
133
+ 'meta' => array(
134
+ 'class' => 'quads_ad_check_warning',
135
+ 'target' => '_blank'
136
+ )
137
+ ) );
138
+ $error = true;
139
+ }
140
+
141
+ if( !$wp_the_query->is_singular() && !empty( $quads_options['disabled-ads']['archives'] ) ) {
142
+ $wp_admin_bar->add_node( array(
143
+ 'parent' => 'quads_ad_check',
144
+ 'id' => 'quads_ad_check_no_archive',
145
+ 'title' => __( 'Ads are disabled on non singular pages', 'quick-adsense-reloaded' ),
146
+ 'href' => admin_url( 'admin.php?page=quads-settings' ),
147
+ 'meta' => array(
148
+ 'class' => 'quads_ad_check_warning',
149
+ 'target' => '_blank'
150
+ )
151
+ ) );
152
+ $error = true;
153
+ }
154
+
155
+ if( !extension_loaded( 'dom' ) ) {
156
+ $wp_admin_bar->add_node( array(
157
+ 'parent' => 'quads_ad_check',
158
+ 'id' => 'quads_ad_check_no_dom_document',
159
+ 'title' => sprintf( __( 'The %s extension(s) is not loaded', 'quick-adsense-reloaded' ), 'dom' ),
160
+ 'href' => 'http://php.net/manual/en/book.dom.php',
161
+ 'meta' => array(
162
+ 'class' => 'quads_ad_check_warning',
163
+ 'target' => '_blank'
164
+ )
165
+ ) );
166
+ $error = true;
167
+ }
168
+
169
+ if( !$error ) {
170
+ $wp_admin_bar->add_node( array(
171
+ 'parent' => 'quads_ad_check',
172
+ 'id' => 'quads_ad_check_fine',
173
+ 'title' => __( 'WP QUADS is working fine', 'quick-adsense-reloaded' ),
174
+ 'href' => false,
175
+ 'meta' => array(
176
+ 'target' => '_blank',
177
+ )
178
+ ) );
179
+ }
180
+
181
+ $wp_admin_bar->add_node( array(
182
+ 'parent' => 'quads_ad_check',
183
+ 'id' => 'quads_ad_check_debug_dfp',
184
+ 'title' => __( 'debug DFP ads', 'quick-adsense-reloaded' ),
185
+ 'href' => esc_url( add_query_arg( 'googfc', '' ) ),
186
+ 'meta' => array(
187
+ 'class' => 'quads-hidden quads_ad_check_debug_dfp_link',
188
+ 'target' => '_blank',
189
+ )
190
+ ) );
191
+
192
+ $wp_admin_bar->add_node( array(
193
+ 'parent' => 'quads_ad_check',
194
+ 'id' => 'quads_ad_check_highlight_ads',
195
+ 'title' => sprintf( '<label><input id="quads_highlight_ads_checkbox" type="checkbox"> %s</label>', __( 'highlight ads', 'quick-adsense-reloaded' ) )
196
+ ) );
197
+ }
198
+
199
+ /**
200
+ * Set variable to 'true' when 'the_content' filter is available.
201
+ *
202
+ * @param string $content
203
+ * @return string $content
204
+ */
205
+ function quads_check_the_content_filter( $content ) {
206
+ global $the_content;
207
+
208
+ $the_content = true;
209
+
210
+ return $content;
211
+ }
212
+
213
+ /**
214
+ * Check conditions and display warning. Conditions: AdBlocker enabled, jQuery is included in header
215
+ */
216
+ function quads_check_adblocker() {
217
+ ?>
218
+ <!--noptimize--><style>.quads-hidden { display: none; } .quads-adminbar-is-warnings { background: #ef4000 ! important; color: #fff !important; }
219
+ .quads-highlight-ads { outline:6px solid #83c11f !important; }</style>
220
+ <script type="text/javascript" src="<?php echo QUADS_PLUGIN_URL . 'assets/js/ads.js' ?>"></script>
221
+ <script>
222
+ (function (d, w) {
223
+ var jquery_not_detected = typeof jQuery === 'undefined';
224
+
225
+ var addEvent = function (obj, type, fn) {
226
+ if (obj.addEventListener)
227
+ obj.addEventListener(type, fn, false);
228
+ else if (obj.attachEvent)
229
+ obj.attachEvent('on' + type, function () {
230
+ return fn.call(obj, window.event);
231
+ });
232
+ };
233
+
234
+ function highlight_ads() {
235
+ try {
236
+ var ad_wrappers = document.querySelectorAll('div[id^="quads-ad"]')
237
+ } catch (e) {
238
+ return;
239
+ }
240
+ for (i = 0; i < ad_wrappers.length; i++) {
241
+ if (this.checked) {
242
+ ad_wrappers[i].className += ' quads-highlight-ads';
243
+ } else {
244
+ ad_wrappers[i].className = ad_wrappers[i].className.replace('quads-highlight-ads', '');
245
+ }
246
+ }
247
+ }
248
+
249
+ addEvent(w, 'load', function () {
250
+ var adblock_item = d.getElementById('wp-admin-bar-quads_ad_check_adblocker_enabled'),
251
+ jQuery_item = d.getElementById('wp-admin-bar-quads_ad_check_jquery'),
252
+ fine_item = d.getElementById('wp-admin-bar-quads_ad_check_fine'),
253
+ hide_fine = false;
254
+
255
+ var highlight_checkbox = d.getElementById('quads_highlight_ads_checkbox');
256
+ if (highlight_checkbox) {
257
+ addEvent(highlight_checkbox, 'change', highlight_ads);
258
+ }
259
+ if (adblock_item && typeof wpquads_adblocker_check === 'undefined' || false === wpquads_adblocker_check) {
260
+ // show quads-hidden item
261
+ adblock_item.className = adblock_item.className.replace(/quads-hidden/, '');
262
+ hide_fine = true;
263
+ }
264
+
265
+ if (jQuery_item && jquery_not_detected) {
266
+ // show quads-hidden item
267
+ jQuery_item.className = jQuery_item.className.replace(/quads-hidden/, '');
268
+ hide_fine = true;
269
+ }
270
+
271
+ if (hide_fine && fine_item) {
272
+ fine_item.className += ' quads-hidden';
273
+ }
274
+
275
+ showCount();
276
+ });
277
+
278
+ var showCount = function () {
279
+ try {
280
+ // select not quads-hidden warning items, exclude the 'fine_item'
281
+ var warning_count = document.querySelectorAll('.quads_ad_check_warning:not(.quads-hidden)').length;
282
+ } catch (e) {
283
+ return;
284
+ }
285
+
286
+ if (warning_count) {
287
+ var header = document.querySelector('#wp-admin-bar-quads_ad_check > div');
288
+
289
+ if (header) {
290
+ header.innerHTML += ' <i>(' + warning_count + ')</i>';
291
+ header.className += ' quads-adminbar-is-warnings';
292
+ }
293
+ }
294
+ };
295
+ })(document, window);
296
+ </script><!--/noptimize-->
297
+ <?php
298
+ }
includes/meta-boxes.php CHANGED
@@ -8,11 +8,12 @@
8
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
  * @since 0.9.6
10
  */
11
- function quads_load_meta_box () {
12
  new Quads_Meta_Box();
13
- }
14
- add_action( 'load-post.php', 'quads_load_meta_box' );
15
- add_action( 'load-post-new.php', 'quads_load_meta_box' );
 
16
  /**
17
  * Ads options for a single post
18
  */
@@ -40,7 +41,7 @@ class Quads_Meta_Box {
40
  __('WP QUADS - Hide Ads', 'quick-adsense-reloaded'), // title
41
  array($this, 'render_meta_box'), // render function callback
42
  $post_type, // post_type
43
- 'normal', // context
44
  'default' // priority
45
  );
46
  }
8
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
  * @since 0.9.6
10
  */
11
+ //function quads_load_meta_box () {
12
  new Quads_Meta_Box();
13
+ //}
14
+ //add_action( 'load-post.php', 'quads_load_meta_box' );
15
+ //add_action( 'load-post-new.php', 'quads_load_meta_box' );
16
+ //add_action( 'add_meta_boxes', 'quads_load_meta_box' );
17
  /**
18
  * Ads options for a single post
19
  */
41
  __('WP QUADS - Hide Ads', 'quick-adsense-reloaded'), // title
42
  array($this, 'render_meta_box'), // render function callback
43
  $post_type, // post_type
44
+ 'advanced', // context
45
  'default' // priority
46
  );
47
  }
includes/quicktags.php CHANGED
@@ -43,6 +43,8 @@ function quads_get_quicktags_from_content ( $content ) {
43
  }
44
  return $found;
45
  }
 
 
46
  /**
47
  * Removes all quicktags from content
48
  *
43
  }
44
  return $found;
45
  }
46
+
47
+
48
  /**
49
  * Removes all quicktags from content
50
  *
includes/shortcodes.php CHANGED
@@ -32,8 +32,9 @@ function quads_shortcode_display_ad( $atts ) {
32
 
33
 
34
  //return quads_check_meta_setting('NoAds');
35
- if( quads_check_meta_setting( 'NoAds' ) === '1' )
36
  return;
 
37
 
38
  // The ad id
39
  $id = isset( $atts['id'] ) ? ( int ) $atts['id'] : 0;
@@ -94,8 +95,9 @@ function quads_get_ad($id = 0) {
94
  function quads_check_meta_setting($key){
95
  global $post;
96
 
97
- if ( !isset($post->ID ) )
98
- return false;
 
99
 
100
  $meta_key = '_quads_config_visibility';
101
 
32
 
33
 
34
  //return quads_check_meta_setting('NoAds');
35
+ if( quads_check_meta_setting( 'NoAds' ) === '1' ){
36
  return;
37
+ }
38
 
39
  // The ad id
40
  $id = isset( $atts['id'] ) ? ( int ) $atts['id'] : 0;
95
  function quads_check_meta_setting($key){
96
  global $post;
97
 
98
+ if ( !isset($post->ID ) ){
99
+ return false;
100
+ }
101
 
102
  $meta_key = '_quads_config_visibility';
103
 
includes/template-functions.php CHANGED
@@ -16,20 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
16
  add_filter('the_content', 'quads_post_settings_to_quicktags', 5);
17
  add_filter('the_content', 'quads_process_content', quads_get_load_priority());
18
 
19
- /**
20
- * Get load priority
21
- *
22
- * @global arr $quads_options
23
- * @return int
24
- */
25
- function quads_get_load_priority(){
26
- global $quads_options;
27
-
28
- if (!empty($quads_options['priority'])){
29
- return intval($quads_options['priority']);
30
- }
31
- return 20;
32
- }
33
 
34
  /**
35
  * Adds quicktags, defined via post meta options, to content.
@@ -79,412 +66,598 @@ function quads_get_visibility_quicktags_str ( $post_id = null ) {
79
  }
80
 
81
  /**
82
- * Main processing for the_content filter
83
- *
84
- * @global arr $quads_options all plugin settings
85
- * @global int $visibleContentAds number of active content ads (reseted internally so we have to use a similar global below for external purposes: $visibleContentAdsGlobal)
86
- * @global arr $AdsId Whitespace trimmed array of ad codes
87
- * @global int $maxWidgets maximum number of ad widgets
88
- * @global int $maxAds number of maximum available ads
89
- * @global string $AdsWidName name of widget
90
- * @global int $visibleContentAdsGlobal number of active content ads
91
- * @global int $visibleShortcodeAds number of active shortcode ads
92
- * @global int $ad_count_widget number of active widget ads
93
- * @param string $content
94
  *
95
- * @return string
 
 
 
 
 
 
 
 
 
 
 
 
96
  *
97
- * @since 0.9.0
 
 
 
98
  */
 
 
 
99
 
100
- function quads_process_content($content){
101
- global $quads_options, $visibleContentAds, $AdsId, $maxWidgets, $maxAds, $AdsWidName, $visibleContentAdsGlobal, $visibleShortcodeAds, $ad_count_widget;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- // Return original content if QUADS is not allowed
104
- if ( !quads_ad_is_allowed($content) ) {
105
- $content = quads_clean_tags($content);
106
- return $content;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
- // Maximum allowed ads
109
- $maxAds = isset($quads_options['maxads']) ? $quads_options['maxads'] : 10;
110
-
111
- // count active widget ads
112
- if (strpos($content,'<!--OffWidget-->')===false) {
113
- for($i=1;$i<=$maxWidgets;$i++) {
114
- $wadsid = sanitize_title(str_replace(array('(',')'),'',sprintf($AdsWidName,$i)));
115
- //$maxAds -= (is_active_widget('', '', $wadsid)) ? 1 : 0 ;
116
- $ad_count_widget += (is_active_widget('', '', $wadsid)) ? 1 : 0 ;
117
- }
118
- }
119
 
 
 
 
 
 
 
120
 
121
- // Return here if max visible ads are exceeded
122
- if( $visibleContentAds+$visibleShortcodeAds+$ad_count_widget >= $maxAds ) { // ShownAds === 0 or larger/equal than $maxAds
123
- $content = quads_clean_tags($content);
124
- return $content;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
- // Create array of valid id's
128
- if( count( $AdsId ) === 0 ) { //
129
- for ( $i = 1; $i <= $maxAds; $i++ ) {
130
- $tmp = isset($quads_options['ad' . $i]['code']) ? trim( $quads_options['ad' . $i]['code'] ) : '';
131
- // id is valid if there is either the plain text field populated or the adsense ad slot and the ad client id
132
- if( !empty( $tmp ) || (!empty($quads_options['ad' . $i]['g_data_ad_slot']) && !empty($quads_options['ad' . $i]['g_data_ad_client'] ) ) ) {
133
- $AdsId[] = $i;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
  }
136
- // echo '<pre>';
137
- // wp_die(var_dump($AdsId));
138
  }
 
 
 
 
 
 
 
 
139
 
140
- // Ad code array is empty so break here
141
- if( count($AdsId) === 0 ) {
142
- $content = quads_clean_tags($content);
143
- return $content;
144
- };
 
 
 
 
 
 
 
 
 
 
 
145
 
146
- /* ... Tidy up content ... */
147
- // Replace all <p></p> tags with placeholder ##QA-TP1##
148
- // Replace all
149
- $content = str_replace("<p></p>", "##QA-TP1##", $content);
150
- // Replace all <p>&nbsp;</p> tags with placeholder ##QA-TP2##
151
- $content = str_replace("<p>&nbsp;</p>", "##QA-TP2##", $content);
152
- $off_default_ads = (strpos($content,'<!--OffDef-->')!==false);
153
-
154
- if( !$off_default_ads ) { // disabled default positioned ads
155
 
156
- $AdsIdCus = array(); // ids of used ads
157
-
158
- $cusrnd = 'CusRnd'; // placeholder string for random ad
159
- $cusads = 'CusAds'; // placeholder string for custom ad spots
160
-
161
- $begn1 = isset($quads_options['pos1']['BegnAds']) ? true : false;
162
- $begn2 = isset($quads_options['pos1']['BegnRnd']) ? $quads_options['pos1']['BegnRnd'] : 0;
163
 
164
- $midd1 = isset($quads_options['pos2']['MiddAds']) ? true : false;
165
- $midd2 = isset($quads_options['pos2']['MiddRnd']) ? $quads_options['pos2']['MiddRnd'] : 0;
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
- $endi1 = isset($quads_options['pos3']['EndiAds']) ? true : false;
168
- $endi2 = isset($quads_options['pos3']['EndiRnd']) ? $quads_options['pos3']['EndiRnd'] : 0;
169
-
170
- $more1 = isset($quads_options['pos4']['MoreAds']) ? true : false;
171
- $more2 = isset($quads_options['pos4']['MoreRnd']) ? $quads_options['pos4']['MoreRnd'] : 0;
172
-
173
- $lapa1 = isset($quads_options['pos5']['LapaAds']) ? true : false;
174
- $lapa2 = isset($quads_options['pos5']['LapaRnd'])? $quads_options['pos5']['LapaRnd'] : 0 ;
175
-
176
-
177
-
178
- $number = 3; // number of paragraph ads | default value 3.
179
- $default = 5; // Position. Let's start with id 5
180
- for($i=1;$i<=$number;$i++) {
181
-
182
- $key = $default +$i; // 6,7,8
183
-
184
- $paragraph['status'][$i] = isset($quads_options['pos' . $key]['Par'.$i .'Ads']) ? $quads_options['pos' . $key]['Par'.$i .'Ads'] : 0; // Status - active | inactive
185
- $paragraph['id'][$i] = isset($quads_options['pos' . $key]['Par'.$i .'Rnd']) ? $quads_options['pos' . $key]['Par'.$i .'Rnd'] : 0; // Ad id
186
- $paragraph['position'][$i] = isset($quads_options['pos' . $key]['Par'.$i .'Nup']) ? $quads_options['pos' . $key]['Par'.$i .'Nup'] : 0; // Paragraph No
187
- $paragraph['end_post'][$i] = isset($quads_options['pos' . $key]['Par'.$i .'Con']) ? $quads_options['pos' . $key]['Par'.$i .'Con'] : 0; // End of post - yes | no
188
-
189
- }
190
- // Position 9 Ad after Image
191
- $imageActive = isset($quads_options['pos9']['Img1Ads']) ? $quads_options['pos9']['Img1Ads'] : false;
192
- $imageAdNo = isset($quads_options['pos9']['Img1Rnd']) ? $quads_options['pos9']['Img1Rnd'] : false;
193
- $imageNo = isset($quads_options['pos9']['Img1Nup']) ? $quads_options['pos9']['Img1Nup'] : false;
194
- $imageCaption = isset($quads_options['pos9']['Img1Con']) ? $quads_options['pos9']['Img1Con'] : false;
195
-
196
 
197
- if ( $begn2 == 0 ) { $b1 = $cusrnd; } else { $b1 = $cusads.$begn2; array_push($AdsIdCus, $begn2); };
198
- if ( $more2 == 0 ) { $r1 = $cusrnd; } else { $r1 = $cusads.$more2; array_push($AdsIdCus, $more2); };
199
- if ( $midd2 == 0 ) { $m1 = $cusrnd; } else { $m1 = $cusads.$midd2; array_push($AdsIdCus, $midd2); };
200
- if ( $lapa2 == 0 ) { $g1 = $cusrnd; } else { $g1 = $cusads.$lapa2; array_push($AdsIdCus, $lapa2); };
201
- if ( $endi2 == 0 ) { $b2 = $cusrnd; } else { $b2 = $cusads.$endi2; array_push($AdsIdCus, $endi2); };
202
-
203
- for($i=1;$i<=$number;$i++) {
204
- if ( $paragraph['id'][$i] == 0 ) {
205
- $paragraph[$i] = $cusrnd;
206
- } else {
207
- $paragraph[$i] = $cusads.$paragraph['id'][$i];
208
- array_push($AdsIdCus, $paragraph['id'][$i]);
209
-
210
- };
211
- }
212
-
213
- // Create the arguments for filter quads_filter_paragraphs
214
- $quads_args = array (
215
- 'paragraph' => $paragraph,
216
- 'cusads' => $cusads,
217
- 'cusrnd' => $cusrnd,
218
- 'AdsIdCus' => $AdsIdCus,
219
 
220
- );
 
 
 
 
221
 
222
- // Execute filter to add more paragraph ad spots
223
- $quads_filtered = apply_filters('quads_filter_paragraphs', $quads_args);
224
-
225
- // The filtered arguments
226
- $paragraph = $quads_filtered['paragraph'];
227
-
228
- // filtered list of ad spots
229
- $AdsIdCus = $quads_filtered['AdsIdCus'];
230
-
231
- // Create paragraph ads
232
- $number = 6;
233
- //$number = 3;
234
- for($i=$number;$i>=1;$i--) {
235
- if ( !empty($paragraph['status'][$i]) ){
236
-
237
- $sch = "</p>";
238
- $content = str_replace("</P>", $sch, $content);
239
- // paragraphs in content
240
- $paragraphsArray = explode($sch, $content);
241
- if ( (int)$paragraph['position'][$i] < count($paragraphsArray) ) {
242
- $content = implode($sch, array_slice($paragraphsArray, 0, $paragraph['position'][$i])).$sch .'<!--'.$paragraph[$i].'-->'. implode($sch, array_slice($paragraphsArray, $paragraph['position'][$i]));
243
- } elseif ($paragraph['end_post'][$i]) {
244
- $content = implode($sch, $paragraphsArray).'<!--'.$paragraph[$i].'-->';
245
- }
246
- }
247
- }
248
 
249
- // Check if image ad is random one
250
- if ( $imageAdNo == 0 ) {
251
- $imageAd = $cusrnd;
252
- } else {
253
- $imageAd = $cusads.$imageAdNo;
254
- array_push($AdsIdCus, $imageAdNo);
255
- };
256
-
257
- // Check if image ad is middle one
258
- if( $midd1 && strpos($content,'<!--OffMiddle-->')===false) {
259
- if( substr_count(strtolower($content), '</p>')>=2 ) {
260
- $sch = "</p>";
261
- $content = str_replace("</P>", $sch, $content);
262
- $paragraphsArray = explode($sch, $content);
263
- $nn = 0; $mm = strlen($content)/2;
264
- for($i=0;$i<count($paragraphsArray);$i++) {
265
- $nn += strlen($paragraphsArray[$i]) + 4;
266
- if($nn>$mm) {
267
- if( ($mm - ($nn - strlen($paragraphsArray[$i]))) > ($nn - $mm) && $i+1<count($paragraphsArray) ) {
268
- $paragraphsArray[$i+1] = '<!--'.$m1.'-->'.$paragraphsArray[$i+1];
269
- } else {
270
- $paragraphsArray[$i] = '<!--'.$m1.'-->'.$paragraphsArray[$i];
271
- }
272
- break;
273
- }
274
- }
275
- $content = implode($sch, $paragraphsArray);
276
- }
277
- }
278
-
279
- // Check if image ad is "More Tag" one
280
- if( $more1 && strpos($content,'<!--OffAfMore-->')===false) {
281
- $mmr = '<!--'.$r1.'-->';
282
- $postid = get_the_ID();
283
- $content = str_replace('<span id="more-'.$postid.'"></span>', $mmr, $content);
284
- }
285
-
286
- if( $begn1 && strpos($content,'<!--OffBegin-->')===false) {
287
- $content = '<!--'.$b1.'-->'.$content;
288
- }
289
- if( $endi1 && strpos($content,'<!--OffEnd-->')===false) {
290
- $content = $content.'<!--'.$b2.'-->';
291
- }
292
- if( $lapa1 && strpos($content,'<!--OffBfLastPara-->')===false){
293
- $sch = "<p>";
294
- $content = str_replace("<P>", $sch, $content);
295
- $paragraphsArray = explode($sch, $content);
296
- if ( count($paragraphsArray) > 2 ) {
297
- $content = implode($sch, array_slice($paragraphsArray, 0, count($paragraphsArray)-1)) .'<!--'.$g1.'-->'. $sch. $paragraphsArray[count($paragraphsArray)-1];
298
- }
299
- }
300
 
301
- if ( $imageActive ){
302
-
303
- // Sanitation
304
- $imgtag = "<img";
305
- $delimiter = ">";
306
- $caption = "[/caption]";
307
- $atag = "</a>";
308
- $content = str_replace("<IMG", $imgtag, $content);
309
- $content = str_replace("</A>", $atag, $content);
310
-
311
- // Start
312
- $paragraphsArray = explode($imgtag, $content);
313
- if ( (int)$imageNo < count($paragraphsArray) ) {
314
- $paragraphsArrayImages = explode($delimiter, $paragraphsArray[$imageNo]);
315
- if ( count($paragraphsArrayImages) > 1 ) {
316
- $tss = explode($caption, $paragraphsArray[$imageNo]);
317
- $ccp = ( count($tss) > 1 ) ? strpos(strtolower($tss[0]),'[caption ')===false : false ;
318
- $paragraphsArrayAtag = explode($atag, $paragraphsArray[$imageNo]);
319
- $cdu = ( count($paragraphsArrayAtag) > 1 ) ? strpos(strtolower($paragraphsArrayAtag[0]),'<a href')===false : false ;
320
- if ( $imageCaption && $ccp ) {
321
- $paragraphsArray[$imageNo] = implode($caption, array_slice($tss, 0, 1)).$caption. "\r\n".'<!--'.$imageAd.'-->'."\r\n". implode($caption, array_slice($tss, 1));
322
- }else if ( $cdu ) {
323
- $paragraphsArray[$imageNo] = implode($atag, array_slice($paragraphsArrayAtag, 0, 1)).$atag. "\r\n".'<!--'.$imageAd.'-->'."\r\n". implode($atag, array_slice($paragraphsArrayAtag, 1));
324
- }else{
325
- $paragraphsArray[$imageNo] = implode($delimiter, array_slice($paragraphsArrayImages, 0, 1)).$delimiter. "\r\n".'<!--'.$imageAd.'-->'."\r\n". implode($delimiter, array_slice($paragraphsArrayImages, 1));
326
- }
327
- }
328
- $content = implode($imgtag, $paragraphsArray);
329
- }
330
- }
331
- } // end disabled default positioned ads
332
-
333
- /*
334
- * Tidy up content
335
- */
336
- $content = '<!--EmptyClear-->'.$content."\n".'<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>';
337
- $content = quads_clean_tags($content, true);
338
-
339
-
340
- /*
341
- * Replace Beginning/Middle/End/Paragraph Ads1-10
342
- */
343
-
344
- if( !$off_default_ads ) { // disabled default ads
345
- for( $i=1; $i<=count($AdsIdCus); $i++ ) {
346
-
347
- if( strpos($content,'<!--'.$cusads.$AdsIdCus[$i-1].'-->')!==false && in_array($AdsIdCus[$i-1], $AdsId)) {
348
-
349
- $content = quads_replace_ads( $content, $cusads.$AdsIdCus[$i-1], $AdsIdCus[$i-1] );
350
- // Comment this to allow the use of the same ad on several ad spots
351
- //$AdsId = quads_del_element($AdsId, array_search($AdsIdCus[$i-1], $AdsId)) ;
352
- $visibleContentAds += 1;
353
-
354
- quads_set_ad_count_content();
355
- if ( quads_ad_reach_max_count() ){
356
- $content = quads_clean_tags($content);
357
- }
358
- }
359
- }
360
  }
361
-
362
- /**
363
- * Replace Quicktags Ads1 to Ads10
364
- **/
365
-
366
- $tcn = count($AdsId); $tt = 0;
367
- for( $i=1; $i<=$tcn; $i++ ) {
368
- if( strpos($content, '<!--Ads'.$AdsId[$tt].'-->')!==false ) {
369
- $content = quads_replace_ads( $content, 'Ads'.$AdsId[$tt], $AdsId[$tt] );
370
- $AdsId = quads_del_element($AdsId, $tt) ;
371
- $visibleContentAds += 1;
372
- quads_set_ad_count_content();
373
- if (quads_ad_reach_max_count()){
374
- $content = quads_clean_tags($content);
375
- return $content;
376
- }
377
-
378
- } else {
379
- $tt += 1;
380
- }
381
- }
382
-
383
-
384
-
385
- /* ... Replace Beginning/Middle/End random Ads ... */
386
- if( !$off_default_ads ) {
387
- if( strpos($content, '<!--'.$cusrnd.'-->')!==false && is_singular() ) {
388
- $tcx = count($AdsId);
389
- $tcy = substr_count($content, '<!--'.$cusrnd.'-->');
390
-
391
- for( $i=$tcx; $i<=$tcy-1; $i++ ) {
392
- array_push($AdsId, -1);
393
- }
394
- shuffle($AdsId);
395
- for( $i=1; $i<=$tcy; $i++ ) {
396
- $content = quads_replace_ads( $content, $cusrnd, $AdsId[0] );
397
- $AdsId = quads_del_element($AdsId, 0) ;
398
- $visibleContentAds += 1;
399
- quads_set_ad_count_content();
400
- if (quads_ad_reach_max_count()){
401
- $content = quads_clean_tags($content);
402
- return $content;
403
- }
404