AdSense Plugin WP QUADS - Version 1.7.4

Version Description

  • New: Option to explicetely allow wp quads to create the ads.txt
  • Fix: Invalid arguments and several thrown errors when no ads are defined
  • Fix: Can not use vi if wordpress is installed in sub directory
Download this release

Release Info

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

Code changes from version 1.7.3 to 1.7.4

includes/admin/admin-actions.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Admin Actions
4
  *
@@ -8,9 +9,9 @@
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
  /**
16
  * Processes all QUADS actions sent via POST and GET by looking for the 'quads-action'
@@ -20,23 +21,25 @@ if ( ! defined( 'ABSPATH' ) ) exit;
20
  * @return void
21
  */
22
  function quads_process_actions() {
23
- if ( isset( $_POST['quads-action'] ) ) {
24
- do_action( 'quads_' . $_POST['quads-action'], $_POST );
25
- }
26
 
27
- if ( isset( $_GET['quads-action'] ) ) {
28
- do_action( 'quads_' . $_GET['quads-action'], $_GET );
29
- }
30
  }
31
- add_action( 'admin_init', 'quads_process_actions' );
 
32
 
33
  /**
34
  * Update option quads_show_theme_notice
35
  * "no" means no further upgrade notices are shown
36
  */
37
- function quads_close_upgrade_notice(){
38
- update_option ('quads_show_theme_notice', 'no');
39
  }
 
40
  add_action('quads_close_upgrade_notice', 'quads_close_upgrade_notice');
41
 
42
 
@@ -52,80 +55,88 @@ add_action('quads_close_upgrade_notice', 'quads_close_upgrade_notice');
52
  /**
53
  * Close vi welcome notice and do not show again
54
  */
55
- function quads_close_vi_welcome_notice(){
56
- update_option ('quads_close_vi_welcome_notice', 'yes');
57
  }
 
58
  add_action('quads_close_vi_welcome_notice', 'quads_close_vi_welcome_notice');
59
 
60
  /**
61
  * Close vi update notice and show it one week later again
62
  */
63
- function quads_show_vi_notice_later(){
64
  $nextweek = time() + (7 * 24 * 60 * 60);
65
- $human_date = date( 'Y-m-d h:i:s', $nextweek );
66
- update_option( 'quads_show_vi_notice_later', $human_date );
67
- update_option( 'quads_close_vi_notice', 'yes' );
68
-
69
  }
 
70
  add_action('quads_show_vi_notice_later', 'quads_show_vi_notice_later');
71
 
72
  /**
73
  * Save vi token
74
  */
75
- function quads_save_vi_token(){
76
- global $quads_options;
77
 
78
- if (empty($_POST['token'])){
79
- echo json_encode( array("status" => "failed") );
80
  wp_die();
81
  }
82
-
83
  // Save token before trying to create ads.txt
84
  update_option('quads_vi_token', $_POST['token']);
85
-
 
 
 
 
 
 
 
 
86
  $vi = new wpquads\vi();
87
-
88
- if($vi->createAdsTxt()){
89
- set_transient('quads_vi_ads_txt_notice', true, 300);
90
- delete_transient('quads_vi_ads_txt_error');
91
  } else {
92
- set_transient('quads_vi_ads_txt_error', true, 300);
93
- delete_transient('quads_vi_ads_txt_notice');
94
  }
95
-
96
-
97
  // Create AdSense ads.txt entries
98
  $adsense = new \wpquads\adsense($quads_options);
99
  $adsense->writeAdsTxt();
100
-
101
  //sleep(5);
102
- echo json_encode( array("status" => "success", "token" => $_POST['token']) );
103
  wp_die();
104
  }
105
- add_action( 'wp_ajax_quads_save_vi_token', 'quads_save_vi_token' );
 
106
 
107
  /**
108
  * Save vi ad settings and create ad code
109
  */
110
- function quads_save_vi_ads(){
111
  global $quads;
112
-
113
  $return = $quads->vi->setAdCode();
114
-
115
- if ($return){
116
  wp_die($return);
117
  } else {
118
  wp_die(array('status' => 'error', 'message' => 'Unknown API Error. Can not get vi ad code'));
119
  }
120
  }
121
- add_action( 'wp_ajax_quads_save_vi_ads', 'quads_save_vi_ads' );
122
-
123
-
124
 
125
  /**
126
  * Logout of vi
127
  */
128
- function quads_logout_vi(){
129
  delete_option('quads_vi_token');
130
  }
131
  add_action('quads_logout_vi', 'quads_logout_vi');
@@ -133,7 +144,7 @@ add_action('quads_logout_vi', 'quads_logout_vi');
133
  /**
134
  * Hide ads txt information notice
135
  */
136
- function quads_close_ads_txt_notice(){
137
  delete_transient('quads_ads_txt_notice');
138
  }
139
  add_action('quads_close_ads_txt_notice', 'quads_close_ads_txt_notice');
@@ -141,7 +152,7 @@ add_action('quads_close_ads_txt_notice', 'quads_close_ads_txt_notice');
141
  /**
142
  * Hide ads txt error notice
143
  */
144
- function quads_close_ads_txt_error(){
145
  delete_transient('quads_ads_txt_error');
146
  }
147
  add_action('quads_close_ads_txt_error', 'quads_close_ads_txt_error');
1
  <?php
2
+
3
  /**
4
  * Admin Actions
5
  *
9
  * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
  * @since 1.0
11
  */
 
12
  // Exit if accessed directly
13
+ if (!defined('ABSPATH'))
14
+ exit;
15
 
16
  /**
17
  * Processes all QUADS actions sent via POST and GET by looking for the 'quads-action'
21
  * @return void
22
  */
23
  function quads_process_actions() {
24
+ if (isset($_POST['quads-action'])) {
25
+ do_action('quads_' . $_POST['quads-action'], $_POST);
26
+ }
27
 
28
+ if (isset($_GET['quads-action'])) {
29
+ do_action('quads_' . $_GET['quads-action'], $_GET);
30
+ }
31
  }
32
+
33
+ add_action('admin_init', 'quads_process_actions');
34
 
35
  /**
36
  * Update option quads_show_theme_notice
37
  * "no" means no further upgrade notices are shown
38
  */
39
+ function quads_close_upgrade_notice() {
40
+ update_option('quads_show_theme_notice', 'no');
41
  }
42
+
43
  add_action('quads_close_upgrade_notice', 'quads_close_upgrade_notice');
44
 
45
 
55
  /**
56
  * Close vi welcome notice and do not show again
57
  */
58
+ function quads_close_vi_welcome_notice() {
59
+ update_option('quads_close_vi_welcome_notice', 'yes');
60
  }
61
+
62
  add_action('quads_close_vi_welcome_notice', 'quads_close_vi_welcome_notice');
63
 
64
  /**
65
  * Close vi update notice and show it one week later again
66
  */
67
+ function quads_show_vi_notice_later() {
68
  $nextweek = time() + (7 * 24 * 60 * 60);
69
+ $human_date = date('Y-m-d h:i:s', $nextweek);
70
+ update_option('quads_show_vi_notice_later', $human_date);
71
+ update_option('quads_close_vi_notice', 'yes');
 
72
  }
73
+
74
  add_action('quads_show_vi_notice_later', 'quads_show_vi_notice_later');
75
 
76
  /**
77
  * Save vi token
78
  */
79
+ function quads_save_vi_token() {
80
+ global $quads_options;
81
 
82
+ if (empty($_POST['token'])) {
83
+ echo json_encode(array("status" => "failed"));
84
  wp_die();
85
  }
86
+
87
  // Save token before trying to create ads.txt
88
  update_option('quads_vi_token', $_POST['token']);
89
+
90
+ if (!isset($quads_options['adsTxtEnabled'])) {
91
+ set_transient('quads_vi_ads_txt_disabled', true, 300);
92
+ delete_transient('quads_vi_ads_txt_error');
93
+ delete_transient('quads_vi_ads_txt_notice');
94
+ echo json_encode(array("status" => "success", "token" => $_POST['token'], "adsTxt" => 'disabled'));
95
+ wp_die();
96
+ }
97
+
98
  $vi = new wpquads\vi();
99
+
100
+ if ($vi->createAdsTxt()) {
101
+ set_transient('quads_vi_ads_txt_notice', true, 300);
102
+ delete_transient('quads_vi_ads_txt_error');
103
  } else {
104
+ set_transient('quads_vi_ads_txt_error', true, 300);
105
+ delete_transient('quads_vi_ads_txt_notice');
106
  }
107
+
108
+
109
  // Create AdSense ads.txt entries
110
  $adsense = new \wpquads\adsense($quads_options);
111
  $adsense->writeAdsTxt();
112
+
113
  //sleep(5);
114
+ echo json_encode(array("status" => "success", "token" => $_POST['token']));
115
  wp_die();
116
  }
