| 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_Features 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-features'; |
| 31: | } |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | public function get_title() { |
| 40: | return esc_html__( 'Feature List', 'easy-property-listings' ); |
| 41: | } |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public function get_icon() { |
| 50: | return 'eicon-bullet-list'; |
| 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', 'features', 'amenities', '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: | 'show_title', |
| 89: | array( |
| 90: | 'label' => esc_html__( 'Show Title', 'easy-property-listings' ), |
| 91: | 'description' => esc_html__( 'The features list already includes its own heading; enable this only for an additional custom title.', 'easy-property-listings' ), |
| 92: | 'type' => \Elementor\Controls_Manager::SWITCHER, |
| 93: | 'label_on' => esc_html__( 'Yes', 'easy-property-listings' ), |
| 94: | 'label_off' => esc_html__( 'No', 'easy-property-listings' ), |
| 95: | 'return_value' => 'yes', |
| 96: | 'default' => '', |
| 97: | ) |
| 98: | ); |
| 99: | |
| 100: | $this->add_control( |
| 101: | 'title_text', |
| 102: | array( |
| 103: | 'label' => esc_html__( 'Title', 'easy-property-listings' ), |
| 104: | 'type' => \Elementor\Controls_Manager::TEXT, |
| 105: | 'default' => esc_html__( 'Features', 'easy-property-listings' ), |
| 106: | 'condition' => array( |
| 107: | 'show_title' => 'yes', |
| 108: | ), |
| 109: | ) |
| 110: | ); |
| 111: | |
| 112: | $this->end_controls_section(); |
| 113: | |
| 114: | |
| 115: | $this->start_controls_section( |
| 116: | 'section_style', |
| 117: | array( |
| 118: | 'label' => esc_html__( 'Style', 'easy-property-listings' ), |
| 119: | 'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 120: | ) |
| 121: | ); |
| 122: | |
| 123: | $this->add_control( |
| 124: | 'text_color', |
| 125: | array( |
| 126: | 'label' => esc_html__( 'Color', 'easy-property-listings' ), |
| 127: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 128: | 'selectors' => array( |
| 129: | '{{WRAPPER}} .epl-property-features' => 'color: {{VALUE}};', |
| 130: | ), |
| 131: | ) |
| 132: | ); |
| 133: | |
| 134: | $this->add_group_control( |
| 135: | \Elementor\Group_Control_Typography::get_type(), |
| 136: | array( |
| 137: | 'name' => 'typography', |
| 138: | 'selector' => '{{WRAPPER}} .epl-property-features', |
| 139: | ) |
| 140: | ); |
| 141: | |
| 142: | $this->end_controls_section(); |
| 143: | } |
| 144: | |
| 145: | |
| 146: | |
| 147: | |
| 148: | |
| 149: | protected function render() { |
| 150: | $property = EPL_Elementor::setup_listing_context(); |
| 151: | $is_editor = \Elementor\Plugin::$instance->editor->is_edit_mode(); |
| 152: | |
| 153: | if ( ! $property ) { |
| 154: | if ( $is_editor ) { |
| 155: | echo '<div class="epl-elementor-placeholder">' . esc_html__( 'Property Features - No listings found.', 'easy-property-listings' ) . '</div>'; |
| 156: | } |
| 157: | EPL_Elementor::restore_listing_context(); |
| 158: | return; |
| 159: | } |
| 160: | |
| 161: | $settings = $this->get_settings_for_display(); |
| 162: | |
| 163: | echo '<div class="epl-property-features">'; |
| 164: | |
| 165: | if ( 'yes' === $settings['show_title'] && ! empty( $settings['title_text'] ) ) { |
| 166: | echo '<h5 class="epl-features-title">' . esc_html( $settings['title_text'] ) . '</h5>'; |
| 167: | } |
| 168: | |
| 169: | do_action( 'epl_property_features' ); |
| 170: | |
| 171: | echo '</div>'; |
| 172: | |
| 173: | EPL_Elementor::restore_listing_context(); |
| 174: | } |
| 175: | } |
| 176: | |