PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 1.13
Advanced Ads – Ad Manager & AdSense v1.13
2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / admin / includes / class-settings.php
advanced-ads / admin / includes Last commit date
ad-health-notices.php 7 years ago class-ad-groups-list.php 7 years ago class-ad-type.php 7 years ago class-licenses.php 7 years ago class-list-filters.php 7 years ago class-menu.php 7 years ago class-meta-box.php 7 years ago class-notices.php 7 years ago class-options.php 9 years ago class-overview-widgets.php 7 years ago class-settings.php 7 years ago class-shortcode-creator.php 9 years ago notices.php 7 years ago shortcode-creator-l10n.php 10 years ago
class-settings.php
688 lines
1 <?php
2 defined( 'ABSPATH' ) || exit;
3
4 class Advanced_Ads_Admin_Settings {
5 /**
6 * Instance of this class.
7 *
8 * @var object
9 */
10 protected static $instance = null;
11
12 /**
13 * Advanced_Ads_Admin_Settings constructor.
14 */
15 private function __construct() {
16 // settings handling.
17 add_action( 'admin_init', array( $this, 'settings_init' ) );
18 }
19
20 /**
21 * Return an instance of this class.
22 *
23 * @return object A single instance of this class.
24 */
25 public static function get_instance() {
26 // If the single instance hasn't been set, set it now.
27 if ( null == self::$instance ) {
28 self::$instance = new self();
29 }
30
31 return self::$instance;
32 }
33
34 /**
35 * Initialize settings
36 *
37 * @since 1.0.1
38 */
39 public function settings_init() {
40
41 // get settings page hook.
42 $hook = Advanced_Ads_Admin::get_instance()->plugin_screen_hook_suffix;
43
44 // register settings.
45 register_setting( ADVADS_SLUG, ADVADS_SLUG, array( $this, 'sanitize_settings' ) );
46
47 // "Management" settings section.
48 add_settings_section(
49 'advanced_ads_setting_section',
50 __( 'Admin', 'advanced-ads' ),
51 array( $this, 'render_settings_section_callback' ),
52 $hook
53 );
54
55 // "Disable ads" settings section.
56 add_settings_section(
57 'advanced_ads_setting_section_disable_ads',
58 __( 'Disable ads', 'advanced-ads' ),
59 array( $this, 'render_settings_section_disable_ads_callback' ),
60 $hook
61 );
62
63 // "Layout / Output" settings section.
64 add_settings_section(
65 'advanced_ads_setting_section_output',
66 __( 'Layout / Output', 'advanced-ads' ),
67 array( $this, 'render_settings_section_output_callback' ),
68 $hook
69 );
70
71 // "Content injection" settings section.
72 add_settings_section(
73 'advanced_ads_setting_section_injection',
74 __( 'Content injection', 'advanced-ads' ),
75 array( $this, 'render_settings_section_injection_callback' ),
76 $hook
77 );
78
79 // Pro pitch section.
80 if ( ! defined( 'AAP_VERSION' ) ) {
81 add_settings_section(
82 'advanced_ads_settings_pro_pitch_section',
83 '',
84 array( $this, 'render_settings_pro_pitch_section_callback' ),
85 'advanced-ads-settings-pro-pitch-page'
86 );
87
88 add_filter( 'advanced-ads-setting-tabs', array( $this, 'pro_pitch_tab' ) );
89 }
90
91 // Tracking pitch section.
92 if ( ! defined( 'AAT_VERSION' ) ) {
93 add_settings_section(
94 'advanced_ads_settings_tracking_pitch_section',
95 '',
96 array( $this, 'render_settings_tracking_pitch_section_callback' ),
97 'advanced-ads-settings-tracking-pitch-page'
98 );
99
100 add_filter( 'advanced-ads-setting-tabs', array( $this, 'tracking_pitch_tab' ) );
101 }
102
103 // licenses section only for main blog.
104 if ( is_main_site( get_current_blog_id() ) ) {
105 // register license settings.
106 register_setting( ADVADS_SLUG . '-licenses', ADVADS_SLUG . '-licenses' );
107
108 add_settings_section(
109 'advanced_ads_settings_license_section',
110 '',
111 array( $this, 'render_settings_licenses_section_callback' ),
112 'advanced-ads-settings-license-page'
113 );
114
115 add_filter( 'advanced-ads-setting-tabs', array( $this, 'license_tab' ) );
116
117 add_settings_section(
118 'advanced_ads_settings_license_pitch_section',
119 '',
120 array( $this, 'render_settings_licenses_pitch_section_callback' ),
121 'advanced-ads-settings-license-page'
122 );
123 }
124
125 // add setting fields to disable ads.
126 add_settings_field(
127 'disable-ads',
128 __( 'Disable ads', 'advanced-ads' ),
129 array( $this, 'render_settings_disable_ads' ),
130 $hook,
131 'advanced_ads_setting_section_disable_ads'
132 );
133 // add setting fields for user role.
134 add_settings_field(
135 'hide-for-user-role',
136 __( 'Hide ads for logged in users', 'advanced-ads' ),
137 array( $this, 'render_settings_hide_for_users' ),
138 $hook,
139 'advanced_ads_setting_section_disable_ads'
140 );
141 // add setting fields for content injection protection.
142 add_settings_field(
143 'content-injection-everywhere',
144 __( 'Unlimited ad injection', 'advanced-ads' ),
145 array( $this, 'render_settings_content_injection_everywhere' ),
146 $hook,
147 'advanced_ads_setting_section_injection'
148 );
149 // add setting fields for content injection priority.
150 add_settings_field(
151 'content-injection-priority',
152 __( 'Priority of content injection filter', 'advanced-ads' ),
153 array( $this, 'render_settings_content_injection_priority' ),
154 $hook,
155 'advanced_ads_setting_section_injection'
156 );
157 // add setting fields to remove injection level limitation.
158 add_settings_field(
159 'content-injection-level-limitation',
160 __( 'Disable level limitation', 'advanced-ads' ),
161 array( $this, 'render_settings_content_injection_level_limitation' ),
162 $hook,
163 'advanced_ads_setting_section_injection'
164 );
165 // add setting fields for hiding ads from bots.
166 add_settings_field(
167 'block-bots',
168 __( 'Hide ads from bots', 'advanced-ads' ),
169 array( $this, 'render_settings_block_bots' ),
170 $hook,
171 'advanced_ads_setting_section_disable_ads'
172 );
173 // opt out from internal notices.
174 add_settings_field(
175 'disable-notices',
176 __( 'Disable Ad Health and other notices', 'advanced-ads' ),
177 array( $this, 'render_settings_disabled_notices' ),
178 $hook,
179 'advanced_ads_setting_section'
180 );
181 // opt out from internal notices.
182 add_settings_field(
183 'front-prefix',
184 __( 'ID prefix', 'advanced-ads' ),
185 array( $this, 'render_settings_front_prefix' ),
186 $hook,
187 'advanced_ads_setting_section_output'
188 );
189 // allow editors to manage ads.
190 add_settings_field(
191 'editors-manage-ads',
192 __( 'Allow editors to manage ads', 'advanced-ads' ),
193 array( $this, 'render_settings_editors_manage_ads' ),
194 $hook,
195 'advanced_ads_setting_section'
196 );
197 // ad label.
198 add_settings_field(
199 'add-custom-label',
200 __( 'Ad label', 'advanced-ads' ),
201 array( $this, 'render_settings_add_custom_label' ),
202 $hook,
203 'advanced_ads_setting_section_output'
204 );
205
206 // add setting fields.
207 add_settings_field(
208 'link-target',
209 __( 'Open links in a new window', 'advanced-ads' ),
210 array( $this, 'render_settings_link_target_callback' ),
211 $hook,
212 'advanced_ads_setting_section_output'
213 );
214 // add setting fields for advanced js.
215 add_settings_field(
216 'activate-advanced-js',
217 __( 'Use advanced JavaScript', 'advanced-ads' ),
218 array( $this, 'render_settings_advanced_js' ),
219 $hook,
220 'advanced_ads_setting_section_output'
221 );
222
223 // only for main blog.
224 if ( is_main_site( get_current_blog_id() ) ) {
225 add_settings_field(
226 'uninstall-delete-data',
227 __( 'Delete data on uninstall', 'advanced-ads' ),
228 array( $this, 'render_settings_uninstall_delete_data' ),
229 $hook,
230 'advanced_ads_setting_section'
231 );
232 }
233
234 // allow to disable shortcode button in TinyMCE.
235 add_settings_field(
236 'disable-shortcode-button',
237 __( 'Disable shortcode button', 'advanced-ads' ),
238 array( $this, 'render_settings_disable_shortcode_button' ),
239 $hook,
240 'advanced_ads_setting_section'
241 );
242
243 // hook for additional settings from add-ons.
244 do_action( 'advanced-ads-settings-init', $hook );
245 }
246
247 /**
248 * Add license tab
249 *
250 * @param array $tabs setting tabs.
251 * @return array
252 */
253 public function license_tab( array $tabs ) {
254
255 $tabs['licenses'] = array(
256 'page' => 'advanced-ads-settings-license-page',
257 'group' => ADVADS_SLUG . '-licenses',
258 'tabid' => 'licenses',
259 'title' => __( 'Licenses', 'advanced-ads' ),
260 );
261
262 return $tabs;
263 }
264
265 /**
266 * Add pro pitch tab
267 *
268 * @oaram array $tabs setting tabs
269 */
270 public function pro_pitch_tab( array $tabs ) {
271
272 $tabs['pro_pitch'] = array(
273 'page' => 'advanced-ads-settings-pro-pitch-page',
274 //'group' => ADVADS_SLUG . '-pro-pitch',
275 'tabid' => 'pro-pitch',
276 'title' => __( 'Pro', 'advanced-ads' ),
277 );
278
279 return $tabs;
280 }
281
282 /**
283 * Add tracking pitch tab
284 *
285 * array $tabs setting tabs
286 */
287 public function tracking_pitch_tab( array $tabs ) {
288
289 $tabs['tracking_pitch'] = array(
290 'page' => 'advanced-ads-settings-tracking-pitch-page',
291 'tabid' => 'tracking-pitch',
292 'title' => __( 'Tracking', 'advanced-ads' ),
293 );
294
295 return $tabs;
296 }
297
298 /**
299 * Render settings section
300 *
301 * @since 1.1.1
302 */
303 public function render_settings_section_callback() {
304 // for whatever purpose there might come.
305 }
306
307 /**
308 * Render "Disable Ads" settings section
309 *
310 * @since 1.12
311 */
312 public function render_settings_section_disable_ads_callback() {
313 // for whatever purpose there might come.
314 }
315
316 /**
317 * Render "Content Injection" settings section
318 *
319 * @since 1.12
320 */
321 public function render_settings_section_output_callback() {
322 // for whatever purpose there might come.
323 }
324
325 /**
326 * Render "Content Injection" settings section
327 *
328 * @since 1.12
329 */
330 public function render_settings_section_injection_callback() {
331 // for whatever purpose there might come.
332 }
333
334 /**
335 * render licenses settings section
336 *
337 * @since 1.5.1
338 */
339 public function render_settings_licenses_section_callback() {
340 echo '<p>' . sprintf( __( 'Enter license keys for our powerful <a href="%s" target="_blank">add-ons</a>.', 'advanced-ads' ), ADVADS_URL . 'add-ons/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses' );
341 echo ' ' . sprintf( __( 'See also <a href="%s" target="_blank">Issues and questions about licenses</a>.', 'advanced-ads' ), ADVADS_URL . 'manual-category/purchase-licenses/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses' ) . '</p>';
342 // nonce field
343 echo '<input type="hidden" id="advads-licenses-ajax-referrer" value="' . wp_create_nonce( "advads_ajax_license_nonce" ) . '"/>';
344 }
345
346 /**
347 * render licenses pithces settings section
348 *
349 * @since 1.8.12
350 */
351 public function render_settings_licenses_pitch_section_callback() {
352
353 echo '<h3>' . esc_attr__( 'Are you missing something?', 'advanced-ads' ) . '</h3>';
354
355 $link = ADVADS_URL . 'manual/how-to-install-an-add-on/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses';
356 echo '<p><a href="' . esc_url( $link ) . '" target="_blank">' . esc_attr__( 'How to install and activate an add-on.', 'advanced-ads' ) . '</p>';
357
358 Advanced_Ads_Overview_Widgets_Callbacks::render_addons( true );
359 }
360
361 /**
362 * render pro pitch settings section
363 *
364 * @since 1.8.12
365 */
366 public function render_settings_pro_pitch_section_callback() {
367 echo '<br/>';
368 include ADVADS_BASE_PATH . 'admin/views/pitch-pro-tab.php';
369 }
370
371 /**
372 * render tracking pitch settings section
373 *
374 * @since 1.8.12
375 */
376 public function render_settings_tracking_pitch_section_callback() {
377 echo '<br/>';
378 include ADVADS_BASE_PATH . 'admin/views/pitch-tracking.php';
379 }
380
381 /**
382 * options to disable ads
383 *
384 * @since 1.3.11
385 */
386 public function render_settings_disable_ads() {
387 $options = Advanced_Ads::get_instance()->options();
388
389 // set the variables.
390 $disable_all = isset( $options['disabled-ads']['all'] ) ? 1 : 0;
391 $disable_404 = isset( $options['disabled-ads']['404'] ) ? 1 : 0;
392 $disable_archives = isset( $options['disabled-ads']['archives'] ) ? 1 : 0;
393 $disable_secondary = isset( $options['disabled-ads']['secondary'] ) ? 1 : 0;
394 $disable_feed = ( ! isset( $options['disabled-ads']['feed'] ) || $options['disabled-ads']['feed'] ) ? 1 : 0;
395
396 // load the template.
397 include ADVADS_BASE_PATH . 'admin/views/settings-disable-ads.php';
398 }
399
400 /**
401 * render setting to hide ads from logged in users
402 *
403 * @since 1.1.1
404 */
405 public function render_settings_hide_for_users() {
406 $options = Advanced_Ads::get_instance()->options();
407 $current_capability_role = isset( $options['hide-for-user-role'] ) ? $options['hide-for-user-role'] : 0;
408
409 $capability_roles = array(
410 '' => __( '(display to all)', 'advanced-ads' ),
411 'read' => __( 'Subscriber', 'advanced-ads' ),
412 'delete_posts' => __( 'Contributor', 'advanced-ads' ),
413 'edit_posts' => __( 'Author', 'advanced-ads' ),
414 'edit_pages' => __( 'Editor', 'advanced-ads' ),
415 'activate_plugins' => __( 'Admin', 'advanced-ads' ),
416 );
417 echo '<select name="' . ADVADS_SLUG . '[hide-for-user-role]">';
418 foreach ( $capability_roles as $_capability => $_role ) {
419 echo '<option value="' . $_capability . '" ' . selected( $_capability, $current_capability_role, false ) . '>' . $_role . '</option>';
420 }
421 echo '</select>';
422
423 echo '<p class="description">' . __( 'Choose the lowest role a user must have in order to not see any ads.', 'advanced-ads' ) . '</p>';
424 }
425
426 /**
427 * render setting to display advanced js file
428 *
429 * @since 1.2.3
430 */
431 public function render_settings_advanced_js() {
432 $options = Advanced_Ads::get_instance()->options();
433 $checked = ( ! empty( $options['advanced-js'] ) ) ? 1 : 0;
434
435 // display notice if js file was overridden
436 if ( ! $checked && apply_filters( 'advanced-ads-activate-advanced-js', $checked ) ) {
437 echo '<p>' . __( '<strong>notice: </strong>the file is currently enabled by an add-on that needs it.', 'advanced-ads' ) . '</p>';
438 }
439 echo '<input id="advanced-ads-advanced-js" type="checkbox" value="1" name="' . ADVADS_SLUG . '[advanced-js]" ' . checked( $checked, 1, false ) . '>';
440 echo '<p class="description">' . sprintf( __( 'Enable advanced JavaScript functions (<a href="%s" target="_blank">here</a>). Some features and add-ons might override this setting if they need features from this file.', 'advanced-ads' ), ADVADS_URL . 'javascript-functions/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings' ) . '</p>';
441 }
442
443 /**
444 * render setting for content injection protection
445 *
446 * @since 1.4.1
447 */
448 public function render_settings_content_injection_everywhere() {
449 $options = Advanced_Ads::get_instance()->options();
450
451 if ( ! isset( $options['content-injection-everywhere'] ) ) {
452 $everywhere = 0;
453 } elseif ( $options['content-injection-everywhere'] === 'true' ) {
454 $everywhere = - 1;
455 } else {
456 $everywhere = absint( $options['content-injection-everywhere'] );
457 }
458
459 echo '<input id="advanced-ads-injection-everywhere" type="number" value="' . $everywhere . '" min="-1" name="' . ADVADS_SLUG . '[content-injection-everywhere]">';
460 echo '<p class="description">' . __( 'Some plugins and themes trigger ad injections where it shouldn’t happen. Therefore, Advanced Ads ignores injected placements on non-singular pages and outside the loop. However, this can cause problems with some themes. Set this option to -1 in order to enable unlimited ad injection at your own risk, set it to 0 to keep it disabled or choose a positive number to enable the injection only in the first x posts on your archive pages.', 'advanced-ads' ) . '</p>';
461
462 }
463
464 /**
465 * render setting for content injection priority
466 *
467 * @since 1.4.1
468 */
469 public function render_settings_content_injection_priority() {
470 $options = Advanced_Ads::get_instance()->options();
471 $priority = ( isset( $options['content-injection-priority'] ) ) ? intval( $options['content-injection-priority'] ) : 100;
472
473 echo '<input id="advanced-ads-content-injection-priority" type="number" value="' . $priority . '" name="' . ADVADS_SLUG . '[content-injection-priority]" size="3"/>';
474 echo '<p class="description">';
475 if ( $priority < 11 ) {
476 echo '<span class="advads-error-message">' . __( 'Please check your post content. A priority of 10 and below might cause issues (wpautop function might run twice).', 'advanced-ads' ) . '</span><br />';
477 }
478 _e( 'Play with this value in order to change the priority of the injected ads compared to other auto injected elements in the post content.', 'advanced-ads' );
479 echo '</p>';
480 }
481
482 /**
483 * render setting to disable content injection level limitation
484 *
485 * @since 1.7.22
486 */
487 public function render_settings_content_injection_level_limitation() {
488 $options = Advanced_Ads::get_instance()->options();
489 $checked = ( ! empty( $options['content-injection-level-disabled'] ) ) ? 1 : 0;
490
491 echo '<input id="advanced-ads-content-injection-level-disabled" type="checkbox" value="1" name="' . ADVADS_SLUG . '[content-injection-level-disabled]" ' . checked( $checked, 1, false ) . '>';
492 echo '<p class="description">' . __( 'Advanced Ads ignores paragraphs and other elements in containers when injecting ads into the post content. Check this option to ignore this limitation and ads might show up again.', 'advanced-ads' ) . '</p>';
493 }
494
495 /**
496 * render setting for blocking bots
497 *
498 * @since 1.4.9
499 */
500 public function render_settings_block_bots() {
501 $options = Advanced_Ads::get_instance()->options();
502 $checked = ( ! empty( $options['block-bots'] ) ) ? 1 : 0;
503
504 echo '<input id="advanced-ads-block-bots" type="checkbox" value="1" name="' . ADVADS_SLUG . '[block-bots]" ' . checked( $checked, 1, false ) . '>';
505 if ( Advanced_Ads::get_instance()->is_bot() ) {
506 echo '<span class="advads-error-message">' . __( 'You look like a bot', 'advanced-ads' ) . '</a>. </span>';
507 }
508 echo '<span class="description"><a href="' . ADVADS_URL . 'hide-ads-from-bots/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings" target="blank">' . __( 'Read this first', 'advanced-ads' ) . '</a></span>';
509 echo '<p class="description">' . __( 'Hide ads from crawlers, bots and empty user agents.', 'advanced-ads' ) . '</p>';
510 }
511
512 /**
513 * render setting to disable notices
514 *
515 * @since 1.5.3
516 * @updated 1.13 disable Ad Health as well
517 */
518 public function render_settings_disabled_notices() {
519 $options = Advanced_Ads::get_instance()->options();
520 $checked = ( ! empty( $options['disable-notices'] ) ) ? 1 : 0;
521
522 echo '<input id="advanced-ads-disabled-notices" type="checkbox" value="1" name="' . ADVADS_SLUG . '[disable-notices]" ' . checked( $checked, 1, false ) . '>';
523 echo '<p class="description">' . sprintf(
524 // translators: %1$s is a starting <a> tag and %2$s a closing one
525 __( 'Disable %1$sAd Health%2$s in frontend and backend, warnings and internal notices like tips, tutorials, email newsletters and update notices.', 'advanced-ads' ), '<a href="'
526 . ADVADS_URL . 'manual/ad-health/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-ad-health" target="_blank"> ', '</a>' ) . '</p>';
527 }
528
529 /**
530 * render setting for frontend prefix
531 *
532 * @since 1.6.8
533 */
534 public function render_settings_front_prefix() {
535 $options = Advanced_Ads::get_instance()->options();
536
537 $prefix = Advanced_Ads_Plugin::get_instance()->get_frontend_prefix();
538 $old_prefix = ( isset( $options['id-prefix'] ) ) ? esc_attr( $options['id-prefix'] ) : '';
539
540 echo '<input id="advanced-ads-front-prefix" type="text" value="' . $prefix . '" name="' . ADVADS_SLUG . '[front-prefix]" />';
541 // deprecated
542 echo '<input type="hidden" value="' . $old_prefix . '" name="' . ADVADS_SLUG . '[id-prefix]" />';
543 echo '<p class="description">' . __( 'Prefix of class or id attributes in the frontend. Change it if you don’t want <strong>ad blockers</strong> to mark these blocks as ads.<br/>You might need to <strong>rewrite css rules afterwards</strong>.', 'advanced-ads' ) . '</p>';
544 }
545
546 /**
547 * render setting to allow editors to manage ads
548 *
549 * @since 1.6.14
550 */
551 public function render_settings_editors_manage_ads() {
552 $options = Advanced_Ads::get_instance()->options();
553
554 // is false by default if no options where previously set
555 if ( isset( $options['editors-manage-ads'] ) && $options['editors-manage-ads'] ) {
556 $allow = true;
557 } else {
558 $allow = false;
559 }
560
561 echo '<input id="advanced-ads-editors-manage-ads" type="checkbox" ' . checked( $allow, true, false ) . ' name="' . ADVADS_SLUG . '[editors-manage-ads]" />';
562 echo '<p class="description">' . __( 'Allow editors to also manage and publish ads.', 'advanced-ads' ) .
563 ' ' . sprintf( __( 'You can assign different ad-related roles on a user basis with <a href="%s" target="_blank">Advanced Ads Pro</a>.', 'advanced-ads' ), ADVADS_URL . 'add-ons/advanced-ads-pro/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings' ) . '</p>';
564 }
565
566 /**
567 * render setting to add an "Advertisement" label before ads
568 *
569 */
570 public function render_settings_add_custom_label() {
571 $options = Advanced_Ads::get_instance()->options();
572
573 $enabled = isset( $options['custom-label']['enabled'] );
574 $label = ! empty ( $options['custom-label']['text'] ) ? esc_html( $options['custom-label']['text'] ) : _x( 'Advertisements', 'label before ads', 'advanced-ads' );
575 ?>
576
577 <fieldset>
578 <input type="checkbox" <?php checked( $enabled, true ); ?> value="1"
579 name="<?php echo ADVADS_SLUG . '[custom-label][enabled]'; ?>"/>
580 <input id="advads-custom-label" type="text" value="<?php echo $label; ?>"
581 name="<?php echo ADVADS_SLUG . '[custom-label][text]'; ?>"/>
582 </fieldset>
583 <p class="description"><?php _e( 'Displayed above ads.', 'advanced-ads' ); ?>&nbsp;<a target="_blank"
584 href="<?php echo ADVADS_URL . 'manual/advertisement-label/#utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-advertisement-label' ?>"><?php _e( 'Manual', 'advanced-ads' ); ?></a>
585 </p>
586
587 <?php
588 }
589
590 /**
591 * render link-nofollow setting
592 *
593 * @since 1.8.4 – moved here from Tracking add-on
594 */
595 public function render_settings_link_target_callback() {
596
597 // get option if saved for tracking
598 $options = Advanced_Ads::get_instance()->options();
599 if ( ! isset( $options['target-blank'] ) && class_exists( 'Advanced_Ads_Tracking_Plugin' ) ) {
600 $tracking_options = Advanced_Ads_Tracking_Plugin::get_instance()->options();
601 if ( isset( $tracking_options['target'] ) ) {
602 $options['target-blank'] = $tracking_options['target'];
603 }
604 }
605
606 $target = isset( $options['target-blank'] ) ? $options['target-blank'] : 0;
607 include ADVADS_BASE_PATH . 'admin/views/setting-target.php';
608 }
609
610 /**
611 * render setting 'Delete data on uninstall"
612 *
613 */
614 public function render_settings_uninstall_delete_data() {
615 $options = Advanced_Ads::get_instance()->options();
616 $enabled = ! empty( $options['uninstall-delete-data'] ); ?>
617
618 <input type="checkbox" value="1"
619 name="<?php echo ADVADS_SLUG; ?>[uninstall-delete-data]" <?php checked( $enabled, 1 ); ?>>
620 <p class="description"><?php _e( 'Clean up all data related to Advanced Ads when removing the plugin.', 'advanced-ads' ); ?></p>
621 <?php
622 }
623
624 /**
625 * Render setting to disable shortcode button.
626 */
627 public function render_settings_disable_shortcode_button() {
628 $options = Advanced_Ads::get_instance()->options();
629
630 $checked = ! empty( $options['disable-shortcode-button'] );
631
632 echo '<input id="advanced-ads-disable-shortcode-button" type="checkbox" ' . checked( $checked, true, false ) . ' name="' . ADVADS_SLUG . '[disable-shortcode-button]" />';
633 echo '<p class="description">' . __( 'Disable shortcode button in visual editor.', 'advanced-ads' ) . '</p>';
634 }
635
636 /**
637 * sanitize plugin settings
638 *
639 * @since 1.5.1
640 *
641 * @param array $options all the options
642 */
643 public function sanitize_settings( $options ) {
644
645 // sanitize whatever option one wants to sanitize
646
647 if ( isset( $options['front-prefix'] ) ) {
648 $options['front-prefix'] = sanitize_html_class( $options['front-prefix'], Advanced_Ads_Plugin::DEFAULT_FRONTEND_PREFIX );
649 }
650
651 $options = apply_filters( 'advanced-ads-sanitize-settings', $options );
652
653 // check if editors can edit ads now and set the rights
654 // else, remove that right
655 $editor_role = get_role( 'editor' );
656 if ( null == $editor_role ) {
657 return $options;
658 }
659 if ( isset( $options['editors-manage-ads'] ) && $options['editors-manage-ads'] ) {
660 $editor_role->add_cap( 'advanced_ads_see_interface' );
661 $editor_role->add_cap( 'advanced_ads_edit_ads' );
662 $editor_role->add_cap( 'advanced_ads_manage_placements' );
663 $editor_role->add_cap( 'advanced_ads_place_ads' );
664 } else {
665 $editor_role->remove_cap( 'advanced_ads_see_interface' );
666 $editor_role->remove_cap( 'advanced_ads_edit_ads' );
667 $editor_role->remove_cap( 'advanced_ads_manage_placements' );
668 $editor_role->remove_cap( 'advanced_ads_place_ads' );
669 }
670
671 // we need 3 states: ! isset, 1, 0
672 $options['disabled-ads']['feed'] = isset( $options['disabled-ads']['feed'] ) ? 1 : 0;
673
674 if ( isset( $options['content-injection-everywhere'] ) ) {
675 if ( $options['content-injection-everywhere'] == 0 ) {
676 unset( $options['content-injection-everywhere'] );
677 } elseif ( $options['content-injection-everywhere'] <= - 1 ) {
678 $options['content-injection-everywhere'] = "true";
679 } else {
680 $options['content-injection-everywhere'] = absint( $options['content-injection-everywhere'] );
681 }
682 }
683
684 return $options;
685 }
686
687 }
688