/**
 * GMW PT function - add location to GEO my WP 
 * 
 * use this function if you want to add location using a custom form.
 * 
 * function accepts an accociative array as below:
 * 
 * $args = array (
 *       'post_id'           => false, 	//must pass post id in order to work
 *       'address'           => false,	//can be eiter single line of full address field or an array of the adress components ex ( array( 'street' => '5060 lincoln st', 'city' => 'hollywood', 'state' => 'florida' )
 *       'additional_info'   => array( 'phone' => false, 'fax' => false, 'email' => false, 'website' => false ),
 *       'map_icon'          => false
 *  );
 */
function gmw_pt_update_location($args, $force_refresh = false)
{
    $args = array_replace_recursive(array('post_id' => false, 'address' => false, 'additional_info' => array('phone' => false, 'fax' => false, 'email' => false, 'website' => false), 'map_icon' => '_default.png'), $args);
    if (empty($args['post_id']) || empty($args['address'])) {
        return;
    }
    if (empty($args['map_icon'])) {
        $args['map_icon'] = '_default.png';
    }
    $address_apt = $address = $args['address'];
    $multiple_fields = false;
    if (is_array($args['address'])) {
        $mulitple_field = true;
        $address_apt = implode(' ', $address);
        unset($address['apt']);
        $address = implode(' ', $address);
    }
    //geocode the address
    $geocoded_address = GEO_my_WP::geocoder($address, $force_refresh);
    //if geocode failed delete the user's location
    if (isset($geocoded_address['error'])) {
        global $wpdb;
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}places_locator WHERE `post_id` = %d", array($args['post_id'])));
        do_action('gmw_pt_udpate_location_after_location_deleted', $args, $geocoded_address);
        return;
    }
    //if multiple address field passed through array
    if ($multiple_fields == true) {
        if (!in_array('street', $args['address']) || empty($args['address']['street'])) {
            $street = $geocoded_address['street'];
        }
        if (!in_array('apt', $args['address']) || empty($args['address']['apt'])) {
            $apt = $geocoded_address['apt'];
        }
        if (!in_array('city', $args['address']) || empty($args['address']['city'])) {
            $city = $geocoded_address['city'];
        }
        if (!in_array('zipcode', $args['address']) || empty($args['address']['zipcode'])) {
            $zipcode = $geocoded_address['zipcode'];
        }
        $state = $geocoded_address['state_short'];
        $country = $geocoded_address['country_short'];
    } else {
        $street = $geocoded_address['street'];
        $apt = $geocoded_address['apt'];
        $city = $geocoded_address['city'];
        $state = $geocoded_address['state_short'];
        $zipcode = $geocoded_address['zipcode'];
        $country = $geocoded_address['country_short'];
    }
    $locationArgs = array('args' => $args, 'address' => $address, 'geocoded' => $geocoded_address);
    $LocationArgs = apply_filters('gmw_pt_before_location_updated', $locationArgs);
    do_action('gmw_pt_before_location_updated', $locationArgs);
    //$featuredPost = ( isset( $_POST['_wppl_featured_post'] ) ) ? $_POST['_wppl_featured_post'] : 0;
    //Save information to database
    global $wpdb;
    $wpdb->replace($wpdb->prefix . 'places_locator', array('post_id' => $locationArgs['args']['post_id'], 'feature' => 0, 'post_type' => get_post_type($locationArgs['args']['post_id']), 'post_title' => get_the_title($locationArgs['args']['post_id']), 'post_status' => 'publish', 'street_number' => !empty($locationArgs['geocoded']['street_number']) ? $locationArgs['geocoded']['street_number'] : '', 'street_name' => !empty($locationArgs['geocoded']['street_name']) ? $locationArgs['geocoded']['street_name'] : '', 'street' => $street, 'apt' => $apt, 'city' => $city, 'state' => $state, 'state_long' => $locationArgs['geocoded']['state_long'], 'zipcode' => $zipcode, 'country' => $country, 'country_long' => $locationArgs['geocoded']['country_long'], 'address' => $address_apt, 'formatted_address' => $locationArgs['geocoded']['formatted_address'], 'phone' => $locationArgs['args']['additional_info']['phone'], 'fax' => $locationArgs['args']['additional_info']['fax'], 'email' => $locationArgs['args']['additional_info']['email'], 'website' => $locationArgs['args']['additional_info']['website'], 'lat' => $locationArgs['geocoded']['lat'], 'long' => $locationArgs['geocoded']['lng'], 'map_icon' => $args['map_icon']));
    do_action('gmw_pt_after_location_updated', $locationArgs);
}
/**
 * gmw_shortcode
 *
 * GEO my WP's main shortcode
 * @param unknown_type $atts
 */
function gmw_shortcode($atts)
{
    //abort if no attributes found
    if (empty($atts)) {
        return;
    }
    //get the first attribute of the shortcode.
    //the first attribute must be the element ( form, search_form, map or search_results ).
    $element = key($atts);
    //get the form ID
    $formId = $atts[$element];
    //make sure the element is lagit
    if (empty($formId) || !in_array($element, array('search_form', 'map', 'search_results', 'form'))) {
        return;
    }
    /**
     * GEO my WP URL parameteres prefix
     *
     * This is the prefix used for the URL paramaters that GEO my WP
     * uses with submitted form. IT can modified if needed
     * 
     * @var string
     */
    $gmw_prefix = gmw_get_option('general_settings', 'url_px', 'gmw_');
    //modify the URL parameters
    $_GET = apply_filters('gmw_modify_get_args', $_GET);
    //if this is results page we get the formId from URL
    if ($formId == 'results') {
        if (empty($_GET['action']) || $_GET['action'] != $gmw_prefix . 'post' || empty($_GET[$gmw_prefix . 'form'])) {
            return;
        }
        $formId = absint($_GET[$gmw_prefix . 'form']);
        $element = 'results_page';
    } else {
        $formId = absint($atts[$element]);
    }
    //get the forms from database
    $forms = get_option('gmw_forms');
    //look for the form based on the form ID. Abort if no form was found
    if (empty($forms[$formId])) {
        return;
    }
    //get the current form
    $form = $forms[$formId];
    //make sure the add-on of the form is activated
    if (!GEO_my_WP::gmw_check_addon($form['addon'])) {
        return;
    }
    $form['element_triggered'] = $element;
    $form['params'] = $atts;
    $form['url_px'] = $gmw_prefix;
    $form_output = new GMW_Form_Init($form);
    ob_start();
    $form_output->display();
    $output_string = ob_get_contents();
    ob_end_clean();
    return $output_string;
}
 /**
  * When displaying results on page load
  *
  * @since 2.5
  *
  */
 public function page_load_results()
 {
     $page_load_options = $this->form['page_load_results'];
     $this->form['org_address'] = '';
     $this->form['get_per_page'] = !empty($_GET[$this->form['url_px'] . 'per_page']) ? $_GET[$this->form['url_px'] . 'per_page'] : current(explode(",", $page_load_options['per_page']));
     $this->form['radius'] = !empty($page_load_options['radius']) ? $page_load_options['radius'] : 200;
     $this->form['search_results']['display_map'] = $page_load_options['display_map'];
     $this->form['units_array'] = gmw_get_units_array($this->form['page_load_results']['units']);
     //temporary solution - this part needs improvment.
     //need to change all kind of display_? options to the one global name such as results_list.
     //to easier control the outcome
     if (isset($page_load_options['display_posts'])) {
         $this->form['search_results']['display_posts'] = true;
         $this->form['search_results']['display_members'] = true;
         $this->form['search_results']['display_groups'] = true;
         $this->form['search_results']['display_users'] = true;
     } else {
         unset($this->form['search_results']['display_posts'], $this->form['search_results']['display_groups'], $this->form['search_results']['display_members'], $this->form['search_results']['display_users']);
     }
     //display results based on user's current location
     if (isset($page_load_options['user_location']) && !empty($this->form['user_position'])) {
         // get user's current location
         $this->form['org_address'] = $this->form['user_position']['address'];
         $this->form['your_lat'] = $this->form['user_position']['lat'];
         $this->form['your_lng'] = $this->form['user_position']['lng'];
         //if no user's position check for address filter
     } elseif (!empty($page_load_options['address_filter'])) {
         // get user's current location exsit
         $this->form['org_address'] = sanitize_text_field($page_load_options['address_filter']);
         $this->form['location'] = GEO_my_WP::geocoder($this->form['org_address']);
         //if geocode was unsuccessful return error message
         if (isset($this->form['location']['error'])) {
             //return $this->no_results( $this->form['location']['error'] );
             return;
         } else {
             $this->form['your_lat'] = $this->form['location']['lat'];
             $this->form['your_lng'] = $this->form['location']['lng'];
         }
     }
     $this->form = apply_filters("gmw_page_load_results_before_results", $this->form);
     $this->form = apply_filters("gmw_page_load_results_before_results_{$this->form['ID']}", $this->form);
     $this->form = apply_filters("gmw_{$this->form['prefix']}_page_load_results_before_results", $this->form);
     $this->results();
 }