117
+
118
+ add_action('wp_ajax_quads_save_vi_token', 'quads_save_vi_token');
119
 
120
  /**
121
  * Save vi ad settings and create ad code
122
  */
123
+ function quads_save_vi_ads() {
124
  global $quads;
125
+
126
  $return = $quads->vi->setAdCode();
127
+
128
+ if ($return) {
129
  wp_die($return);
130
  } else {
131
  wp_die(array('status' => 'error', 'message' => 'Unknown API Error. Can not get vi ad code'));
132
  }
133
  }
134
+ add_action('wp_ajax_quads_save_vi_ads', 'quads_save_vi_ads');
 
 
135
 
136
  /**
137
  * Logout of vi
138
  */
139
+ function quads_logout_vi() {
140
  delete_option('quads_vi_token');
141
  }
142
  add_action('quads_logout_vi', 'quads_logout_vi');
144
  /**
145
  * Hide ads txt information notice
146
  */
147
+ function quads_close_ads_txt_notice() {
148
  delete_transient('quads_ads_txt_notice');
149
  }
150
  add_action('quads_close_ads_txt_notice', 'quads_close_ads_txt_notice');
152
  /**
153
  * Hide ads txt error notice
154
  */
155
+ function quads_close_ads_txt_error() {
156
  delete_transient('quads_ads_txt_error');
157
  }
158
  add_action('quads_close_ads_txt_error', 'quads_close_ads_txt_error');
includes/admin/admin-notices.php CHANGED
@@ -9,7 +9,7 @@
9
  * @since 1.0.9
10
  */
11
  // Exit if accessed directly
12
- if( !defined( 'ABSPATH' ) )
13
  exit;
14
 
15
  /**
@@ -22,57 +22,56 @@ if( !defined( 'ABSPATH' ) )
22
  function quads_admin_messages() {
23
  global $quads_options;
24
 
25
- if( !current_user_can( 'update_plugins' ) || quads_is_addon_page() ) {
26
  return;
27
  }
28
 
29
  quads_theme_notice();
30
 
31
  quads_update_notice();
32
-
33
  quads_update_notice_v2();
34
-
35
  quads_update_notice_1_5_3();
36
-
37
  quads_show_vi_api_error();
38
 
39
 
40
  echo quads_get_vi_notice();
41
-
42
  echo quads_show_vi_notices();
43
-
44
  quads_show_ads_txt_notice();
45
-
46
 
47
- if( quads_is_admin_page() ) {
48
- echo '<div class="notice notice-error" id="wpquads-adblock-notice" style="display:none;">' . sprintf( __( '<strong><p>You need to deactivate your ad blocker to use WP QUADS settings.</strong> Your ad blocker browser extension is removing WP QUADS css ressources and is breaking the settings screen! Deactivating the ad blocker will resolve it. WP QUADS is used on 60.000 websites and is into focus of the big adblocking companies. That\'s the downside of our success but nothing you need to worry about.</p>', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header' ) . '</div>';
 
49
  }
50
-
51
  // if( !quads_is_any_ad_activated() && quads_is_admin_page() ) {
52
  // 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>';
53
  // }
54
-
55
  // if( quads_get_active_ads() === 0 && quads_is_admin_page() ) {
56
  // 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>';
57
  // }
58
 
59
- if( !quads_is_post_type_activated() && quads_is_admin_page() ) {
60
- echo '<div class="notice notice-warning">' . sprintf( __( '<strong>No ads are shown - No post type chosen!</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>';
61
  }
62
 
63
- 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 ) {
64
- 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>';
65
  }
66
 
67
 
68
- $install_date = get_option( 'quads_install_date' );
69
- $display_date = date( 'Y-m-d h:i:s' );
70
- $datetime1 = new DateTime( $install_date );
71
- $datetime2 = new DateTime( $display_date );
72
- $diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
73
 
74
- $rate = get_option( 'quads_rating_div', false);
75
- if( $diff_intrval >= 7 && ($rate === "no" || false === $rate || quads_rate_again() ) ) {
76
  echo '<div class="quads_fivestar updated " style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);background-color:white;">
77
  <p>Awesome, you\'ve been using <strong>WP QUADS</strong> for more than 1 week. <br> May i ask you to give it a <strong>5-star rating</strong> on Wordpress? </br>
78
  This will help to spread its popularity and to make this plugin a better one.
@@ -95,7 +94,7 @@ function quads_admin_messages() {
95
  var data={\'action\':\'quads_hide_rating\'}
96
  jQuery.ajax({
97
 
98
- url: "' . admin_url( 'admin-ajax.php' ) . '",
99
  type: "post",
100
  data: data,
101
  dataType: "json",
@@ -115,7 +114,7 @@ function quads_admin_messages() {
115
  var data={\'action\':\'quads_hide_rating_week\'}
116
  jQuery.ajax({
117
 
118
- url: "' . admin_url( 'admin-ajax.php' ) . '",
119
  type: "post",
120
  data: data,
121
  dataType: "json",
@@ -136,7 +135,7 @@ function quads_admin_messages() {
136
  }
137
  }
138
 
139
- add_action( 'admin_notices', 'quads_admin_messages' );
140
 
141
 
142
  /* Hide the rating div
@@ -151,26 +150,27 @@ add_action( 'admin_notices', 'quads_admin_messages' );
151
  */
152
 
153
  function quads_hide_rating_div() {
154
- update_option( 'quads_rating_div', 'yes' );
155
- delete_option( 'quads_date_next_notice' );
156
- echo json_encode( array("success") );
157
  exit;
158
  }
159
- add_action( 'wp_ajax_quads_hide_rating', 'quads_hide_rating_div' );
 
160
 
161
  /**
162
  * Write the timestamp when rating notice will be opened again
163
  */
164
  function quads_hide_rating_notice_week() {
165
  $nextweek = time() + (7 * 24 * 60 * 60);
166
- $human_date = date( 'Y-m-d h:i:s', $nextweek );
167
- update_option( 'quads_date_next_notice', $human_date );
168
- update_option( 'quads_rating_div', 'yes' );
169
- echo json_encode( array("success") );
170
  exit;
171
  }
172
 
173
- add_action( 'wp_ajax_quads_hide_rating_week', 'quads_hide_rating_notice_week' );
174
 
175
  /**
176
  * Check if admin notice will open again after one week of closing
@@ -178,18 +178,18 @@ add_action( 'wp_ajax_quads_hide_rating_week', 'quads_hide_rating_notice_week' );
178
  */
179
  function quads_rate_again() {
180
 
181
- $rate_again_date = get_option( 'quads_date_next_notice' );
182
 
183
- if( false === $rate_again_date ) {
184
  return false;
185
  }
186
 
187
- $current_date = date( 'Y-m-d h:i:s' );
188
- $datetime1 = new DateTime( $rate_again_date );
189
- $datetime2 = new DateTime( $current_date );
190
- $diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
191
 
192
- if( $diff_intrval >= 0 ) {
193
  return true;
194
  }
195
  }
