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
lang.php
74 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Language 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 Lang. |
| 20 | */ |
| 21 | class Lang extends Condition { |
| 22 | |
| 23 | /** |
| 24 | * Get Controls Options. |
| 25 | * |
| 26 | * @access public |
| 27 | * @since 4.7.0 |
| 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::SELECT2, |
| 36 | 'default' => array(), |
| 37 | 'label_block' => true, |
| 38 | 'options' => Helper_Functions::get_lang_prefixes(), |
| 39 | 'multiple' => true, |
| 40 | 'condition' => array( |
| 41 | 'pa_condition_key' => 'lang', |
| 42 | ), |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Compare Condition Value. |
| 48 | * |
| 49 | * @access public |
| 50 | * @since 4.7.0 |
| 51 | * |
| 52 | * @param array $settings element settings. |
| 53 | * @param string $operator condition operator. |
| 54 | * @param string $value condition value. |
| 55 | * @param string $compare_val compare value. |
| 56 | * @param string|bool $tz time zone. |
| 57 | * |
| 58 | * @return bool|void |
| 59 | */ |
| 60 | public function compare_value( $settings, $operator, $value, $compare_val, $tz ) { |
| 61 | |
| 62 | $current_lang = function_exists( 'get_locale' ) ? get_locale() : false; |
| 63 | |
| 64 | if ( ! $current_lang || empty( $value ) ) { |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | $condition_result = in_array( $current_lang, (array) $value, true ) ? true : false; |
| 69 | |
| 70 | return Helper_Functions::get_final_result( $condition_result, $operator ); |
| 71 | } |
| 72 | |
| 73 | } |
| 74 |