/**
 * GMW function - add location to Users
 *
 * use this function if you want to add location to users using a custom form.
 *
 * function accepts an accociative array as below:
 *
 * $args = array (
 *      'user_id'   => false, 	//must pass user id in order for it to work
 *      'address'   => false,	//can be eiter single line of full address field or an array of the adress components ex ( array( 'street' => '5060 lincoln st', 'city' => 'hollywood', 'state' => 'florida' )
 *      'map_icon'  => false
 *  );
 */
function gmw_update_user_location($args)
{
    //default args
    $args = array_replace_recursive(array('user_id' => false, 'address' => false, 'map_icon' => '_default.png'), $args);
    if (empty($args['user_id']) || empty($args['address'])) {
        return;
    }
    if (empty($args['map_icon'])) {
        $args['map_icon'] = '_default.png';
    }
    $address_apt = $address = $args['address'];
    $multiple_fields = false;
    if (is_array($args['address'])) {
        $mulitple_field = true;
        $address_apt = implode(' ', $address);
        unset($address['apt']);
        $address = implode(' ', $address);
    }
    //geocode the address
    $geocoded_address = GEO_my_WP::geocoder($address);
    //if geocode failed delete the user's location
    if (isset($geocoded_address['error'])) {
        global $wpdb;
        $wpdb->query($wpdb->prepare("DELETE FROM wppl_friends_locator WHERE member_id = %d", $args['user_id']));
        do_action('gmw_user_after_location_deleted', $args, $geocoded_address);
        return;
    }
    //if multiple address field passed through array
    if ($multiple_fields == true) {
        //if no street entered by the user try to get it from the geocoded details
        if (!in_array('street', $args['address'])) {
            $street = $geocoded_address['street'];
        }
        //if no apt entered by the user try to get it from the geocoded details
        if (!in_array('apt', $args['address'])) {
            $apt = $geocoded_address['apt'];
        }
        //if no city entered by the user try to get it from the geocoded details
        if (!in_array('city', $args['address'])) {
            $city = $geocoded_address['city'];
        }
        $state = $geocoded_address['state_short'];
        //if no zipcode entered by the user try to get it from the geocoded details
        if (!in_array('zipcode', $args['address'])) {
            $zipcode = $geocoded_address['zipcode'];
        }
        $country = $geocoded_address['country_short'];
        //if single address field entered
    } else {
        $street = $geocoded_address['street'];
        $apt = $geocoded_address['apt'];
        $city = $geocoded_address['city'];
        $state = $geocoded_address['state_short'];
        $zipcode = $geocoded_address['zipcode'];
        $country = $geocoded_address['country_short'];
    }
    //get the locaiton information into array
    $locationArgs = array('args' => $args, 'address' => $address, 'geocoded' => $geocoded_address);
    //allow plugins filter the information
    $LocationArgs = apply_filters('gmw_user_before_location_updated', $locationArgs);
    //actions before saving the location in database
    do_action('gmw_user_before_location_updated', $locationArgs);
    //Save information to database
    global $wpdb;
    $wpdb->replace('wppl_friends_locator', array('member_id' => $args['user_id'], 'street_number' => $locationArgs['geocoded']['street_number'], 'street_name' => $locationArgs['geocoded']['street_name'], 'street' => $street, 'apt' => $apt, 'city' => $city, 'state' => $state, 'state_long' => $locationArgs['geocoded']['state_long'], 'zipcode' => $zipcode, 'country' => $country, 'country_long' => $locationArgs['geocoded']['country_long'], 'address' => $address_apt, 'formatted_address' => $locationArgs['geocoded']['formatted_address'], 'lat' => $locationArgs['geocoded']['lat'], 'long' => $locationArgs['geocoded']['lng'], 'map_icon' => $args['map_icon']));
    //actions after saving the location in database
    do_action('gmw_user_after_location_updated', $locationArgs);
}
    /**
     *  Members Query
     */
    function members_query()
    {
        global $wpdb, $bp;
        //set join type based on the query. if no address entered will join all members even if they have no location
        $tJoin = "RIGHT";
        $tJoin2 = "LEFT";
        //when doing query by address entered
        if ($this->formData['address']) {
            // $this->formData['orderby']  = 'distance';
            //do INNER JOIN. we will show only members with location
            $tJoin = $tJoin2 = "INNER";
            //geocode the address entered
            $this->returned_address = GEO_my_WP::geocoder($this->formData['address']);
            //If form submitted and address was not found stop search and display no results
            if (!isset($this->returned_address) || empty($this->returned_address)) {
                $this->formData['query'] = false;
                $this->gmwSD['your_lat'] = false;
                $this->gmwSD['your_lng'] = false;
                $this->gmwSD['org_address'] = 'bad';
                //modify the query to no results
                $this->clauses['bp_user_query']['where'] = ' AND 0 = 1 ';
                $this->clauses['bp_user_query']['orderby'] = ' ORDER BY u.display_name';
                $message = apply_filters('gmw_sd_no_addrss_found_message', __('Sorry, the address was not found. Please try a different address.', 'GMW'));
                ?>
                <script>
                    jQuery('#message').html('<p>' + '<?php 
                echo $message;
                ?>
' + '</p>');
                </script>
                <?php 
            } else {
                $this->formData['query'] = 'address';
                $this->gmwSD['your_lat'] = $this->returned_address['lat'];
                $this->gmwSD['your_lng'] = $this->returned_address['lng'];
                $this->gmwSD['org_address'] = !empty($_POST) ? $_POST['search_terms'] : $this->formData['address'];
            }
        } elseif ($this->formData['orderby'] == 'distance') {
            $this->formData['orderby'] = 'active';
        }
        $users_table = $bp->version < '2.0' ? $wpdb->usermeta : $bp->members->table_name_last_activity;
        if ($this->formData['orderby'] == 'alphabetical') {
            // if ( !bp_disable_profile_sync() || !bp_is_active( 'xprofile' ) ) {
            $this->clauses['bp_user_query']['select'] = "SELECT DISTINCT u.ID as id , gmwlocations.member_id";
            $this->clauses['bp_user_query']['from'] = " FROM wppl_friends_locator gmwlocations {$tJoin} JOIN {$wpdb->users} u ON gmwlocations.member_id = u.ID";
            $this->clauses['bp_user_query']['orderby'] = "ORDER BY u.display_name";
            $this->clauses['bp_user_query']['order'] = "ASC";
            // When profile sync is disabled, alphabetical sorts must happen against
            // the xprofile table
            /* } else {
            
                            $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) );
            
                            $this->clauses['bp_user_query']['select']  = "SELECT DISTINCT u.user_id as id , gmwlocations.member_id";
                            $this->clauses['bp_user_query']['from']    = " FROM wppl_friends_locator gmwlocations {$tJoin} JOIN {$bp->profile->table_name_data} u ON gmwlocations.member_id = id";
                            //$this->clauses['bp_user_query']['where']   = "WHERE u.field_id = {$fullname_field_id} ";
                            $this->clauses['bp_user_query']['orderby'] = "ORDER BY u.value";
                            $this->clauses['bp_user_query']['order']   = "ASC";
                        } */
        } elseif ($this->formData['orderby'] == 'newest' || $this->formData['orderby'] == 'active' || $this->formData['orderby'] == '') {
            $orderby = $bp->version < '2.0' ? 'u.meta_value' : 'u.date_recorded';
            $this->clauses['bp_user_query']['select'] = "SELECT DISTINCT u.user_id , gmwlocations.member_id";
            $this->clauses['bp_user_query']['from'] = " FROM wppl_friends_locator gmwlocations {$tJoin} JOIN {$users_table} u ON gmwlocations.member_id = u.user_id";
            //$this->clauses['bp_user_query']['where']  = "u.component = 'members' AND u.type = 'last_activity''";
            if ($this->formData['orderby'] == 'newest') {
                $this->clauses['bp_user_query']['orderby'] = "ORDER BY u.user_id";
            } else {
                $this->clauses['bp_user_query']['orderby'] = "ORDER BY {$orderby}";
            }
            $this->clauses['bp_user_query']['order'] = "DESC";
            //when order by distance
        } elseif ($this->formData['orderby'] == 'distance') {
            $this->clauses['bp_user_query']['select'] = "SELECT gmwlocations.member_id, u.user_id as id";
            $this->clauses['bp_user_query']['from'] = " FROM wppl_friends_locator gmwlocations INNER JOIN {$users_table} u ON gmwlocations.member_id = u.user_id";
            //$this->clauses['bp_user_query']['where']  = "WHERE u.meta_key = 'last_activity'";
            if ($this->gmwSD['your_lat'] != false) {
                $this->clauses['bp_user_query']['orderby'] = "ORDER BY distance";
            } else {
                $this->formData['query'] = false;
                $this->gmwSD['your_lat'] = false;
                $this->gmwSD['your_lng'] = false;
                $this->clauses['bp_user_query']['where'] = 'AND 0 = 1';
                $this->clauses['bp_user_query']['orderby'] = 'ORDER BY u.user_id';
                ?>
                <script>
                    jQuery(window).ready(function() {
                        jQuery('#message').html("<p>We couldn't find the address you enter. Please try a different address.</p>");
                    });
                </script>
                <?php 
            }
            $this->clauses['bp_user_query']['order'] = "ASC";
        }
        /*
         * if address entered
         * prepare the filter of the select clause of the SQL function. the function join the members table with
         * wppl_friends_locator table, will calculate the distance and will get only the members that
         * within the radius was chosen
         */
        if ($this->gmwSD['your_lat'] !== false) {
            $this->clauses['bp_user_query']['select'] .= $wpdb->prepare(" , ROUND( %d * acos( cos( radians( %s ) ) * cos( radians( gmwlocations.lat ) ) * cos( radians( gmwlocations.long ) - radians( %s ) ) + sin( radians( %s ) ) * sin( radians( gmwlocations.lat) ) ),1 ) AS distance ", $this->gmwSD['units'], $this->gmwSD['your_lat'], $this->gmwSD['your_lng'], $this->gmwSD['your_lat']);
            $this->clauses['bp_user_query']['having'] = $wpdb->prepare(" HAVING distance <= %d OR distance IS NULL", $this->formData['radius']);
            $this->clauses['wp_user_query']['query_fields'] = $wpdb->prepare(" ,ROUND( %d * acos( cos( radians( %s ) ) * cos( radians( gmwlocations.lat ) ) * cos( radians( gmwlocations.long ) - radians( %s ) ) + sin( radians( %s ) ) * sin( radians( gmwlocations.lat) ) ),1 ) AS distance", $this->gmwSD['units'], $this->gmwSD['your_lat'], $this->gmwSD['your_lng'], $this->gmwSD['your_lat']);
        }
        //select all fields from location table
        $this->clauses['wp_user_query']['query_fields'] .= " , gmwlocations.lat, gmwlocations.long, gmwlocations.address, gmwlocations.formatted_address";
        $this->clauses['wp_user_query']['query_from'] = " {$tJoin2} JOIN wppl_friends_locator gmwlocations ON ID = gmwlocations.member_id ";
    }
 /**
  * Get results template fiels
  * @return multitype:string NULL
  */
 public static function search_results_templates($prefix)
 {
     if (GEO_my_WP::gmw_check_addon('posts') != false) {
         $folder['pt'] = array(GMW_PT_PATH . '/search-results/', 'posts/search-results/');
     }
     if (GEO_my_WP::gmw_check_addon('friends') != false && class_exists('BuddyPress')) {
         $folder['fl'] = array(GMW_FL_PATH . '/search-results/', 'friends/search-results/');
     }
     $folder = apply_filters('gmw_admin_results_templates_folder', $folder);
     if (!array_key_exists($prefix, $folder)) {
         return array();
     }
     $themes = array();
     foreach (glob($folder[$prefix][0] . '*', GLOB_ONLYDIR) as $dir) {
         $themes[basename($dir)] = basename($dir);
     }
     $custom_templates = glob(STYLESHEETPATH . '/geo-my-wp/' . $folder[$prefix][1] . '*', GLOB_ONLYDIR);
     if (!empty($custom_templates)) {
         foreach ($custom_templates as $dir) {
             $themes['custom_' . basename($dir)] = 'Custom: ' . basename($dir);
         }
     }
     return $themes;
 }
示例#7
0
 /**
  * Include core add-ons if needed
  */
 private function core_addons()
 {
     //load current_location add-on
     if (GEO_my_WP::gmw_check_addon('current_location')) {
         include 'plugins/current-location/loader.php';
     }
     //load single_location add-on
     if (GEO_my_WP::gmw_check_addon('single_location')) {
         include 'plugins/single-location/loader.php';
     }
     //load Posts Types locator add-on
     if (GEO_my_WP::gmw_check_addon('posts')) {
         include 'plugins/posts/loader.php';
     }
     //load friends locator add-on
     if (GEO_my_WP::gmw_check_addon('friends')) {
         include 'plugins/friends/loader.php';
     }
     //load Sweetdate Theme locator add-on
     if (GEO_my_WP::gmw_check_addon('sweetdate_geolocation')) {
         include 'plugins/sweetdate-geolocation/loader.php';
     }
 }
/**
 * GMW get address field
 * @param  array  $gmw    the form being used
 * @param  false $id      deprecated
 * @param  string  $class additional classes for the input field
 * @return mix            HTML element
 * @since 1.0
 */
function gmw_get_search_form_address_field($gmw, $id = false, $class = '')
{
    $am = isset($gmw['search_form']['address_field']['mandatory']) ? 'mandatory' : '';
    $title = !empty($gmw['search_form']['address_field']['title']) ? $gmw['search_form']['address_field']['title'] : '';
    $value = !empty($_GET[$gmw['url_px'] . 'address']) ? esc_attr(sanitize_text_field(stripslashes(implode(' ', $_GET[$gmw['url_px'] . 'address'])))) : '';
    $placeholder = isset($gmw['search_form']['address_field']['within']) ? $title : '';
    $output = '<div id="gmw-address-field-wrapper-' . $gmw['ID'] . '" class="gmw-address-field-wrapper gmw-address-field-wrapper-' . $gmw['ID'] . ' ' . esc_attr($class) . '">';
    if (!isset($gmw['search_form']['address_field']['within']) && !empty($title)) {
        $output .= '<label class="gmw-field-label" for="gmw-address-' . $gmw['ID'] . '">' . esc_attr($title) . '</label>';
    }
    $output .= '<input type="text" name="' . esc_attr($gmw['url_px']) . 'address[]" id="gmw-address-' . $gmw['ID'] . '" autocomplete="off" 
    		class="gmw-address gmw-full-address gmw-address-' . $gmw['ID'] . ' ' . $class . ' ' . $am . '" 
    		value="' . $value . '" placeholder="' . esc_attr($placeholder) . '" />';
    if ($gmw['search_form']['locator_icon'] == 'within_address_field') {
        $lSubmit = isset($gmw['search_form']['locator_submit']) ? 'gmw-locator-submit' : '';
        $output .= '<div class="gmw-locator-btn-wrapper gmw-locator-btn-within-wrapper">';
        $output .= "<i id=\"{$gmw['ID']}\" class=\"fa fa-map-marker gmw-locator-btn-within gmw-locator-button gmw-locate-btn {$lSubmit}\"></i>";
        $output .= "<i id=\"gmw-locator-btn-loader-{$gmw['ID']}\" class=\"gmw-locator-btn-loader fa fa-refresh fa-spin\" alt=\"Locator image loader\" style=\"display:none;\"></i>";
        $output .= '</div>';
    }
    $output .= '</div>';
    if (isset($gmw['search_form']['address_field']['address_autocomplete'])) {
        GEO_my_WP::google_places_address_autocomplete(array('gmw-address-' . $gmw['ID']));
    }
    return apply_filters('gmw_search_form_address_field', $output, $gmw, false, $class);
}
        }
        ?>
 
            </select>
        </p>
        <p>
        	<input type="checkbox" value="1" name="<?php 
        echo $this->get_field_name('scrollwheel');
        ?>
