예제 #1
0
 public static function set_property_dir($base)
 {
     if (defined('WPMU_PLUGIN_DIR') && file_exists(WPMU_PLUGIN_DIR . '/' . basename($base))) {
         self::$SP_property_dir = trailingslashit(WPMU_PLUGIN_URL);
     } elseif (defined('WP_PLUGIN_DIR') && file_exists(WP_PLUGIN_DIR . '/staypressproperty/' . basename($base))) {
         self::$SP_property_dir = trailingslashit(WP_PLUGIN_DIR . '/staypressproperty');
     } else {
         self::$SP_property_dir = trailingslashit(WP_PLUGIN_DIR . '/staypressproperty');
     }
 }
예제 #2
0
 function handle_search_redirect()
 {
     global $wpdb;
     $this->property = new property_model($wpdb, false);
     // Check the search criteria and see if any meta information has been added - if so then
     // we need to resort to straight searching and bypass the quick find stuff.
     switch (addslashes($_REQUEST['searchmadeby'])) {
         case 'quicksearchwidget':
             $search = $_REQUEST['sp_quicksearchfor'];
             break;
         case 'advsearchwidget':
             $search = $_REQUEST['sp_advsearchfor'];
             break;
         case 'shortcodesearch':
             $search = $_REQUEST['sp_shortcodesearchfor'];
             break;
         case 'advshortcodesearch':
             $search = $_REQUEST['sp_advshortcodesearchfor'];
             break;
     }
     $metasearch = array();
     if (!empty($_GET['meta'])) {
         foreach ((array) $_GET['meta'] as $metakey => $metadata) {
             if (!empty($metadata)) {
                 $metasearch[$metakey] = $metadata;
             }
         }
     }
     $tagsearch = apply_filters('staypress_advsearch_extendshortcode_tags', array());
     if (__($this->propertyoptions['propertysearchtext'], 'property') == $search) {
         // no text put into the search box, so blank out the standard placeholder text
         $search = '';
     }
     // Check criteria for property ID or reference - overrides meta information serch
     $property = $this->property->public_quickfind_propertyreforid($search, 'publish');
     if ($property !== false && !empty($property)) {
         // if it exists - redirect to correct permalink
         $url = sp_get_permalink('property', $property);
         $url = apply_filters('staypress_search_redirect_url', $url);
         wp_safe_redirect($url);
         exit;
     }
     if (empty($metasearch) && empty($tagsearch)) {
         // Check criteria for nearby locations
         $dest = $this->property->public_quickfind_location($search);
         if ($dest !== false && !empty($dest)) {
             // if it exists - redirect to correct permalink
             $page_prefix = SPPCommon::get_option('property_rewrite_prefix', '');
             if (!empty($page_prefix)) {
                 $page_prefix = trailingslashit($page_prefix);
             }
             if (!empty($dest->town)) {
                 $url = $page_prefix . __('in', 'property') . '/' . $this->make_url($dest->country);
                 $url .= '/' . $this->make_url($dest->region);
                 $url .= '/' . $this->make_url($dest->town);
             } elseif (!empty($dest->region)) {
                 $url = $page_prefix . __('in', 'property') . '/' . $this->make_url($dest->country);
                 $url .= '/' . $this->make_url($dest->region);
             } elseif (!empty($dest->country)) {
                 $url = $page_prefix . __('in', 'property') . '/' . $this->make_url($dest->country);
             } else {
                 return false;
             }
             $url = apply_filters('staypress_search_redirect_url', $url);
             wp_safe_redirect(trailingslashit(get_option('home')) . $url);
             exit;
         }
         // Check criteria for keyword
         $searchingfor = array_map(array(&$this, 'make_url'), array_map('trim', explode(',', $search)));
         $keyworded = $this->property->get_properties_with_tags((array) $searchingfor);
         if (empty($keyworded) || count($keyworded) == 1 && $keyworded[0] == '0') {
         } else {
             // There are properties with those keywords to redirect
             $url = sp_get_permalink('with', false, implode('/', $searchingfor));
             $url = apply_filters('staypress_search_redirect_url', $url);
             wp_safe_redirect($url);
             exit;
         }
         // Add in final keyword bit
         $extend = 'keyword:' . urlencode($search) . "/searchfor:" . urlencode($search);
         $url = sp_get_permalink('search', false, $extend);
         $url = apply_filters('staypress_search_redirect_url', $url);
         wp_safe_redirect($url);
         exit;
     } else {
         $urlextend = array();
         // More advanced serching - need to build a meta information url and then process later
         // Check criteria for nearby locations
         $dest = $this->property->public_quickfind_location($search);
         if ($dest !== false && !empty($dest)) {
             // if it exists - redirect to correct permalink
             if (!empty($dest->town)) {
                 $urlextend[] = 'intown:' . $this->make_url($dest->town);
                 $urlextend[] = 'inregion:' . $this->make_url($dest->region);
                 $urlextend[] = 'incountry:' . $this->make_url($dest->country);
             } elseif (!empty($dest->region)) {
                 $urlextend[] = 'inregion:' . $this->make_url($dest->region);
                 $urlextend[] = 'incountry:' . $this->make_url($dest->country);
             } elseif (!empty($dest->country)) {
                 $urlextend[] = 'incountry:' . $this->make_url($dest->country);
             }
         }
         // Check criteria for keyword
         if (empty($urlextend)) {
             $searchingfor = array_map(array(&$this, 'make_url'), array_map('trim', explode(',', $search)));
             $keyworded = $this->property->get_properties_with_tags((array) $searchingfor);
             if (empty($keyworded) || count($keyworded) == 1 && $keyworded[0] == '0') {
             } else {
                 // There are properties with those keywords to redirect
                 foreach ($searchingfor as $sf) {
                     $urlextend[] = 'tag:' . $sf;
                 }
             }
         }
         if (!empty($tagsearch)) {
             foreach ($tagsearch as $tag) {
                 $urlextend[] = 'tag:' . $tag;
             }
         }
         if (empty($urlextend)) {
             $urlextend[] = 'keyword:' . urlencode($search);
         }
         if (!empty($metasearch)) {
             foreach ((array) $metasearch as $key => $value) {
                 $fac = $this->property->get_metaforfac($key);
                 if (!empty($fac)) {
                     $urlextend[] = $this->make_url($fac->metaname) . ':' . urlencode($value);
                 }
             }
         }
         $urlextend[] = "searchfor:" . urlencode($search);
         $url = sp_get_permalink('search', false, implode('/', $urlextend));
         $url = apply_filters('staypress_search_redirect_url', $url);
         wp_safe_redirect($url);
         exit;
     }
 }
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
// This is a holder plugin file and only loads the administration classes
// If we are in the administration panel - thus saving memory and processing
// on the public side of the site
//define('SP_ONMS', true);
require_once 'includes/config.php';
require_once 'classes/common.php';
// Set up my location
SPPCommon::set_property_url(__FILE__);
SPPCommon::set_property_dir(__FILE__);
if (is_admin()) {
    require_once 'classes/postmodel.php';
    // custom post types model
    require_once 'classes/queue.php';
    require_once 'classes/administration.php';
    // Adminstration interface
    $sp_propertyadmin = new sp_propertyadmin();
} else {
    require_once 'classes/postmodel.php';
    // custom post types model
    require_once 'classes/public.php';
    require_once 'includes/images.php';
    //  Public interface
    $sp_property = new sp_propertypublic();
}
// Load secondary plugins
SPPCommon::load_property_addons();
예제 #4
0
 function update_tables_from($installed_build = false)
 {
     include_once SPPCommon::property_dir('includes/upgrade.php');
     sp_upgradeproperty($installed_build);
 }
 function show_options_rightpanel()
 {
     if (!defined('STAYPRESS_HIDE_DONATIONS')) {
         echo "<div class='sidebarbox'>";
         echo '<div title="Click to toggle" class="handlediv" id="handlestatus"><br></div>';
         echo "<h2 class='rightbarheading'>" . __('Show Your Support', 'property') . "</h2>";
         echo "<div class='innersidebarbox'>";
         echo "<div class='highlightbox blue'>";
         echo "<p>";
         echo __('We don\'t take donations here. Instead, we pick a charity every month and ask you to donate directly to them if you feel the urge to give.', 'property');
         echo "</p>";
         echo "</div>";
         echo "<div class='highlightbox'>";
         echo "<p>";
         echo __('<strong>Support Bite-Back</strong><br/><br/>Bite-Back is a pioneering shark and marine conservation charity which is running successful campaigns to end the sale of shark fin soup in Britain.<br/><br/>', 'property');
         echo '<img src="' . SPPCommon::property_url('images/biteback.jpg') . '" alt="bite-back" style="margin-left: 30px;" />';
         echo "</p>";
         echo "<p>";
         echo __('To find out more about Bite-Back visit their website <a href="http://www.bite-back.com/">here</a>.<br/><br/><strong>To make a direct donation please go <a href="https://uk.virginmoneygiving.com/fundraiser-web/donate/makeDonationForCharityDisplay.action?charityId=1002357&frequencyType=S">here</a></strong>.', 'property');
         echo "</p>";
         echo "<p>";
         echo __('If you make a donation, then please let us know and we\'ll make sure we put out a big thank you on our site.', 'property');
         echo "</p>";
         echo "</div>";
         echo "<br/>";
         echo "</div> <!-- innersidebarbox -->";
         echo "</div> <!-- sidebarbox -->";
         echo "<br/>";
     }
 }
 function show_property_map_options($propertyoptions)
 {
     $defaults = array('latitude' => '37.94199', 'longitude' => '-0.74363', 'zoom' => '12');
     $propertyoptions = SPPCommon::get_option('property_location_defaults', array());
     $propertyoptions = array_merge($defaults, $propertyoptions);
     echo "<h3>" . __('Default Map Co-ordinates', 'property') . "</h3>";
     echo "<p>" . __('Move and/or zoom the map to the default location you want to show on the property edit/add pages.', 'property') . "</p>";
     echo "<div id='locationmap'></div>";
     echo "<input type='hidden' name='latitude' id='latitude' value='" . esc_attr($propertyoptions['latitude']) . "' />";
     echo "<input type='hidden' name='longitude' id='longitude' value='" . esc_attr($propertyoptions['longitude']) . "' />";
     echo "<input type='hidden' name='zoom' id='zoom' value='" . esc_attr($propertyoptions['zoom']) . "' />";
 }
 function replace_text($transtext, $normtext, $domain)
 {
     static $sp_options, $from, $to;
     if (empty($sp_options)) {
         $sp_options = SPPCommon::get_option('sp_property_options');
         $from = array();
         $from[] = '/property/';
         $from[] = '/Property/';
         $from[] = '/properties/';
         $from[] = '/Properties/';
         $to = array();
         $to[] = strtolower($sp_options['propertytext']);
         $to[] = ucfirst(strtolower($sp_options['propertytext']));
         $to[] = strtolower($sp_options['propertiestext']);
         $to[] = ucfirst(strtolower($sp_options['propertiestext']));
     }
     if (($domain == 'property' || $domain == 'booking') && !empty($sp_options)) {
         $transtext = preg_replace($from, $to, $transtext);
     }
     return $transtext;
 }
 function enqueue_propertynear_data($posts)
 {
     global $wp_query;
     //print_r($wp_query);
     static $alphabet = array("-", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
     static $propertydata = array();
     static $count = 1;
     $defaultoptions = array('propertytext' => 'property', 'propertiestext' => 'properties', 'permalinkhasid' => 'yes', 'firstelement' => 'reference', 'propertytitlelayout' => '%title%', 'propertytitlemarker' => 'numeric');
     $this->propertyoptions = SPPCommon::get_option('sp_property_options', $defaultoptions);
     foreach (array_slice((array) $posts, 0, 19) as $postkey => $post) {
         if (!empty($post->latitude)) {
             $key = $count++;
             $propertydata[$key] = array('ID' => $post->ID, 'post_title' => $post->post_title, 'post_excerpt' => $post->post_excerpt, 'latitude' => $post->latitude, 'longitude' => $post->longitude, 'permalink' => sp_get_permalink('property', $post));
             if ($this->enhancetitle) {
                 $title = $post->post_title;
                 if (empty($this->propertyoptions['propertytitlelayout'])) {
                     $this->propertyoptions['propertytitlelayout'] = '%title%';
                 }
                 $posts[$postkey]->post_title = str_replace('%title%', $title, $this->propertyoptions['propertytitlelayout']);
                 $posts[$postkey]->post_title = str_replace('%listmarker%', $key, $posts[$postkey]->post_title);
             }
         }
     }
     if (!empty($propertydata)) {
         SPPCommon::enqueue_data('staypress_data', 'propertylist_near', $propertydata);
     }
     return $posts;
 }