PluginProbe
Advanced Ads – Ad Manager & AdSense / 2.0.22
Advanced Ads – Ad Manager & AdSense v2.0.22
2.0.26 2.0.25 2.0.24 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 All 348 releases
advanced-ads / includes / functions-conditional.php
functions-conditional.php
85 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Conditional functions.
4 *
5 * @package AdvancedAds
6 * @author Advanced Ads <info@wpadvancedads.com>
7 * @since 2.0.0
8 */
9
10 use AdvancedAds\Framework\Utilities\Params;
11
12 /**
13 * Return true if ads can be displayed
14 *
15 * @since 1.4.9
16 *
17 * @return bool, true if ads can be displayed
18 */
19 function advads_can_display_ads() {
20 return Advanced_Ads::get_instance()->can_display_ads();
21 }
22
23 /**
24 * Are we currently on an AMP URL?
25 * Will always return `false` and show PHP Notice if called before the `wp` hook.
26 *
27 * @return bool true if amp url, false otherwise
28 */
29 function advads_is_amp() {
30 global $pagenow;
31
32 if (
33 is_admin() ||
34 is_embed() ||
35 is_feed() ||
36 ( isset( $pagenow ) && in_array( $pagenow, [ 'wp-login.php', 'wp-signup.php', 'wp-activate.php' ], true ) ) ||
37 ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ||
38 ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
39 ) {
40 return false;
41 }
42
43 if ( ! did_action( 'wp' ) ) {
44 return false;
45 }
46
47 return ( function_exists( 'is_amp_endpoint' ) && \is_amp_endpoint() ) ||
48 ( function_exists( 'is_wp_amp' ) && \is_wp_amp() ) ||
49 ( function_exists( 'ampforwp_is_amp_endpoint' ) && \ampforwp_is_amp_endpoint() ) ||
50 ( function_exists( 'is_penci_amp' ) && \is_penci_amp() ) ||
51 Params::get( 'wpamp' );
52 }
53
54 /**
55 * Test if a placement has ads.
56 *
57 * @param int $id Id of the placement.
58 *
59 * @return bool
60 */
61 function placement_has_ads( $id = '' ) {
62 $args = [
63 'global_output' => false,
64 'cache-busting' => 'ignore',
65 ];
66
67 return get_the_placement( $id, '', $args ) !== '';
68 }
69
70 /**
71 * Test if a group has ads.
72 *
73 * @param int $id Id of the placement.
74 *
75 * @return bool
76 */
77 function group_has_ads( $id = '' ) {
78 $args = [
79 'global_output' => false,
80 'cache-busting' => 'ignore',
81 ];
82
83 return get_the_group( $id, '', $args ) !== '';
84 }
85