acf-boolean.php
3 years ago
acf-choice.php
3 years ago
acf-text.php
3 years ago
browser.php
3 years ago
condition.php
3 years ago
date-range.php
3 years ago
date.php
3 years ago
day.php
3 years ago
device.php
3 years ago
ip-location.php
3 years ago
lang.php
3 years ago
login-status.php
3 years ago
operating-system.php
3 years ago
page.php
3 years ago
post-type.php
3 years ago
post.php
3 years ago
return-visitor.php
3 years ago
shortcode.php
3 years ago
static-page.php
3 years ago
time-range.php
3 years ago
url-referer.php
3 years ago
url-string.php
3 years ago
user-role.php
3 years ago
woo-cart-products.php
3 years ago
woo-cat-page.php
3 years ago
woo-category.php
3 years ago
woo-last-purchase.php
3 years ago
woo-orders.php
3 years ago
woo-product-cat.php
3 years ago
woo-product-price.php
3 years ago
woo-product-stock.php
3 years ago
woo-total-price.php
3 years ago
page.php
84 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Page Condition Handler. |
| 4 | */ |
| 5 | |
| 6 | namespace PremiumAddons\Includes\PA_Display_Conditions\Conditions; |
| 7 | |
| 8 | // Elementor Classes. |
| 9 | use Elementor\Controls_Manager; |
| 10 | |
| 11 | // PA Classes. |
| 12 | use PremiumAddons\Includes\Helper_Functions; |
| 13 | use PremiumAddons\Includes\Premium_Template_Tags; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; // Exit if accessed directly. |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Class Page |
| 21 | */ |
| 22 | class Page extends Condition { |
| 23 | |
| 24 | /** |
| 25 | * Get Controls Options. |
| 26 | * |
| 27 | * @access public |
| 28 | * @since 4.7.0 |
| 29 | * |
| 30 | * @return array|void controls options |
| 31 | */ |
| 32 | public function get_control_options() { |
| 33 | $posts = Premium_Template_Tags::get_default_posts_list( 'page' ); |
| 34 | |
| 35 | return array( |
| 36 | 'label' => __( 'Value', 'premium-addons-for-elementor' ), |
| 37 | 'type' => Controls_Manager::SELECT2, |
| 38 | 'default' => array(), |
| 39 | 'label_block' => true, |
| 40 | 'options' => $posts, |
| 41 | 'multiple' => true, |
| 42 | 'condition' => array( |
| 43 | 'pa_condition_key' => 'page', |
| 44 | ), |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Compare Condition Value. |
| 50 | * |
| 51 | * @access public |
| 52 | * @since 4.7.0 |
| 53 | * |
| 54 | * @param array $settings element settings. |
| 55 | * @param string $operator condition operator. |
| 56 | * @param string $value condition value. |
| 57 | * @param string $compare_val compare value. |
| 58 | * @param string|bool $tz time zone. |
| 59 | * |
| 60 | * @return bool|void |
| 61 | */ |
| 62 | public function compare_value( $settings, $operator, $value, $compare_val, $tz ) { |
| 63 | |
| 64 | $current_id = get_the_ID(); |
| 65 | |
| 66 | if ( is_array( $value ) && ! empty( $value ) ) { |
| 67 | foreach ( $value as $index => $page_id ) { |
| 68 | |
| 69 | if ( intval( $page_id ) === $current_id ) { |
| 70 | |
| 71 | if ( 'is' === $operator ) { |
| 72 | |
| 73 | return Helper_Functions::get_final_result( true, $operator ); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | return false; |
| 80 | |
| 81 | } |
| 82 | |
| 83 | } |
| 84 |