@@ -201,17 +201,17 @@ function quads_rate_again() {
201
  * @not used
202
  */
203
  function quads_plugin_deactivated_notice() {
204
- if( false !== ( $deactivated_notice_id = get_transient( 'quads_deactivated_notice_id' ) ) ) {
205
- if( '1' === $deactivated_notice_id ) {
206
- $message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS.", 'wpstg' );
207
  } else {
208
- $message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS Pro.", 'wpstg' );
209
  }
210
  ?>
211
  <div class="updated notice is-dismissible" style="border-left: 4px solid #ffba00;">
212
- <p><?php echo esc_html( $message ); ?></p>
213
  </div> <?php
214
- delete_transient( 'quads_deactivated_notice_id' );
215
  }
216
  }
217
 
@@ -222,10 +222,10 @@ function quads_plugin_deactivated_notice() {
222
  */
223
  function quads_theme_notice() {
224
 
225
- $show_notice = get_option( 'quads_show_theme_notice' );
226
 
227
- if( false !== $show_notice && 'no' !== $show_notice && quads_is_commercial_theme() ) {
228
- $message = __( '<strong>Extend the' . quads_is_commercial_theme() . '</strong> theme with <strong>WP QUADS PRO!</strong><br>Save time and earn more - Bring your AdSense earnings to next level. <a href="http://wpquads.com?utm_campaign=adminnotice&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank"> Purchase Now</a> or <a href="http://wpquads.com?utm_campaign=free_plugin&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank">Get Details</a> <p> <a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_upgrade_notice" class="button">Close Notice</a>', 'quick-adsense-reloaded' );
229
  ?>
230
  <div class="updated notice" style="border-left: 4px solid #ffba00;">
231
  <p><?php echo $message; ?></p>
@@ -240,15 +240,15 @@ function quads_theme_notice() {
240
  */
241
  function quads_update_notice() {
242
 
243
- $show_notice = get_option( 'quads_show_update_notice' );
244
 
245
  // do not do anything
246
- if( false !== $show_notice ) {
247
  return false;
248
  }
249
 
250
- if( (version_compare( QUADS_VERSION, '1.3.9', '>=' ) ) && quads_is_pro_active() && (version_compare( QUADS_PRO_VERSION, '1.3.0', '<' ) ) ) {
251
- $message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Update WP QUADS PRO to get custom post type support from <a href="%s">General Settings</a>.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings' );
252
  $message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
253
  ?>
254
  <div class="updated notice" style="border-left: 4px solid #ffba00;">
@@ -256,8 +256,8 @@ function quads_update_notice() {
256
  </div> <?php
257
  //update_option ('quads_show_update_notice', 'no');
258
  } else
259
- if( !quads_is_extra() ) {
260
- $message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Install <a href="%1s" target="_blank">WP QUADS PRO</a> to get custom post type support in <a href="%2s">General Settings</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com?utm_campaign=admin_notice&utm_source=admin_notice&utm_medium=admin&utm_content=custom_post_type', admin_url() . 'admin.php?page=quads-settings' );
261
  $message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
262
  ?>
263
  <div class="updated notice" style="border-left: 4px solid #ffba00;">
@@ -271,10 +271,10 @@ function quads_update_notice() {
271
  * Show upgrade notice if wp quads pro is lower than 1.3.6
272
  * @return boolean
273
  */
274
- function quads_update_notice_v2(){
275
 
276
- if( quads_is_pro_active() && (version_compare( QUADS_PRO_VERSION, '1.3.6', '<' ) ) && quads_is_admin_page() ) {
277
- $message = sprintf( __( 'You need to update <strong>WP QUADS PRO to version 1.3.6</strong> or higher. Your version of <strong>WP QUADS Pro</strong> is '.QUADS_PRO_VERSION. '.<br>WP QUADS Pro '.QUADS_PRO_VERSION.' supports unlimited amount of ads. <br>Updating requires a valid <a href="%s" target="_new">license key</a>.', 'quick-adsense-reloaded' ), 'https://wpquads.com/#buy-wpquads?utm_source=plugin_notice&utm_medium=admin&utm_campaign=activate_license' );
278
  ?>
279
  <div class="notice notice-error">
280
  <p><?php echo $message; ?></p>
@@ -286,48 +286,47 @@ function quads_update_notice_v2(){
286
  * Show upgrade notice after updating from 1.5.2 to 1.5.3 and higher
287
  * @return boolean
288
  */
289
- function quads_update_notice_1_5_3(){
290
 
291
  // do not show anything
292
- if( false !== get_option( 'quads_hide_update_notice_1_5_3' )) {
293
  return false;
294
  }
295
-
296
  $previous_version = get_option('quads_version_upgraded_from');
297
-
298
- //wp_die(QUADS_VERSION);
299
 
 
300
  // Show update message if previous version was lower than 1.7 - This makes sure that the message is shown for future updates without complicated version number conditions
301
- if( !empty($previous_version) && version_compare( QUADS_VERSION, '1.7.0', '<=' ) ) {
302
 
303
- $message = sprintf( __( 'This is a huge update! The data structure of WP QUADS has been modified and improved for better performance and great new features. <br> For the case you\'d experience issues, we made a <a href="%1s" target="_self">backup of previous WP QUADS data</a>. So you can <a href="%2s" target="_new">switch back to the previous version</a> anytime. <br><br>Please <a href="%3s" target="_new">open first a support ticket</a> if you experience any issue.', 'quick-adsense-reloaded' ), admin_url() . '?page=quads-settings&tab=help', 'https://wpquads.com/docs/install-older-plugin-version/?utm_source=plugin_notice&utm_medium=admin&utm_campaign=install_older_version', 'https://wordpress.org/support/plugin/quick-adsense-reloaded' );
304
  ?>
305
  <div class="notice notice-error">
306
  <p><?php echo $message; ?></p>
307
  <?php
308
- echo '<p><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice_1_5_3" class="button-primary" target="_self" title="Close Notice" style="font-weight:bold;">' . __('Close Notice','quick-adsense-reloaded') . '</a>';
309
  ?>
310
  </div> <?php
311
  }
312
  }
313
 
314
-
315
  /**
316
  * Hide Notice and update db option quads_hide_notice
317
  */
318
  function quads_hide_notice() {
319
- update_option( 'quads_show_update_notice', 'no' );
320
  }
321
 
322
- add_action( 'quads_hide_update_notice', 'quads_hide_notice', 10 );
323
 
324
  /**
325
  * Set option to hide admin notice 1.5.3
326
  * @return boolean
327
  */
328
- function quads_hide_notice_1_5_3(){
329
- update_option('quads_hide_update_notice_1_5_3', '1');
330
  }
 
331
  add_action('quads_hide_update_notice_1_5_3', 'quads_hide_notice_1_5_3');
332
 
333
  /**
@@ -341,28 +340,28 @@ function quads_is_any_ad_activated() {
341
 
342
  // Check if custom positions location_settings is empty or does not exists
343
  $check = array();
344
- if( isset( $quads_options['location_settings'] ) ) {
345
- foreach ( $quads_options['location_settings'] as $location_array ) {
346
- if( isset( $location_array['status'] ) ) {
347
  $check[] = $location_array['status'];
348
  }
349
  }
350
  }
351
-
352
  // ad activated with api (custom position)
353
- if( count( $check ) > 0 ) {
354
  return true;
355
  }
356
  // check if any other ad is assigned and activated
357
- if( isset( $quads_options['pos1']['BegnAds'] ) ||
358
- isset( $quads_options['pos2']['MiddAds'] ) ||
359
- isset( $quads_options['pos3']['EndiAds'] ) ||
360
- isset( $quads_options['pos4']['MoreAds'] ) ||
361
- isset( $quads_options['pos5']['LapaAds'] ) ||
362
- isset( $quads_options['pos6']['Par1Ads'] ) ||
363
- isset( $quads_options['pos7']['Par2Ads'] ) ||
364
- isset( $quads_options['pos8']['Par3Ads'] ) ||
365
- isset( $quads_options['pos9']['Img1Ads'] )
366
  ) {
367
  return true;
368
  }
@@ -379,7 +378,7 @@ function quads_is_any_ad_activated() {
379
  function quads_is_post_type_activated() {
380
  global $quads_options;
381
 
382
- if( empty( $quads_options['post_types'] ) ) {
383
  return false;
384
  }
385
  return true;
@@ -396,12 +395,12 @@ function quads_ads_empty() {
396
 
397
  $check = array();
398
 
399
- for ( $i = 1; $i <= 10; $i++ ) {
400
- if( !empty( $quads_options['ads']['ad' . $i]['code'] ) ) {
401
  $check[] = 'true';
402
  }
403
  }
404
- if( count( $check ) === 0 ) {
405
  return true;
406
  }
407
  return false;
@@ -436,59 +435,53 @@ function quads_ads_empty() {
436
  */
437
  function quads_get_vi_notice() {
438
  global $quads;
439
-
440
- if (false !== get_option ('quads_close_vi_welcome_notice') ) {
441
  return false;
442
  }
443
-
444
  $mail = get_option('admin_email');
445
  $domain = $quads->vi->getDomain();
446
-
447
 
448
  $white = '<div class="quads-banner-wrapper">
449
  <section class="quads-banner-content">
450
  <div class="quads-banner-columns">
451
- <main class="quads-banner-main"><p>' .
452
  sprintf(
453
- __('This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
454
  content and video advertising.<br>
455
  To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
456
- <p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaed'),
457
- 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain='.$domain.'&email='.$mail.'&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white',
458
- admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header',
459
- 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white'
460
- )
461
  . '</p></main>
462
  <!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
463
  <aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-white.png" width="168" height="72"></a></p></aside>
464
  </div>
465
- <aside class="quads-banner-close"><div style="margin-top:5px;"><a href="'.admin_url().'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
466
  </section>
467
  </div>';
468
-
469
-
470
  $black = '<div class="quads-banner-wrapper" style="background-color:black;">
471
  <section class="quads-banner-content">
472
  <div class="quads-banner-columns">
473
- <main class="quads-banner-main" style="color:white;"><p>' .
474
  sprintf(
475
- __('This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
476
  content and video advertising.<br>
477
  To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
478
- <p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaded'),
479
- 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain='.$domain.'&email='.$mail.'&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black',
480
- admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header',
481
- 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black'
482
- )
483
  . '</p></main>
484
  <!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
485
  <aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-black.png" width="168" height="72"></a></p></aside>
486
  </div>
487
- <aside class="quads-banner-close"><div style="margin-top:5px;"><a href="'.admin_url().'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
488
  </section>
489
  </div>';
490
 
491
- $variant = get_option('quads_vi_variant');
492
 
493
  switch ($variant) {
494
  case 'a':
@@ -509,18 +502,18 @@ $variant = get_option('quads_vi_variant');
509
  */
510
  function quads_show_vi_notice_again() {
511
 
512
- $show_again_date = get_option( 'quads_show_vi_notice_later' );
513
 
514
- if( false === $show_again_date ) {
515
  return false;
516
  }
517
 
518
- $current_date = date( 'Y-m-d h:i:s' );
519
- $datetime1 = new DateTime( $show_again_date );
520
- $datetime2 = new DateTime( $current_date );
521
- $diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
522
 
523
- if( $diff_intrval >= 0 ) {
524
  return true;
525
  }
526
  }
@@ -528,122 +521,147 @@ function quads_show_vi_notice_again() {
528
  /**
529
  * Show all vi notices
530
  */
531
- function quads_show_vi_notices(){
532
  global $quads, $quads_options;
533
-
534
- if (!quads_is_admin_page())
535
  return false;
536
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  // show ad.txt update notice
538
  if (get_transient('quads_vi_ads_txt_notice')) {
539
  $notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated your ads.txt '
540
- . 'file with lines that declare video inteligence as a legitmate seller of your inventory and enables you to make more money through video inteligence. <a href="https://www.vi.ai/publisher-video-monetization/?utm_source=WordPress&utm_medium=Plugin%20blurb&utm_campaign=wpquads" target="blank" rel="external nofollow">FAQ</a>';
541
  $notice['type'] = 'update-nag';
542
  $adsUpdated = new wpquads\template('/includes/vendor/vi/views/notices', $notice);
543
  echo $adsUpdated->render();
544
  }
545
-
546
  // show ad.txt update notice
547
  if (get_transient('quads_vi_ads_txt_error')) {
548
-
549
-
550
- // Check if adsense is used and add the adsense publisherId to ads.txt blurb as well
551
- $adsense = new wpquads\adsense($quads_options);
552
- $adsensePublisherIds = $adsense->getPublisherIds();
553
-
554
- $adsenseAdsTxtText = '';
555
- if (!empty($adsensePublisherIds)){
556
- foreach ($adsensePublisherIds as $adsensePublisherId){
557
- $adsenseAdsTxtText .= "google.com, " . $adsensePublisherId . ", DIRECT, f08c47fec0942fa0\r\n";
558
- }
559
- }
560
-
561
  // ads.txt content
562
  $notice['message'] = "<p><strong>ADS.TXT couldn't be added</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <br><strong>" . get_home_path() . "ads.txt</strong>:"
563
- . "<p>"
564
- . "<pre>vi.ai " . $quads->vi->getPublisherId() . " DIRECT # 41b5eef6<br>"
565
- . $adsenseAdsTxtText
566
- . "</pre></p>"
567
- . "Only by doing so you are able to make more money through video inteligence.</p>";
568
  $notice['type'] = 'error';
569
-
570
  // render blurb
571
  $adsTxtError = new wpquads\template('/includes/vendor/vi/views/notices', $notice);
572
  echo $adsTxtError->render();
573
  }
574
-
575
  }
576
 
577
  /**
578
- * Show a ads.txt notices
579
  */
580
- function quads_show_ads_txt_notice(){
581
  global $quads, $quads_options;
582
-
583
  if (!quads_is_admin_page())
584
  return false;
585
-
 
586
  // show ad.txt update notice
587
- if (get_transient('quads_ads_txt_notice')) {
588
- $notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated the file '.ABSPATH .'ads.txt '
589
- . 'file with lines that declare Google.com as a legitmate seller of your inventory and is recommended setting by AdSense.<br><a href="https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/" target="blank" rel="external nofollow">What is ads.txt?</a>';
590
  $notice['type'] = 'update-nag';
591
  $notice['action'] = 'close_ads_txt_notice';
592
  $adsUpdated = new wpquads\template('/includes/admin/views/notices', $notice);
593
  echo $adsUpdated->render();
594
  }
595
-
596
  // show ads.txt error notice
597
- if (get_transient('close_ads_txt_error')) {
598
-
599
  // Check if adsense is used and add the adsense publisherId to ads.txt blurb as well
600
  $adsense = new wpquads\adsense($quads_options);
601
  $adsensePublisherIds = $adsense->getPublisherIds();
602
-
603
-
604
  $adsenseAdsTxtText = '';
605
- if (!empty($adsensePublisherIds)){
606
- foreach ($adsensePublisherIds as $adsensePublisherId){
607
- $adsenseAdsTxtText .= "google.com, " . $adsensePublisherId . ", DIRECT, f08c47fec0942fa0\n\r";
608
  }
609
  }
610
-
611
  $viAdsTxtText = '';
612
  if ($quads->vi->getPublisherId()) {
613
  $viAdsTxtText = $quads->vi->getAdsTxtContent();
614
  }
615
 
616
  // ads.txt content
617
- $notice['message'] = "<p><strong>ADS.TXT couldn't be updated</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <strong>" . get_home_path() . "ads.txt</strong>:"
618
- . "<p>"
619
- . "<pre>".$viAdsTxtText."<br>"
620
- . $adsenseAdsTxtText
621
- . "</pre></p>"
622
- . "Only by doing so AdSense ads are shown on your site.</p>";
623
  $notice['type'] = 'error';
624
  $notice['action'] = 'quads_ads_txt_error';
625
-
626
  // render blurb
627
  $adsTxtError = new wpquads\template('/includes/admin/views/notices', $notice);
628
  echo $adsTxtError->render();
629
  }
630
-
631
  }
632
 
633
- /**
634
- * Show api errors
635
- */
636
- function quads_show_vi_api_error() {
637
- if (!quads_is_admin_page()){
638
- return false;
639
- }
640
 
641
- if (false !== get_option('quads_vi_api_error')) {
642
- $notice['message'] = 'WP QUADS - Can not retrive ad settings from vi API. Error: ' . get_option('quads_vi_api_error');
643
- $notice['type'] = 'error';
644
- $notice['action'] = '';
645
- // render blurb
646
- $blurb = new wpquads\template('/includes/admin/views/notices', $notice);
647
- echo $blurb->render();
648
- }
649
  }
 
9
  * @since 1.0.9
10
  */
11
  // Exit if accessed directly
12
+ if (!defined('ABSPATH'))
13
  exit;
14
 
15
  /**
22
  function quads_admin_messages() {
23
  global $quads_options;
24
 
25
+ if (!current_user_can('update_plugins') || quads_is_addon_page()) {
26
  return;
27
  }
28
 
29
  quads_theme_notice();
30
 
31
  quads_update_notice();
32
+
33
  quads_update_notice_v2();
34
+
35
  quads_update_notice_1_5_3();
36
+
37
  quads_show_vi_api_error();
38
 
39
 
40
  echo quads_get_vi_notice();
41
+
42
  echo quads_show_vi_notices();
43
+
44
  quads_show_ads_txt_notice();
 
45
 
46
+
47
+ if (quads_is_admin_page()) {
48
+ echo '<div class="notice notice-error" id="wpquads-adblock-notice" style="display:none;">' . sprintf(__('<strong><p>You need to deactivate your ad blocker to use WP QUADS settings.</strong> Your ad blocker browser extension is removing WP QUADS css ressources and is breaking the settings screen! Deactivating the ad blocker will resolve it. WP QUADS is used on 60.000 websites and is into focus of the big adblocking companies. That\'s the downside of our success but nothing you need to worry about.</p>', 'quick-adsense-reloaded'), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header') . '</div>';
49
  }
50
+
51
  // if( !quads_is_any_ad_activated() && quads_is_admin_page() ) {
52
  // 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>';
53
  // }
 
54
  // if( quads_get_active_ads() === 0 && quads_is_admin_page() ) {
55
  // 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>';
56
  // }
57
 
58
+ if (!quads_is_post_type_activated() && quads_is_admin_page()) {
59
+ echo '<div class="notice notice-warning">' . sprintf(__('<strong>No ads are shown - No post type chosen!</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>';
60
  }
61
 
62
+ 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) {
63
+ 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>';
64
  }
65
 
66
 
67
+ $install_date = get_option('quads_install_date');
68
+ $display_date = date('Y-m-d h:i:s');
69
+ $datetime1 = new DateTime($install_date);
70
+ $datetime2 = new DateTime($display_date);
71
+ $diff_intrval = round(($datetime2->format('U') - $datetime1->format('U')) / (60 * 60 * 24));
72
 
73
+ $rate = get_option('quads_rating_div', false);
74
+ if ($diff_intrval >= 7 && ($rate === "no" || false === $rate || quads_rate_again() )) {
75
  echo '<div class="quads_fivestar updated " style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);background-color:white;">
76
  <p>Awesome, you\'ve been using <strong>WP QUADS</strong> for more than 1 week. <br> May i ask you to give it a <strong>5-star rating</strong> on Wordpress? </br>
77
  This will help to spread its popularity and to make this plugin a better one.
94
  var data={\'action\':\'quads_hide_rating\'}
95
  jQuery.ajax({
96
 
97
+ url: "' . admin_url('admin-ajax.php') . '",
98
  type: "post",
99
  data: data,
100
  dataType: "json",
114
  var data={\'action\':\'quads_hide_rating_week\'}
115
  jQuery.ajax({
116
 
117
+ url: "' . admin_url('admin-ajax.php') . '",
118
  type: "post",
119
  data: data,
120
  dataType: "json",
135
  }
136
  }
137
 
138
+ add_action('admin_notices', 'quads_admin_messages');
139
 
140
 
141
  /* Hide the rating div
150
  */
151
 
152
  function quads_hide_rating_div() {
153
+ update_option('quads_rating_div', 'yes');
154
+ delete_option('quads_date_next_notice');
155
+ echo json_encode(array("success"));
156
  exit;
157
  }
158
+
159
+ add_action('wp_ajax_quads_hide_rating', 'quads_hide_rating_div');
160
 
161
  /**
162
  * Write the timestamp when rating notice will be opened again
163
  */
164
  function quads_hide_rating_notice_week() {
165
  $nextweek = time() + (7 * 24 * 60 * 60);
166
+ $human_date = date('Y-m-d h:i:s', $nextweek);
167
+ update_option('quads_date_next_notice', $human_date);
168
+ update_option('quads_rating_div', 'yes');
169
+ echo json_encode(array("success"));
170
  exit;
171
  }
172
 
173
+ add_action('wp_ajax_quads_hide_rating_week', 'quads_hide_rating_notice_week');
174
 
175
  /**
176
  * Check if admin notice will open again after one week of closing
178
  */
179
  function quads_rate_again() {
180
 
181
+ $rate_again_date = get_option('quads_date_next_notice');
182
 
183
+ if (false === $rate_again_date) {
184
  return false;
185
  }
186
 
187
+ $current_date = date('Y-m-d h:i:s');
188
+ $datetime1 = new DateTime($rate_again_date);
189
+ $datetime2 = new DateTime($current_date);
190
+ $diff_intrval = round(($datetime2->format('U') - $datetime1->format('U')) / (60 * 60 * 24));
191
 
192
+ if ($diff_intrval >= 0) {
193
  return true;
194
  }
195
  }
201
  * @not used
202
  */
203
  function quads_plugin_deactivated_notice() {
204
+ if (false !== ( $deactivated_notice_id = get_transient('quads_deactivated_notice_id') )) {
205
+ if ('1' === $deactivated_notice_id) {
206
+ $message = __("WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS.", 'wpstg');
207
  } else {
208
+ $message = __("WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS Pro.", 'wpstg');
209
  }
210
  ?>
211
  <div class="updated notice is-dismissible" style="border-left: 4px solid #ffba00;">
212
+ <p><?php echo esc_html($message); ?></p>
213
  </div> <?php
214
+ delete_transient('quads_deactivated_notice_id');
215
  }
216
  }
217
 
222
  */
223
  function quads_theme_notice() {
224
 
225
+ $show_notice = get_option('quads_show_theme_notice');
226
 
227
+ if (false !== $show_notice && 'no' !== $show_notice && quads_is_commercial_theme()) {
228
+ $message = __('<strong>Extend the' . quads_is_commercial_theme() . '</strong> theme with <strong>WP QUADS PRO!</strong><br>Save time and earn more - Bring your AdSense earnings to next level. <a href="http://wpquads.com?utm_campaign=adminnotice&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank"> Purchase Now</a> or <a href="http://wpquads.com?utm_campaign=free_plugin&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank">Get Details</a> <p> <a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_upgrade_notice" class="button">Close Notice</a>', 'quick-adsense-reloaded');
229
  ?>
230
  <div class="updated notice" style="border-left: 4px solid #ffba00;">
231
  <p><?php echo $message; ?></p>
240
  */
241
  function quads_update_notice() {
242
 
243
+ $show_notice = get_option('quads_show_update_notice');
244
 
245
  // do not do anything
246
+ if (false !== $show_notice) {
247
  return false;
248
  }
249
 
250
+ if ((version_compare(QUADS_VERSION, '1.3.9', '>=') ) && quads_is_pro_active() && (version_compare(QUADS_PRO_VERSION, '1.3.0', '<') )) {
251
+ $message = sprintf(__('<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Update WP QUADS PRO to get custom post type support from <a href="%s">General Settings</a>.', 'quick-adsense-reloaded'), admin_url() . 'admin.php?page=quads-settings');
252
  $message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
253
  ?>
254
  <div class="updated notice" style="border-left: 4px solid #ffba00;">
256
  </div> <?php
257
  //update_option ('quads_show_update_notice', 'no');
258
  } else
259
+ if (!quads_is_extra()) {
260
+ $message = sprintf(__('<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Install <a href="%1s" target="_blank">WP QUADS PRO</a> to get custom post type support in <a href="%2s">General Settings</a>.', 'quick-adsense-reloaded'), 'http://wpquads.com?utm_campaign=admin_notice&utm_source=admin_notice&utm_medium=admin&utm_content=custom_post_type', admin_url() . 'admin.php?page=quads-settings');
261
  $message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
262
  ?>
263
  <div class="updated notice" style="border-left: 4px solid #ffba00;">
271
  * Show upgrade notice if wp quads pro is lower than 1.3.6
272
  * @return boolean
273
  */
274
+ function quads_update_notice_v2() {
275
 
276
+ if (quads_is_pro_active() && (version_compare(QUADS_PRO_VERSION, '1.3.6', '<') ) && quads_is_admin_page()) {
277
+ $message = sprintf(__('You need to update <strong>WP QUADS PRO to version 1.3.6</strong> or higher. Your version of <strong>WP QUADS Pro</strong> is ' . QUADS_PRO_VERSION . '.<br>WP QUADS Pro ' . QUADS_PRO_VERSION . ' supports unlimited amount of ads. <br>Updating requires a valid <a href="%s" target="_new">license key</a>.', 'quick-adsense-reloaded'), 'https://wpquads.com/#buy-wpquads?utm_source=plugin_notice&utm_medium=admin&utm_campaign=activate_license');
278
  ?>
279
  <div class="notice notice-error">
280
  <p><?php echo $message; ?></p>
286
  * Show upgrade notice after updating from 1.5.2 to 1.5.3 and higher
287
  * @return boolean
288
  */
289
+ function quads_update_notice_1_5_3() {
290
 
291
  // do not show anything
292
+ if (false !== get_option('quads_hide_update_notice_1_5_3')) {
293
  return false;
294
  }
295
+
296
  $previous_version = get_option('quads_version_upgraded_from');
 
 
297
 
298
+ //wp_die(QUADS_VERSION);
299
  // Show update message if previous version was lower than 1.7 - This makes sure that the message is shown for future updates without complicated version number conditions
300
+ if (!empty($previous_version) && version_compare(QUADS_VERSION, '1.7.0', '<=')) {
301
 
302
+ $message = sprintf(__('This is a huge update! The data structure of WP QUADS has been modified and improved for better performance and great new features. <br> For the case you\'d experience issues, we made a <a href="%1s" target="_self">backup of previous WP QUADS data</a>. So you can <a href="%2s" target="_new">switch back to the previous version</a> anytime. <br><br>Please <a href="%3s" target="_new">open first a support ticket</a> if you experience any issue.', 'quick-adsense-reloaded'), admin_url() . '?page=quads-settings&tab=help', 'https://wpquads.com/docs/install-older-plugin-version/?utm_source=plugin_notice&utm_medium=admin&utm_campaign=install_older_version', 'https://wordpress.org/support/plugin/quick-adsense-reloaded');
303
  ?>
304
  <div class="notice notice-error">
305
  <p><?php echo $message; ?></p>
306
  <?php
307
+ echo '<p><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice_1_5_3" class="button-primary" target="_self" title="Close Notice" style="font-weight:bold;">' . __('Close Notice', 'quick-adsense-reloaded') . '</a>';
308
  ?>
309
  </div> <?php
310
  }
311
  }
312
 
 
313
  /**
314
  * Hide Notice and update db option quads_hide_notice
315
  */
316
  function quads_hide_notice() {
317
+ update_option('quads_show_update_notice', 'no');
318
  }
319
 
320
+ add_action('quads_hide_update_notice', 'quads_hide_notice', 10);
321
 
322
  /**
323
  * Set option to hide admin notice 1.5.3
324
  * @return boolean
325
  */
326
+ function quads_hide_notice_1_5_3() {
327
+ update_option('quads_hide_update_notice_1_5_3', '1');
328
  }
329
+
330
  add_action('quads_hide_update_notice_1_5_3', 'quads_hide_notice_1_5_3');
331
 
332
  /**
340
 
341
  // Check if custom positions location_settings is empty or does not exists
342
  $check = array();
343
+ if (isset($quads_options['location_settings'])) {
344
+ foreach ($quads_options['location_settings'] as $location_array) {
345
+ if (isset($location_array['status'])) {
346
  $check[] = $location_array['status'];
347
  }
348
  }
349
  }
350
+
351
  // ad activated with api (custom position)
352
+ if (count($check) > 0) {
353
  return true;
354
  }
355
  // check if any other ad is assigned and activated
356
+ if (isset($quads_options['pos1']['BegnAds']) ||
357
+ isset($quads_options['pos2']['MiddAds']) ||
358
+ isset($quads_options['pos3']['EndiAds']) ||
359
+ isset($quads_options['pos4']['MoreAds']) ||
360
+ isset($quads_options['pos5']['LapaAds']) ||
361
+ isset($quads_options['pos6']['Par1Ads']) ||
362
+ isset($quads_options['pos7']['Par2Ads']) ||
363
+ isset($quads_options['pos8']['Par3Ads']) ||
364
+ isset($quads_options['pos9']['Img1Ads'])
365
  ) {
366
  return true;
367
  }
378
  function quads_is_post_type_activated() {
379
  global $quads_options;
380
 
381
+ if (empty($quads_options['post_types'])) {
382
  return false;
383
  }
384
  return true;
395
 
396
  $check = array();
397
 
398
+ for ($i = 1; $i <= 10; $i++) {
399
+ if (!empty($quads_options['ads']['ad' . $i]['code'])) {
400
  $check[] = 'true';
401
  }
402
  }
403
+ if (count($check) === 0) {
404
  return true;
405
  }
406
  return false;
435
  */
436
  function quads_get_vi_notice() {
437
  global $quads;
438
+
439
+ if (false !== get_option('quads_close_vi_welcome_notice')) {
440
  return false;
441
  }
442
+
443
  $mail = get_option('admin_email');
444
  $domain = $quads->vi->getDomain();
445
+
446
 
447
  $white = '<div class="quads-banner-wrapper">
448
  <section class="quads-banner-content">
449
  <div class="quads-banner-columns">
450
+ <main class="quads-banner-main"><p>' .
451
  sprintf(
452
+ __('This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
453
  content and video advertising.<br>
454
  To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
455
+ <p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaed'), 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white', admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white'
456
+ )
 
 
 
457
  . '</p></main>
458
  <!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
459
  <aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-white.png" width="168" height="72"></a></p></aside>
460
  </div>
461
+ <aside class="quads-banner-close"><div style="margin-top:5px;"><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
462
  </section>
463
  </div>';
464
+
465
+
466
  $black = '<div class="quads-banner-wrapper" style="background-color:black;">
467
  <section class="quads-banner-content">
468
  <div class="quads-banner-columns">
469
+ <main class="quads-banner-main" style="color:white;"><p>' .
470
  sprintf(
471
+ __('This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
472
  content and video advertising.<br>
473
  To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
474
+ <p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaded'), 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black', admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black'
475
+ )
 
 
 
476
  . '</p></main>
477
  <!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
478
  <aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-black.png" width="168" height="72"></a></p></aside>
479
  </div>
480
+ <aside class="quads-banner-close"><div style="margin-top:5px;"><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
481
  </section>
482
  </div>';
483
 
484
+ $variant = get_option('quads_vi_variant');
485
 
486
  switch ($variant) {
487
  case 'a':
502
  */
503
  function quads_show_vi_notice_again() {
504
 
505
+ $show_again_date = get_option('quads_show_vi_notice_later');
506
 
507
+ if (false === $show_again_date) {
508
  return false;
509
  }
510
 
511
+ $current_date = date('Y-m-d h:i:s');
512
+ $datetime1 = new DateTime($show_again_date);
513
+ $datetime2 = new DateTime($current_date);
514
+ $diff_intrval = round(($datetime2->format('U') - $datetime1->format('U')) / (60 * 60 * 24));
515
 
516
+ if ($diff_intrval >= 0) {
517
  return true;
518
  }
519
  }
521
  /**
522
  * Show all vi notices
523
  */
524
+ function quads_show_vi_notices() {
525
  global $quads, $quads_options;
526
+
527
+ if (!quads_is_admin_page()) {
528
  return false;
529
+ }
530
+
531
+
532
+ // adsense ads.txt content
533
+ $adsense = new wpquads\adsense($quads_options);
534
+ $adsensePublisherIds = $adsense->getPublisherIds();
535
+
536
+ $adsenseAdsTxtText = '';
537
+ if (!empty($adsensePublisherIds)) {
538
+ foreach ($adsensePublisherIds as $adsensePublisherId) {
539
+ $adsenseAdsTxtText .= "google.com, " . $adsensePublisherId . ", DIRECT, f08c47fec0942fa0\r\n";
540
+ }
541
+ }
542
+
543
+ // vi ads.txt content
544
+ $viAdsTxtText = '';
545
+ if ($quads->vi->getPublisherId()) {
546
+ $viAdsTxtText = $quads->vi->getAdsTxtContent();
547
+ }
548
+
549
+ // Show ads.txt warning if logged into vi and ads.txt option is disabled
550
+ if (get_transient('quads_vi_ads_txt_disabled') && get_option('quads_vi_token')) {
551
+ // ads.txt content
552
+ $notice['message'] = sprintf('<p><strong>ADS.TXT couldn\'t be updated automatically.</strong><br><br>You need the ads.txt to display vi video ads. <br>If you want WP QUADS to create an ads.txt automatically you can enable the ads.txt option at <a href="%1$s">General & Position</a>. Alternatively you can also enter the following line manually into <strong>' . get_site_url() . '/ads.txt</strong>:'
553
+ . "<p>"
554
+ . "<pre>" . $viAdsTxtText . "<br>"
555
+ . $adsenseAdsTxtText
556
+ . "</pre></p>"
557
+ . 'If the file does not exist you need to create it first. <a href="%2$s" target="_blank">Learn More</a></p>'
558
+ , admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header'
559
+ , 'https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/'
560
+ );
561
+ $notice['type'] = 'update-nag';
562
+ $adsTxtDisabled = new wpquads\template('/includes/vendor/vi/views/notices', $notice);
563
+ echo $adsTxtDisabled->render();
564
+ return false;
565
+ }
566
+
567
  // show ad.txt update notice
568
  if (get_transient('quads_vi_ads_txt_notice')) {
569
  $notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated your ads.txt '
570
+ . 'file with lines that declare video inteligence as a legitmate seller of your inventory and enables you to make more money through video inteligence. <a href="https://www.vi.ai/publisher-video-monetization/?utm_source=WordPress&utm_medium=Plugin%20blurb&utm_campaign=wpquads" target="blank" rel="external nofollow">FAQ</a>';
571
  $notice['type'] = 'update-nag';
572
  $adsUpdated = new wpquads\template('/includes/vendor/vi/views/notices', $notice);
573
  echo $adsUpdated->render();
574
  }
575
+
576
  // show ad.txt update notice
577
  if (get_transient('quads_vi_ads_txt_error')) {
578
+
579
+
 
 
 
 
 
 
 
 
 
 
 
580
  // ads.txt content
581
  $notice['message'] = "<p><strong>ADS.TXT couldn't be added</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <br><strong>" . get_home_path() . "ads.txt</strong>:"
582
+ . "<p>"
583
+ . "<pre>vi.ai " . $quads->vi->getPublisherId() . " DIRECT # 41b5eef6<br>"
584
+ . $adsenseAdsTxtText
585
+ . "</pre></p>"
586
+ . "Only by doing so you are able to make more money through video inteligence.</p>";
587
  $notice['type'] = 'error';
588
+
589
  // render blurb
590
  $adsTxtError = new wpquads\template('/includes/vendor/vi/views/notices', $notice);
591
  echo $adsTxtError->render();
592
  }
 
593
  }
594
 
595
  /**
596
+ * Show a ads.txt notices if WP QUADS has permission to update or create an ads.txt
597
  */
598
+ function quads_show_ads_txt_notice() {
599
  global $quads, $quads_options;
600
+
601
  if (!quads_is_admin_page())
602
  return false;
603
+
604
+
605
  // show ad.txt update notice
606
+ if (get_transient('quads_ads_txt_notice') && isset($quads_options['adsTxtEnabled'])) {
607
+ $notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated the file ' . ABSPATH . 'ads.txt '
608
+ . 'file with lines that declare Google.com as a legitmate seller of your inventory and is recommended setting by AdSense.<br><a href="https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/" target="blank" rel="external nofollow">What is ads.txt?</a>';
609
  $notice['type'] = 'update-nag';
610
  $notice['action'] = 'close_ads_txt_notice';
611
  $adsUpdated = new wpquads\template('/includes/admin/views/notices', $notice);
612
  echo $adsUpdated->render();
613
  }
614
+
615
  // show ads.txt error notice
616
+ if (get_transient('close_ads_txt_error') && isset($quads_options['adsTxtEnabled'])) {
617
+
618
  // Check if adsense is used and add the adsense publisherId to ads.txt blurb as well
619
  $adsense = new wpquads\adsense($quads_options);
620
  $adsensePublisherIds = $adsense->getPublisherIds();
621
+
622
+
623
  $adsenseAdsTxtText = '';
624
+ if (!empty($adsensePublisherIds)) {
625
+ foreach ($adsensePublisherIds as $adsensePublisherId) {
626
+ $adsenseAdsTxtText .= "google.com, " . $adsensePublisherId . ", DIRECT, f08c47fec0942fa0\n\r";
627
  }
628
  }
629
+
630
  $viAdsTxtText = '';
631
  if ($quads->vi->getPublisherId()) {
632
  $viAdsTxtText = $quads->vi->getAdsTxtContent();
633
  }
634
 
635
  // ads.txt content
636
+ $notice['message'] = "<p><strong>ADS.TXT couldn't be updated automatically</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <strong>" . get_home_path() . "ads.txt</strong>:"
637
+ . "<p>"
638
+ . "<pre>" . $viAdsTxtText . "<br>"
639
+ . $adsenseAdsTxtText
640
+ . "</pre></p>"
641
+ . "Only by doing so AdSense ads are shown on your site.</p>";
642
  $notice['type'] = 'error';
643
  $notice['action'] = 'quads_ads_txt_error';
644
+
645
  // render blurb
646
  $adsTxtError = new wpquads\template('/includes/admin/views/notices', $notice);
647
  echo $adsTxtError->render();
648
  }
 
649
  }
650
 
651
+ /**
652
+ * Show api errors
653
+ */
654
+ function quads_show_vi_api_error() {
655
+ if (!quads_is_admin_page()) {
656
+ return false;
657
+ }
658
 
659
+ if (false !== get_option('quads_vi_api_error')) {
660
+ $notice['message'] = 'WP QUADS - Can not retrive ad settings from vi API. Error: ' . get_option('quads_vi_api_error');
661
+ $notice['type'] = 'error';
662
+ $notice['action'] = '';
663
+ // render blurb
664
+ $blurb = new wpquads\template('/includes/admin/views/notices', $notice);
665
+ echo $blurb->render();
 
666
  }
667
+ }
includes/admin/settings/register-settings.php CHANGED
@@ -192,6 +192,23 @@ function quads_get_registered_settings() {
192
  'desc' => __( '', 'quick-adsense-reloaded' ),
193
  'type' => 'quicktags'
194
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  array(
196
  'id' => 'vi_header',
197
  'name' => '<strong>' . __( 'New: vi', 'quick-adsense-reloaded' ) . '</strong>',
@@ -1653,6 +1670,10 @@ function quads_new_ad_callback(){
1653
  function quads_ad_code_callback(){
1654
  global $quads_options;
1655
 
 
 
 
 
1656
  $args = array();
1657
 
1658
  $i = 1;
@@ -2233,13 +2254,21 @@ function quads_adsense_code_callback( $args ) {
2233
  }
2234
 
2235
  /**
2236
- * Create ads.txt for Google AdSense
2237
  * @return boolean
2238
  */
2239
  function quads_write_adsense_ads_txt() {
2240
- //global $quads_options;
2241
  // Get the current recently updated settings
2242
  $quads_options = get_option('quads_settings');
 
 
 
 
 
 
 
 
 
2243
  // Create AdSense ads.txt entries
2244
  $adsense = new \wpquads\adsense($quads_options);
2245
  if ($adsense->writeAdsTxt()){
@@ -2264,7 +2293,7 @@ function quads_adsense_code_callback( $args ) {
2264
  */
2265
  function updateAdsTxt(){
2266
  global $quads, $quads_options;
2267
- if(is_file('ads.txt')){
2268
  return false;
2269
  }
2270
  $quads->vi->createAdsTxt();
192
  'desc' => __( '', 'quick-adsense-reloaded' ),
193
  'type' => 'quicktags'
194
  ),
195
+ array(
196
+ 'id' => 'adsTxtEnabled',
197
+ 'name' => __( 'ads.txt - Automatic Creation', 'quick-adsense-reloaded' ),
198
+ 'desc' => __( 'Create an ads.txt file', 'quick-adsense-reloaded' ),
199
+ "helper-desc" => sprintf(__( 'Allow WP QUADS to generate automatically the ads.txt file in root of your website domain. After enabling and saving settings,'
200
+ . ' check if your ads.txt is correct by opening: <a href="%1$s" target="_blank">%1$s</a> <br><a href="%2$s" target="_blank">Read here</a> to learn more about ads.txt', 'quick-adsense-reloaded' ),
201
+ get_site_url() . '/ads.txt',
202
+ 'https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/'
203
+ ),
204
+ 'type' => 'checkbox'
205
+ ),
206
+ array(
207
+ 'id' => 'quicktags',
208
+ 'name' => __( 'Quicktags', 'quick-adsense-reloaded' ),
209
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
210
+ 'type' => 'quicktags'
211
+ ),
212
  array(
213
  'id' => 'vi_header',
214
  'name' => '<strong>' . __( 'New: vi', 'quick-adsense-reloaded' ) . '</strong>',
1670
  function quads_ad_code_callback(){
1671
  global $quads_options;
1672
 
1673
+ // echo '<tr><td>';
1674
+ // echo 'test2';
1675
+ // echo '</td></tr>';
1676
+
1677
  $args = array();
1678
 
1679
  $i = 1;
2254
  }
2255
 
2256
  /**
2257
+ * Create ads.txt for Google AdSense when saving settings
2258
  * @return boolean
2259
  */
2260
  function quads_write_adsense_ads_txt() {
 
2261
  // Get the current recently updated settings
2262
  $quads_options = get_option('quads_settings');
2263
+
2264
+ // ads.txt is disabled
2265
+ if (!isset($quads_options['adsTxtEnabled'])) {
2266
+ set_transient('quads_ads_txt_disabled', true, 100);
2267
+ delete_transient('quads_ads_txt_error');
2268
+ delete_transient('quads_ads_txt_notice');
2269
+ return false;
2270
+ }
2271
+
2272
  // Create AdSense ads.txt entries
2273
  $adsense = new \wpquads\adsense($quads_options);
2274
  if ($adsense->writeAdsTxt()){
2293
  */
2294
  function updateAdsTxt(){
2295
  global $quads, $quads_options;
2296
+ if(is_file('ads.txt') || !isset($quads_options['adsTxtEnabled'])){
2297
  return false;
2298
  }
2299
  $quads->vi->createAdsTxt();
includes/admin/upgrades/upgrade-functions.php CHANGED
@@ -78,9 +78,14 @@ function quads_update_settings_1_5_3(){
78
 
79
  // Do not update - we already did it
80
  if (isset($settings['ads'])){
81
- //wp_die('test');
82
  return false;
83
  }
 
 
 
 
 
 
84
 
85
  foreach ( $settings as $key => $value ) {
86
 
78
 
79
  // Do not update - we already did it
80
  if (isset($settings['ads'])){
 
81
  return false;
82
  }
83
+ // Do not update - no data available
84
+ if (false == $settings){
85
+ return false;
86
+ }
87
+
88
+
89
 
90
  foreach ( $settings as $key => $value ) {
91
 
includes/vendor/google/adsense.php CHANGED
@@ -34,6 +34,13 @@ class adsense {
34
  * @return string
35
  */
36
  public function setPublisherID() {
 
 
 
 
 
 
 
37
  // loop through all adsense g_data_ad_client fields and check if there is any adsense publisher id
38
  foreach ($this->settings['ads'] as $key => $value) {
39
  if (!empty($value['g_data_ad_client'])){
@@ -130,6 +137,10 @@ class adsense {
130
  */
131
  public function writeAdsTxt(){
132
 
 
 
 
 
133
  $publisherIds = $this->getPublisherIds();
134
 
135
  if (empty($publisherIds)){
34
  * @return string
35
  */
36
  public function setPublisherID() {
37
+
38
+ if (!isset($this->settings['ads'])){
39
+ $this->publisherIds[] = '';
40
+ return $this->publisherIds;
41
+
42
+ }
43
+
44
  // loop through all adsense g_data_ad_client fields and check if there is any adsense publisher id
45
  foreach ($this->settings['ads'] as $key => $value) {
46
  if (!empty($value['g_data_ad_client'])){
137
  */
138
  public function writeAdsTxt(){
139
 
140
+ // if (!isset($this->settings['adsTxtEnabled'])){
141
+ // return false;
142
+ // }
143
+
144
  $publisherIds = $this->getPublisherIds();
145
 
146
  if (empty($publisherIds)){
includes/vendor/vi/vi.php CHANGED
@@ -584,12 +584,19 @@ class vi {
584
  return isset($this->token->publisherId) ? $this->token->publisherId : '';
585
  }
586
 
 
587
  public function getDomain() {
588
- $domain = str_replace('www.', '', get_home_url());
589
- $domain = str_replace('https://', '', $domain);
590
- $domain = str_replace('http://', '', $domain);
591
 
592
- return $domain;
 
 
 
 
 
 
 
 
 
593
  }
594
 
595
  /**
584
  return isset($this->token->publisherId) ? $this->token->publisherId : '';
585
  }
586
 
587
+ // Domain
588
  public function getDomain() {
 
 
 
589
 
590
+ $url = parse_url(get_bloginfo('url'));
591
+ $domain = isset($url['host']) ? $url['host'] : '';
592
+ if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $result)) {
593
+ return $result['domain'];
594
+ }
595
+ // Else
596
+ $domainNew = str_replace('www.', '', get_home_url());
597
+ $domainNew = str_replace('https://', '', $domainNew);
598
+ $domainNew = str_replace('http://', '', $domainNew);
599
+ return $domainNew;
600
  }
601
 
602
  /**
quick-adsense-reloaded.php CHANGED
@@ -6,7 +6,7 @@
6
  * Description: Insert Google AdSense and other ad formats fully automatic into your website
7
  * Author: Rene Hermenau, WP-Staging
8
  * Author URI: https://wordpress.org/plugins/quick-adsense-reloaded/
9
- * Version: 1.7.3
10
  * Text Domain: quick-adsense-reloaded
11
  * Domain Path: languages
12
  * Credits: WP QUADS - Quick AdSense Reloaded is a fork of Quick AdSense
@@ -38,7 +38,7 @@ if( !defined( 'ABSPATH' ) )
38
 
39
  // Plugin version
40
  if( !defined( 'QUADS_VERSION' ) ) {
41
- define( 'QUADS_VERSION', '1.7.3' );
42
  }
43
 
44
  // Plugin name
6
  * Description: Insert Google AdSense and other ad formats fully automatic into your website
7
  * Author: Rene Hermenau, WP-Staging
8
  * Author URI: https://wordpress.org/plugins/quick-adsense-reloaded/
9
+ * Version: 1.7.4
10
  * Text Domain: quick-adsense-reloaded
11
  * Domain Path: languages
12
  * Credits: WP QUADS - Quick AdSense Reloaded is a fork of Quick AdSense
38
 
39
  // Plugin version
40
  if( !defined( 'QUADS_VERSION' ) ) {
41
+ define( 'QUADS_VERSION', '1.7.4' );
42
  }
43
 
44
  // Plugin name
readme.txt CHANGED
@@ -10,7 +10,7 @@ Tags: adsense, ads, ad, google adsense, advertising, amp, ad injection, ad inser
10
  Requires at least: 3.6+
11
  Tested up to: 4.9
12
  Requires PHP: 5.3
13
- Stable tag: 1.7.3
14
 
15
  Quick Adsense Reloaded! Quickest way to insert Google AdSense & other ads into your website. Google AdSense integration with Google AMP support
16
 
@@ -130,6 +130,11 @@ Alternative Installation:
130
 
131
  == Changelog ==
132
 
 
 
 
 
 
133
  = 1.7.3 =
134
  * New: Support for multiple google AdSense publisher accounts in ads.txt
135
  * Fix: Remove duplicate html id elements
10
  Requires at least: 3.6+
11
  Tested up to: 4.9
12
  Requires PHP: 5.3
13
+ Stable tag: 1.7.4
14
 
15
  Quick Adsense Reloaded! Quickest way to insert Google AdSense & other ads into your website. Google AdSense integration with Google AMP support
16
 
130
 
131
  == Changelog ==
132
 
133
+ = 1.7.4 =
134
+ * New: Option to explicetely allow wp quads to create the ads.txt
135
+ * Fix: Invalid arguments and several thrown errors when no ads are defined
136
+ * Fix: Can not use vi if wordpress is installed in sub directory
137
+
138
  = 1.7.3 =
139
  * New: Support for multiple google AdSense publisher accounts in ads.txt
140
  * Fix: Remove duplicate html id elements