array( 'label' => __( 'General', 'nodebook' ), 'noun' => __( 'page', 'nodebook' ), 'interests' => __( 'Interests', 'nodebook' ), 'demand' => __( 'Most viewed by known contacts', 'nodebook' ), /* translators: %s: the item someone asked about */ 'inquiry' => __( 'Inquiry about %s', 'nodebook' ), /* translators: 1: first name, 2: what they looked at */ 'followup' => __( 'Hi %1$s, thanks for your interest in %2$s. Do you have any questions I can help with?', 'nodebook' ), 'intent' => array( '/pricing*', '/prices*', '/contact*', '/book*', '/quote*', '/demo*', '/cart*', '/checkout*' ), ), 'shop' => array( 'label' => __( 'Online shop', 'nodebook' ), 'noun' => __( 'product', 'nodebook' ), 'interests' => __( 'Products viewed', 'nodebook' ), 'demand' => __( 'Products in demand', 'nodebook' ), /* translators: %s: the item someone asked about */ 'inquiry' => __( 'Question about %s', 'nodebook' ), /* translators: 1: first name, 2: what they looked at */ 'followup' => __( 'Hi %1$s, I saw you were looking at %2$s. Can I help you choose, or answer any questions?', 'nodebook' ), 'intent' => array( '/cart*', '/checkout*', '/carrito*', '/finalizar-compra*', '/winkelwagen*', '/afrekenen*', '/contact*', '/contacto*' ), ), 'rentals' => array( 'label' => __( 'Vacation rentals', 'nodebook' ), 'noun' => __( 'property', 'nodebook' ), 'interests' => __( 'Properties and dates they checked', 'nodebook' ), 'demand' => __( 'Properties in demand', 'nodebook' ), /* translators: %s: the item someone asked about */ 'inquiry' => __( 'Inquiry about %s', 'nodebook' ), /* translators: 1: first name, 2: what they looked at */ 'followup' => __( 'Hi %1$s, I saw you were looking at %2$s. Shall I check availability for your dates?', 'nodebook' ), 'intent' => array( '/book*', '/reserve*', '/availability*', '/search-results*', '/checkout*', '/contact*', '/rates*' ), ), 'realestate' => array( 'label' => __( 'Real estate', 'nodebook' ), 'noun' => __( 'listing', 'nodebook' ), 'interests' => __( 'Listings viewed', 'nodebook' ), 'demand' => __( 'Listings in demand', 'nodebook' ), /* translators: %s: the item someone asked about */ 'inquiry' => __( 'Viewing request: %s', 'nodebook' ), /* translators: 1: first name, 2: what they looked at */ 'followup' => __( 'Hi %1$s, I saw you were looking at %2$s. Would you like to schedule a viewing?', 'nodebook' ), 'intent' => array( '/schedule*', '/viewing*', '/tour*', '/mortgage*', '/contact*', '/sell*', '/valuation*' ), ), 'services' => array( 'label' => __( 'Services, clinics & med spas', 'nodebook' ), 'noun' => __( 'treatment', 'nodebook' ), 'interests' => __( 'Treatments and services viewed', 'nodebook' ), 'demand' => __( 'Treatments in demand', 'nodebook' ), /* translators: %s: the item someone asked about */ 'inquiry' => __( 'Question about %s', 'nodebook' ), /* translators: 1: first name, 2: what they looked at */ 'followup' => __( 'Hi %1$s, I saw you were reading about %2$s. Would you like me to find you an appointment?', 'nodebook' ), 'intent' => array( '/book*', '/appointment*', '/pricing*', '/prices*', '/consult*', '/contact*', '/financing*' ), ), 'retreats' => array( 'label' => __( 'Retreats & gatherings', 'nodebook' ), 'noun' => __( 'retreat', 'nodebook' ), 'interests' => __( 'Retreats and pages viewed', 'nodebook' ), 'demand' => __( 'Retreats in demand', 'nodebook' ), /* translators: %s: the item someone asked about */ 'inquiry' => __( 'Question about %s', 'nodebook' ), /* translators: 1: first name, 2: what they looked at */ 'followup' => __( 'Hi %1$s, thanks for your interest in %2$s. Would a short call help to see if it is the right fit for you?', 'nodebook' ), 'intent' => array( '/apply*', '/application*', '/register*', '/registration*', '/book*', '/reserve*', '/retreat*', '/program*', '/itinerary*', '/pricing*', '/contact*' ), ), 'b2b' => array( 'label' => __( 'B2B & industrial', 'nodebook' ), 'noun' => __( 'product', 'nodebook' ), 'interests' => __( 'Products and specs viewed', 'nodebook' ), 'demand' => __( 'Products in demand', 'nodebook' ), /* translators: %s: the item someone asked about */ 'inquiry' => __( 'Quote request: %s', 'nodebook' ), /* translators: 1: first name, 2: what they looked at */ 'followup' => __( 'Hi %1$s, I saw your team was looking at %2$s. Can I send you a quote or answer any technical questions?', 'nodebook' ), 'intent' => array( '/quote*', '/request*', '/contact*', '/distributor*', '/dealer*', '/pricing*', '/datasheet*', '/downloads*' ), ), ) ); } public static function current() { static $detected = null; $key = (string) Nodebook_Settings::get( 'niche' ); $all = self::all(); if ( isset( $all[ $key ] ) ) { return $key; } if ( null === $detected ) { $detected = self::detect(); } return $detected; } public static function get( $field ) { $n = self::all()[ self::current() ]; return isset( $n[ $field ] ) ? $n[ $field ] : ''; } /** Best guess from what is installed. */ public static function detect() { if ( function_exists( 'post_type_exists' ) ) { if ( post_type_exists( 'mphb_room_type' ) ) { return 'rentals'; } foreach ( array( 'property', 'properties', 'estate_property', 'listing', 'es_property' ) as $pt ) { if ( post_type_exists( $pt ) ) { return 'realestate'; } } } if ( defined( 'LATEPOINT_VERSION' ) || defined( 'AMELIA_VERSION' ) || function_exists( 'ssa' ) || class_exists( '\Bookly\Lib\Plugin' ) ) { return 'services'; } if ( class_exists( 'WooCommerce' ) ) { return 'shop'; } return 'general'; } /** * A few key facts about an item for the profile and reports (price, bedrooms, city…). * Works with Houzez, RealHomes, Estatik, MotoPress and WooCommerce through generic meta matching. * * @return array label => value (max 4) */ public static function attributes( $post_id ) { $post_id = absint( $post_id ); $out = array(); if ( ! $post_id || ! get_post( $post_id ) ) { return $out; } if ( function_exists( 'wc_get_product' ) && 'product' === get_post_type( $post_id ) ) { $p = wc_get_product( $post_id ); if ( $p && '' !== (string) $p->get_price() ) { $out[ __( 'Price', 'nodebook' ) ] = wp_strip_all_tags( wc_price( (float) $p->get_price() ) ); } return apply_filters( 'nodebook_item_attributes', $out, $post_id ); } $patterns = array( __( 'Price', 'nodebook' ) => '/(^|_)(sale_)?price$|_property_price$|^price$/i', __( 'Bedrooms', 'nodebook' ) => '/bed(room)?s?$/i', __( 'Bathrooms', 'nodebook' ) => '/bath(room)?s?$/i', __( 'Size', 'nodebook' ) => '/(_size|_area|sqft|_m2|land_size)$/i', __( 'Guests', 'nodebook' ) => '/(adults(_capacity)?|max_guests|guests|capacity)$/i', ); foreach ( (array) get_post_meta( $post_id ) as $key => $values ) { if ( '_' === $key[0] && ! preg_match( '/^_price$/', $key ) ) { continue; } $v = is_array( $values ) ? reset( $values ) : $values; if ( ! is_scalar( $v ) || '' === trim( (string) $v ) || strlen( (string) $v ) > 40 ) { continue; } foreach ( $patterns as $label => $re ) { if ( ! isset( $out[ $label ] ) && preg_match( $re, $key ) ) { $out[ $label ] = is_numeric( $v ) ? number_format_i18n( (float) $v, floor( (float) $v ) === (float) $v ? 0 : 2 ) : sanitize_text_field( (string) $v ); } } } foreach ( get_object_taxonomies( get_post_type( $post_id ) ) as $tax ) { if ( count( $out ) >= 4 ) { break; } if ( preg_match( '/city|location|area|region|neighbou?rhood/i', $tax ) ) { $terms = get_the_terms( $post_id, $tax ); if ( $terms && ! is_wp_error( $terms ) ) { $out[ __( 'Location', 'nodebook' ) ] = $terms[0]->name; } } } return apply_filters( 'nodebook_item_attributes', array_slice( $out, 0, 4, true ), $post_id ); } }