function load_textdomain() { $locale = apply_filters('staypress_locale', get_locale()); $mofile = SPPCommon::property_dir("includes/lang/property-{$locale}.mo"); if (file_exists($mofile)) { load_textdomain('property', $mofile); } }
function do_propertylist_shortcode($atts, $content = null, $code = "") { /* // List shortcode helpers */ global $wp_query, $post; $defaults = array("show" => '25', "page" => 'wp_query', "holder" => '', "holderclass" => '', "item" => '', "itemclass" => '', "postfix" => '', "prefix" => '', "wrapwith" => '', "wrapwithclass" => '', "showpagination" => 'yes', "paginationholder" => 'div', "paginationclass" => 'pagination'); extract(shortcode_atts($defaults, $atts)); $html = ''; if ($page == 'wp_query') { $page = $wp_query->query_vars['type']; } // Backup the original wp_query and post $backup_query = $wp_query; $backup_post = $post; $wp_query = new WP_Query(); $wp_query->query_vars['post_type'] = 'property'; $wp_query->query_vars['orderby'] = 'post_modified'; $wp_query->query_vars['order'] = 'DESC'; $wp_query->query_vars['paged'] = $backup_query->query_vars['paged']; switch ($page) { case 'list': $wp_query->query_vars['post_status'] = 'publish'; $positive_ids = array(); $negative_ids = array(); $positive_ids = apply_filters('staypress_process_list_positive', $positive_ids, $backup_query); $negative_ids = apply_filters('staypress_process_list_negative', $negative_ids, $backup_query); $positive_ids = array_diff($positive_ids, $negative_ids); $wp_query->query_vars['posts_per_page'] = STAYPRESS_PROPERTY_PER_PAGE; $wp_query->query_vars['post__in'] = $positive_ids; // reset incorrectly set wp_query variables $wp_query->is_singular = false; $wp_query->is_home = false; $wp_query->is_archive = true; add_action('the_posts', array(&$this, 'unset_single_flag'), 999); break; case 'tag': global $sp_tags; $wp_query->query_vars['post_status'] = 'publish'; $wp_query->query_vars['posts_per_page'] = STAYPRESS_PROPERTY_PER_PAGE; $tag = $backup_query->query_vars['with']; if (!empty($tag)) { $sp_tags = explode('/', $tag); $positive_ids = $this->property->get_properties_with_tags($sp_tags); $wp_query->query_vars['tag'] = ''; } $positive_ids = apply_filters('staypress_process_tag_positive', $positive_ids, $backup_query); $negative_ids = apply_filters('staypress_process_tag_negative', array(), $backup_query); $positive_ids = array_diff($positive_ids, $negative_ids); if (empty($positive_ids)) { $positive_ids = array(0); } $wp_query->query_vars['post__in'] = $positive_ids; // reset incorrectly set wp_query variables $wp_query->is_singular = false; $wp_query->is_home = false; $wp_query->is_archive = true; $wp_query->is_category = false; $wp_query->is_tag = false; $wp_query->is_tax = false; add_action('the_posts', array(&$this, 'unset_single_flag'), 999); break; case 'dest': $wp_query->query_vars['post_status'] = 'publish'; $wp_query->query_vars['posts_per_page'] = STAYPRESS_PROPERTY_PER_PAGE; if (!empty($backup_query->query_vars['name'])) { unset($wp_query->query_vars['name']); } $this->locations = explode('/', $backup_query->query_vars['dest']); switch (count($this->locations)) { case 1: // country $positive_ids = $this->property->get_country_ids($this->locations[0]); break; case 2: // region $positive_ids = $this->property->get_region_ids($this->locations[0], $this->locations[1]); break; case 3: // town $positive_ids = $this->property->get_town_ids($this->locations[0], $this->locations[1], $this->locations[2]); break; } $positive_ids = apply_filters('staypress_process_dest_positive', $positive_ids, $backup_query); $negative_ids = apply_filters('staypress_process_dest_negative', array(), $backup_query); $positive_ids = array_diff($positive_ids, $negative_ids); if (empty($positive_ids)) { $positive_ids = array(0); } $wp_query->query_vars['post__in'] = $positive_ids; // reset incorrectly set wp_query variables $wp_query->is_singular = false; $wp_query->is_home = false; $wp_query->is_archive = true; add_action('the_posts', array(&$this, 'unset_single_flag'), 999); break; case 'near': $wp_query->query_vars['post_status'] = 'publish'; $wp_query->query_vars['posts_per_page'] = STAYPRESS_PROPERTY_PER_PAGE; if (isset($_GET['radius'])) { $radius = (int) $_GET['radius']; } else { $radius = 100; } //$wp_query->query_vars['paged'] = $this->paged; // Need to add in a bounds calculation to these two following functions $near = $backup_query->query_vars['near']; if (strpos($near, ',') === false) { // we want properties near an id $near = (int) $near; if (!defined('STAYPRESS_ON_PROPERTY_NEAR')) { define('STAYPRESS_ON_PROPERTY_NEAR', $near); } $nearby = $this->get_properties_near_property($near, $radius, STAYPRESS_PROPERTY_PER_PAGE); } else { // we want properties near a location $near = explode(',', $near); if (count($near) >= 2) { $nearby = $this->get_properties_near($near[0], $near[1], $radius, STAYPRESS_PROPERTY_PER_PAGE); } else { $nearby = array(); } } $positive_ids = array(); if (!empty($nearby)) { foreach ($nearby as $key => $property) { if ($property->post_id != $near) { // we don't want our current property listed $positive_ids[] = $property->post_id; } } } $positive_ids = apply_filters('staypress_process_near_positive', $positive_ids, $backup_query); $negative_ids = apply_filters('staypress_process_near_negative', array(), $backup_query); $positive_ids = array_diff($positive_ids, $negative_ids); if (empty($positive_ids)) { $positive_ids = array(0); } $wp_query->query_vars['post__in'] = $positive_ids; // reset incorrectly set wp_query variables $wp_query->is_singular = false; $wp_query->is_home = false; $wp_query->is_archive = true; add_action('the_posts', array(&$this, 'unset_single_flag'), 999); break; case 'available': $wp_query->query_vars['post_status'] = 'publish'; $wp_query->query_vars['posts_per_page'] = STAYPRESS_PROPERTY_PER_PAGE; $negative_ids = apply_filters('staypress_process_unavailable_properties', $backup_query); if (empty($negative_ids)) { $negative_ids = array(0); } $wp_query->query_vars['post__not_in'] = $negative_ids; // reset incorrectly set wp_query variables $wp_query->is_singular = false; $wp_query->is_home = false; $wp_query->is_archive = true; add_action('the_posts', array(&$this, 'unset_single_flag'), 999); break; case 'search': //echo "<pre>"; //print_r($backup_query); //echo "</pre>"; $searchfrom = addslashes($_REQUEST['searchmadeby']); $wp_query->query_vars['post_status'] = 'publish'; // default is no results $positive_ids = array(0); $negative_ids = array(0); if (has_filter('staypress_process_full_search_positive')) { $positive_ids = apply_filters('staypress_process_full_search_positive', $positive_ids, $backup_query); $negative_ids = apply_filters('staypress_process_full_search_negative', $negative_ids, $backup_query); } elseif (has_filter('staypress_process_' . $searchfrom . '_search_positive')) { $positive_ids = apply_filters('staypress_process_' . $searchfrom . '_search_positive', $positive_ids, $backup_query); $negative_ids = apply_filters('staypress_process_' . $searchfrom . '_search_negative', $negative_ids, $backup_query); } else { $positive_ids = apply_filters('staypress_process_search_positive', $positive_ids, $backup_query); $negative_ids = apply_filters('staypress_process_search_negative', $negative_ids, $backup_query); } $positive_ids = array_diff((array) $positive_ids, (array) $negative_ids); if (empty($positive_ids)) { $positive_ids = array(0); } $wp_query->query_vars['posts_per_page'] = STAYPRESS_PROPERTY_PER_PAGE; $wp_query->query_vars['post__in'] = $positive_ids; // reset incorrectly set wp_query variables $wp_query->is_singular = false; $wp_query->is_home = false; $wp_query->is_search = true; add_action('the_posts', array(&$this, 'unset_single_flag'), 999); break; case 'map': $wp_query->query_vars['post_status'] = 'publish'; break; default: // Everything else $wp_query->query_vars['post_status'] = 'publish'; $wp_query->query_vars['posts_per_page'] = STAYPRESS_PROPERTY_PER_PAGE; do_action('staypress_process_page_type_' . $wp_query->query_vars['type'], $backup_query); add_action('the_posts', array(&$this, 'unset_single_flag'), 999); break; } $wp_query->get_posts(); if (have_posts()) { // Get the template if (empty($content) && file_exists(apply_filters('staypress_propertylist_template', SPPCommon::property_dir('includes/propertylist.template.php')))) { ob_start(); include_once apply_filters('staypress_propertylist_template', SPPCommon::property_dir('includes/propertylist.template.php')); $content = ob_get_contents(); ob_end_clean(); } if ($showpagination == 'yes') { // show some pagination here $html .= $this->build_list_pagination($paginationholder, $paginationclass, $backup_query->query_vars['paged'], $wp_query->max_num_pages); } $this->inshortcodelist = true; while (have_posts()) { the_post(); $this->shortcodeproperty = $post->ID; $html .= do_shortcode($content); } $this->inshortcodelist = false; if ($showpagination == 'yes') { // show some pagination here $html .= $this->build_list_pagination($paginationholder, $paginationclass, $backup_query->query_vars['paged'], $wp_query->max_num_pages); } } // Restore the original wp_query and post $wp_query = $backup_query; $post = $backup_post; return $html; }
function update_tables_from($installed_build = false) { include_once SPPCommon::property_dir('includes/upgrade.php'); sp_upgradeproperty($installed_build); }
function sp_recentproperties() { // Load the text-domain $locale = apply_filters('staypress_locale', get_locale()); $mofile = SPPCommon::property_dir("includes/lang/property-{$locale}.mo"); if (file_exists($mofile)) { load_textdomain('property', $mofile); } $widget_ops = array('classname' => 'sp_recentproperties', 'description' => __('StayPress Recent Properties', 'property')); $control_ops = array('width' => 250, 'height' => 350, 'id_base' => 'sp_recentproperties'); $this->WP_Widget('sp_recentproperties', __('StayPress Recent Properties', 'property'), $widget_ops, $control_ops); add_action('init', array(&$this, 'enqueue_page_headings')); }