| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | if ( ! defined( 'ABSPATH' ) ) { |
| 11: | exit; |
| 12: | } |
| 13: | |
| 14: | |
| 15: | class EPL_Elementor_Staff_Listings extends \Elementor\Widget_Base { |
| 16: | use EPL_Elementor_Dynamic_Widget; |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | public function get_name() { |
| 24: | return 'epl-staff-listings'; |
| 25: | } |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | public function get_title() { |
| 33: | return esc_html__( 'Staff Listings', 'easy-property-listings' ); |
| 34: | } |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | public function get_icon() { |
| 42: | return 'eicon-posts-grid'; |
| 43: | } |
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | public function get_categories() { |
| 51: | return array( 'epl-staff' ); |
| 52: | } |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | public function get_keywords() { |
| 60: | return array( 'staff', 'agent', 'listings', 'properties', 'tabs', 'directory', 'epl' ); |
| 61: | } |
| 62: | |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | |
| 68: | protected function register_controls() { |
| 69: | $this->start_controls_section( |
| 70: | 'section_content', |
| 71: | array( |
| 72: | 'label' => esc_html__( 'Staff Listings', 'easy-property-listings' ), |
| 73: | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 74: | ) |
| 75: | ); |
| 76: | |
| 77: | $this->add_control( |
| 78: | 'display_mode', |
| 79: | array( |
| 80: | 'label' => esc_html__( 'Layout', 'easy-property-listings' ), |
| 81: | 'type' => \Elementor\Controls_Manager::SELECT, |
| 82: | 'default' => '', |
| 83: | 'options' => array( |
| 84: | '' => esc_html__( 'Staff Directory Setting', 'easy-property-listings' ), |
| 85: | 'list' => esc_html__( 'Combined List', 'easy-property-listings' ), |
| 86: | 'tabbed' => esc_html__( 'Tabbed', 'easy-property-listings' ), |
| 87: | 'section' => esc_html__( 'Separate Sections', 'easy-property-listings' ), |
| 88: | ), |
| 89: | ) |
| 90: | ); |
| 91: | |
| 92: | $this->add_control( |
| 93: | 'tab_style', |
| 94: | array( |
| 95: | 'label' => esc_html__( 'Tab Style', 'easy-property-listings' ), |
| 96: | 'type' => \Elementor\Controls_Manager::SELECT, |
| 97: | 'default' => '', |
| 98: | 'options' => array( |
| 99: | '' => esc_html__( 'Staff Directory Setting', 'easy-property-listings' ), |
| 100: | 'horizontal' => esc_html__( 'Horizontal', 'easy-property-listings' ), |
| 101: | 'vertical' => esc_html__( 'Vertical', 'easy-property-listings' ), |
| 102: | ), |
| 103: | 'condition' => array( 'display_mode' => array( '', 'tabbed' ) ), |
| 104: | ) |
| 105: | ); |
| 106: | |
| 107: | $this->add_control( |
| 108: | 'custom_title', |
| 109: | array( |
| 110: | 'label' => esc_html__( 'Title', 'easy-property-listings' ), |
| 111: | 'type' => \Elementor\Controls_Manager::TEXT, |
| 112: | 'placeholder' => esc_html__( 'Use Staff Directory setting', 'easy-property-listings' ), |
| 113: | 'label_block' => true, |
| 114: | ) |
| 115: | ); |
| 116: | |
| 117: | $this->end_controls_section(); |
| 118: | |
| 119: | $this->start_controls_section( |
| 120: | 'section_title_style', |
| 121: | array( |
| 122: | 'label' => esc_html__( 'Headings', 'easy-property-listings' ), |
| 123: | 'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 124: | ) |
| 125: | ); |
| 126: | $this->add_control( |
| 127: | 'title_color', |
| 128: | array( |
| 129: | 'label' => esc_html__( 'Color', 'easy-property-listings' ), |
| 130: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 131: | 'selectors' => array( '{{WRAPPER}} .epl-sd-section-title, {{WRAPPER}} .epl-section__title' => 'color: {{VALUE}};' ), |
| 132: | ) |
| 133: | ); |
| 134: | $this->add_group_control( |
| 135: | \Elementor\Group_Control_Typography::get_type(), |
| 136: | array( |
| 137: | 'name' => 'title_typography', |
| 138: | 'selector' => '{{WRAPPER}} .epl-sd-section-title, {{WRAPPER}} .epl-section__title', |
| 139: | ) |
| 140: | ); |
| 141: | $this->end_controls_section(); |
| 142: | |
| 143: | $this->start_controls_section( |
| 144: | 'section_tabs_style', |
| 145: | array( |
| 146: | 'label' => esc_html__( 'Tabs', 'easy-property-listings' ), |
| 147: | 'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 148: | ) |
| 149: | ); |
| 150: | $this->add_control( |
| 151: | 'tab_text_color', |
| 152: | array( |
| 153: | 'label' => esc_html__( 'Text Color', 'easy-property-listings' ), |
| 154: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 155: | 'selectors' => array( '{{WRAPPER}} [class*="epl-sd-tabs-"] > ul a' => 'color: {{VALUE}};' ), |
| 156: | ) |
| 157: | ); |
| 158: | $this->add_control( |
| 159: | 'tab_background', |
| 160: | array( |
| 161: | 'label' => esc_html__( 'Background', 'easy-property-listings' ), |
| 162: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 163: | 'selectors' => array( '{{WRAPPER}} [class*="epl-sd-tabs-"] > ul a' => 'background-color: {{VALUE}};' ), |
| 164: | ) |
| 165: | ); |
| 166: | $this->add_control( |
| 167: | 'tab_active_color', |
| 168: | array( |
| 169: | 'label' => esc_html__( 'Active Text Color', 'easy-property-listings' ), |
| 170: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 171: | 'selectors' => array( '{{WRAPPER}} [class*="epl-sd-tabs-"] > ul .ui-tabs-active a' => 'color: {{VALUE}};' ), |
| 172: | ) |
| 173: | ); |
| 174: | $this->add_control( |
| 175: | 'tab_active_background', |
| 176: | array( |
| 177: | 'label' => esc_html__( 'Active Background', 'easy-property-listings' ), |
| 178: | 'type' => \Elementor\Controls_Manager::COLOR, |
| 179: | 'selectors' => array( '{{WRAPPER}} [class*="epl-sd-tabs-"] > ul .ui-tabs-active a' => 'background-color: {{VALUE}};' ), |
| 180: | ) |
| 181: | ); |
| 182: | $this->end_controls_section(); |
| 183: | } |
| 184: | |
| 185: | |
| 186: | |
| 187: | |
| 188: | |
| 189: | |
| 190: | protected function render() { |
| 191: | if ( ! class_exists( 'EPL_SD_Listings' ) ) { |
| 192: | $this->render_placeholder( esc_html__( 'The EPL Staff Directory extension is required.', 'easy-property-listings' ) ); |
| 193: | return; |
| 194: | } |
| 195: | |
| 196: | global $epl_author; |
| 197: | $property = EPL_Elementor::setup_listing_context(); |
| 198: | $author = $property ? EPL_Elementor::get_listing_agent( $property ) : null; |
| 199: | |
| 200: | if ( ! $author ) { |
| 201: | EPL_Elementor::restore_listing_context(); |
| 202: | $this->render_placeholder( esc_html__( 'Select a staff member as the preview context.', 'easy-property-listings' ) ); |
| 203: | return; |
| 204: | } |
| 205: | |
| 206: | $settings = $this->get_settings_for_display(); |
| 207: | $epl_author = $author; |
| 208: | $title = isset( $settings['custom_title'] ) ? trim( (string) $settings['custom_title'] ) : ''; |
| 209: | $filter = static function ( $existing ) use ( $title ) { |
| 210: | return '' !== $title ? $title : $existing; |
| 211: | }; |
| 212: | |
| 213: | if ( '' !== $title ) { |
| 214: | add_filter( 'epl_sd_single_listing_title', $filter ); |
| 215: | } |
| 216: | |
| 217: | echo '<div class="epl-elementor-staff-listings">'; |
| 218: | EPL_SD_Listings::instance()->render_single_staff_listings( $settings['display_mode'], $settings['tab_style'] ); |
| 219: | echo '</div>'; |
| 220: | |
| 221: | if ( '' !== $title ) { |
| 222: | remove_filter( 'epl_sd_single_listing_title', $filter ); |
| 223: | } |
| 224: | EPL_Elementor::restore_listing_context(); |
| 225: | } |
| 226: | |
| 227: | |
| 228: | |
| 229: | |
| 230: | |
| 231: | |
| 232: | private function render_placeholder( $message ) { |
| 233: | if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { |
| 234: | echo '<div class="epl-elementor-placeholder">' . esc_html( $message ) . '</div>'; |
| 235: | } |
| 236: | } |
| 237: | } |
| 238: | |