" <?php 
        if (isset($instance["scrollwheel"])) {
            echo 'checked="checked"';
        }
        ?>
 class="checkbox" />
            <label><?php 
        echo esc_attr(__('ScrollWheel Enabled', 'GMW'));
        ?>
</label>       
        	<em style="font-size:12px;color:#777;display:block;margin:5px 0px;">
            	<?php 
        _e("When enabled the map will zoom in/out using the mouse scrollwheel.", 'GMW');
        ?>
            </em> 
        </p>
        <?php 
    }
}
if (!GEO_my_WP::gmw_check_addon('current_location')) {
    add_action('widgets_init', create_function('', 'return register_widget( "GMW_Current_Location_Widget_Dep" );'));
}
示例#10
0
    /**
     * Modify the BP query caluses
     * 
     * @param unknown_type $gmwBpQuery
     * @return unknown
     */
    public function bp_pre_user_query($gmwBpQuery)
    {
        global $wpdb;
        //break the select clause into 2: SELECT and FROM so we can modify it based on out needs
        $select_clause = explode('FROM', $gmwBpQuery->uid_clauses['select']);
        //find the user_id column based on the query type
        $uid_col = in_array($gmwBpQuery->query_vars['type'], array("alphabetical", 'distance')) ? 'u.ID' : 'u.user_id';
        //default values
        $fields = '';
        $from = '';
        $having = '';
        $where = '';
        $orderby = '';
        //if address entered
        if (!empty($this->formData['address'])) {
            //geocode the address entered
            $this->returned_address = GEO_my_WP::geocoder(sanitize_text_field($this->formData['address']));
            //If form submitted and address was not found stop search and display no results
            if (isset($this->returned_address['error'])) {
                $this->formData['address_found'] = false;
                $this->formData['your_lat'] = false;
                $this->formData['your_lng'] = false;
                $this->formData['address'] = 'error';
                //modify the query to no results
                $gmwBpQuery->uid_clauses['where'] = ' WHERE 0 = 1 ';
                $gmwBpQuery->uid_clauses['orderby'] = ' ';
                $gmwBpQuery->uid_clauses['limit'] = ' ';
                $gmwBpQuery->uid_clauses['order'] = ' ';
                ?>
    			<script> 
    				//pass some values to javascript     	
    				jQuery(window).ready(function($) {          		
    			       	jQuery('#members-dir-list #message').html('<?php 
                echo $this->labels['address_error_message'];
                ?>
');     	
    			 	});
    			</script>
    			<?php 
            } else {
                $this->formData['address_found'] = true;
                $this->formData['your_lat'] = $this->returned_address['lat'];
                $this->formData['your_lng'] = $this->returned_address['lng'];
                //do radius calculation
                $fields = $wpdb->prepare(" , ROUND( %d * acos( cos( radians( %s ) ) * cos( radians( gmwlocations.lat ) ) * cos( radians( gmwlocations.long ) - radians( %s ) ) + sin( radians( %s ) ) * sin( radians( gmwlocations.lat) ) ),1 ) AS distance ", array($this->settings['units'], $this->formData['your_lat'], $this->formData['your_lng'], $this->formData['your_lat']));
                //from clause joining locations table
                $from = "INNER JOIN wppl_friends_locator gmwlocations ON {$uid_col} = gmwlocations.member_id";
                //HAVING clause to display members within the distance entered
                if (!empty($this->formData['radius'])) {
                    $having = $wpdb->prepare('HAVING distance <= %d OR distance IS NULL ', $this->formData['radius']);
                }
                //if order by distance
                if ($gmwBpQuery->query_vars['type'] == 'distance') {
                    $gmwBpQuery->uid_clauses['orderby'] = 'ORDER BY distance';
                }
            }
            //if no address entered
        } else {
            //join the locations table to the query
            $from = "LEFT JOIN wppl_friends_locator gmwlocations ON {$uid_col} = gmwlocations.member_id";
            if ($this->formData['orderby'] == 'distance') {
                $this->formData['orderby'] = 'active';
            }
        }
        //apply our filters to BP_user_qeury clauses
        $gmwBpQuery->query_vars['count_total'] = 'sql_calc_found_rows';
        $gmwBpQuery->uid_clauses['select'] = "{$select_clause[0]} {$fields} FROM {$select_clause[1]} {$from} ";
        $gmwBpQuery->uid_clauses['where'] .= $where;
        $gmwBpQuery->uid_clauses['where'] .= $having;
        //modify the clauses
        $gmwBpQuery = apply_filters('gmw_sd_after_bp_pre_user_query', $gmwBpQuery, $this->formData, $this->settings);
        return $gmwBpQuery;
    }
/**
 * Export/Import tab output
 *
 * @access public
 * @since 2.5
 * @author Eyal Fitoussi
 */
function gmw_output_import_export_tab()
{
    ?>
	
	<div class="gmw-tabs-table">
		<div class="gmw-tabs-table gmw-edit-form-page-nav-tabs gmw-nav-tab-wrapper">
			<?php 
    $ei_tabs = array('ei_data' => __('GEO my WP Data', 'GMW'));
    if (GEO_my_WP::gmw_check_addon('posts')) {
        $ei_tabs['ei_pt_locations'] = __('Post Types Locations', 'GMW');
        $ei_tabs['plugins_importer'] = __('Other Plugins Importer', 'GMW');
    }
    $ei_tabs = apply_filters('gmw_tools_page_import_export_tabs', $ei_tabs);
    foreach ($ei_tabs as $key => $title) {
        echo '<span><a href="#settings-' . sanitize_title($key) . '" id="' . sanitize_title($key) . '" title="' . esc_html($title) . '"  class="gmw-nav-tab gmw-nav-trigger">' . esc_html($title) . '</a></span>';
    }
    ?>
		</div>
	</div>
		
	<div id="gmw-import-export-tab-content" class="gmw-tools-tab-content">
	
		<div id="settings-ei_data" class="gmw-settings-panel gmw-import-export-page-tab-wrapper">
	
			<?php 
    do_action('gmw_export_import_top');
    ?>
	
			<?php 
    do_action('gmw_export_import_before_ei_data');
    ?>
						
			<!-- Export Settings box -->
			<div class="postbox">
				
				<div class="inside-top">
					<h3>
						<span><?php 
    _e('Export/Import Data', 'GMW');
    ?>
 </span>
					</h3>
					<div class="inside">
						<p>
							<?php 
    _e("Use the Export and Import data forms below to create a back-up file ( .json ) of GEO my WP's data; the settings of GEO my WP and its add-ons, the forms you created and license keys you might have activated.", "GMW");
    ?>
<br />
							<?php 
    _e("You can use the back-up file to restore the data on this site in case that something goes wrong or you could import it into a different site.", "GMW");
    ?>
<br />
						</p>
						<p>
							<?php 
    _e("Please follow the steps of each form below for a complete process of exporting and importing your data.", "GMW");
    ?>
<br />	
							<br />
							<span class="description">
								<?php 
    _e("*Note, the license keys should only be imported back to the same site it was exported from. If you need to activate your license keys on a different site you should first deactivate them on this site then activate them back on the other site.", "GMW");
    ?>
							</span>
						</p>
					</div>
				</div>
				
				<div class="inside-middle">
					<h3>
						<span><?php 
    _e('Export Data', 'GMW');
    ?>
 </span>
					</h3>
					<div class="inside">
						<p>
							<?php 
    _e('To export your data please check the checkboxes of the items that you would like to export then click the "Export" button to create a .json file.', 'GMW');
    ?>
						</p>
						</strong>
		
						<form method="post" action="<?php 
    echo admin_url('admin.php?page=gmw-tools&tab=import_export');
    ?>
">
							<p>
								<span>
									<input type="checkbox" class="cb-export-item" name="export_item[]" value="settings" checked="checked" /><?php 
    _e('Settings', 'GMW');
    ?>
									<em class="description"><?php 
    _e('( GEO my WP and its add-ons )', 'GMW');
    ?>
</em>
								</span>
								<span><input type="checkbox" class="cb-export-item" name="export_item[]" value="forms" checked="checked" /><?php 
    _e('Forms', 'GMW');
    ?>
</span>
								<span>
									<input type="checkbox" class="cb-export-item" name="export_item[]" value="licenses" checked="checked" /><?php 
    _e('License Keys', 'GMW');
    ?>
									<em class="description"><?php 
    _e('( exported license keys should only be imported back to this site. )', 'GMW');
    ?>
</em>
								</span>
							</p>
							<p>
								<input type="hidden" name="gmw_action" value="export_data" />
								<?php 
    wp_nonce_field('gmw_export_data_nonce', 'gmw_export_data_nonce');
    ?>
								<?php 
    submit_button(__('Export', 'GMW'), 'secondary', 'submit', false, array('onclick' => "if ( !jQuery('.cb-export-item').is(':checked') ) { alert('You must check at least one item that you\\'d like to export.'); return false; }"));
    ?>
							</p>
						</form>
		
					</div>
				</div>
				<!-- .inside -->
	
				<div class="inside-bottom">
					<h3>
						<span><?php 
    _e('Import Data', 'GMW');
    ?>
 </span>
					</h3>
					<div class="inside">
		
						<p>
							<?php 
    _e('Import GEO my WP data from a .json file. The file can be created using the export form above.', 'GMW');
    ?>
						</p>
		
						<form method="post" enctype="multipart/form-data" action="<?php 
    echo admin_url('admin.php?page=gmw-tools&tab=import_export');
    ?>
">
							<p>
								<?php 
    _e("To import data first choose the .json file you would like to use. Then check the checkboxes of the items that you would like to import and click the \"Import\" button.", "GMW");
    ?>
							</p>
							<p>
								<input type="file" name="import_file" />
							</p>
							<p>
								<span><input type="checkbox" class="cb-import-item" name="import_item[]" value="settings" checked="checked" /><?php 
    _e('Settings', 'GMW');
    ?>
</span>
								<span><input type="checkbox" class="cb-import-item" name="import_item[]" value="forms"    checked="checked" /><?php 
    _e('Forms', 'GMW');
    ?>
</span>
								<span><input type="checkbox" class="cb-import-item" name="import_item[]" value="licenses" checked="checked" /> <?php 
    _e('License Keys', 'GMW');
    ?>
</span>
							</p>
							<p>
								<input type="hidden" name="gmw_action" value="import_data" />
								<?php 
    wp_nonce_field('gmw_import_nonce', 'gmw_import_nonce');
    ?>
								<?php 
    submit_button(__('Import', 'GMW'), 'secondary', 'submit', false, array('onclick' => "if ( !jQuery('.cb-import-item').is(':checked') ) { alert('You must check at least one item that you\\'d like to import.'); return false; }"));
    ?>
							</p>
						</form>
		
					</div>
				</div>
	
			</div>
			<!-- .postbox -->
	
			<?php 
    do_action('gmw_export_import_after_ei_data');
    ?>
		</div>
		
		<div id="settings-ei_pt_locations" class="gmw-settings-panel gmw-import-export-page-tab-wrapper">
			
			<?php 
    do_action('gmw_export_import_before_pt_locations_to_post_meta');
    ?>
			
			<!--  make sure Post types locator add-on is activated -->
			<?php 
    if (GEO_my_WP::gmw_check_addon('posts')) {
        ?>
				
			<!-- Import settings box -->
			<div class="postbox">
				
				<div class="inside-top">
					<h3>
						<span><?php 
        _e("Export/Import Posts Types Locations using GEO my WP's post_meta", "GMW");
        ?>
 </span>
					</h3>
		
					<div class="inside">
						<p>
							<?php 
        _e("The forms below will help you in the process of exporting the post types locations created on this site and importing them into a different site.", "GMW");
        ?>
<br />
							<?php 
        printf(__("The export/import forms below need to be used together with the native <a href=\"%s\" target=\"blank\"> WordPress export system*</a> and <a href=\"%s\" target\"_blank\">WordPress importer*</a> for a complete process.", "GMW"), admin_url('export.php'), admin_url('import.php'));
        ?>
<br />
						</p>
						<p class="description">	
							<?php 
        _e("*You can use other plugins ( other than the WordPress native plugins mentioned above ) to export/import your WordPress posts. However, the plugins you chose to use must export and import the custom fields of these posts in order to import/export the locations.", "GMW");
        ?>
						</p>
						<p>
							<?php 
        _e("Please follow the steps of each form below for a complete process of exporting and importing your post types locations.", "GMW");
        ?>
<br />				
						</p>
		
					</div>
				</div>
				
				<div class="inside-middle">
					<h3>
						<span><?php 
        _e("Export Posts Types Locations To GEO my WP's post_meta", "GMW");
        ?>
 </span>
					</h3>
		
					<div class="inside">
						<ol>	
							<?php 
        global $wpdb;
        ?>
 
							<li>
								<?php 
        printf(__("Click on the \"Export\" button below. By doing so the plugin will duplicate each post type location created on this site from GEO my WP's custom table ( %splaces_locator ) into a custom field of the post it belongs to.", "GMW"), $wpdb->prefix);
        ?>
								<form method="post" enctype="multipart/form-data" action="<?php 
        echo admin_url('admin.php?page=gmw-tools&tab=import_export');
        ?>
">
									<p>
										<input type="hidden" name="gmw_action" value="pt_locations_post_meta_export" />
										<?php 
        wp_nonce_field('gmw_pt_locations_post_meta_export_nonce', 'gmw_pt_locations_post_meta_export_nonce');
        ?>
										<?php 
        submit_button(__('Export', 'GMW'), 'secondary', 'submit', false);
        ?>
									</p>
								</form>
							</li>
							<li><?php 
        printf(__("The next step will be to export your posts using the native <a href=\"%s\" target=\"blank\"> WordPress export system</a>.", "GMW"), admin_url('export.php'));
        ?>
</li>
						</ol>
					</div>
				</div>
				<!-- .inside -->
	
				<div class="inside-bottom">
					<h3>
						<span><?php 
        _e("Import Posts Types Locations From GEO my WP's post_meta", "GMW");
        ?>
 </span>
					</h3>
		
					<div class="inside">
						<ol>
							<li><?php 
        _e("Before importing your locations into this site make sure you used the \"Export\" form above on the original site in order to export your locations.", "GMW");
        ?>
</li>
							<li><?php 
        printf(__("Import your posts using <a href=\"%s\" target\"_blank\">WordPress importer</a>. After done so come back to this page to complete step 3.", "GMW"), admin_url('import.php'));
        ?>
</li>
							<li><?php 
        printf(__("Click on the \"Import\" button. By doing so the plugin will duplicate each post type location from the custom field of the post it belongs to into GEO my WP's custom table in database ( %splaces_locator ).", "GMW"), $wpdb->prefix);
        ?>
</li>
						</ol>
		
						<?php 
        //get all custom fields with gmw location from database
        $check_pm_locations = $wpdb->get_results("\n\t\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\t\tFROM `{$wpdb->prefix}postmeta`\n\t\t\t\t\t\t\t\tWHERE `meta_key` = 'gmw_pt_location'", ARRAY_A);
        //abort if no locations found
        $check_pm_locations = !empty($check_pm_locations) ? true : false;
        ?>
						<form method="post" enctype="multipart/form-data" action="<?php 
        echo admin_url('admin.php?page=gmw-tools&tab=import_export');
        ?>
">
							<p>
								<input type="hidden" name="gmw_action" value="pt_locations_post_meta_import" />
								<?php 
        wp_nonce_field('gmw_pt_locations_post_meta_import_nonce', 'gmw_pt_locations_post_meta_import_nonce');
        ?>
								<input type="submit" class="button-secondary" value="<?php 
        _e("Import", "GMW");
        ?>
" <?php 
        if (!$check_pm_locations) {
            echo 'disabled="disabled"';
        }
        ?>
/>
								<?php 
        echo $check_pm_locations ? '<em style="color:green">' . __('Locations are avalible for import.', "GMW") . '</em>' : '<em style="color:red">' . __('No locations are avalible for import.', "GMW") . '</em>';
        ?>
							</p>
						</form>
		
					</div>
				</div>
			</div>
			
			<!-- .postbox -->
	
			<?php 
        do_action('gmw_export_import_after_pt_locations_to_post_meta');
        ?>
			
			<?php 
        do_action('gmw_export_import_before_pt_locations_to_custom_post_meta');
        ?>
							
			<!-- Import settings box -->
			<div class="postbox">
				
				<div class="inside-top">
					<h3>
						<span><?php 
        _e('Import Posts Types Locations Using Custom post_meta', 'GMW');
        ?>
 </span>
					</h3>
					
					<div class="inside">
						<p>
							<?php 
        _e("Using this form you can import locations to GEO my WP using the custom fields of your choice. This can be helpful when you want to import locations created by other plugin and its location data is being saved in custom fields.", "GMW");
        ?>
<br />
						</p>
						<p>
							<?php 
        _e("To import the locations click on the \"Set custom field\" link to see the fields. You can choose a custom field from the dropdown menus for each location component that exists in GEO my WP database table.", "GMW");
        ?>
<br />				
							<?php 
        _e("Note that the latitude and longitude fields are mandatory as without both of the fields GEO my WP cannot perform the search query.", "GMW");
        ?>
<br />
							<?php 
        _e("Other than the lat/long fields the rest of the fields are optional and search can be performed without them. However, certain fields might be needed for certain features. ", "GMW");
        ?>
<br />
						</p>
		
						<form method="post" enctype="multipart/form-data" action="<?php 
        echo admin_url('admin.php?page=gmw-tools&tab=import_export');
        ?>
">
							<?php 
        $gmw_settings = get_option('gmw_options');
        $saved_field = !empty($gmw_settings['tools_page_options']['gmw_pt_import_custom_post_meta']) ? $gmw_settings['tools_page_options']['gmw_pt_import_custom_post_meta'] : array();
        global $wpdb;
        //get custom fields
        $cFields = $wpdb->get_col("\n\t\t\t\t\t        \tSELECT meta_key\n\t\t\t\t\t        \tFROM {$wpdb->postmeta}\n\t\t\t\t\t        \tGROUP BY meta_key\n\t\t\t\t\t        \tORDER BY meta_id DESC");
        if ($cFields) {
            natcasesort($cFields);
        }
        $fieldsArray = array('lat' => __('Latitude ( mandatory )', 'GMW'), 'long' => __('Longitude ( mandatory )', 'GMW'), 'street' => __('Street', 'GMW'), 'apt' => __('Apt', 'GMW'), 'city' => __('City', 'GMW'), 'state' => __('State Short Name ( ex. FL )', 'GMW'), 'state_long' => __('State Long name ( ex. Florida )', 'GMW'), 'zipcode' => __('zipcode', 'GMW'), 'country' => __('Country Short Name ( ex. US )', 'GMW'), 'country_long' => __('Country Long Name ( ex. United States )', 'GMW'), 'address' => __('Address ( address field the way the user enteres )', 'GMW'), 'formatted_address' => __('Formatted Address ( formatted address returned from Google after geocoding )', 'GMW'), 'phone' => __('Phone', 'GMW'), 'fax' => __('Fax', 'GMW'), 'email' => __('Email', 'GMW'), 'website' => __('Website', 'GMW'), 'map_icon' => __('Map Icon', 'GMW'));
        ?>
					        <a href="#" id="post-meta-fields-toggle" onclick="event.preventDefault(); jQuery('#post-meta-wrapper').slideToggle();"><?php 
        _e('Set Custom Fields', 'GMW');
        ?>
</a>
					        <div id="post-meta-wrapper" style="display:none">					
								<?php 
        foreach ($fieldsArray as $name => $title) {
            ?>
			
									<p>
										<label><?php 
            echo $title;
            ?>
: </label><br />
										<select id="gmw-import-custom-field-<?php 
            echo $name;
            ?>
" class="gmw-import-custom-field" name="gmw_post_meta[<?php 
            echo $name;
            ?>
]">
											<option value="" selected="selected"><?php 
            _e('N/A', 'GMW');
            ?>
 
											<?php 
            foreach ($cFields as $cField) {
                ?>
			
										   		<option <?php 
                if (!empty($saved_field[$name])) {
                    selected($saved_field[$name], $cField);
                }
                ?>
 value="<?php 
                echo $cField;
                ?>
"><?php 
                echo $cField;
                ?>
</option>										
											<?php 
            }
            ?>
										</select>
									</p>	
								<?php 
        }
        ?>
							</div>
							<p>	
								<input type="hidden" name="gmw_action" value="pt_locations_custom_post_meta_import" />
								<?php 
        wp_nonce_field('gmw_pt_locations_custom_post_meta_import_nonce', 'gmw_pt_locations_custom_post_meta_import_nonce');
        ?>
								<input type="submit" id="import-custom-post-meta-submit" class="button-secondary" value="<?php 
        _e("Import", "GMW");
        ?>
" />
								<script>
									jQuery(document).ready(function($) {
										$('#import-custom-post-meta-submit').click(function() {
											if ( $('#gmw-import-custom-field-lat').val() == '' || $('#gmw-import-custom-field-long').val() == '' ) {
												alert( 'You must have both Latitude and longitude field to be able to import locations' );
												return false;
											};
										});
									});
								</script>
							</p>
						</form>
		
					</div>
				</div>
			</div>
			<!-- .postbox -->
	
			<?php 
        do_action('gmw_export_import_after_pt_locations_to_custom_post_meta');
        ?>
		
			<?php 
        do_action('gmw_export_import_before_pt_locations_to_csv');
        ?>
			
			<div class="postbox">
				
				<div class="inside-top">
					<h3>
						<?php 
        _e('Export/Import Post Type Locations using CSV File', 'GMW');
        ?>
					</h3>
					
					<div class="inside">
						
						<p>
						   <?php 
        _e("Export/Import locations using CSV file should be used for backup purposes only. The best method for export/import post types locations between different sites is by using the post_meta export/import forms above. ", "GMW");
        ?>
<br />
						   <?php 
        _e("Export/import locations between different sites using CSV file can only be done when the posts and thier post ID are equal on both the original site and the target site.", "GMW");
        ?>
<br />
						   <?php 
        printf(__("By exporting the locations to CSV file the plugin simply backup GEO my WP's custom database table ( %splaces_locator ) when each location has the post ID it belongs to.", "GMW"), $wpdb->prefix);
        ?>
<br />
						   <?php 
        _e("And so, when importing the location back from the CSV file the posts from the original site must exists with thier original post ID in the target site. ", "GMW");
        ?>
<br />
						<p>
							
					</div>
				</div>
				
				<div class="inside-middle">
				
					<h3>
						<?php 
        _e('Export Post Type Locations to CSV File', 'GMW');
        ?>
					</h3>
					
					<div class="inside">
						
						<p><?php 
        _e("Click the \"Generate CSV\" button to created a CSV back file of the post types locations created on this site.", "GMW");
        ?>
</p>
						<p>
							<form method="post" id="gmw_csv_export_pt_locations">
							
								<input type="hidden" name="gmw_action" value="pt_locations_csv_export"/>
								<input type="submit" value="<?php 
        _e('Generate CSV', 'GMW');
        ?>
" class="button-secondary"/>
							</form>
						</p>
						
					</div><!-- .inside -->
				</div>
				
				<div class="inside-bottom">
						
					<h3>
						<span><?php 
        _e('Import Post Type Locations From CSV File', 'GMW');
        ?>
 </span>
					</h3>
					<div class="inside">
		
						<p>
							<?php 
        _e("Choose the CSV file you would like to import and click the \"Import\" button to import the locations into GEO my WP's database table.", "GMW");
        ?>
						</p>
		
						<form method="post" enctype="multipart/form-data" action="<?php 
        echo admin_url('admin.php?page=gmw-tools&tab=import_export');
        ?>
">
							<p>
								<input type="file" name="import_csv_file" />
							</p>						
							<p>
								<input type="hidden" name="gmw_action" value="pt_locations_csv_import" />
								<?php 
        wp_nonce_field('gmw_pt_locations_csv_import_nonce', 'gmw_pt_locations_csv_import_nonce');
        ?>
								<?php 
        submit_button(__('Import', 'GMW'), 'secondary', 'submit', false);
        ?>
							</p>
						</form>
		
					</div>
				</div>
	
			</div>
				
			<?php 
        do_action('gmw_export_import_after_pt_locations_to_csv');
        ?>
			
		</div>
		<?php 
        /* ?>
        		<div id="settings-ei_users_locations" class="gmw-settings-panel gmw-import-export-page-tab-wrapper">
        			
        			<?php do_action( 'gmw_export_import_before_fl_locations_to_csv' ); ?>
        			
        			<div class="postbox">
        				
        				<div class="inside-top">
        					<h3>
        						<?php _e('Export/Import Users Locations using CSV File', 'GMW'); ?>
        					</h3>
        					
        					<div class="inside">
        						
        						<p>
        						   <?php _e( "Export/Import locations using CSV file should be used for backup purposes only. The best method for export/import post types locations between different sites is by using the post_meta export/import forms above. ", "GMW" ); ?><br />
        						   <?php _e( "Export/import locations between different sites using CSV file can only be done when the posts and thier post ID are equal on both the original site and the target site.", "GMW" ); ?><br />
        						   <?php printf( __( "By exporting the locations to CSV file the plugin simply backup GEO my WP's custom database table ( %splaces_locator ) when each location has the post ID it belongs to.", "GMW" ), $wpdb->prefix ); ?><br />
        						   <?php _e( "And so, when importing the location back from the CSV file the posts from the original site must exists with thier original post ID in the target site. ", "GMW" ); ?><br />
        						<p>
        							
        					</div>
        				</div>
        				
        				<div class="inside-middle">
        				
        					<h3>
        						<?php _e('Export User Locations to CSV File', 'GMW'); ?>
        					</h3>
        					
        					<div class="inside">
        						
        						<p><?php _e( "Click the \"Generate CSV\" button to created a CSV back file of the post types locations created on this site.", "GMW" ); ?></p>
        						<p>
        							<form method="post" id="gmw_csv_export_pt_locations">
        							
        								<input type="hidden" name="gmw_action" value="pt_locations_csv_export"/>
        								<input type="submit" value="<?php _e( 'Generate CSV', 'GMW' ); ?>" class="button-secondary"/>
        							</form>
        						</p>
        						
        					</div><!-- .inside -->
        				</div>
        				
        				<div class="inside-bottom">
        						
        					<h3>
        						<span><?php _e( 'Import User Locations From CSV File', 'GMW' ); ?> </span>
        					</h3>
        					<div class="inside">
        		
        						<p>
        							<?php _e( "Choose the CSV file you would like to import and click the \"Import\" button to import the locations into GEO my WP's database table.", "GMW" ); ?>
        						</p>
        		
        						<form method="post" enctype="multipart/form-data" action="<?php echo admin_url( 'admin.php?page=gmw-tools&tab=import_export' ); ?>">
        							<p>
        								<input type="file" name="import_csv_file" />
        							</p>						
        							<p>
        								<input type="hidden" name="gmw_action" value="pt_locations_csv_import" />
        								<?php wp_nonce_field( 'gmw_pt_locations_csv_import_nonce', 'gmw_pt_locations_csv_import_nonce' ); ?>
        								<?php submit_button( __( 'Import', 'GMW' ), 'secondary', 'submit', false ); ?>
        							</p>
        						</form>
        		
        					</div>
        				</div>
        	
        			</div>
        			
        			<?php do_action( 'gmw_export_import_after_pt_locations_to_csv' ); ?>
        		</div>
        			*/
        ?>
		<div id="settings-plugins_importer" class="gmw-settings-panel gmw-import-export-page-tab-wrapper">
			
			<?php 
        do_action('gmw_export_import_before_other_plugins_import');
        ?>
			
			<div class="postbox">
				
				<div class="inside-top">
					<h3>
						<?php 
        _e('Import Locations From Other Plugins', 'GMW');
        ?>
					</h3>
					
					<div class="inside">
						
						<p>
						   <?php 
        _e("Use the forms below to import locations created by different plugins into GEO my WP.", "GMW");
        ?>
<br />
						<p>
							
					</div>
				</div>
					
				<div class="inside-middle">
				
					<?php 
        $store_locator_status = is_plugin_active('store-locator/store-locator.php') ? 'active' : 'inactive';
        ?>
					<h3>
						<?php 
        printf(__('Store Locator Plugin %s', 'GMW'), $store_locator_status == 'inactive' ? ' - <em style="color:red;font-size:12px;">Plugin Inactive</em>' : '');
        ?>
					</h3>
					
					<div class="inside">
						
						<p>
							<?php 
        _e("Use this form to import locations created by <a href=\"https://wordpress.org/plugins/store-locator/\" target=\"_blank\">Store Locator plugin</a>.", "GMW");
        ?>
<br />
							<?php 
        _e("Because Store Locator plugin doesn't use post type with its locations new post will need to be created for each location being imported.", "GMW");
        ?>
<br />
							<?php 
        _e("To import the locations from Store Locator plugin first choose from the drop-down menu the post type you would like be used when importing the locations then click the \"Import\" button.", "GMW");
        ?>
<br />
						
						</p>
						<p>
							<form method="post" enctype="multipart/form-data" action="<?php 
        echo admin_url('admin.php?page=gmw-tools&tab=import_export');
        ?>
">	
							
								<p>
									<?php 
        _e("Choose a post type:", "GMW");
        ?>
								</p>
								<select id="post-type-selector" name="post_type" <?php 
        if ($store_locator_status == 'inactive') {
            echo 'disabled="disabled"';
        }
        ?>
>
									<?php 
        foreach (get_post_types() as $post_type) {
            ?>
										<option value="<?php 
            echo $post_type;
            ?>
"><?php 
            echo $post_type;
            ?>
</option>
									<?php 
        }
        ?>
								</select>				
								<p>
									<input type="hidden" name="gmw_action" value="store_locator_import" />
									<?php 
        wp_nonce_field('gmw_store_locator_import_nonce', 'gmw_store_locator_import_nonce');
        ?>
									<input type="submit" class="button-secondary" <?php 
        if ($store_locator_status == 'inactive') {
            echo 'disabled="disabled"';
        }
        ?>
 value="<?php 
        _e('Import', 'GMW');
        ?>
" />
								</p>
							</form>
						</p>
						
					</div><!-- .inside -->
				</div>
				
				<div class="inside-middle">
				
					<?php 
        $mappress_status = is_plugin_active('mappress-google-maps-for-wordpress/mappress.php') ? 'active' : 'inactive';
        ?>
					<h3>
						<?php 
        printf(__('Map-Press Plugin %s', 'GMW'), $mappress_status == 'inactive' ? ' - <em style="color:red;font-size:12px;">Plugin Inactive</em>' : '');
        ?>
					</h3>
					
					<div class="inside">
						
						<p>
							<?php 
        _e("Use this form to import locations created by <a href=\"https://wordpress.org/plugins/mappress-google-maps-for-wordpress/\" target=\"_blank\">MapPress Easy Google Maps</a> plugin.", "GMW");
        ?>
<br />
							<br />
							<span class="description">
								<?php 
        _e("*MapPress allows to creates multiple locations per post where GEO my WP does not have this capability yet. For this reason at the moment GEO my WP will only import the first location of each post. ", "GMW");
        ?>
								<br />
								<?php 
        _e("And so, if your posts have multiple locations they will be ignored except for the first one that will be imported. ", "GMW");
        ?>
								<br />
								<?php 
        _e("This issue might be improved in the future.", "GMW");
        ?>
							</span>
						<p>
							<form method="post" enctype="multipart/form-data" action="<?php 
        echo admin_url('admin.php?page=gmw-tools&tab=import_export');
        ?>
">					
								<p>
									<input type="hidden" name="gmw_action" value="mappress_import" />
									<?php 
        wp_nonce_field('gmw_mappress_import_nonce', 'gmw_mappress_import_nonce');
        ?>
									<input type="submit" class="button-secondary" <?php 
        if ($mappress_status == 'inactive') {
            echo 'disabled="disabled"';
        }
        ?>
 value="<?php 
        _e('Import', 'GMW');
        ?>
" />
								</p>
							</form>
						</p>
						
					</div><!-- .inside -->
				</div>
			</div>
		
		</div>	
			
			<!-- end of addon check -->
		<?php 
    }
    ?>
	
			
		<?php 
    do_action('gmw_export_import_bottom');
    ?>
	
		<?php 
    $current_tab = isset($_COOKIE['gmw_admin_tab']) ? $_COOKIE['gmw_admin_tab'] : false;
    ?>
	</div>
 	<script type="text/javascript">
		jQuery(document).ready(function($) {
         	if ( '<?php 
    echo $current_tab;
    ?>
' != false ) { 
         		jQuery('#<?php 
    echo $current_tab;
    ?>
').click();
         	}
		});
	</script>
<?php 
}