/**
  * Register core post types
  */
 public static function register_post_types()
 {
     if (post_type_exists('property')) {
         return;
     }
     do_action('propertyhive_register_post_type');
     //$permalinks        = get_option( 'property_permalinks' );
     //$product_permalink = empty( $permalinks['property_base'] ) ? _x( 'property', 'slug', 'propertyhive' ) : $permalinks['property_base'];
     register_post_type("property", apply_filters('propertyhive_register_post_type_property', array('labels' => array('name' => __('Properties', 'propertyhive'), 'singular_name' => __('Property', 'propertyhive'), 'menu_name' => _x('Properties', 'Admin menu name', 'propertyhive'), 'add_new' => __('Add Property', 'propertyhive'), 'add_new_item' => __('Add New Property', 'propertyhive'), 'edit' => __('Edit', 'propertyhive'), 'edit_item' => __('Edit Property', 'propertyhive'), 'new_item' => __('New Property', 'propertyhive'), 'view' => __('View Property', 'propertyhive'), 'view_item' => __('View Property', 'propertyhive'), 'search_items' => __('Search Properties', 'propertyhive'), 'not_found' => __('No properties found', 'propertyhive'), 'not_found_in_trash' => __('No properties found in trash', 'propertyhive'), 'parent' => __('Parent Property', 'propertyhive')), 'description' => __('This is where you can add new properties to your site.', 'propertyhive'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title', 'excerpt'), 'has_archive' => ($search_results_page_id = ph_get_page_id('search_results')) && get_page($search_results_page_id) ? get_page_uri($search_results_page_id) : 'search_results', 'show_in_nav_menus' => false, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'show_in_rest' => true)));
     register_post_type("contact", apply_filters('propertyhive_register_post_type_contact', array('labels' => array('name' => __('Contacts', 'propertyhive'), 'singular_name' => __('Contact', 'propertyhive'), 'menu_name' => _x('Contacts', 'Admin menu name', 'propertyhive'), 'add_new' => __('Add Contact', 'propertyhive'), 'add_new_item' => __('Add New Contact', 'propertyhive'), 'edit' => __('Edit', 'propertyhive'), 'edit_item' => __('Edit Contact', 'propertyhive'), 'new_item' => __('New Contact', 'propertyhive'), 'view' => __('View Contact', 'propertyhive'), 'view_item' => __('View Contact', 'propertyhive'), 'search_items' => __('Search Contacts', 'propertyhive'), 'not_found' => __('No contacts found', 'propertyhive'), 'not_found_in_trash' => __('No contacts found in trash', 'propertyhive'), 'parent' => __('Parent Contact', 'propertyhive')), 'description' => __('This is where you can add new contacts to your site.', 'propertyhive'), 'public' => false, 'show_ui' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title'), 'show_in_nav_menus' => false, 'show_in_menu' => false)));
     register_post_type("office", apply_filters('propertyhive_register_post_type_office', array('public' => true, 'show_ui' => false, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title'), 'show_in_nav_menus' => false, 'show_in_menu' => false)));
     register_post_type("enquiry", apply_filters('propertyhive_register_post_type_enquiry', array('labels' => array('name' => __('Enquiries', 'propertyhive'), 'singular_name' => __('Enquiry', 'propertyhive'), 'menu_name' => _x('Enquiries', 'Admin menu name', 'propertyhive'), 'add_new' => __('Add Enquiry', 'propertyhive'), 'add_new_item' => __('Add New Enquiry', 'propertyhive'), 'edit' => __('Edit', 'propertyhive'), 'edit_item' => __('Edit Enquiry', 'propertyhive'), 'new_item' => __('New Enquiry', 'propertyhive'), 'view' => __('View Enquiry', 'propertyhive'), 'view_item' => __('View Enquiry', 'propertyhive'), 'search_items' => __('Search Enquiries', 'propertyhive'), 'not_found' => __('No enquiries found', 'propertyhive'), 'not_found_in_trash' => __('No enquiries found in trash', 'propertyhive'), 'parent' => __('Parent Enquiry', 'propertyhive')), 'public' => false, 'show_ui' => true, 'capability_type' => 'post', 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'hierarchical' => false, 'query_var' => true, 'supports' => array('title'), 'show_in_nav_menus' => false, 'show_in_menu' => false)));
     do_action('propertyhive_after_register_post_types');
 }
/**
 * Fix active class in wp_list_pages for search results page.
 *
 * @param string $pages
 * @return string
 */
function ph_list_pages($pages)
{
    if (is_propertyhive()) {
        // Remove current_page_parent class from any item.
        $pages = str_replace('current_page_parent', '', $pages);
        // Find search_results_page_id through Property Hive options.
        $search_results_page = 'page-item-' . ph_get_page_id('search_results');
        if (is_search_results()) {
            // Add current_page_item class to search results page.
            $pages = str_replace($search_results_page, $search_results_page . ' current_page_item', $pages);
        } else {
            // Add current_page_parent class to search results page.
            $pages = str_replace($search_results_page, $search_results_page . ' current_page_parent', $pages);
        }
    }
    return $pages;
}
 /**
  * Load a template.
  *
  * Handles template usage so that we can use our own templates instead of the themes.
  *
  * Templates are in the 'templates' folder. propertyhive looks for theme
  * overrides in /theme/propertyhive/ by default
  *
  * For beginners, it also looks for a propertyhive.php template first. If the user adds
  * this to the theme (containing a propertyhive() inside) this will be used for all
  * propertyhive templates.
  *
  * @param mixed $template
  * @return string
  */
 public function template_loader($template)
 {
     $find = array('propertyhive.php');
     $file = '';
     if (is_single() && get_post_type() == 'property') {
         $file = 'single-property.php';
         $find[] = $file;
         $find[] = PH_TEMPLATE_PATH . $file;
     } elseif (is_post_type_archive('property') || is_page(ph_get_page_id('search_results'))) {
         $file = 'archive-property.php';
         $find[] = $file;
         $find[] = PH_TEMPLATE_PATH . $file;
     }
     if ($file) {
         $template = locate_template(array_unique($find));
         $status_options = get_option('propertyhive_status_options', array());
         if (!$template || !empty($status_options['template_debug_mode']) && current_user_can('manage_options')) {
             $template = PH()->plugin_path() . '/templates/' . $file;
         }
     }
     return $template;
 }
 /**
  * is_search_results - Returns true when viewing the property archive (search results).
  *
  * @access public
  * @return bool
  */
 function is_search_results()
 {
     return is_post_type_archive('property') || is_page(ph_get_page_id('search_results')) ? true : false;
 }
 /**
  * propertyhive_page_title function.
  *
  * @param  boolean $echo
  * @return string
  */
 function propertyhive_page_title($echo = true)
 {
     if (is_search()) {
         $page_title = sprintf(__('Search Results: “%s”', 'propertyhive'), get_search_query());
         if (get_query_var('paged')) {
             $page_title .= sprintf(__(' – Page %s', 'propertyhive'), get_query_var('paged'));
         }
     } elseif (is_tax()) {
         $page_title = single_term_title("", false);
     } else {
         $search_results_page_id = ph_get_page_id('search_results');
         $page_title = get_the_title($search_results_page_id);
     }
     $page_title = apply_filters('propertyhive_page_title', $page_title);
     if ($echo) {
         echo $page_title;
     } else {
         return $page_title;
     }
 }
 /**
  * Install Property Hive
  */
 public function install()
 {
     $this->create_options();
     $this->create_tables();
     $this->create_roles();
     // Register post types
     include_once 'class-ph-post-types.php';
     PH_Post_types::register_post_types();
     PH_Post_types::register_taxonomies();
     // Also register endpoints - this needs to be done prior to rewrite rule flush
     /*PH()->query->init_query_vars();
     		PH()->query->add_endpoints();*/
     $this->create_terms();
     $this->create_primary_office();
     $this->create_cron_jobs();
     /*$this->create_files();
     		$this->create_css_from_less();
     
     		// Clear transient cache
     		ph_delete_property_transients();
     		ph_delete_contact_transients();
     		ph_delete_enquiry_transients();*/
     // Queue upgrades
     $current_version = get_option('propertyhive_version', null);
     $current_db_version = get_option('propertyhive_db_version', null);
     update_option('propertyhive_db_version', PH()->version);
     // Check if pages are needed
     if (ph_get_page_id('search_results') < 1) {
         update_option('_ph_needs_pages', 1);
     }
     // Update version
     update_option('propertyhive_version', PH()->version);
     // Flush rules after install
     flush_rewrite_rules();
     // Redirect to welcome screen
     set_transient('_ph_activation_redirect', 1, 60 * 60);
 }
 /**
  * wpseo_metakey function.
  * Hooked into wpseo_ hook already, so no need for function_exist
  *
  * @access public
  * @return string
  */
 public function wpseo_metakey()
 {
     return WPSEO_Meta::get_value('metakey', ph_get_page_id('search_results'));
 }