function update_property_map_options($ignoreproperty)
 {
     $property = array();
     // Location details
     $property['latitude'] = $_POST['latitude'];
     $property['longitude'] = $_POST['longitude'];
     $property['zoom'] = $_POST['zoom'];
     SPPCommon::update_option('property_location_defaults', $property);
 }
Ejemplo n.º 2
0
 function initialise_property()
 {
     // Assign the user id to the property model
     $user = wp_get_current_user();
     $this->property->set_userid($user->ID);
     // Set permissions if they haven't already been set
     $role = get_role('contributor');
     if (!$role->has_cap('read_destination')) {
         $role->add_cap('read_property');
         $role->add_cap('edit_property');
         $role->add_cap('delete_property');
         // Needed so they can upload files - well duh
         $role->add_cap('upload_files');
         // Author
         $role = get_role('author');
         $role->add_cap('read_property');
         $role->add_cap('edit_property');
         $role->add_cap('delete_property');
         $role->add_cap('publish_properties');
         // Editor
         $role = get_role('editor');
         $role->add_cap('read_property');
         $role->add_cap('edit_property');
         $role->add_cap('delete_property');
         $role->add_cap('publish_properties');
         $role->add_cap('edit_properties');
         $role->add_cap('edit_others_properties');
         // Administrator
         $role = get_role('administrator');
         $role->add_cap('read_property');
         $role->add_cap('edit_property');
         $role->add_cap('delete_property');
         $role->add_cap('publish_properties');
         $role->add_cap('edit_properties');
         $role->add_cap('edit_others_properties');
         // Contacts
         $role = get_role('contributor');
         $role->add_cap('read_contact');
         $role->add_cap('edit_contact');
         $role->add_cap('delete_contact');
         // Author
         $role = get_role('author');
         $role->add_cap('read_contact');
         $role->add_cap('edit_contact');
         $role->add_cap('delete_contact');
         $role->add_cap('publish_contacts');
         // Editor
         $role = get_role('editor');
         $role->add_cap('read_contact');
         $role->add_cap('edit_contact');
         $role->add_cap('delete_contact');
         $role->add_cap('publish_contacts');
         $role->add_cap('edit_contacts');
         $role->add_cap('edit_others_contacts');
         // Administrator
         $role = get_role('administrator');
         $role->add_cap('read_contact');
         $role->add_cap('edit_contact');
         $role->add_cap('delete_contact');
         $role->add_cap('publish_contacts');
         $role->add_cap('edit_contacts');
         $role->add_cap('edit_others_contacts');
         // Destinations
         $role = get_role('contributor');
         $role->add_cap('read_destination');
         $role->add_cap('edit_destination');
         $role->add_cap('delete_destination');
         // Author
         $role = get_role('author');
         $role->add_cap('read_destination');
         $role->add_cap('edit_destination');
         $role->add_cap('delete_destination');
         $role->add_cap('publish_destinations');
         // Editor
         $role = get_role('editor');
         $role->add_cap('read_destination');
         $role->add_cap('edit_destination');
         $role->add_cap('delete_destination');
         $role->add_cap('publish_destinations');
         $role->add_cap('edit_destinations');
         $role->add_cap('edit_others_destinations');
         // Administrator
         $role = get_role('administrator');
         $role->add_cap('read_destination');
         $role->add_cap('edit_destination');
         $role->add_cap('delete_destination');
         $role->add_cap('publish_destinations');
         $role->add_cap('edit_destinations');
         $role->add_cap('edit_others_destinations');
     }
     // Register the property post type
     register_post_type(STAYPRESS_PROPERTY_POST_TYPE, array('labels' => array('name' => __('Properties', 'property'), 'singular_name' => __('Property', 'property'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Property'), 'edit' => __('Edit'), 'edit_item' => __('Edit Property'), 'new_item' => __('New Property'), 'view' => __('View Property'), 'view_item' => __('View Property'), 'search_items' => __('Search Properties'), 'not_found' => __('No Properties found'), 'not_found_in_trash' => __('No Properties found in Trash'), 'parent' => __('Parent Property')), 'public' => false, 'show_ui' => false, 'publicly_queryable' => false, 'exclude_from_search' => true, 'hierarchical' => true, 'capability_type' => 'property', 'edit_cap' => 'edit_property', 'edit_type_cap' => 'edit_properties', 'edit_others_cap' => 'edit_others_properties', 'publish_others_cap' => 'publish_properties', 'read_cap' => 'read_property', 'delete_cap' => 'delete_property', 'rewrite' => array('slug' => __('property', 'property'), 'with_front' => false)));
     // Register the destination post type
     register_post_type(STAYPRESS_DESTINATION_POST_TYPE, array('labels' => array('name' => __('Destinations', 'property'), 'singular_name' => __('Destination', 'property'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Destination'), 'edit' => __('Edit'), 'edit_item' => __('Edit Destination'), 'new_item' => __('New Destination'), 'view' => __('View Destination'), 'view_item' => __('View Destination'), 'search_items' => __('Search Destinations'), 'not_found' => __('No Destinations found'), 'not_found_in_trash' => __('No Destinations found in Trash'), 'parent' => __('Parent Destination')), 'public' => true, 'show_ui' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => true, 'supports' => array('title', 'editor', 'excerpt', 'custom-fields', 'thumbnail', 'page-attributes'), 'capability_type' => 'destination', 'edit_cap' => 'edit_destination', 'edit_type_cap' => 'edit_destinations', 'edit_others_cap' => 'edit_others_destinations', 'publish_others_cap' => 'publish_destinations', 'read_cap' => 'read_destination', 'delete_cap' => 'delete_destination', 'rewrite' => array('slug' => __('destination', 'property'), 'with_front' => false)));
     $locationsettings = array('labels' => array('name' => __('Location', 'property'), 'singular_name' => __('Location', 'property'), 'search_items' => __('Search Locations', 'property'), 'popular_items' => __('Popular Locations', 'property'), 'all_items' => __('All Locations', 'property'), 'parent_item' => __('Parent Location', 'property'), 'parent_item_colon' => __('Parent Location:', 'property'), 'edit_item' => __('Edit Location', 'property'), 'update_item' => __('Update Location', 'property'), 'add_new_item' => __('Add New Location', 'property'), 'new_item_name' => __('New Location Name', 'property'), 'separate_items_with_commas' => __('Separate Locations with commas', 'property'), 'add_or_remove_items' => __('Add or remove Locations', 'property'), 'choose_from_most_used' => __('Choose from the most used Locations', 'property')), 'public' => true, 'show_ui' => true, 'show_tagcloud' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, 'query_var' => 'location', 'rewrite' => array('slug' => __('location', 'property'), 'with_front' => false));
     register_taxonomy('propertylocation', array(STAYPRESS_DESTINATION_POST_TYPE, STAYPRESS_PROPERTY_POST_TYPE), $locationsettings);
     // Register the contact post type
     if (!post_type_exists(STAYPRESS_CONTACT_POST_TYPE)) {
         register_post_type(STAYPRESS_CONTACT_POST_TYPE, array('labels' => array('name' => __('Contacts', 'property'), 'singular_name' => __('Contact', 'property'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Contact'), 'edit' => __('Edit'), 'edit_item' => __('Edit Contact'), 'new_item' => __('New Contact'), 'view' => __('View Contact'), 'view_item' => __('View Contact'), 'search_items' => __('Search Contacts'), 'not_found' => __('No Contacts found'), 'not_found_in_trash' => __('No Contacts found in Trash'), 'parent' => __('Parent Contact')), 'public' => false, 'show_ui' => false, 'publicly_queryable' => false, 'exclude_from_search' => true, 'hierarchical' => true, 'capability_type' => 'contact', 'edit_cap' => 'edit_contact', 'edit_type_cap' => 'edit_contacts', 'edit_others_cap' => 'edit_others_contacts', 'publish_others_cap' => 'publish_contacts', 'read_cap' => 'read_contact', 'delete_cap' => 'delete_contact'));
     }
     $taxonomies = SPPCommon::get_option('property_taxonomies', false);
     $taxonomies = apply_filters('staypress_property_taxonomies', $taxonomies);
     $page_prefix = SPPCommon::get_option('property_rewrite_prefix', '');
     if ($taxonomies) {
         foreach ($taxonomies as $key => $tax) {
             register_taxonomy($key, STAYPRESS_PROPERTY_POST_TYPE, array('hierarchical' => false, 'label' => $tax['label'], 'query_var' => false, 'rewrite' => array('slug' => $page_prefix . 'with', 'with_front' => false)));
         }
     } else {
         $taxonomies = array("propertyfeature" => array('label' => __('Feature', 'property'), 'slug' => 'features'), "propertytype" => array('label' => __('Property type', 'property'), 'slug' => 'propertytypes'), "propertyrental" => array('label' => __('Rental type', 'property'), 'slug' => 'rentaltypes'), "propertysetting" => array('label' => __('Setting', 'property'), 'slug' => 'settings'), "propertyactivity" => array('label' => __('Activity', 'property'), 'slug' => 'activities'), "propertysuitability" => array('label' => __('Suitability', 'property'), 'slug' => 'suitability'));
         SPPCommon::update_option('property_taxonomies', $taxonomies);
         foreach ($taxonomies as $key => $tax) {
             register_taxonomy($key, STAYPRESS_PROPERTY_POST_TYPE, array('public' => true, 'show_ui' => false, 'show_tagcloud' => true, 'show_in_nav_menus' => true, 'hierarchical' => false, 'label' => $tax['label'], 'query_var' => false, 'rewrite' => array('slug' => $page_prefix . 'with', 'with_front' => false)));
         }
     }
     register_taxonomy('propertyadministration', STAYPRESS_PROPERTY_POST_TYPE, array('public' => false, 'show_ui' => false, 'show_tagcloud' => false, 'show_in_nav_menus' => false, 'hierarchical' => false, 'label' => __('Adminstration', 'property'), 'query_var' => false, 'rewrite' => false));
     register_taxonomy('destinationadministration', STAYPRESS_DESTINATION_POST_TYPE, array('public' => false, 'show_ui' => false, 'show_tagcloud' => false, 'show_in_nav_menus' => false, 'hierarchical' => false, 'label' => __('Adminstration', 'property'), 'query_var' => false, 'rewrite' => false));
     // Add in the query extension functions
     // Join our property table so we don't need to mess with a lot of extra look ups later on
     add_filter('posts_join_request', array(&$this->property, 'add_to_property_to_join'), 10, 2);
     add_filter('posts_fields_request', array(&$this->property, 'add_to_property_to_fields'), 10, 2);
     // Add in extension fields when on a single posts details - if they are not already there.
     add_filter('the_post', array(&$this->property, 'extend_property'));
     // Load default options
     $defaultoptions = array('propertytext' => 'property', 'propertiestext' => 'properties', 'permalinkhasid' => 'yes', 'firstelement' => 'reference', 'propertytitlelayout' => '%title%', 'propertytitlemarker' => 'numeric', 'propertysearchtext' => 'Search for...', 'listingmethod' => 'permalink');
     $this->propertyoptions = SPPCommon::get_option('sp_property_options', $defaultoptions);
     // If we are using a mapping widget - then enqueue the data at the footer for it.
     // This may move to the widget itself, but I think it will be useful for other items as well so the if may extend.
     if (is_active_widget(false, false, 'sp_propertylistingmap') || defined('STAYPRESS_ENFORCE_MAP_DATA') && STAYPRESS_ENFORCE_MAP_DATA == true) {
         // Add in a filter that enqueues the data for property post types.
         add_filter('the_posts', array(&$this, 'enqueue_propertylist_data'));
         // Output any data that the filter enqueued - make sure it's in the footer so we get the lot.
         add_action('wp_footer', array('SPPCommon', 'print_data'));
     }
     // Register shortcodes
     $this->register_shortcodes();
     // Check for a search URL
     if (!empty($_REQUEST['searchmadeby'])) {
         // We seem to have a search so lets do some parsing.
         $this->handle_search_redirect();
     }
     // register search functions - fallback full search processing
     add_filter('staypress_process_search_positive', array(&$this, 'get_fullsearch_results_postive'), 10, 2);
     // enqueue our basic global js stuff - may move to another area for page specific items
     if (!current_theme_supports('staypress_property_script')) {
         wp_enqueue_script('propertypublicjs', SPPCommon::property_url('js/public.js'), array('jquery'), $this->build);
         wp_localize_script('propertypublicjs', 'staypresspublic', array("searchtext" => __($this->propertyoptions['propertysearchtext'], 'property')));
     }
     // Permalink overriding
     add_filter('post_type_link', array(&$this, 'override_wp_permalinks'), 10, 4);
 }
 function update_property_pages()
 {
     global $action, $page, $wp_rewrite;
     wp_reset_vars(array('action', 'page'));
     if (isset($action) && $action == 'updateoptions') {
         check_admin_referer('update-property-page-options');
         $options = array();
         $options['permalinkhasid'] = strtolower($_POST['permalinkhasid']);
         $options['firstelement'] = strtolower($_POST['firstelement']);
         $options['propertypage'] = strtolower($_POST['propertypage']);
         $options['propertylistpage'] = strtolower($_POST['propertylistpage']);
         $options['propertytagpage'] = strtolower($_POST['propertytagpage']);
         $options['propertydestpage'] = strtolower($_POST['propertydestpage']);
         $options['propertynearpage'] = strtolower($_POST['propertynearpage']);
         $options['propertyavailpage'] = strtolower($_POST['propertyavailpage']);
         $options['propertysearchpage'] = strtolower($_POST['propertysearchpage']);
         $options['propertymappage'] = strtolower($_POST['propertymappage']);
         $options = apply_filters('staypress_property_prepageoptions_update', $options);
         SPPCommon::update_option('sp_property_page_options', $options);
         do_action('staypress_property_postpageoptions_update');
         $wp_rewrite->flush_rules();
         wp_safe_redirect(add_query_arg('msg', 1, wp_get_referer()));
     }
 }