class-conditional.php
2 years ago
class-data.php
2 years ago
class-groups.php
2 years ago
class-str.php
2 years ago
class-wordpress.php
2 years ago
index.php
2 years ago
class-conditional.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The class provides utility functions related to check condition related to plugin. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.47.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Utilities; |
| 11 | |
| 12 | use AdvancedAds\Framework\Utilities\Params; |
| 13 | |
| 14 | defined( 'ABSPATH' ) || exit; |
| 15 | |
| 16 | /** |
| 17 | * Conditional. |
| 18 | */ |
| 19 | class Conditional { |
| 20 | |
| 21 | /** |
| 22 | * Check if the current screen belongs to Advanced Ads |
| 23 | * |
| 24 | * @return bool |
| 25 | */ |
| 26 | public static function is_screen_advanced_ads(): bool { |
| 27 | if ( ! function_exists( 'get_current_screen' ) ) { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | $screen = get_current_screen(); |
| 32 | if ( ! isset( $screen->id ) ) { |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | return in_array( $screen->id, Data::get_admin_screen_ids(), true ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Check if the current screen uses a search or filter. |
| 41 | * |
| 42 | * @return bool |
| 43 | */ |
| 44 | public static function has_filter_or_search(): bool { |
| 45 | $params = [ 's', 'adtype', 'adsize', 'adgroup' ]; |
| 46 | |
| 47 | foreach ( $params as $param ) { |
| 48 | if ( ! empty( Params::get( $param ) ) ) { |
| 49 | return true; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return false; |
| 54 | } |
| 55 | } |
| 56 |