acf-boolean.php
7 months ago
acf-choice.php
7 months ago
acf-text.php
7 months ago
browser.php
7 months ago
condition.php
7 months ago
date-range.php
7 months ago
date.php
7 months ago
day.php
7 months ago
device.php
7 months ago
ip-location.php
7 months ago
lang.php
7 months ago
login-status.php
7 months ago
operating-system.php
7 months ago
page.php
7 months ago
post-category.php
7 months ago
post-format.php
7 months ago
post-type.php
7 months ago
post.php
7 months ago
return-visitor.php
7 months ago
shortcode.php
7 months ago
static-page.php
7 months ago
time-range.php
7 months ago
url-referer.php
7 months ago
url-string.php
7 months ago
user-role.php
7 months ago
woo-cart-products.php
7 months ago
woo-cat-page.php
7 months ago
woo-category.php
7 months ago
woo-last-purchase.php
7 months ago
woo-orders.php
7 months ago
woo-product-cat.php
7 months ago
woo-product-price.php
7 months ago
woo-product-stock.php
7 months ago
woo-purchase-products.php
7 months ago
woo-total-price.php
7 months ago
shortcode.php
93 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shortcode 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 | |
| 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | exit; // Exit if accessed directly. |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Class Shortcode. |
| 20 | */ |
| 21 | class Shortcode extends Condition { |
| 22 | |
| 23 | /** |
| 24 | * Get Controls Options. |
| 25 | * |
| 26 | * @access public |
| 27 | * @since 4.9.4 |
| 28 | * |
| 29 | * @return array|void controls options |
| 30 | */ |
| 31 | public function get_control_options() { |
| 32 | |
| 33 | return array( |
| 34 | 'label' => __( 'Value', 'premium-addons-for-elementor' ), |
| 35 | 'type' => Controls_Manager::TEXTAREA, |
| 36 | 'options' => array(), |
| 37 | 'label_block' => true, |
| 38 | 'condition' => array( |
| 39 | 'pa_condition_key' => 'shortcode', |
| 40 | ), |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Get Value Controls Options. |
| 46 | * |
| 47 | * @access public |
| 48 | * @since 4.9.4 |
| 49 | * |
| 50 | * @return array controls options. |
| 51 | */ |
| 52 | public function add_value_control() { |
| 53 | |
| 54 | return array( |
| 55 | 'label' => __( 'Shortcode', 'premium-addons-for-elementor' ), |
| 56 | 'type' => Controls_Manager::TEXT, |
| 57 | 'label_block' => true, |
| 58 | 'description' => __( 'Insert the shortcode you want to check its result value.', 'premium-addons-for-elementor' ), |
| 59 | 'condition' => array( |
| 60 | 'pa_condition_key' => 'shortcode', |
| 61 | ), |
| 62 | ); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | /** |
| 67 | * Compare Condition Value. |
| 68 | * |
| 69 | * @access public |
| 70 | * @since 4.9.4 |
| 71 | * |
| 72 | * @param array $settings element settings. |
| 73 | * @param string $operator condition operator. |
| 74 | * @param string|void $compare_val compare value. |
| 75 | * @param string $shortcode shortcode. |
| 76 | * @param string|bool $tz time zone. |
| 77 | * |
| 78 | * @return bool|void |
| 79 | */ |
| 80 | public function compare_value( $settings, $operator, $compare_val, $shortcode, $tz ) { |
| 81 | |
| 82 | if ( empty( $shortcode ) ) { |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | $return_value = do_shortcode( shortcode_unautop( $shortcode ) ); |
| 87 | |
| 88 | $condition_result = $return_value == $compare_val ? true : false; |
| 89 | |
| 90 | return Helper_Functions::get_final_result( $condition_result, $operator ); |
| 91 | } |
| 92 | } |
| 93 |