directorist_taxonomy_custom_fields_init(); /* ============================== All Listing Layout ===============================*/ // Added & Modified widgets on Builder --> All Listing Layout (Grid & List View) add_filter( 'atbdp_listing_type_settings_field_list', array( $this, 'all_listing_widgets' ) ); /* ============================== Single Page Layout ===============================*/ // Added and Modifying: Builder-> Single Page Layout -> Listing Header add_filter( 'directorist_listing_header_layout', array( $this, 'single_listing_header_layout' ) ); // Adds New Sections: Builder-> Single Page Layout-> Contents. add_filter( 'atbdp_single_listing_other_fields_widget', array( $this, 'single_listing_other_fields' ) ); // Adds New Sections: Builder-> Single Page Layout-> Contents. add_filter( 'atbdp_single_listing_content_widgets', array( $this, 'single_listing_preset_widgets' ) ); /* ========================================= Listing with Map ==========================================*/ // Listing with Map. add_filter( 'bdmv_view_as', array( $this, 'bdmv_view_as' ) ); // Listing with Map. add_filter( 'atbdp_listings_with_map_header_sort_by_button', array( $this, 'atbdp_listings_with_map_header_sort_by_button' ) ); // Map Header Title by JS. add_action( 'wp_ajax_best_listing_map_header_title', array( $this, 'wp_ajax_best_listing_map_header_title' ) ); add_action( 'wp_ajax_nopriv_best_listing_map_header_title', array( $this, 'wp_ajax_best_listing_map_header_title' ) ); // All Listings Ajax. add_action( 'wp_ajax_best_listing_archive_listings', array( $this, 'wp_ajax_nopriv_best_listing_archive_listings' ) ); add_action( 'wp_ajax_nopriv_best_listing_archive_listings', array( $this, 'wp_ajax_nopriv_best_listing_archive_listings' ) ); /* ============================== Add Listing Form ===============================*/ // Listing form present field. add_filter( 'atbdp_form_preset_widgets', array( $this, 'atbdp_form_preset_widgets' ) ); // Listing form custom field. add_filter( 'atbdp_submission_form_settings', array( $this, 'atbdp_submission_form_settings' ) ); add_action( 'directorist_before_add_listing_from_frontend', array( $this, 'directorist_before_add_listing_from_frontend' ) ); add_filter( 'atbdp_form_custom_widgets', array( $this, 'atbdp_form_custom_widgets' ) ); // Add Listing Popup Login. add_filter( 'atbdp_listing_form_login_link', array( $this, 'atbdp_listing_form_login_link' ) ); // Add Listing Popup Sign up. add_filter( 'atbdp_listing_form_signup_link', array( $this, 'atbdp_listing_form_signup_link' ) ); // Improved listing type widget in frontend add_filter( 'atbdp_listing_type_form_fields', array( $this, 'add_listing_group_field_icon' ) ); /* ============================================ Additional modifications ===============================================*/ // Contact Button Modal HTML for Single Listing. add_action( 'wp_footer', array( $this, 'contact_listing_owner_html' ), 100 ); // Modified the query $args for All Locations. add_filter( 'atbdp_all_locations_argument', array( $this, 'atbdp_all_locations_argument' ) ); // Add Title in Taxonomy Page. add_action( 'atbdp_before_all_categories_loop', array( $this, 'taxonomy_title' ) ); add_action( 'atbdp_before_all_locations_loop', array( $this, 'taxonomy_title' ) ); // Add category image size. add_action( 'atbdp_category_image_size', array( $this, 'atbdp_category_image_size' ) ); // Add location image size. add_action( 'atbdp_location_image_size', array( $this, 'atbdp_location_image_size' ) ); // Unique Classes are Added Based on Directorist Template. add_filter( 'body_class', array( $this, 'body_classes' ) ); // Enqueue scripts for Builder. add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); // Removing the 'directorist-inline-style' to prevent CSS conflict. add_filter( 'directorist_css_scripts', array( $this, 'directorist_css_scripts' ) ); // Unset Option Value. add_filter( 'directorist_option', array( $this, 'directorist_option' ), 10, 2 ); } // Initialize the class. public static function instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } public function all_listing_widgets( $fields ) { // Adds & Modified Grid & List View. foreach ( $fields as $key => $value ) { if ( 'listings_card_grid_view' === $key ) { array_push( $fields[ $key ]['card_templates']['grid_view_with_thumbnail']['layout']['thumbnail']['bottom_left']['acceptedWidgets'], 'pricing' ); if ( class_exists( 'BD_Business_Hour' ) ) { array_push( $fields[ $key ]['card_templates']['grid_view_with_thumbnail']['layout']['footer']['right']['acceptedWidgets'], 'open_close_badge' ); array_push( $fields[ $key ]['card_templates']['grid_view_without_thumbnail']['layout']['footer']['right']['acceptedWidgets'], 'open_close_badge' ); } } if ( 'listings_card_list_view' === $key ) { array_push( $fields[ $key ]['card_templates']['list_view_with_thumbnail']['layout']['footer']['right']['acceptedWidgets'], 'pricing' ); if ( class_exists( 'BD_Business_Hour' ) ) { array_push( $fields[ $key ]['card_templates']['list_view_without_thumbnail']['layout']['footer']['right']['acceptedWidgets'], 'open_close_badge' ); } } } // Adds Pricing Plan Listing Type Section Settings if ( class_exists( 'ATBDP_Pricing_Plans' ) ) { $fields['enable_onelisting_listing_type'] = array( 'label' => __( 'Show Listing Type Section at Top', 'best-listing' ), 'type' => 'toggle', 'name' => 'enable_onelisting_listing_type', 'value' => true, ); $fields['onelisting_choose_listing_type_label'] = array( 'type' => 'text', 'name' => 'general_label', 'label' => esc_html__( 'Section Title', 'best-listing' ), 'value' => esc_html__( 'Choose listing type', 'best-listing' ), ); $fields['onelisting_general_label'] = array( 'type' => 'text', 'name' => 'general_label', 'label' => esc_html__( 'General listing label', 'best-listing' ), 'value' => esc_html__( 'Regular listing', 'best-listing' ), ); $fields['onelisting_featured_label'] = array( 'type' => 'text', 'name' => 'featured_label', 'label' => esc_html__( 'Featured listing label', 'best-listing' ), 'value' => esc_html__( 'Featured listing', 'best-listing' ), ); } // Add sSimilar Listings Section at Bottom of the Single Listing Page $fields['show_similar_listings'] = array( 'type' => 'toggle', 'label' => __( 'BestListing: Similar Listings at Bottom', 'best-listing' ), 'labelType' => 'h3', 'value' => true, ); $fields['similar_listings_label'] = array( 'type' => 'text', 'name' => 'featured_label', 'label' => esc_html__( 'Section Title', 'best-listing' ), 'value' => esc_html__( 'Similar Properties', 'best-listing' ), 'show_if' => array( 'where' => 'show_similar_listings', 'conditions' => array( array( 'key' => 'value', 'compare' => '=', 'value' => true, ), ), ), ); return $fields; } // Adds and Modified: Builder-> Single Page Layout -> Listing Header. public function single_listing_header_layout( $fields ) { if ( class_exists( 'BD_Business_Hour' ) ) { $fields['widgets']['open_close_badge'] = array( 'type' => 'button', 'label' => esc_html__( 'Open/Close', 'best-listing' ), 'icon' => 'uil uil-text-fields', ); array_push( $fields['layout']['listings_header']['quick_info']['acceptedWidgets'], 'open_close_badge' ); } // Add Listing Title in General Area. $fields['card-options']['general']['listing_title'] = array( 'type' => 'title', 'label' => __( 'Listing Title', 'best-listing' ), 'options' => array( 'title' => __( 'Listing Title Settings', 'best-listing' ), 'fields' => array( 'enable_title' => array( 'type' => 'toggle', 'label' => __( 'Show Title', 'best-listing' ), 'value' => true, ), ), ), ); // Remove Unused Fields. unset( $fields['card-options']['content_settings']['listing_description'] ); unset( $fields['card-options']['content_settings']['listing_title'] ); unset( $fields['card-options']['general']['section_title'] ); unset( $fields['card-options']['general']['back'] ); unset( $fields['widgets']['listing_slider']['options'] ); return $fields; } // Adds New Sections: Builder-> Single Page Layout-> Contents. public function single_listing_other_fields( $fields ) { $fields['onelisting_description'] = array( 'type' => 'section', 'label' => esc_html__( 'Best Listing: Description', 'best-listing' ), 'icon' => 'uil uil-text-fields', 'options' => array( 'label' => array( 'type' => 'text', 'label' => esc_html__( 'Label', 'best-listing' ), 'value' => 'Description', ), 'custom_block_id' => array( 'type' => 'text', 'label' => esc_html__( 'Custom block ID', 'best-listing' ), 'value' => '', ), 'custom_block_classes' => array( 'type' => 'text', 'label' => esc_html__( 'Custom block Classes', 'best-listing' ), 'value' => '', ), ), ); return $fields; } // Adds New Sections: Builder-> Single Page Layout-> Contents. public function single_listing_preset_widgets( $fields ) { $fields['onelisting_feature_list'] = array( 'options' => array( 'icon' => array( 'type' => 'icon', 'label' => esc_html__( 'Icon', 'best-listing' ), 'value' => 'las la-list', ), ), ); return $fields; } // Contact Button Modal HTML for Single Listing. public function contact_listing_owner_html() { if ( is_singular( 'at_biz_dir' ) ) { return BestListingHelper::get_template_part( 'directorist/custom/listing-contact' ); } } // Listing with Map public function bdmv_view_as( $html ) { $html = BestListingHelper::get_template_part( 'directorist/custom/sort-map' ); $html .= BestListingHelper::get_template_part( 'directorist/custom/view-mode-map' ); return $html; } // unset Listing with Map sort by button. public function atbdp_listings_with_map_header_sort_by_button( $html ) { return; } // Map Header Title by JS. public function wp_ajax_best_listing_map_header_title() { $post_id = isset( $_POST['post_id'] ) ? wp_unslash( $_POST['post_id'] ) : get_the_ID(); // @codingStandardsIgnoreLine $js_data = isset( $_POST['form'] ) ? esc_html( $_POST['form'] ) : ''; // @codingStandardsIgnoreLine echo wp_kses_post( self::get_header_title( $post_id, $js_data ) ); wp_die(); } // All Listings Ajax. public function wp_ajax_nopriv_best_listing_archive_listings() { $type = isset( $_POST['type'] ) ? wp_unslash( $_POST['type'] ) : null; // @codingStandardsIgnoreLine $atts = isset( $_POST['atts'] ) ? $_POST['atts'] : array(); // @codingStandardsIgnoreLine $atts['directory_type'] = $type; $listings = new Directorist_Listings( $atts, 'listing' ); $listings->directory_type = $type; $view = isset( $atts['view'] ) ? sanitize_text_field( $atts['view'] ) : 'grid'; $template_file = "archive/{$view}-view"; Helper::get_template( $template_file, array( 'listings' => $listings ) ); wp_die(); } // Listing form present field. public function atbdp_form_preset_widgets( $fields ) { // Removed unused field. unset( $fields['tagline'] ); return $fields; } public function atbdp_submission_form_settings( $settings ) { // Adds Pricing Plan Listing Type Section Settings if ( class_exists( 'ATBDP_Pricing_Plans' ) ) { $settings['onelisting_listing_type'] = array( 'title' => __( 'BestListing: Pricing Plan Listing Type', 'best-listing' ), 'container' => 'short-width', 'fields' => array( 'enable_onelisting_listing_type', 'onelisting_choose_listing_type_label', 'onelisting_general_label', 'onelisting_featured_label', ), ); } return $settings; } public function directorist_before_add_listing_from_frontend() { // Add Pricing Plan Listing Type Section Markup if ( ! class_exists( 'ATBDP_Pricing_Plans' ) ) { return; } if ( strpos( $_SERVER['REQUEST_URI'], 'edit' ) ) { // @codingStandardsIgnoreLine return; } BestListingHelper::get_template_part( 'directorist/custom/add-listing_listing_type', $this->get_add_listing_settings_data( Directorist_Listing_Form::instance()->current_listing_type ) ); } // Listing form custom field. public function atbdp_form_custom_widgets( $fields ) { $custom_field_meta_key_field = apply_filters( 'directorist_custom_field_meta_key_field_args', array( 'type' => 'hidden', 'label' => esc_html__( 'Key', 'best-listing' ), 'value' => 'custom-text', 'rules' => array( 'unique' => true, 'required' => true, ), ) ); $fields['onelisting_feature_list'] = array( 'label' => 'Best Listing: Feature List', 'icon' => 'las la-list', 'options' => array( 'type' => array( 'type' => 'hidden', 'value' => 'textarea', ), 'label' => array( 'type' => 'text', 'label' => esc_html__( 'Label', 'best-listing' ), 'value' => 'Feature List', ), 'field_key' => array_merge( $custom_field_meta_key_field, array( 'value' => 'custom-feature-list', ) ), 'rows' => array( 'type' => 'number', 'label' => esc_html__( 'Rows', 'best-listing' ), 'value' => 8, ), 'placeholder' => array( 'type' => 'text', 'label' => esc_html__( 'Placeholder', 'best-listing' ), 'value' => esc_html__( 'ex: Air Conditioning', 'best-listing' ), ), 'description' => array( 'type' => 'text', 'label' => esc_html__( 'Description', 'best-listing' ), 'value' => esc_html__( 'Each new line will print a feature', 'best-listing' ), ), 'required' => array( 'type' => 'toggle', 'label' => esc_html__( 'Required', 'best-listing' ), 'value' => false, ), ), ); return $fields; } // Add Listing Popup Login. public function atbdp_listing_form_login_link() { return __( 'Here', 'best-listing' ); } // Add Listing Popup Sign up. public function atbdp_listing_form_signup_link() { return __( 'Sign Up', 'best-listing' ); } // Icon support in group fields public function add_listing_group_field_icon( $args ) { $args['groupFields']['icon'] = array( 'type' => 'text', 'label' => 'Icon', 'value' => 'las la-bars', 'placeholder' => 'icon name', ); return $args; } // Modified the query $args for All Locations. public function atbdp_all_locations_argument( $args ) { // If Locations don't have any parent. foreach ( $args as $key => $value ) { if ( 'parent' === $key ) { $args[ $key ] = ''; } } return $args; } // Add Title in Taxonomy Page. public function taxonomy_title() { if ( ! is_page() ) { return; } if ( get_the_ID() === get_directorist_option( 'all_categories_page' ) || get_the_ID() === get_directorist_option( 'single_category_page' ) || get_the_ID() === get_directorist_option( 'all_locations_page' ) || get_the_ID() === get_directorist_option( 'single_location_page' ) || get_the_ID() === get_directorist_option( 'single_tag_page' ) ) { printf( '