| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | if ( ! defined( 'ABSPATH' ) ) { |
| 12: | exit; |
| 13: | } |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | class EPL_Elementor_Property_Price extends \Elementor\Widget_Base { |
| 21: | use EPL_Elementor_Dynamic_Widget; |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public function get_name() { |
| 30: | return 'epl-property-price'; |
| 31: | } |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public function get_title() { |
| 40: | return esc_html__( 'Price', 'easy-property-listings' ); |
| 41: | } |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public function get_icon() { |
| 50: | return 'eicon-product-price'; |
| 51: | } |
| 52: | |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public function get_categories() { |
| 60: | return array( 'epl-elements' ); |
| 61: | } |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | public function get_keywords() { |
| 70: | return array( 'property', 'price', 'cost', 'rent', 'epl' ); |
| 71: | } |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | protected function register_controls() { |
| 78: | |
| 79: | $this->start_controls_section( |
| 80: | 'section_content', |
| 81: | array( |
| 82: | 'label' => esc_html__( 'Content', 'easy-property-listings' ), |
| 83: | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 84: | ) |
| 85: | ); |
| 86: | |
| 87: | $this->add_control( |
| 88: | 'price_prefix', |
| 89: | array( |
| 90: | 'label' => esc_html__( 'Price Prefix', 'easy-property-listings' ), |
| 91: | 'type' => \Elementor\Controls_Manager::TEXT, |
| 92: | 'default' => '', |
| 93: | 'placeholder' => esc_html__( 'e.g., From', 'easy-property-listings' ), |
| 94: | ) |
| 95: | ); |
| 96: | |
| 97: | $this->end_controls_section(); |
| 98: | |
| 99: | |
| 100: | $this->start_controls_section( |
| 101: | 'section_style', |
| 102: | array( |
| 103: | 'label' => esc_html__( 'Style', 'easy-property-listings' ), |
| 104: | 'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 105: | ) |
| 106: | ); |
| 107: | |
| 108: | $this->add_control( |
| 109: | 'price_color', |
| 110: | array( |
| 111: | 'label' => esc_html__( 'Price Color', 'easy-property-listings' ), |
| 112: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 113: | 'selectors' => array( |
| 114: | '{{WRAPPER}} .epl-property-price' => 'color: {{VALUE}};', |
| 115: | ), |
| 116: | ) |
| 117: | ); |
| 118: | |
| 119: | $this->add_group_control( |
| 120: | \Elementor\Group_Control_Typography::get_type(), |
| 121: | array( |
| 122: | 'name' => 'typography', |
| 123: | 'selector' => '{{WRAPPER}} .epl-property-price', |
| 124: | ) |
| 125: | ); |
| 126: | |
| 127: | $this->add_responsive_control( |
| 128: | 'text_align', |
| 129: | array( |
| 130: | 'label' => esc_html__( 'Alignment', 'easy-property-listings' ), |
| 131: | 'type' => \Elementor\Controls_Manager::CHOOSE, |
| 132: | 'options' => array( |
| 133: | 'left' => array( |
| 134: | 'title' => esc_html__( 'Left', 'easy-property-listings' ), |
| 135: | 'icon' => 'eicon-text-align-left', |
| 136: | ), |
| 137: | 'center' => array( |
| 138: | 'title' => esc_html__( 'Center', 'easy-property-listings' ), |
| 139: | 'icon' => 'eicon-text-align-center', |
| 140: | ), |
| 141: | 'right' => array( |
| 142: | 'title' => esc_html__( 'Right', 'easy-property-listings' ), |
| 143: | 'icon' => 'eicon-text-align-right', |
| 144: | ), |
| 145: | ), |
| 146: | 'selectors' => array( |
| 147: | '{{WRAPPER}} .epl-property-price' => 'text-align: {{VALUE}};', |
| 148: | ), |
| 149: | ) |
| 150: | ); |
| 151: | |
| 152: | $this->end_controls_section(); |
| 153: | } |
| 154: | |
| 155: | |
| 156: | |
| 157: | |
| 158: | |
| 159: | protected function render() { |
| 160: | $property = EPL_Elementor::setup_listing_context(); |
| 161: | $is_editor = \Elementor\Plugin::$instance->editor->is_edit_mode(); |
| 162: | |
| 163: | if ( ! $property ) { |
| 164: | if ( $is_editor ) { |
| 165: | echo '<div class="epl-elementor-placeholder">' . esc_html__( 'Property Price - No listings found.', 'easy-property-listings' ) . '</div>'; |
| 166: | } |
| 167: | EPL_Elementor::restore_listing_context(); |
| 168: | return; |
| 169: | } |
| 170: | |
| 171: | $settings = $this->get_settings_for_display(); |
| 172: | |
| 173: | |
| 174: | |
| 175: | ob_start(); |
| 176: | do_action( 'epl_property_price' ); |
| 177: | $price_html = ob_get_clean(); |
| 178: | |
| 179: | if ( '' === trim( $price_html ) ) { |
| 180: | EPL_Elementor::restore_listing_context(); |
| 181: | return; |
| 182: | } |
| 183: | |
| 184: | echo '<div class="epl-property-price">'; |
| 185: | |
| 186: | if ( ! empty( $settings['price_prefix'] ) ) { |
| 187: | echo '<span class="epl-price-prefix">' . esc_html( $settings['price_prefix'] ) . ' </span>'; |
| 188: | } |
| 189: | |
| 190: | echo $price_html; |
| 191: | |
| 192: | echo '</div>'; |
| 193: | |
| 194: | EPL_Elementor::restore_listing_context(); |
| 195: | } |
| 196: | } |
| 197: | |