コード例 #1
0
/**
 * Output the author page title including HTML wrappers.
 *
 * @global string $term Current term slug.
 * @since 1.0.0
 * @package GeoDirectory
 */
function geodir_action_author_page_title()
{
    global $term;
    $gd_post_type = geodir_get_current_posttype();
    $post_type_info = get_post_type_object($gd_post_type);
    $add_string_in_title = __('All', GEODIRECTORY_TEXTDOMAIN) . ' ';
    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
        $add_string_in_title = __('My Favorite', GEODIRECTORY_TEXTDOMAIN) . ' ';
    }
    $list_title = $add_string_in_title . $post_type_info->labels->name;
    $single_name = $post_type_info->labels->singular_name;
    $taxonomy = geodir_get_taxonomies($gd_post_type);
    if (!empty($term)) {
        $current_term = get_term_by('slug', $term, $taxonomy[0]);
        if (!empty($current_term)) {
            $list_title .= __(' in', GEODIRECTORY_TEXTDOMAIN) . " '" . ucwords($current_term->name) . "'";
        }
    }
    if (is_search()) {
        $list_title = __('Search', GEODIRECTORY_TEXTDOMAIN) . ' ' . __($post_type_info->labels->name, GEODIRECTORY_TEXTDOMAIN) . __(' For :', GEODIRECTORY_TEXTDOMAIN) . " '" . get_search_query() . "'";
    }
    /** This action is documented in geodirectory_template_actions.php */
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
    /** This action is documented in geodirectory_template_actions.php */
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . apply_filters('geodir_author_page_title_text', wptexturize($list_title)) . '</h1></header>';
}
コード例 #2
0
/**
 * Update markers on category Edit.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @global string $plugin_prefix Geodirectory plugin table prefix.
 * @param string $term_id The term ID as string.
 * @param int $tt_id The term taxonomy ID.
 * @param string $taxonomy The taxonomy slug.
 */
function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy)
{
    global $plugin_prefix, $wpdb;
    $gd_taxonomies = geodir_get_taxonomies();
    if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
        $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
        $table = $plugin_prefix . $geodir_post_type . '_detail';
        $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
        $posts = $wpdb->get_results($wpdb->prepare("SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", array($term_id, $taxonomy)));
        if (!empty($posts)) {
            foreach ($posts as $post_obj) {
                $lat = $post_obj->post_latitude;
                $lng = $post_obj->post_longitude;
                $json = '{';
                $json .= '"id":"' . $post_obj->post_id . '",';
                $json .= '"lat_pos": "' . $lat . '",';
                $json .= '"long_pos": "' . $lng . '",';
                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
                $json .= '"icon":"' . $term_icon . '",';
                $json .= '"group":"catgroup' . $term_id . '"';
                $json .= '}';
                if ($post_obj->default_category == $term_id) {
                    $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET marker_json = %s where post_id = %d", array($json, $post_obj->post_id)));
                }
                $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", array($json, $post_obj->post_id, $term_id)));
            }
        }
    }
}
コード例 #3
0
/**
* The geodirectory listings shortcode.
*
* This implements the functionality of the shortcode for displaying geodirectory listings.
*
* @since 1.4.2
*
* @param array $atts {
*     Attributes of the shortcode.
*
*     @type string $title         The title to be displayed above listings.
*     @type string $post_type     Post type of listing. Default gd_place.
*     @type string $category      Category ids to filter listings. Ex: 1,3. Default empty.
*     @type string $list_sort     Sorting for listings. Should be from az, latest, featured, 
                                  high_review, high_rating.Default 'latest'.
*     @type string $event_type    Event type filter. Should today, upcoming, past, all. Default empty.
                                  For post type gd_event only. 
*     @type int    $post_number   No. of post to display. Default 10.
*     @type string $layout        Layout to display listing. Should be gridview_onehalf, gridview_onethird
                                  gridview_onefourth, gridview_onefifth, list. Default 'gridview_onehalf'.
*     @type string $listing_width Listing width. Optional
*     @type int      $character_count     The excerpt length of content
*     @type int|bool $add_location_filter Filter listings using current location. Default 1.
*     @type int|bool $show_featured_only  Display only featured listings. Default empty.
*     @type int|bool $show_special_only   Display only special offers listings. Default empty.
*     @type int|bool $with_pics_only      Display listings which has image available. Default empty.
*     @type int|bool $with_videos_only    Display listings which has video available. Default empty.
*     @type int|bool $with_pagination     Display pagination for listings. Default 1.
*     @type int|bool $top_pagination      Display pagination on top of listings. Default 0.
                                          Required $with_pagination true.
*     @type int|bool $bottom_pagination   Display pagination on bottom of listings. Default 1.
                                          Required $with_pagination true.
* }
* @param string $content The enclosed content. Optional.
* @return string HTML content to display geodirectory listings.
*/
function geodir_sc_gd_listings($atts, $content = '')
{
    $defaults = array('title' => '', 'post_type' => 'gd_place', 'category' => 0, 'list_sort' => 'latest', 'event_type' => '', 'post_number' => 10, 'layout' => 'gridview_onehalf', 'listing_width' => '', 'character_count' => 20, 'add_location_filter' => 1, 'show_featured_only' => '', 'show_special_only' => '', 'with_pics_only' => '', 'with_videos_only' => '', 'with_pagination' => '1', 'top_pagination' => '0', 'bottom_pagination' => '1');
    $params = shortcode_atts($defaults, $atts);
    $params['title'] = wp_strip_all_tags($params['title']);
    $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place';
    // Validate the selected category/ies - Grab the current list based on post_type
    $category_taxonomy = geodir_get_taxonomies($params['post_type']);
    $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids'));
    // Make sure we have an array
    if (!is_array($params['category'])) {
        $params['category'] = explode(',', $params['category']);
    }
    // Array_intersect returns only the items in $params['category'] that are also in our category list
    // Otherwise it becomes empty and later on that will mean "All"
    $params['category'] = array_intersect($params['category'], $categories);
    // Post_number needs to be a positive integer
    $params['post_number'] = absint($params['post_number']);
    $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10;
    // Validate character_count
    //todo: is this necessary?
    $params['character_count'] = $params['character_count'];
    // Validate our layout choice
    // Outside of the norm, I added some more simple terms to match the existing
    // So now I just run the switch to set it properly.
    $params['layout'] = gdsc_validate_layout_choice($params['layout']);
    // Validate our sorting choice
    $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']);
    // Validate Listing width, used in the template widget-listing-listview.php
    // The context is in width=$listing_width% - So we need a positive number between 0 & 100
    $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
    // Validate the checkboxes used on the widget
    $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
    $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']);
    $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']);
    $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']);
    $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']);
    $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']);
    $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']);
    $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']);
    /**
     * End of validation
     */
    if (isset($atts['geodir_ajax'])) {
        $params['geodir_ajax'] = $atts['geodir_ajax'];
        unset($atts['geodir_ajax']);
    }
    if (isset($atts['pageno'])) {
        $params['pageno'] = $atts['pageno'];
        unset($atts['pageno']);
    }
    $params['shortcode_atts'] = $atts;
    $output = geodir_sc_gd_listings_output($params);
    return $output;
}
コード例 #4
0
/**
 *
 * @global object $wpdb WordPress Database object.
 *
 * @param $atts
 * @return string
 */
function geodir_sc_popular_in_neighbourhood($atts)
{
    ob_start();
    $defaults = array('post_type' => 'gd_place', 'category' => '0', 'list_sort' => 'latest', 'post_number' => 5, 'layout' => 'gridview_onehalf', 'character_count' => 20, 'add_location_filter' => 1);
    $params = shortcode_atts($defaults, $atts);
    /**
     * Being validating $params
     */
    // Check we have a valid post_type
    if (!gdsc_is_post_type_valid($params['post_type'])) {
        $params['post_type'] = 'gd_place';
    }
    // Manage the entered categories
    if (0 != $params['category'] || '' != $params['category']) {
        $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']);
    }
    // Validate our sorting choice
    $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']);
    // Post_number needs to be a positive integer
    $params['post_number'] = absint($params['post_number']);
    if (0 == $params['post_number']) {
        $params['post_number'] = 1;
    }
    // Validate our layout choice
    // Outside of the norm, I added some more simple terms to match the existing
    // So now I just run the switch to set it properly.
    $params['layout'] = gdsc_validate_layout_choice($params['layout']);
    // Validate character_count
    $params['character_count'] = absint($params['character_count']);
    if (20 > $params['character_count']) {
        $params['character_count'] = 20;
    }
    /**
     * End validation
     */
    global $wpdb, $post, $geodir_post_type;
    if ($geodir_post_type == '') {
        $geodir_post_type = 'gd_place';
    }
    $all_postypes = geodir_get_posttypes();
    $location_id = '';
    $not_in_array = array();
    if (geodir_is_page('detail') || geodir_is_page('preview') || geodir_is_page('add-listing')) {
        if (isset($post->post_type) && $post->post_type == $params['post_type'] && isset($post->post_location_id)) {
            $not_in_array[] = $post->ID;
            $location_id = $post->post_location_id;
        }
    } elseif (in_array($geodir_post_type, $all_postypes) && $geodir_post_type == $params['post_type']) {
        if (isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '') {
            $location_id = $wpdb->get_var($wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug = %s", array($_SESSION['gd_city'])));
        } else {
            $default_location = geodir_get_default_location();
            $location_id = $default_location->location_id;
        }
    }
    $gd_neighbourhoods = geodir_get_neighbourhoods($location_id);
    if ($gd_neighbourhoods) {
        ?>

		<div class="geodir_locations geodir_location_listing">
			<?php 
        $hood_slug_arr = array();
        if (!empty($gd_neighbourhoods)) {
            foreach ($gd_neighbourhoods as $hoodslug) {
                $hood_slug_arr[] = $hoodslug->hood_slug;
            }
        }
        $query_args = array('posts_per_page' => $params['post_number'], 'is_geodir_loop' => true, 'post__not_in' => $not_in_array, 'gd_neighbourhood' => $hood_slug_arr, 'gd_location' => $params['add_location_filter'] ? true : false, 'post_type' => $params['post_type'], 'order_by' => $params['list_sort'], 'excerpt_length' => $params['character_count']);
        if ($params['category'] != 0 || $params['category'] != '') {
            $category_taxonomy = geodir_get_taxonomies($params['post_type']);
            $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $params['category']);
            $query_args['tax_query'] = array($tax_query);
        }
        global $gridview_columns;
        query_posts($query_args);
        if (strstr($params['layout'], 'gridview')) {
            $listing_view_exp = explode('_', $params['layout']);
            $gridview_columns = $params['layout'];
            $layout = $listing_view_exp[0];
        }
        $template = apply_filters("geodir_template_part-listing-listview", geodir_plugin_path() . '/geodirectory-templates/listing-listview.php');
        include $template;
        wp_reset_query();
        ?>

		</div>

	<?php 
    }
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
コード例 #5
0
/**
 * Output the author page title including HTML wrappers.
 *
 * @global string $term Current term slug.
 * @since 1.0.0
 * @package GeoDirectory
 */
function geodir_action_author_page_title()
{
    global $term;
    $gd_post_type = geodir_get_current_posttype();
    $post_type_info = get_post_type_object($gd_post_type);
    $add_string_in_title = __('All', 'geodirectory') . ' ';
    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
        $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
    }
    $list_title = $add_string_in_title . $post_type_info->labels->name;
    $single_name = $post_type_info->labels->singular_name;
    $taxonomy = geodir_get_taxonomies($gd_post_type);
    if (!empty($term)) {
        $current_term = get_term_by('slug', $term, $taxonomy[0]);
        if (!empty($current_term)) {
            $list_title .= __(' in', 'geodirectory') . " '" . geodir_ucwords($current_term->name) . "'";
        }
    }
    if (is_search()) {
        $list_title = __('Search', 'geodirectory') . ' ' . __($post_type_info->labels->name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
    }
    /** This action is documented in geodirectory_template_actions.php */
    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
    /** This action is documented in geodirectory_template_actions.php */
    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
    $title = $list_title;
    if (geodir_is_page('author')) {
        $gd_page = 'author';
        if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
            $title = get_option('geodir_page_title_favorite') ? get_option('geodir_page_title_favorite') : $title;
        } else {
            $title = get_option('geodir_page_title_author') ? get_option('geodir_page_title_author') : $title;
        }
    }
    /**
     * Filter page title to replace variables.
     *
     * @since 1.5.4
     * @param string $title The page title including variables.
     * @param string $gd_page The GeoDirectory page type if any.
     */
    $title = apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . apply_filters('geodir_author_page_title_text', $title) . '</h1></header>';
}
コード例 #6
0
/**
 * Set location data in session.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 *
 * @param object $wp WordPress object.
 */
function geodir_set_location_var_in_session($wp)
{
    //unset($_SESSION['gd_location_shared']);
    /*$point1=array('latitude'=>'-22.5260060699' ,'longitude'=> '-43.7334400235' ) ;
    $point1=array('latitude'=>'28.635308' ,'longitude'=> '77.22496' ) ;
    $point2=array('latitude'=>'-22.7024218' ,'longitude'=> '-43.33662349999997' ) ;
    $point2=array('latitude'=>'-22.7356363' ,'longitude'=> '-43.44001100000003' ) ;
    
    echo geodir_calculateDistanceFromLatLong($point1, $point2);
    */
    // Avoide all the changes made by core, restore original queryvars ;
    //	$wp->query_vars=$wp->geodir_query_vars ;
    // this code will determine when a user wants to switch location
    // A location can be switched using 3 ways
    //1. usign location switcher, in this case the url will always have location prefix
    // Query Vars will have page_id parameter
    // check if query var has page_id and that page id is location page
    //print_r($_SESSION);
    // my location set start
    //Fix for WPML removing page_id query var:
    if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename'])) {
        global $wpdb;
        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename']));
        if ($real_page_id) {
            $wp->query_vars['page_id'] = $real_page_id;
        }
    }
    if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me' && isset($_SESSION['user_lat']) && $_SESSION['user_lat'] && isset($_SESSION['user_lon']) && $_SESSION['user_lon'] || isset($_SESSION['all_near_me']) && is_admin()) {
        if (isset($_REQUEST['user_lat']) && $_REQUEST['user_lat']) {
            $_SESSION['user_lat'] = $_REQUEST['user_lat'];
        }
        if (isset($_REQUEST['user_lon']) && $_REQUEST['user_lon']) {
            $_SESSION['user_lon'] = $_REQUEST['user_lon'];
        }
        if (isset($_SESSION['near_me_range']) && $_SESSION['near_me_range']) {
            $_REQUEST['sdist'] = $_SESSION['near_me_range'];
        }
        $_SESSION['all_near_me'] = 1;
        $_REQUEST['sgeo_lat'] = $_SESSION['user_lat'];
        $_REQUEST['sgeo_lon'] = $_SESSION['user_lon'];
        $_REQUEST['snear'] = 1;
        $_SESSION['gd_multi_location'] = 0;
        //unset any locations
        unset($_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']);
        return;
    } elseif (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') {
        // at the near me page but with no location
        add_action('wp_head', 'geodir_set_user_location_near_me');
        return;
    } else {
        if (isset($_SESSION['all_near_me'])) {
            unset($_SESSION['all_near_me']);
        }
    }
    // my location set end
    geodir_set_is_geodir_page($wp);
    if (!get_option('geodir_set_as_home')) {
        if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
            if ('page' == get_option('show_on_front')) {
                $wp->query_vars['page_id'] = get_option('page_on_front');
            }
        }
    }
    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id() || isset($_REQUEST['set_location_type']) && $_REQUEST['set_location_type'] && isset($_REQUEST['set_location_val']) && $_REQUEST['set_location_val']) {
        $gd_country = '';
        $gd_region = '';
        $gd_city = '';
        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') {
            $gd_country = urldecode($wp->query_vars['gd_country']);
        }
        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') {
            $gd_region = urldecode($wp->query_vars['gd_region']);
        }
        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') {
            $gd_city = urldecode($wp->query_vars['gd_city']);
        }
        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
            $default_location = geodir_get_default_location();
            if (get_option('geodir_add_location_url')) {
                if (get_option('geodir_show_location_url') != 'all') {
                    /*
                     * @todo i don't see the point in this code so i am removing it. (stiofan)
                     */
                    /*
                    					if($gd_region=='' )
                    					{
                    						if(isset($_SESSION['gd_region']))
                    							$gd_region = $_SESSION['gd_region'];
                    						else
                    							$gd_region =$default_location->region_slug;
                    					}
                    					
                    					if($gd_city=='' )
                    					{
                    						if(isset($_SESSION['gd_city']))
                    							$gd_city = $_SESSION['gd_city'];
                    						else
                    							$gd_city =$default_location->city_slug;
                    						
                    						$base_location_link = geodir_get_location_link('base') ;
                    						wp_redirect($base_location_link . '/' .$gd_country . '/' . $gd_region . '/' . $gd_city )	;
                    						exit();
                    					}*/
                }
            }
            $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '');
            $location_array = geodir_get_location_array($args);
            if (!empty($location_array)) {
                $_SESSION['gd_multi_location'] = 1;
                $_SESSION['gd_country'] = $gd_country;
                $_SESSION['gd_region'] = $gd_region;
                $_SESSION['gd_city'] = $gd_city;
                $wp->query_vars['gd_country'] = $gd_country;
                $wp->query_vars['gd_region'] = $gd_region;
                $wp->query_vars['gd_city'] = $gd_city;
            } else {
                unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']);
            }
        } else {
            unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']);
        }
    } else {
        if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
            if (!is_admin()) {
                $requested_post_type = $wp->query_vars['post_type'];
                // check if this post type is geodirectory post types
                $post_type_array = geodir_get_posttypes();
                if (in_array($requested_post_type, $post_type_array)) {
                    // now u can apply geodirectory related manipulation.
                    //echo "good: it is geodirectory post type<br />" ;
                    //print_r($wp->query_vars) ;
                }
            }
        } else {
            // check if a geodirectory taxonomy is set
            $gd_country = '';
            $gd_region = '';
            $gd_city = '';
            $is_geodir_taxonomy = false;
            $is_geodir_taxonomy_term = false;
            // the last term is real geodirectory taxonomy term or not
            $is_geodir_location_found = false;
            $geodir_taxonomy = '';
            $geodir_post_type = '';
            $geodir_term = '';
            $geodir_set_location_session = true;
            $geodir_taxonomis = geodir_get_taxonomies('', true);
            foreach ($geodir_taxonomis as $taxonomy) {
                if (array_key_exists($taxonomy, $wp->query_vars)) {
                    $is_geodir_taxonomy = true;
                    $geodir_taxonomy = $taxonomy;
                    $geodir_post_type = str_replace('category', '', $taxonomy);
                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
                    $geodir_term = $wp->query_vars[$geodir_taxonomy];
                    break;
                }
            }
            // now get an array of all terms seperated by '/'
            $geodir_terms = explode('/', $geodir_term);
            $geodir_last_term = end($geodir_terms);
            if ($is_geodir_taxonomy) {
                $wp->query_vars['post_type'] = $geodir_post_type;
                // now check if last term is a post of geodirectory post types
                $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type));
                if (empty($geodir_post)) {
                    $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type, 'post_status' => 'draft', 'suppress_filters' => false));
                }
                if (!empty($geodir_post)) {
                    if ($geodir_post[0]->post_status != 'publish') {
                        foreach ($wp->query_vars as $key => $vars) {
                            unset($wp->query_vars[$key]);
                        }
                        $wp->query_vars['error'] = '404';
                        // set it as 404 if post exists but its status is not published yet
                    } else {
                        //$wp->query_vars[$geodir_taxonomy] = str_replace( '/'.$geodir_last_term , ''  , $geodir_term);
                        $wp->query_vars[$geodir_post_type] = $geodir_last_term;
                        $wp->query_vars['name'] = $geodir_last_term;
                    }
                    $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
                    if (!$post_title_replace_count) {
                        $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
                    }
                    $geodir_terms = explode('/', $geodir_term);
                    $geodir_last_term = end($geodir_terms);
                    $geodir_set_location_session = false;
                    //return ;
                }
                $geodir_location_terms = '';
                // if last term is not a post then check if last term is a term of the specific texonomy or not
                if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
                    $is_geodir_taxonomy_term = true;
                    $geodir_set_location_session = false;
                }
                // now check if there is location parts in the url or not
                if (get_option('geodir_add_location_url')) {
                    if (get_option('geodir_show_location_url') == 'all') {
                        if (count($geodir_terms) >= 3) {
                            $gd_country = urldecode($geodir_terms[0]);
                            $gd_region = urldecode($geodir_terms[1]);
                            $gd_city = urldecode($geodir_terms[2]);
                        } else {
                            if (count($geodir_terms) >= 2) {
                                $gd_country = urldecode($geodir_terms[0]);
                                $gd_region = urldecode($geodir_terms[1]);
                            } else {
                                if (count($geodir_terms) >= 1) {
                                    $gd_country = urldecode($geodir_terms[0]);
                                }
                            }
                        }
                        $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '', 'format' => array('type' => 'array'));
                        $location_array = geodir_get_location_array($args);
                        if (!empty($location_array)) {
                            $is_geodir_location_found = true;
                        }
                        // if location has not been found for country , region and city then search for country and region only
                        if (!$is_geodir_location_found) {
                            $gd_city = '';
                            $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '', 'format' => array('type' => 'array'));
                            $location_array = geodir_get_location_array($args);
                            if (!empty($location_array)) {
                                $is_geodir_location_found = true;
                            }
                        }
                        // if location has not been found for country , region  then search for country only
                        if (!$is_geodir_location_found) {
                            $gd_city = '';
                            $gd_region = '';
                            $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '', 'format' => array('type' => 'array'));
                            $location_array = geodir_get_location_array($args);
                            if (!empty($location_array)) {
                                $is_geodir_location_found = true;
                            }
                        }
                    } else {
                        $gd_city = urldecode($geodir_terms[0]);
                        $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '', 'format' => array('type' => 'array'));
                        $location_array = geodir_get_location_array($args);
                        if (!empty($location_array)) {
                            $is_geodir_location_found = true;
                        }
                        $args = array('what' => 'region_slug', 'city_val' => $gd_city, 'region_val' => '', 'country_val' => '', 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '', 'format' => array('type' => 'array'));
                        $location_array = geodir_get_location_array($args);
                        if (!empty($location_array)) {
                            $gd_region = $location_array[0]->region_slug;
                        }
                        $args = array('what' => 'country_slug', 'city_val' => $gd_city, 'region_val' => '', 'country_val' => '', 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '', 'format' => array('type' => 'array'));
                        $location_array = geodir_get_location_array($args);
                        if (!empty($location_array)) {
                            $gd_country = $location_array[0]->country_slug;
                        }
                    }
                    // if locaton still not found then clear location related session variables
                    if ($is_geodir_location_found && $geodir_set_location_session) {
                        $_SESSION['gd_multi_location'] = 1;
                        $_SESSION['gd_country'] = $gd_country;
                        $_SESSION['gd_region'] = $gd_region;
                        $_SESSION['gd_city'] = $gd_city;
                    }
                    if (get_option('geodir_show_location_url') != 'all') {
                        $gd_country = '';
                        $gd_region = '';
                    }
                    if ($is_geodir_location_found) {
                        $wp->query_vars['gd_country'] = $gd_country;
                        $wp->query_vars['gd_region'] = $gd_region;
                        $wp->query_vars['gd_city'] = $gd_city;
                    } else {
                        $gd_country = '';
                        $gd_region = '';
                        $gd_city = '';
                    }
                }
                $wp->query_vars[$geodir_taxonomy] = $geodir_term;
                // eliminate location related terms from taxonomy term
                if ($gd_country != '') {
                    $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
                }
                if ($gd_region != '') {
                    $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
                }
                if ($gd_city != '') {
                    $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
                }
                $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
                $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
                $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
                if ($wp->query_vars[$geodir_taxonomy] == '') {
                    unset($wp->query_vars[$geodir_taxonomy]);
                } else {
                    if (!$is_geodir_taxonomy_term) {
                        foreach ($wp->query_vars as $key => $vars) {
                            unset($wp->query_vars[$key]);
                        }
                        $wp->query_vars['error'] = '404';
                    }
                }
            }
        }
    }
    if (isset($wp->query_vars['gd_is_geodir_page']) && is_array($wp->query_vars) && count($wp->query_vars) == '1') {
        if (!isset($_SESSION['gd_location_filter_on_site_load'])) {
            $_SESSION['gd_location_filter_on_site_load'] = 1;
            if (get_option('geodir_result_by_location') == 'default') {
                $location_default = geodir_get_default_location();
                $_SESSION['gd_multi_location'] = 1;
                $_SESSION['gd_country'] = isset($location_default->country_slug) ? $location_default->country_slug : '';
                $_SESSION['gd_region'] = isset($location_default->region_slug) ? $location_default->region_slug : '';
                $_SESSION['gd_city'] = isset($location_default->city_slug) ? $location_default->city_slug : '';
                $wp->query_vars['gd_country'] = isset($location_default->country_slug) ? $location_default->country_slug : '';
                $wp->query_vars['gd_region'] = isset($location_default->region_slug) ? $location_default->region_slug : '';
                $wp->query_vars['gd_city'] = isset($location_default->city_slug) ? $location_default->city_slug : '';
            }
        }
    } else {
        $_SESSION['gd_location_filter_on_site_load'] = 1;
    }
    if (isset($_SESSION['gd_multi_location']) && $_SESSION['gd_multi_location'] == 1) {
        $wp->query_vars['gd_country'] = $_SESSION['gd_country'];
        $wp->query_vars['gd_region'] = $_SESSION['gd_region'];
        $wp->query_vars['gd_city'] = $_SESSION['gd_city'];
    }
    /**/
    // now check if there is location parts in the url or not
    if (get_option('geodir_add_location_url')) {
        if (get_option('geodir_show_location_url') != 'all') {
            if (isset($wp->query_vars['gd_country'])) {
                $wp->query_vars['gd_country'] = '';
            }
            if (isset($wp->query_vars['gd_region'])) {
                $wp->query_vars['gd_region'] = '';
            }
        }
    } else {
        if (isset($wp->query_vars['gd_country'])) {
            $wp->query_vars['gd_country'] = '';
        }
        if (isset($wp->query_vars['gd_region'])) {
            $wp->query_vars['gd_region'] = '';
        }
        if (isset($wp->query_vars['gd_city'])) {
            $wp->query_vars['gd_city'] = '';
        }
    }
    /**/
    //print_r($_SESSION);
    /*
    echo "<pre>" ;
    	print_r($wp) ;
    	echo "</pre>" ;
    	exit();
    */
}
コード例 #7
0
/**
 * Gets term icon using term ID.
 *
 * If term ID not passed returns all icons.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @param int|bool $term_id The term ID.
 * @param bool $rebuild Force rebuild the icons when set to true.
 * @return mixed|string|void Term icon(s).
 */
function geodir_get_term_icon($term_id = false, $rebuild = false)
{
    global $wpdb;
    if (!$rebuild) {
        $terms_icons = get_option('gd_term_icons');
    } else {
        $terms_icons = '';
    }
    if (empty($terms_icons)) {
        $default_icon_url = get_option('geodir_default_marker_icon');
        $taxonomy = geodir_get_taxonomies();
        $post_types = geodir_get_posttypes();
        $tax_arr = array();
        foreach ($post_types as $post_type) {
            $tax_arr[] = "'" . $post_type . "category'";
        }
        $tax_c = implode(',', $tax_arr);
        $terms = $wpdb->get_results("SELECT * FROM {$wpdb->term_taxonomy} WHERE taxonomy IN ({$tax_c})");
        //$terms = get_terms( $taxonomy );
        if ($terms) {
            foreach ($terms as $term) {
                $post_type = str_replace("category", "", $term->taxonomy);
                $a_terms[$post_type][] = $term;
            }
        }
        if ($a_terms) {
            foreach ($a_terms as $pt => $t2) {
                foreach ($t2 as $term) {
                    $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
                    if ($term_icon) {
                        $term_icon_url = $term_icon["src"];
                    } else {
                        $term_icon_url = $default_icon_url;
                    }
                    $terms_icons[$term->term_id] = $term_icon_url;
                }
            }
        }
        update_option('gd_term_icons', $terms_icons);
    }
    if ($term_id && isset($terms_icons[$term_id])) {
        return $terms_icons[$term_id];
    } elseif ($term_id && !isset($terms_icons[$term_id])) {
        return get_option('geodir_default_marker_icon');
    }
    if (is_ssl()) {
        $terms_icons = str_replace("http:", "https:", $terms_icons);
    }
    return $terms_icons;
}
コード例 #8
0
/**
 * Save category location.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 */
function geodir_save_cat_location()
{
    global $wpdb;
    $wpnonce = isset($_REQUEST['wpnonce']) ? $_REQUEST['wpnonce'] : '';
    $locid = isset($_REQUEST['locid']) ? (int) $_REQUEST['locid'] : '';
    $catid = isset($_REQUEST['catid']) ? (int) $_REQUEST['catid'] : '';
    $posttype = isset($_REQUEST['posttype']) ? $_REQUEST['posttype'] : '';
    $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : '';
    $loc_default = isset($_REQUEST['loc_default']) ? $_REQUEST['loc_default'] : '';
    $category_taxonomy = geodir_get_taxonomies($posttype);
    $taxonomy = isset($category_taxonomy[0]) && $category_taxonomy[0] ? $category_taxonomy[0] : 'gd_placecategory';
    if (is_admin() && $wpnonce && current_user_can('manage_options') && $locid > 0 && $catid > 0 && $posttype) {
        $option = array();
        $option['gd_cat_loc_default'] = (int) $loc_default;
        $option['gd_cat_loc_cat_id'] = $catid;
        $option['gd_cat_loc_post_type'] = $posttype;
        $option['gd_cat_loc_taxonomy'] = $taxonomy;
        $option_name = 'geodir_cat_loc_' . $posttype . '_' . $catid;
        update_option($option_name, $option);
        $option = array();
        $option['gd_cat_loc_loc_id'] = (int) $locid;
        $option['gd_cat_loc_cat_id'] = (int) $catid;
        $option['gd_cat_loc_post_type'] = $posttype;
        $option['gd_cat_loc_taxonomy'] = $taxonomy;
        $option['gd_cat_loc_desc'] = $content;
        $option_name = 'geodir_cat_loc_' . $posttype . '_' . $catid . '_' . $locid;
        update_option($option_name, $option);
        echo 'OK';
        exit;
    }
    echo 'FAIL';
    exit;
}
コード例 #9
0
<?php

/**
 * Retrive markers data and marker info window to use in map
 *
 * @since 1.0.0
 * @package GeoDirectory
 */
if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'homemap_catlist') {
    $post_taxonomy = geodir_get_taxonomies($_REQUEST['post_type']);
    $map_canvas_name = $_REQUEST['map_canvas'];
    $child_collapse = $_REQUEST['child_collapse'];
    echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
    die;
}
// Send the content-type header with correct encoding
header("Content-type: text/javascript; charset=utf-8");
if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'cat') {
    // Retrives markers data for categories
    echo get_markers();
    exit;
} else {
    if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'info') {
        // Retrives marker info window html
        /**
         * @global object $wpdb WordPress Database object.
         * @global string $plugin_prefix Geodirectory plugin table prefix.
         */
        global $wpdb, $plugin_prefix;
        if ($_REQUEST['m_id'] != '') {
            $pid = $_REQUEST['m_id'];
コード例 #10
0
/**
 * Admin fields
 *
 * Loops though the geodirectory options array and outputs each field.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $geodirectory GeoDirectory plugin object.
 * @param array $options The options array.
 */
function geodir_admin_fields($options)
{
    global $geodirectory;
    $first_title = true;
    $tab_id = '';
    $i = 0;
    foreach ($options as $value) {
        if (!isset($value['name'])) {
            $value['name'] = '';
        }
        if (!isset($value['class'])) {
            $value['class'] = '';
        }
        if (!isset($value['css'])) {
            $value['css'] = '';
        }
        if (!isset($value['std'])) {
            $value['std'] = '';
        }
        $desc = '';
        switch ($value['type']) {
            case 'dummy_installer':
                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
                geodir_autoinstall_admin_header($post_type);
                break;
            case 'csv_installer':
                geodir_insert_csv_post_data();
                break;
            case 'title':
                if ($i == 0) {
                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
                    echo '<div class="inner_content_tab_main">';
                }
                $i++;
                if (isset($value['id']) && $value['id']) {
                    $tab_id = $value['id'];
                }
                if (isset($value['desc']) && $value['desc']) {
                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
                }
                if (isset($value['name']) && $value['name']) {
                    if ($first_title === true) {
                        $first_title = false;
                    } else {
                        echo '</div>';
                    }
                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
                }
                /**
                 * Called after a GeoDirectory settings title is output in the GD settings page.
                 *
                 * The action is called dynamically geodir_settings_$value['id'].
                 *
                 * @since 1.0.0
                 */
                do_action('geodir_settings_' . sanitize_title($value['id']));
                break;
            case 'no_tabs':
                echo '<div class="inner_content_tab_main">';
                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
                break;
            case 'sectionstart':
                if (isset($value['desc']) && $value['desc']) {
                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
                }
                if (isset($value['name']) && $value['name']) {
                    echo '<h3>' . $value['name'] . $desc . '</h3>';
                }
                /**
                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
                 *
                 * The action is called dynamically geodir_settings_$value['id']_start.
                 *
                 * @since 1.0.0
                 */
                if (isset($value['id']) && $value['id']) {
                    do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
                }
                echo '<table class="form-table">' . "\n\n";
                break;
            case 'sectionend':
                /**
                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
                 *
                 * The action is called dynamically geodir_settings_$value['id']_end.
                 *
                 * @since 1.0.0
                 */
                if (isset($value['id']) && $value['id']) {
                    do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
                }
                echo '</table>';
                /**
                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
                 *
                 * The action is called dynamically geodir_settings_$value['id']_end.
                 *
                 * @since 1.0.0
                 */
                if (isset($value['id']) && $value['id']) {
                    do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
                }
                break;
            case 'text':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><input name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                           id="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                           type="<?php 
                echo esc_attr($value['type']);
                ?>
"
                                           style=" <?php 
                echo esc_attr($value['css']);
                ?>
"
                                           value="<?php 
                if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
                    echo esc_attr(stripslashes(get_option($value['id'])));
                } else {
                    echo esc_attr($value['std']);
                }
                ?>
"/> <span class="description"><?php 
                echo $value['desc'];
                ?>
</span></td>
                </tr><?php 
                break;
            case 'password':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><input name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                           id="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                           type="<?php 
                echo esc_attr($value['type']);
                ?>
"
                                           style="<?php 
                echo esc_attr($value['css']);
                ?>
"
                                           value="<?php 
                if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
                    echo esc_attr(stripslashes(get_option($value['id'])));
                } else {
                    echo esc_attr($value['std']);
                }
                ?>
"/> <span class="description"><?php 
                echo $value['desc'];
                ?>
</span></td>
                </tr><?php 
                break;
            case 'html_content':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><span class="description"><?php 
                echo $value['desc'];
                ?>
</span></td>
                </tr><?php 
                break;
            case 'color':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><input name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                           id="<?php 
                echo esc_attr($value['id']);
                ?>
" type="text"
                                           style="<?php 
                echo esc_attr($value['css']);
                ?>
"
                                           value="<?php 
                if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
                    echo esc_attr(stripslashes(get_option($value['id'])));
                } else {
                    echo esc_attr($value['std']);
                }
                ?>
" class="colorpick"/> <span
                        class="description"><?php 
                echo $value['desc'];
                ?>
</span>

                    <div id="colorPickerDiv_<?php 
                echo esc_attr($value['id']);
                ?>
" class="colorpickdiv"
                         style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
                </td>
                </tr><?php 
                break;
            case 'image_width':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp">

                    <?php 
                _e('Width', GEODIRECTORY_TEXTDOMAIN);
                ?>
 <input
                        name="<?php 
                echo esc_attr($value['id']);
                ?>
_width"
                        id="<?php 
                echo esc_attr($value['id']);
                ?>
_width" type="text" size="3"
                        value="<?php 
                if ($size = get_option($value['id'] . '_width')) {
                    echo stripslashes($size);
                } else {
                    echo $value['std'];
                }
                ?>
"/>

                    <?php 
                _e('Height', GEODIRECTORY_TEXTDOMAIN);
                ?>
 <input
                        name="<?php 
                echo esc_attr($value['id']);
                ?>
_height"
                        id="<?php 
                echo esc_attr($value['id']);
                ?>
_height" type="text" size="3"
                        value="<?php 
                if ($size = get_option($value['id'] . '_height')) {
                    echo stripslashes($size);
                } else {
                    echo $value['std'];
                }
                ?>
"/>

                    <label><?php 
                _e('Hard Crop', GEODIRECTORY_TEXTDOMAIN);
                ?>
 <input
                            name="<?php 
                echo esc_attr($value['id']);
                ?>
_crop"
                            id="<?php 
                echo esc_attr($value['id']);
                ?>
_crop"
                            type="checkbox" <?php 
                if (get_option($value['id'] . '_crop') != '') {
                    checked(get_option($value['id'] . '_crop'), 1);
                } else {
                    checked(1);
                }
                ?>
 /></label>

                    <span class="description"><?php 
                echo $value['desc'];
                ?>
</span></td>
                </tr><?php 
                break;
            case 'select':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><select name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                            id="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                            style="<?php 
                echo esc_attr($value['css']);
                ?>
"
                                            class="<?php 
                if (isset($value['class'])) {
                    echo $value['class'];
                }
                ?>
"
                                            option-ajaxchosen="false">
                        <?php 
                foreach ($value['options'] as $key => $val) {
                    $geodir_select_value = '';
                    if (get_option($value['id']) != '') {
                        if (get_option($value['id']) != '' && get_option($value['id']) == $key) {
                            $geodir_select_value = ' selected="selected" ';
                        }
                    } else {
                        if ($value['std'] == $key) {
                            $geodir_select_value = ' selected="selected" ';
                        }
                    }
                    ?>
                            <option
                                value="<?php 
                    echo esc_attr($key);
                    ?>
" <?php 
                    echo $geodir_select_value;
                    ?>
 ><?php 
                    echo ucfirst($val);
                    ?>
</option>
                        <?php 
                }
                ?>
                    </select> <span class="description"><?php 
                echo $value['desc'];
                ?>
</span>
                </td>
                </tr><?php 
                break;
            case 'multiselect':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><select multiple="multiple" name="<?php 
                echo esc_attr($value['id']);
                ?>
[]"
                                            id="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                            style="<?php 
                echo esc_attr($value['css']);
                ?>
"
                                            class="<?php 
                if (isset($value['class'])) {
                    echo $value['class'];
                }
                ?>
"
                                            data-placeholder="<?php 
                if (isset($value['placeholder_text'])) {
                    echo $value['placeholder_text'];
                }
                ?>
"
                                            option-ajaxchosen="false">
                        <?php 
                foreach ($value['options'] as $key => $val) {
                    if (strpos($key, 'optgroup_start-') === 0) {
                        ?>
<optgroup label="<?php 
                        echo ucfirst($val);
                        ?>
"><?php 
                    } else {
                        if (strpos($key, 'optgroup_end-') === 0) {
                            ?>
</optgroup><?php 
                        } else {
                            ?>
                                <option
                                    value="<?php 
                            echo esc_attr($key);
                            ?>
" <?php 
                            if (is_array(get_option($value['id']))) {
                                if (in_array($key, get_option($value['id']))) {
                                    ?>
 selected="selected" <?php 
                                }
                            }
                            ?>
><?php 
                            echo ucfirst($val);
                            ?>
</option>
                            <?php 
                        }
                    }
                }
                ?>
                    </select> <span class="description"><?php 
                echo $value['desc'];
                ?>
</span>
                </td>
                </tr><?php 
                break;
            case 'file':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp">
                    <input type="file" name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                           id="<?php 
                echo esc_attr($value['id']);
                ?>
" style="<?php 
                echo esc_attr($value['css']);
                ?>
"
                           class="<?php 
                if (isset($value['class'])) {
                    echo $value['class'];
                }
                ?>
"/>
                    <?php 
                if (get_option($value['id'])) {
                    ?>
                        <input type="hidden" name="<?php 
                    echo esc_attr($value['id']);
                    ?>
_remove"
                               id="<?php 
                    echo esc_attr($value['id']);
                    ?>
_remove" value="0">
                        <span class="description"> <?php 
                    $uploads = wp_upload_dir();
                    ?>
 <a
                                href="<?php 
                    echo get_option($value['id']);
                    ?>
"
                                target="_blank"><?php 
                    echo get_option($value['id']);
                    ?>
</a> <i
                                title="<?php 
                    _e('remove file (set to empty)', GEODIRECTORY_TEXTDOMAIN);
                    ?>
"
                                onclick="jQuery('#<?php 
                    echo esc_attr($value['id']);
                    ?>
_remove').val('1'); jQuery( this ).parent().text('<?php 
                    _e('save to remove file', GEODIRECTORY_TEXTDOMAIN);
                    ?>
');"
                                class="fa fa-times gd-remove-file"></i></span>

                    <?php 
                }
                ?>
                </td>
                </tr><?php 
                break;
            case 'map_default_settings':
                ?>

                <tr valign="top">
                    <th class="titledesc" width="40%"><?php 
                _e('Default map language', GEODIRECTORY_TEXTDOMAIN);
                ?>
</th>
                    <td width="60%">
                        <select name="geodir_default_map_language" style="width:60%">
                            <?php 
                $arr_map_langages = array('ar' => __('ARABIC', GEODIRECTORY_TEXTDOMAIN), 'eu' => __('BASQUE', GEODIRECTORY_TEXTDOMAIN), 'bg' => __('BULGARIAN', GEODIRECTORY_TEXTDOMAIN), 'bn' => __('BENGALI', GEODIRECTORY_TEXTDOMAIN), 'ca' => __('CATALAN', GEODIRECTORY_TEXTDOMAIN), 'cs' => __('CZECH', GEODIRECTORY_TEXTDOMAIN), 'da' => __('DANISH', GEODIRECTORY_TEXTDOMAIN), 'de' => __('GERMAN', GEODIRECTORY_TEXTDOMAIN), 'el' => __('GREEK', GEODIRECTORY_TEXTDOMAIN), 'en' => __('ENGLISH', GEODIRECTORY_TEXTDOMAIN), 'en-AU' => __('ENGLISH (AUSTRALIAN)', GEODIRECTORY_TEXTDOMAIN), 'en-GB' => __('ENGLISH (GREAT BRITAIN)', GEODIRECTORY_TEXTDOMAIN), 'es' => __('SPANISH', GEODIRECTORY_TEXTDOMAIN), 'eu' => __('BASQUE', GEODIRECTORY_TEXTDOMAIN), 'fa' => __('FARSI', GEODIRECTORY_TEXTDOMAIN), 'fi' => __('FINNISH', GEODIRECTORY_TEXTDOMAIN), 'fil' => __('FILIPINO', GEODIRECTORY_TEXTDOMAIN), 'fr' => __('FRENCH', GEODIRECTORY_TEXTDOMAIN), 'gl' => __('GALICIAN', GEODIRECTORY_TEXTDOMAIN), 'gu' => __('GUJARATI', GEODIRECTORY_TEXTDOMAIN), 'hi' => __('HINDI', GEODIRECTORY_TEXTDOMAIN), 'hr' => __('CROATIAN', GEODIRECTORY_TEXTDOMAIN), 'hu' => __('HUNGARIAN', GEODIRECTORY_TEXTDOMAIN), 'id' => __('INDONESIAN', GEODIRECTORY_TEXTDOMAIN), 'it' => __('ITALIAN', GEODIRECTORY_TEXTDOMAIN), 'iw' => __('HEBREW', GEODIRECTORY_TEXTDOMAIN), 'ja' => __('JAPANESE', GEODIRECTORY_TEXTDOMAIN), 'kn' => __('KANNADA', GEODIRECTORY_TEXTDOMAIN), 'ko' => __('KOREAN', GEODIRECTORY_TEXTDOMAIN), 'lt' => __('LITHUANIAN', GEODIRECTORY_TEXTDOMAIN), 'lv' => __('LATVIAN', GEODIRECTORY_TEXTDOMAIN), 'ml' => __('MALAYALAM', GEODIRECTORY_TEXTDOMAIN), 'mr' => __('MARATHI', GEODIRECTORY_TEXTDOMAIN), 'nl' => __('DUTCH', GEODIRECTORY_TEXTDOMAIN), 'no' => __('NORWEGIAN', GEODIRECTORY_TEXTDOMAIN), 'pl' => __('POLISH', GEODIRECTORY_TEXTDOMAIN), 'pt' => __('PORTUGUESE', GEODIRECTORY_TEXTDOMAIN), 'pt-BR' => __('PORTUGUESE (BRAZIL)', GEODIRECTORY_TEXTDOMAIN), 'pt-PT' => __('PORTUGUESE (PORTUGAL)', GEODIRECTORY_TEXTDOMAIN), 'ro' => __('ROMANIAN', GEODIRECTORY_TEXTDOMAIN), 'ru' => __('RUSSIAN', GEODIRECTORY_TEXTDOMAIN), 'ru' => __('RUSSIAN', GEODIRECTORY_TEXTDOMAIN), 'sk' => __('SLOVAK', GEODIRECTORY_TEXTDOMAIN), 'sl' => __('SLOVENIAN', GEODIRECTORY_TEXTDOMAIN), 'sr' => __('SERBIAN', GEODIRECTORY_TEXTDOMAIN), 'sv' => __('	SWEDISH', GEODIRECTORY_TEXTDOMAIN), 'tl' => __('TAGALOG', GEODIRECTORY_TEXTDOMAIN), 'ta' => __('TAMIL', GEODIRECTORY_TEXTDOMAIN), 'te' => __('TELUGU', GEODIRECTORY_TEXTDOMAIN), 'th' => __('THAI', GEODIRECTORY_TEXTDOMAIN), 'tr' => __('TURKISH', GEODIRECTORY_TEXTDOMAIN), 'uk' => __('UKRAINIAN', GEODIRECTORY_TEXTDOMAIN), 'vi' => __('VIETNAMESE', GEODIRECTORY_TEXTDOMAIN), 'zh-CN' => __('CHINESE (SIMPLIFIED)', GEODIRECTORY_TEXTDOMAIN), 'zh-TW' => __('CHINESE (TRADITIONAL)', GEODIRECTORY_TEXTDOMAIN));
                $geodir_default_map_language = get_option('geodir_default_map_language');
                if (empty($geodir_default_map_language)) {
                    $geodir_default_map_language = 'en';
                }
                foreach ($arr_map_langages as $language_key => $language_txt) {
                    if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) {
                        $geodir_default_language_selected = "selected='selected'";
                    } else {
                        $geodir_default_language_selected = '';
                    }
                    ?>
                                <option
                                    value="<?php 
                    echo $language_key;
                    ?>
" <?php 
                    echo $geodir_default_language_selected;
                    ?>
><?php 
                    echo $language_txt;
                    ?>
</option>

                            <?php 
                }
                ?>
                        </select>
                    </td>
                </tr>

                <tr valign="top">
                    <th class="titledesc"
                        width="40%"><?php 
                _e('Default post type search on map', GEODIRECTORY_TEXTDOMAIN);
                ?>
</th>
                    <td width="60%">
                        <select name="geodir_default_map_search_pt" style="width:60%">
                            <?php 
                $post_types = geodir_get_posttypes('array');
                $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
                if (empty($geodir_default_map_search_pt)) {
                    $geodir_default_map_search_pt = 'gd_place';
                }
                if (is_array($post_types)) {
                    foreach ($post_types as $key => $post_types_obj) {
                        if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) {
                            $geodir_search_pt_selected = "selected='selected'";
                        } else {
                            $geodir_search_pt_selected = '';
                        }
                        ?>
                                    <option
                                        value="<?php 
                        echo $key;
                        ?>
" <?php 
                        echo $geodir_search_pt_selected;
                        ?>
><?php 
                        echo $post_types_obj['labels']['singular_name'];
                        ?>
</option>

                                <?php 
                    }
                }
                ?>
                        </select>
                    </td>
                </tr>

                <?php 
                break;
            case 'map':
                ?>
                <tr valign="top">
                    <td class="forminp">
                        <?php 
                global $post_cat, $cat_display;
                $post_types = geodir_get_posttypes('object');
                $cat_display = 'checkbox';
                $gd_post_types = get_option('geodir_exclude_post_type_on_map');
                $gd_cats = get_option('geodir_exclude_cat_on_map');
                $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
                $count = 1;
                ?>
                        <table width="70%" class="widefat">
                            <thead>
                            <tr>
                                <th><b><?php 
                echo DESIGN_POST_TYPE_SNO;
                ?>
</b></th>
                                <th><b><?php 
                echo DESIGN_POST_TYPE;
                ?>
</b></th>
                                <th><b><?php 
                echo DESIGN_POST_TYPE_CAT;
                ?>
</b></th>
                            </tr>
                            <?php 
                $gd_categs = $gd_cats;
                foreach ($post_types as $key => $post_types_obj) {
                    $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
                    $gd_taxonomy = geodir_get_taxonomies($key);
                    if ($gd_cats_upgrade) {
                        $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
                        $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
                        $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
                    }
                    $post_cat = implode(',', $gd_cats);
                    $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
                    ?>
                                <tr>
                                    <td valign="top" width="5%"><?php 
                    echo $count;
                    ?>
</td>
                                    <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
                                                                                           name="home_map_post_types[]"
                                                                                           id="<?php 
                    echo esc_attr($value['id']);
                    ?>
"
                                                                                           value="<?php 
                    echo $key;
                    ?>
"
                                                                                           class="map_post_type" <?php 
                    echo $checked;
                    ?>
 />
                                        <?php 
                    echo $post_types_obj->labels->singular_name;
                    ?>
</td>
                                    <td width="40%">
                                        <div class="home_map_category" style="overflow:auto;width:200px;height:100px;"
                                             id="<?php 
                    echo $key;
                    ?>
"><?php 
                    echo $gd_taxonomy_list;
                    ?>
</div>
                                    </td>
                                </tr>
                                <?php 
                    $count++;
                }
                ?>
                            </thead>
                        </table>
                        <p><?php 
                _e('Note: Tick respective post type or categories which you want to hide from home page map widget.', GEODIRECTORY_TEXTDOMAIN);
                ?>
</p>
                    </td>
                </tr>
                <?php 
                break;
            case 'checkbox':
                if (!isset($value['checkboxgroup']) || isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start') {
                    ?>
                    <tr valign="top">
                    <th scope="row" class="titledesc"><?php 
                    echo $value['name'];
                    ?>
</th>
                    <td class="forminp">
                <?php 
                }
                ?>
                <fieldset>
                    <legend class="screen-reader-text"><span><?php 
                echo $value['name'];
                ?>
</span></legend>
                    <label for="<?php 
                echo $value['id'];
                ?>
">
                        <input name="<?php 
                echo esc_attr($value['id']);
                ?>
" id="<?php 
                echo esc_attr($value['id']);
                ?>
"
                               type="checkbox" value="1" <?php 
                checked(get_option($value['id']), true);
                ?>
 />
                        <?php 
                echo $value['desc'];
                ?>
</label><br>
                </fieldset>
                <?php 
                if (!isset($value['checkboxgroup']) || isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end') {
                    ?>
                    </td>
                    </tr>
                <?php 
                }
                break;
            case 'radio':
                if (!isset($value['radiogroup']) || isset($value['radiogroup']) && $value['radiogroup'] == 'start') {
                    ?>
                    <tr valign="top">
                    <th scope="row" class="titledesc"><?php 
                    echo $value['name'];
                    ?>
</th>
                    <td class="forminp">
                <?php 
                }
                ?>
                <fieldset>
                    <legend class="screen-reader-text"><span><?php 
                echo $value['name'];
                ?>
</span></legend>
                    <label for="<?php 
                echo $value['id'];
                ?>
">
                        <input name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                               id="<?php 
                echo esc_attr($value['id'] . $value['value']);
                ?>
" type="radio"
                               value="<?php 
                echo $value['value'];
                ?>
" <?php 
                if (get_option($value['id']) == $value['value']) {
                    echo 'checked="checked"';
                }
                ?>
 />
                        <?php 
                echo $value['desc'];
                ?>
</label><br>
                </fieldset>
                <?php 
                if (!isset($value['radiogroup']) || isset($value['radiogroup']) && $value['radiogroup'] == 'end') {
                    ?>
                    </td>
                    </tr>
                <?php 
                }
                break;
            case 'textarea':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp">
                    <textarea
                        <?php 
                if (isset($value['args'])) {
                    echo $value['args'] . ' ';
                }
                ?>
name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                        id="<?php 
                echo esc_attr($value['id']);
                ?>
"
                        style="<?php 
                echo esc_attr($value['css']);
                ?>
"><?php 
                if (get_option($value['id'])) {
                    echo esc_textarea(stripslashes(get_option($value['id'])));
                } else {
                    echo esc_textarea($value['std']);
                }
                ?>
</textarea><span
                        class="description"><?php 
                echo $value['desc'];
                ?>
</span>

                </td>
                </tr><?php 
                break;
            case 'editor':
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><?php 
                $content = '';
                if (get_option($value['id'])) {
                    $content = stripslashes(get_option($value['id']));
                } else {
                    $content = $value['std'];
                }
                $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
                wp_editor($content, esc_attr($value['id']), $editor_settings);
                ?>
 <span class="description"><?php 
                echo $value['desc'];
                ?>
</span>

                </td>
                </tr><?php 
                break;
            case 'single_select_page':
                $page_setting = (int) get_option($value['id']);
                $args = array('name' => $value['id'], 'id' => $value['id'], 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'show_option_none' => ' ', 'class' => $value['class'], 'echo' => false, 'selected' => $page_setting);
                if (isset($value['args'])) {
                    $args = wp_parse_args($value['args'], $args);
                }
                ?>
                <tr valign="top" class="single_select_page">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp">
                    <?php 
                echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args));
                ?>
                    <span class="description"><?php 
                echo $value['desc'];
                ?>
</span>
                </td>
                </tr><?php 
                break;
            case 'single_select_country':
                $countries = $geodirectory->countries->countries;
                $country_setting = (string) get_option($value['id']);
                if (strstr($country_setting, ':')) {
                    $country = current(explode(':', $country_setting));
                    $state = end(explode(':', $country_setting));
                } else {
                    $country = $country_setting;
                    $state = '*';
                }
                ?>
                <tr valign="top">
                <th scope="rpw" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp"><select name="<?php 
                echo esc_attr($value['id']);
                ?>
"
                                            style="<?php 
                echo esc_attr($value['css']);
                ?>
"
                                            data-placeholder="<?php 
                _e('Choose a country&hellip;', GEODIRECTORY_TEXTDOMAIN);
                ?>
"
                                            title="Country" class="chosen_select">
                        <?php 
                echo $geodirectory->countries->country_dropdown_options($country, $state);
                ?>
                    </select> <span class="description"><?php 
                echo $value['desc'];
                ?>
</span>
                </td>
                </tr><?php 
                break;
            case 'multi_select_countries':
                $countries = $geodirectory->countries->countries;
                asort($countries);
                $selections = (array) get_option($value['id']);
                ?>
                <tr valign="top">
                <th scope="row" class="titledesc"><?php 
                echo $value['name'];
                ?>
</th>
                <td class="forminp">
                    <select multiple="multiple" name="<?php 
                echo esc_attr($value['id']);
                ?>
[]" style="width:450px;"
                            data-placeholder="<?php 
                _e('Choose countries&hellip;', GEODIRECTORY_TEXTDOMAIN);
                ?>
"
                            title="Country" class="chosen_select">
                        <?php 
                if ($countries) {
                    foreach ($countries as $key => $val) {
                        echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
                    }
                }
                ?>
                    </select>
                </td>
                </tr>

                <?php 
                break;
            case 'google_analytics':
                $selections = (array) get_option($value['id']);
                if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
                    ?>
                    <tr valign="top">
                        <th scope="row" class="titledesc"><?php 
                    echo $value['name'];
                    ?>
</th>
                        <td class="forminp">


                            <?php 
                    $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
                    $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
                    $state = "&state=123";
                    //any string
                    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
                    $response_type = "&response_type=code";
                    $client_id = "&client_id=" . get_option('geodir_ga_client_id');
                    $access_type = "&access_type=offline";
                    $approval_prompt = "&approval_prompt=force";
                    $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
                    ?>
                            <script>
                                function gd_ga_popup() {
                                    var win = window.open("<?php 
                    echo $auth_url;
                    ?>
", "Google Analytics", "");
                                    var pollTimer = window.setInterval(function () {
                                        if (win.closed !== false) { // !== is required for compatibility with Opera
                                            window.clearInterval(pollTimer);

                                            jQuery(".general_settings .submit .button-primary").trigger('click');
                                        }
                                    }, 200);
                                }
                            </script>

                            <?php 
                    if (get_option('gd_ga_refresh_token')) {
                        ?>
                                <span class="button-primary"
                                      onclick="gd_ga_popup();"><?php 
                        _e('Re-authorize', GEODIRECTORY_TEXTDOMAIN);
                        ?>
</span>
                                <span
                                    style="color: green; font-weight: bold;"><?php 
                        _e('Authorized', GEODIRECTORY_TEXTDOMAIN);
                        ?>
</span>
                            <?php 
                    } else {
                        ?>
                                <span class="button-primary"
                                      onclick="gd_ga_popup();"><?php 
                        _e('Authorize', GEODIRECTORY_TEXTDOMAIN);
                        ?>
</span>
                            <?php 
                    }
                    ?>
                        </td>
                    </tr>

                <?php 
                }
                break;
            case 'field_seperator':
                ?>
                <tr valign="top">
                    <td colspan="2" class="forminp geodir_line_seperator"></td>
                </tr>
                <?php 
                break;
        }
    }
    if ($first_title === false) {
        echo "</div>";
    }
    ?>

    <script type="text/javascript">


        jQuery(document).ready(function () {

            jQuery('.geodir_option_tabs').each(function (ele) {
                jQuery('#geodir_oiption_tabs').append(jQuery(this));
            });


            jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
            jQuery('.geodir_option_tabs:first').addClass('gd-tab-active');

            jQuery('.gd-content-heading').hide();
            jQuery('.gd-content-heading:first').show();
            jQuery('.geodir_option_tabs').bind('click', function () {
                var tab_id = jQuery(this).attr('id');

                if (tab_id == 'dummy_data_settings') {
                    jQuery('p .button-primary').hide();
                } else if (tab_id == 'csv_upload_settings') {
                    jQuery('p .button-primary').hide();
                } else {
                    jQuery('.button-primary').show();
                }

                if (jQuery('#sub_' + tab_id + ' div').hasClass('geodir_auto_install'))
                    jQuery('p .button-primary').hide();

                jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
                jQuery(this).addClass('gd-tab-active');
                jQuery('.gd-content-heading').hide();
                jQuery('#sub_' + tab_id).show();
                jQuery('.active_tab').val(tab_id);
                jQuery("select.chosen_select").trigger("chosen:updated"); //refresh closen
            });


            <?php 
    if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') {
        ?>
            jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
            jQuery('#<?php 
        echo $_REQUEST['active_tab'];
        ?>
').addClass('gd-tab-active');

            jQuery('.gd-content-heading').hide();
            jQuery('#sub_<?php 
        echo $_REQUEST['active_tab'];
        ?>
').show();


            <?php 
    }
    ?>

        });

    </script>

<?php 
}
コード例 #11
0
ファイル: shortcode_functions.php プロジェクト: bangjojo/wp
/**
 * Get the geodirectory listings.
 *
 * @since 1.4.2
 *
 * @global string $gridview_columns_widget The girdview style of the listings for widget.
 * @global bool $geodir_is_widget_listing Is this a widget listing?. Default: false.
 * @global bool   $geodir_event_widget_listview Check that current listview is event.
 * @global object $post The current post object.
 * @global array $map_jason Map data in json format.
 * @global array $map_canvas_arr Map canvas array.
 *
 * @param array $args Array of arguements to filter listings.
 * @return string Listings HTML content.
 */
function geodir_sc_gd_listings_output($args = array())
{
    $title = !empty($args['title']) ? __($args['title'], 'geodirectory') : '';
    $post_type = !empty($args['post_type']) ? $args['post_type'] : 'gd_place';
    $category = !empty($args['category']) ? $args['category'] : '0';
    $post_number = !empty($args['post_number']) ? $args['post_number'] : 10;
    $add_location_filter = !empty($args['add_location_filter']) ? true : false;
    $list_sort = !empty($args['list_sort']) ? $args['list_sort'] : 'latest';
    $character_count = isset($args['character_count']) ? $args['character_count'] : '';
    $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf';
    $with_pagination = !empty($args['with_pagination']) ? true : false;
    $event_type = !empty($args['event_type']) ? $args['event_type'] : '';
    $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false;
    $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false;
    $shortcode_atts = !empty($args['shortcode_atts']) ? $args['shortcode_atts'] : array();
    // ajax mode
    $geodir_ajax = !empty($args['geodir_ajax']) ? true : false;
    $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1;
    $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'gd_location' => $add_location_filter, 'post_type' => $post_type, 'order_by' => $list_sort, 'pageno' => $pageno);
    if ($character_count >= 0) {
        $query_args['excerpt_length'] = $character_count;
    }
    if (!empty($args['show_featured_only'])) {
        $query_args['show_featured_only'] = 1;
    }
    if (!empty($args['show_special_only'])) {
        $query_args['show_special_only'] = 1;
    }
    if (!empty($args['with_pics_only'])) {
        $query_args['with_pics_only'] = 0;
        $query_args['featured_image_only'] = 1;
    }
    if (!empty($args['with_videos_only'])) {
        $query_args['with_videos_only'] = 1;
    }
    $with_no_results = !empty($args['without_no_results']) ? false : true;
    if (!empty($category) && isset($category[0]) && $category[0] != '0') {
        $category_taxonomy = geodir_get_taxonomies($post_type);
        ######### WPML #########
        if (function_exists('icl_object_id')) {
            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
        }
        ######### WPML #########
        $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $category);
        $query_args['tax_query'] = array($tax_query);
    }
    global $gridview_columns_widget, $geodir_is_widget_listing;
    if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) {
        global $geodir_event_widget_listview;
        $geodir_event_widget_listview = true;
        if ($event_type && in_array($event_type, array('past', 'today', 'upcoming'))) {
            $query_args['geodir_event_type'] = $event_type;
        }
        $total_posts = geodir_event_get_widget_events($query_args, true);
        $widget_listings = $total_posts > 0 ? geodir_event_get_widget_events($query_args) : array();
    } else {
        $total_posts = geodir_get_widget_listings($query_args, true);
        $widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array();
    }
    $current_gridview_columns_widget = $gridview_columns_widget;
    ob_start();
    if (!empty($widget_listings) || $with_no_results) {
        if (!$geodir_ajax) {
            /**
             * Called before the shortcode [gd_listings] content is output.
             *
             * @since 1.0.0
             */
            do_action('geodir_before_sc_gd_listings');
            ?>
        <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings">
		<?php 
        }
        ?>
            <?php 
        if ($title != '') {
            ?>
            <div class="geodir_list_heading clearfix">
                <?php 
            echo $title;
            ?>
            </div>
			<?php 
        }
        ?>
            <?php 
        if (strstr($layout, 'gridview')) {
            $listing_view_exp = explode('_', $layout);
            $gridview_columns_widget = $layout;
            $layout = $listing_view_exp[0];
        } else {
            $gridview_columns_widget = '';
        }
        /**
         * Filter the widget listing listview template.
         *
         * @since 1.0.0
         *
         * @param string The template file to display listing.
         */
        $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
        global $post, $map_jason, $map_canvas_arr;
        $current_post = $post;
        $current_map_jason = $map_jason;
        $current_map_canvas_arr = $map_canvas_arr;
        $geodir_is_widget_listing = true;
        if (isset($_SESSION['gd_listing_view'])) {
            unset($_SESSION['gd_listing_view']);
        }
        if ($with_pagination && $top_pagination) {
            echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno);
        }
        /**
         * Includes listing listview template.
         *
         * @since 1.0.0
         */
        include $template;
        if ($with_pagination && $bottom_pagination) {
            echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno);
        }
        $geodir_is_widget_listing = false;
        $GLOBALS['post'] = $current_post;
        if (!empty($current_post)) {
            setup_postdata($current_post);
        }
        $map_jason = $current_map_jason;
        $map_canvas_arr = $current_map_canvas_arr;
        global $gridview_columns_widget;
        $gridview_columns_widget = $current_gridview_columns_widget;
        ?>
			<p class="geodir-sclisting-loading" style="display:none;"><i class="fa fa-cog fa-spin"></i></p>
			<?php 
        if (!$geodir_ajax) {
            ?>
        </div>
		<script type="text/javascript">
		  function gd_sc_gopage(obj, pid) {
			var pid = parseInt(pid);
			var container = jQuery(obj).closest('.geodir-sc-gd-listings');
			if(!pid > 0 || !(container && typeof container != 'undefined')) {
			  return false;
			}
			var scatts = "<?php 
            echo addslashes(json_encode($shortcode_atts));
            ?>
";
			
			var data = {
			  'action': 'geodir_sclistings',
			  'geodir_sclistings_nonce': '<?php 
            echo wp_create_nonce("geodir-sclistings-nonce");
            ?>
',
			  'scatts': scatts,
			  'geodir_ajax': true,
			  'pageno': pid
			};
			
			jQuery(document).ajaxStop(function() {
			  jQuery(container).find('.geodir_category_list_view').css({'opacity': '1'});
			  jQuery(container).find('.geodir-sclisting-loading').hide();
			});
			
			jQuery(container).find('.geodir_category_list_view').css({'opacity': '0.4'});
			jQuery(container).find('.geodir-sclisting-loading').show();
			
			jQuery.post(geodir_var.geodir_ajax_url, data, function(response) {
			  if(response && response != '0') {
				jQuery(container).html(response);
			  }
			});
		  }
		</script>
		<?php 
        }
        ?>
    <?php 
    }
    $output = ob_get_contents();
    ob_end_clean();
    return trim($output);
}
コード例 #12
0
    /**
     * Front-end display content for best of widget.
     *
     * @since 1.3.9
     * @since 1.5.1 Added filter to view all link.
     * @since 1.5.1 Declare function public.
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        extract($args);
        /**
         * Filter the best of widget tab layout.
         *
         * @since 1.3.9
         *
         * @param string $instance['tab_layout'] Best of widget tab layout name.
         */
        $tab_layout = empty($instance['tab_layout']) ? 'bestof-tabs-on-top' : apply_filters('bestof_widget_tab_layout', $instance['tab_layout']);
        echo '<div class="bestof-widget-tab-layout ' . $tab_layout . '">';
        echo $before_widget;
        $loc_terms = geodir_get_current_location_terms();
        if ($loc_terms) {
            $cur_location = ' : ' . ucwords(str_replace('-', ' ', end($loc_terms)));
        } else {
            $cur_location = '';
        }
        /**
         * Filter the current location name.
         *
         * @since 1.3.9
         *
         * @param string $cur_location Current location name.
         */
        $cur_location = apply_filters('bestof_widget_cur_location', $cur_location);
        /**
         * Filter the widget title.
         *
         * @since 1.3.9
         *
         * @param string $instance['title'] The widget title.
         */
        $title = empty($instance['title']) ? wp_sprintf(__('Best of %s', 'geodirectory'), get_bloginfo('name') . $cur_location) : apply_filters('bestof_widget_title', __($instance['title'], 'geodirectory'));
        /**
         * Filter the post type.
         *
         * @since 1.3.9
         *
         * @param string $instance['post_type'] The post type.
         */
        $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('bestof_widget_post_type', $instance['post_type']);
        /**
         * Filter the listing limit.
         *
         * @since 1.3.9
         *
         * @param int $instance['post_limit'] No. of posts to display.
         */
        $post_limit = empty($instance['post_limit']) ? '5' : apply_filters('bestof_widget_post_limit', $instance['post_limit']);
        /**
         * Filter the category limit.
         *
         * @since 1.3.9
         *
         * @param int $instance['categ_limit'] No. of categories to display.
         */
        $categ_limit = empty($instance['categ_limit']) ? '3' : apply_filters('bestof_widget_categ_limit', $instance['categ_limit']);
        $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
        /**
         * Filter the use of location filter.
         *
         * @since 1.3.9
         *
         * @param int|bool $instance['add_location_filter'] Filter listings using current location.
         */
        $add_location_filter = empty($instance['add_location_filter']) ? '1' : apply_filters('bestof_widget_location_filter', $instance['add_location_filter']);
        // set post type to current viewing post type
        if ($use_viewing_post_type) {
            $current_post_type = geodir_get_current_posttype();
            if ($current_post_type != '' && $current_post_type != $post_type) {
                $post_type = $current_post_type;
            }
        }
        if (isset($instance['character_count'])) {
            /**
             * Filter the widget's excerpt character count.
             *
             * @since 1.3.9
             *
             * @param int $instance['character_count'] Excerpt character count.
             */
            $character_count = apply_filters('bestof_widget_list_character_count', $instance['character_count']);
        } else {
            $character_count = '';
        }
        $category_taxonomy = geodir_get_taxonomies($post_type);
        $term_args = array('hide_empty' => true, 'parent' => 0);
        if (is_tax()) {
            $taxonomy = get_query_var('taxonomy');
            $cur_term = get_query_var('term');
            $term_data = get_term_by('name', $cur_term, $taxonomy);
            $term_args['parent'] = $term_data->term_id;
        }
        $terms = get_terms($category_taxonomy[0], $term_args);
        $term_reviews = geodir_count_reviews_by_terms();
        $a_terms = array();
        foreach ($terms as $term) {
            if ($term->count > 0) {
                if (isset($term_reviews[$term->term_id])) {
                    $term->review_count = $term_reviews[$term->term_id];
                } else {
                    $term->review_count = '0';
                }
                $a_terms[] = $term;
            }
        }
        $terms = geodir_sort_terms($a_terms, 'review_count');
        $query_args = array('posts_per_page' => $post_limit, 'is_geodir_loop' => true, 'post_type' => $post_type, 'gd_location' => $add_location_filter ? true : false, 'order_by' => 'high_review');
        if ($character_count >= 0) {
            $query_args['excerpt_length'] = $character_count;
        }
        $layout = array();
        if ($tab_layout == 'bestof-tabs-as-dropdown') {
            $layout[] = $tab_layout;
        } else {
            $layout[] = 'bestof-tabs-as-dropdown';
            $layout[] = $tab_layout;
        }
        echo $before_title . __($title) . $after_title;
        //term navigation - start
        echo '<div class="geodir-tabs gd-bestof-tabs" id="gd-bestof-tabs" style="position:relative;">';
        $final_html = '';
        foreach ($layout as $tab_layout) {
            $nav_html = '';
            $is_dropdown = $tab_layout == 'bestof-tabs-as-dropdown' ? true : false;
            if ($is_dropdown) {
                $nav_html .= '<select id="geodir_bestof_tab_dd" class="chosen_select" name="geodir_bestof_tab_dd" data-placeholder="' . esc_attr(__('Select Category', 'geodirectory')) . '">';
            } else {
                $nav_html .= '<dl class="geodir-tab-head geodir-bestof-cat-list">';
                $nav_html .= '<dt></dt>';
            }
            $term_icon = geodir_get_term_icon();
            $cat_count = 0;
            foreach ($terms as $cat) {
                $cat_count++;
                if ($cat_count > $categ_limit) {
                    break;
                }
                if ($is_dropdown) {
                    $selected = $cat_count == 1 ? 'selected="selected"' : '';
                    $nav_html .= '<option ' . $selected . ' value="' . $cat->term_id . '">' . ucwords($cat->name) . '</option>';
                } else {
                    if ($cat_count == 1) {
                        $nav_html .= '<dd class="geodir-tab-active">';
                    } else {
                        $nav_html .= '<dd class="">';
                    }
                    $term_icon_url = !empty($term_icon) && isset($term_icon[$cat->term_id]) ? $term_icon[$cat->term_id] : '';
                    $nav_html .= '<a data-termid="' . $cat->term_id . '" href="' . get_term_link($cat, $cat->taxonomy) . '">';
                    $nav_html .= '<img alt="' . $cat->name . ' icon" class="bestof-cat-icon" src="' . $term_icon_url . '"/>';
                    $nav_html .= '<span>';
                    $nav_html .= ucwords($cat->name);
                    $nav_html .= '<small>';
                    if (isset($cat->review_count)) {
                        $num_reviews = $cat->review_count;
                        if ($num_reviews == 0) {
                            $reviews = __('No Reviews', 'geodirectory');
                        } elseif ($num_reviews > 1) {
                            $reviews = $num_reviews . __(' Reviews', 'geodirectory');
                        } else {
                            $reviews = __('1 Review', 'geodirectory');
                        }
                        $nav_html .= $reviews;
                    }
                    $nav_html .= '</small>';
                    $nav_html .= '</span>';
                    $nav_html .= '</a>';
                    $nav_html .= '</dd>';
                }
            }
            if ($is_dropdown) {
                $nav_html .= '</select>';
            } else {
                $nav_html .= '</dl>';
            }
            $final_html .= $nav_html;
        }
        if ($terms) {
            echo $final_html;
        }
        echo '</div>';
        //term navigation - end
        //first term listings by default - start
        $first_term = '';
        if ($terms) {
            $first_term = $terms[0];
            $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $first_term->term_id);
            $query_args['tax_query'] = array($tax_query);
        }
        ?>
        <input type="hidden" id="bestof_widget_post_type" name="bestof_widget_post_type"
               value="<?php 
        echo $post_type;
        ?>
">
        <input type="hidden" id="bestof_widget_post_limit" name="bestof_widget_post_limit"
               value="<?php 
        echo $post_limit;
        ?>
">
        <input type="hidden" id="bestof_widget_taxonomy" name="bestof_widget_taxonomy"
               value="<?php 
        echo $category_taxonomy[0];
        ?>
">
        <input type="hidden" id="bestof_widget_location_filter" name="bestof_widget_location_filter"
               value="<?php 
        if ($add_location_filter) {
            echo 1;
        } else {
            echo 0;
        }
        ?>
">
        <input type="hidden" id="bestof_widget_char_count" name="bestof_widget_char_count"
               value="<?php 
        echo $character_count;
        ?>
">
        <div class="geo-bestof-contentwrap geodir-tabs-content" style="position: relative; z-index: 0;">
            <p id="geodir-bestof-loading" class="geodir-bestof-loading"><i class="fa fa-cog fa-spin"></i></p>
            <?php 
        echo '<div id="geodir-bestof-places">';
        if ($terms) {
            $view_all_link = add_query_arg(array('sort_by' => 'rating_count_desc'), get_term_link($first_term, $first_term->taxonomy));
            /**
             * Filter the page link to view all lisitngs.
             *
             * @since 1.5.1
             *
             * @param array $view_all_link View all listings page link.
             * @param array $post_type The Post type.
             * @param array $first_term The category term object.
             */
            $view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $first_term);
            echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $first_term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>';
        }
        geodir_bestof_places_by_term($query_args);
        echo "</div>";
        ?>
        </div>
        <?php 
        //first term listings by default - end
        ?>
        <?php 
        echo $after_widget;
        echo "</div>";
    }
コード例 #13
0
/**
 * Outputs the listings template title.
 *
 * @since 1.1.6
 *
 * @global object $wp The WordPress object.
 * @global string $term Current term slug.
 *
 * @param string $list_title The post page title.
 * @return string The post page title.
 */
function geodir_cpt_listing_page_title($list_title = '')
{
    global $wp, $term;
    $gd_post_type = geodir_get_current_posttype();
    if (!geodir_cpt_no_location($gd_post_type)) {
        return $list_title;
    }
    $post_type_info = get_post_type_object($gd_post_type);
    $add_string_in_title = __('All', GEODIR_CP_TEXTDOMAIN) . ' ';
    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
        $add_string_in_title = __('My Favorite', GEODIR_CP_TEXTDOMAIN) . ' ';
    }
    $list_title = $add_string_in_title . __(ucfirst($post_type_info->labels->name), GEODIR_CP_TEXTDOMAIN);
    $single_name = $post_type_info->labels->singular_name;
    $taxonomy = geodir_get_taxonomies($gd_post_type, true);
    if (!empty($term)) {
        $current_term_name = '';
        $current_term = get_term_by('slug', $term, $taxonomy[0]);
        if (!empty($current_term)) {
            $current_term_name = __(ucfirst($current_term->name), GEODIR_CP_TEXTDOMAIN);
        } else {
            if (count($taxonomy) > 1) {
                $current_term = get_term_by('slug', $term, $taxonomy[1]);
                if (!empty($current_term)) {
                    $current_term_name = __(ucfirst($current_term->name), GEODIR_CP_TEXTDOMAIN);
                }
            }
        }
        if ($current_term_name != '') {
            $list_title .= __(' in', GEODIR_CP_TEXTDOMAIN) . " '" . $current_term_name . "'";
        }
    }
    if (is_search()) {
        $list_title = __('Search', GEODIR_CP_TEXTDOMAIN) . ' ' . __(ucfirst($post_type_info->labels->name), GEODIR_CP_TEXTDOMAIN) . __(' For :', GEODIRECTORY_TEXTDOMAIN) . " '" . get_search_query() . "'";
    }
    return $list_title;
}
コード例 #14
0
    /**
     * Back-end popular posts widget settings form.
     *
     * @since 1.0.0
     * @since 1.5.1 Declare function public.
     *
     * @param array $instance Previously saved values from database.
     */
    public function form($instance)
    {
        //widgetform in backend
        $instance = wp_parse_args((array) $instance, array('title' => '', 'post_type' => '', 'category' => array(), 'category_title' => '', 'list_sort' => '', 'list_order' => '', 'post_number' => '5', 'layout' => 'gridview_onehalf', 'listing_width' => '', 'add_location_filter' => '1', 'character_count' => '20', 'show_featured_only' => '', 'show_special_only' => '', 'with_pics_only' => '', 'with_videos_only' => '', 'use_viewing_post_type' => ''));
        $title = strip_tags($instance['title']);
        $post_type = strip_tags($instance['post_type']);
        $category = $instance['category'];
        $category_title = strip_tags($instance['category_title']);
        $list_sort = strip_tags($instance['list_sort']);
        $list_order = strip_tags($instance['list_order']);
        $post_number = strip_tags($instance['post_number']);
        $layout = strip_tags($instance['layout']);
        $listing_width = strip_tags($instance['listing_width']);
        $add_location_filter = strip_tags($instance['add_location_filter']);
        $character_count = $instance['character_count'];
        $show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false;
        $show_special_only = isset($instance['show_special_only']) && $instance['show_special_only'] ? true : false;
        $with_pics_only = isset($instance['with_pics_only']) && $instance['with_pics_only'] ? true : false;
        $with_videos_only = isset($instance['with_videos_only']) && $instance['with_videos_only'] ? true : false;
        $use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false;
        ?>

        <p>
            <label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'geodirectory');
        ?>
                <small>(%posttype_singular_label% ,
                    %posttype_plural_label% <?php 
        _e('can be used', 'geodirectory');
        ?>
)
                </small>

                <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($title);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('post_type');
        ?>
"><?php 
        _e('Post Type:', 'geodirectory');
        ?>

                <?php 
        $postypes = geodir_get_posttypes();
        /**
         * Filter the post types to display in widget.
         *
         * @since 1.0.0
         *
         * @param array $postypes Post types array.
         */
        $postypes = apply_filters('geodir_post_type_list_in_p_widget', $postypes);
        ?>

                <select class="widefat" id="<?php 
        echo $this->get_field_id('post_type');
        ?>
"
                        name="<?php 
        echo $this->get_field_name('post_type');
        ?>
"
                        onchange="geodir_change_category_list(this)">

                    <?php 
        foreach ($postypes as $postypes_obj) {
            ?>

                        <option <?php 
            if ($post_type == $postypes_obj) {
                echo 'selected="selected"';
            }
            ?>
 value="<?php 
            echo $postypes_obj;
            ?>
"><?php 
            $extvalue = explode('_', $postypes_obj);
            echo ucfirst($extvalue[1]);
            ?>
</option>

                    <?php 
        }
        ?>

                </select>
            </label>
        </p>


        <p id="post_type_cats">
            <label
                for="<?php 
        echo $this->get_field_id('category');
        ?>
"><?php 
        _e('Post Category:', 'geodirectory');
        ?>

                <?php 
        $post_type = $post_type != '' ? $post_type : 'gd_place';
        $all_postypes = geodir_get_posttypes();
        if (!in_array($post_type, $all_postypes)) {
            $post_type = 'gd_place';
        }
        $category_taxonomy = geodir_get_taxonomies($post_type);
        $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
        ?>

                <select multiple="multiple" class="widefat" name="<?php 
        echo $this->get_field_name('category');
        ?>
[]"
                        onchange="geodir_popular_widget_cat_title(this)">

                    <option <?php 
        if (!is_array($category) || is_array($category) && in_array('0', $category)) {
            echo 'selected="selected"';
        }
        ?>
 value="0"><?php 
        _e('All', 'geodirectory');
        ?>
</option>
                    <?php 
        foreach ($categories as $category_obj) {
            $selected = '';
            if (is_array($category) && in_array($category_obj->term_id, $category)) {
                echo $selected = 'selected="selected"';
            }
            ?>

                        <option <?php 
            echo $selected;
            ?>
                            value="<?php 
            echo $category_obj->term_id;
            ?>
"><?php 
            echo ucfirst($category_obj->name);
            ?>
</option>

                    <?php 
        }
        ?>

                </select>


                <input type="hidden" name="<?php 
        echo $this->get_field_name('category_title');
        ?>
"
                       id="<?php 
        echo $this->get_field_id('category_title');
        ?>
"
                       value="<?php 
        if ($category_title != '') {
            echo $category_title;
        } else {
            echo __('All', 'geodirectory');
        }
        ?>
"/>

            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('list_sort');
        ?>
"><?php 
        _e('Sort by:', 'geodirectory');
        ?>

                <select class="widefat" id="<?php 
        echo $this->get_field_id('list_sort');
        ?>
"
                        name="<?php 
        echo $this->get_field_name('list_sort');
        ?>
">

                    <option <?php 
        if ($list_sort == 'az') {
            echo 'selected="selected"';
        }
        ?>
 value="az"><?php 
        _e('A-Z', 'geodirectory');
        ?>
</option>

                    <option <?php 
        if ($list_sort == 'latest') {
            echo 'selected="selected"';
        }
        ?>
 value="latest"><?php 
        _e('Latest', 'geodirectory');
        ?>
</option>

                    <option <?php 
        if ($list_sort == 'featured') {
            echo 'selected="selected"';
        }
        ?>
 value="featured"><?php 
        _e('Featured', 'geodirectory');
        ?>
</option>

                    <option <?php 
        if ($list_sort == 'high_review') {
            echo 'selected="selected"';
        }
        ?>
 value="high_review"><?php 
        _e('Review', 'geodirectory');
        ?>
</option>

                    <option <?php 
        if ($list_sort == 'high_rating') {
            echo 'selected="selected"';
        }
        ?>
 value="high_rating"><?php 
        _e('Rating', 'geodirectory');
        ?>
</option>

                    <option <?php 
        if ($list_sort == 'random') {
            echo 'selected="selected"';
        }
        ?>
 value="random"><?php 
        _e('Random', 'geodirectory');
        ?>
</option>

                </select>
            </label>
        </p>

        <p>

            <label
                for="<?php 
        echo $this->get_field_id('post_number');
        ?>
"><?php 
        _e('Number of posts:', 'geodirectory');
        ?>

                <input class="widefat" id="<?php 
        echo $this->get_field_id('post_number');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('post_number');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($post_number);
        ?>
"/>
            </label>
        </p>

        <p>
            <label for="<?php 
        echo $this->get_field_id('layout');
        ?>
">
                <?php 
        _e('Layout:', 'geodirectory');
        ?>
                <select class="widefat" id="<?php 
        echo $this->get_field_id('layout');
        ?>
"
                        name="<?php 
        echo $this->get_field_name('layout');
        ?>
">
                    <option <?php 
        if ($layout == 'gridview_onehalf') {
            echo 'selected="selected"';
        }
        ?>
                        value="gridview_onehalf"><?php 
        _e('Grid View (Two Columns)', 'geodirectory');
        ?>
</option>
                    <option <?php 
        if ($layout == 'gridview_onethird') {
            echo 'selected="selected"';
        }
        ?>
                        value="gridview_onethird"><?php 
        _e('Grid View (Three Columns)', 'geodirectory');
        ?>
</option>
                    <option <?php 
        if ($layout == 'gridview_onefourth') {
            echo 'selected="selected"';
        }
        ?>
                        value="gridview_onefourth"><?php 
        _e('Grid View (Four Columns)', 'geodirectory');
        ?>
</option>
                    <option <?php 
        if ($layout == 'gridview_onefifth') {
            echo 'selected="selected"';
        }
        ?>
                        value="gridview_onefifth"><?php 
        _e('Grid View (Five Columns)', 'geodirectory');
        ?>
</option>
                    <option <?php 
        if ($layout == 'list') {
            echo 'selected="selected"';
        }
        ?>
 value="list"><?php 
        _e('List view', 'geodirectory');
        ?>
</option>

                </select>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('listing_width');
        ?>
"><?php 
        _e('Listing width:', 'geodirectory');
        ?>

                <input class="widefat" id="<?php 
        echo $this->get_field_id('listing_width');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('listing_width');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($listing_width);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('character_count');
        ?>
"><?php 
        _e('Post Content excerpt character count :', 'geodirectory');
        ?>
                <input class="widefat" id="<?php 
        echo $this->get_field_id('character_count');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('character_count');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($character_count);
        ?>
"/>
            </label>
        </p>

        <p>
            <label for="<?php 
        echo $this->get_field_id('add_location_filter');
        ?>
">
                <?php 
        _e('Enable Location Filter:', 'geodirectory');
        ?>
                <input type="checkbox" id="<?php 
        echo $this->get_field_id('add_location_filter');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('add_location_filter');
        ?>
" <?php 
        if ($add_location_filter) {
            echo 'checked="checked"';
        }
        ?>
                       value="1"/>
            </label>
        </p>
        <p>
            <label for="<?php 
        echo $this->get_field_id('show_featured_only');
        ?>
">
                <?php 
        _e('Show only featured listings:', 'geodirectory');
        ?>
 <input type="checkbox"
                                                                                            id="<?php 
        echo $this->get_field_id('show_featured_only');
        ?>
"
                                                                                            name="<?php 
        echo $this->get_field_name('show_featured_only');
        ?>
" <?php 
        if ($show_featured_only) {
            echo 'checked="checked"';
        }
        ?>
                                                                                            value="1"/>
            </label>
        </p>
        <p>
            <label for="<?php 
        echo $this->get_field_id('show_special_only');
        ?>
">
                <?php 
        _e('Show only listings with special offers:', 'geodirectory');
        ?>
 <input type="checkbox"
                                                                                                       id="<?php 
        echo $this->get_field_id('show_special_only');
        ?>
"
                                                                                                       name="<?php 
        echo $this->get_field_name('show_special_only');
        ?>
" <?php 
        if ($show_special_only) {
            echo 'checked="checked"';
        }
        ?>
                                                                                                       value="1"/>
            </label>
        </p>
        <p>
            <label for="<?php 
        echo $this->get_field_id('with_pics_only');
        ?>
">
                <?php 
        _e('Show only listings with pics:', 'geodirectory');
        ?>
 <input type="checkbox"
                                                                                             id="<?php 
        echo $this->get_field_id('with_pics_only');
        ?>
"
                                                                                             name="<?php 
        echo $this->get_field_name('with_pics_only');
        ?>
" <?php 
        if ($with_pics_only) {
            echo 'checked="checked"';
        }
        ?>
                                                                                             value="1"/>
            </label>
        </p>
        <p>
            <label for="<?php 
        echo $this->get_field_id('with_videos_only');
        ?>
">
                <?php 
        _e('Show only listings with videos:', 'geodirectory');
        ?>
 <input type="checkbox"
                                                                                               id="<?php 
        echo $this->get_field_id('with_videos_only');
        ?>
"
                                                                                               name="<?php 
        echo $this->get_field_name('with_videos_only');
        ?>
" <?php 
        if ($with_videos_only) {
            echo 'checked="checked"';
        }
        ?>
                                                                                               value="1"/>
            </label>
        </p>
        <p>
            <label
                for="<?php 
        echo $this->get_field_id('use_viewing_post_type');
        ?>
"><?php 
        _e('Use current viewing post type:', 'geodirectory');
        ?>
                <input type="checkbox" id="<?php 
        echo $this->get_field_id('use_viewing_post_type');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('use_viewing_post_type');
        ?>
" <?php 
        if ($use_viewing_post_type) {
            echo 'checked="checked"';
        }
        ?>
  value="1"/>
            </label>
        </p>


        <script type="text/javascript">

            function geodir_popular_widget_cat_title(val) {

                jQuery(val).find("option:selected").each(function (i) {
                    if (i == 0)
                        jQuery(val).closest('form').find('#post_type_cats input').val(jQuery(this).html());

                });

            }

            function geodir_change_category_list(obj, selected) {
                var post_type = obj.value;

                var ajax_url = '<?php 
        echo geodir_get_ajax_url();
        ?>
'

                var myurl = ajax_url + "&geodir_ajax=admin_ajax&ajax_action=get_cat_dl&post_type=" + post_type + "&selected=" + selected;

                jQuery.ajax({
                    type: "GET",
                    url: myurl,
                    success: function (data) {

                        jQuery(obj).closest('form').find('#post_type_cats select').html(data);

                    }
                });

            }

            <?php 
        if (is_active_widget(false, false, $this->id_base, true)) {
            ?>
            var post_type = jQuery('#<?php 
            echo $this->get_field_id('post_type');
            ?>
').val();

            <?php 
        }
        ?>

        </script>

    <?php 
    }
コード例 #15
0
/**
 * Imports data from CSV file using ajax.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @global string $plugin_prefix Geodirectory plugin table prefix.
 * @global object $current_user Current user object.
 */
function geodir_ajax_import_csv()
{
    error_reporting(0);
    // hide error to get clean json response
    global $wpdb, $plugin_prefix, $current_user;
    $uploads = wp_upload_dir();
    ini_set('auto_detect_line_endings', true);
    $wp_post_statuses = get_post_statuses();
    // All of the WordPress supported post statuses.
    $task = isset($_POST['task']) ? $_POST['task'] : '';
    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
    $filename = $uploadedFile;
    $uploads = wp_upload_dir();
    $uploads_dir = $uploads['path'];
    $image_name_arr = explode('/', $filename);
    $filename = end($image_name_arr);
    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
    $return = array();
    $return['file'] = $uploadedFile;
    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
            $return['error'] = NULL;
            $return['rows'] = 0;
            if (($handle = fopen($target_path, "r")) !== FALSE) {
                while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                    if (is_array($data) && !empty($data)) {
                        $file[] = '"' . implode('","', $data) . '"';
                    }
                }
                fclose($handle);
                $file = $file;
            }
            $return['rows'] = !empty($file) && count($file) > 1 ? count($file) - 1 : 0;
            if (!$return['rows'] > 0) {
                $return['error'] = __('No data found in csv file.', 'geodirectory');
            }
        }
    }
    if ($task == 'prepare' || !empty($return['error'])) {
        echo json_encode($return);
        exit;
    }
    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
    $count = $importlimit;
    $requested_limit = $importlimit;
    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
    if ($count < $totRecords) {
        $count = $tmpCnt + $count;
        if ($count > $totRecords) {
            $count = $totRecords;
        }
    } else {
        $count = $totRecords;
    }
    $total_records = 0;
    $rowcount = 0;
    $address_invalid = 0;
    $blank_address = 0;
    $upload_files = 0;
    $invalid_post_type = 0;
    $invalid_title = 0;
    $customKeyarray = array();
    $gd_post_info = array();
    $post_location = array();
    $countpost = 0;
    if (!empty($file)) {
        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
        $customKeyarray = $columns;
        if (empty($columns) || !empty($columns) && $columns[0] == '') {
            $return['error'] = CSV_INVAILD_FILE;
            echo json_encode($return);
            exit;
        }
        for ($i = 1; $i <= $importlimit; $i++) {
            $current_index = $tmpCnt + $i;
            if (isset($file[$current_index])) {
                $total_records++;
                $buffer = geodir_str_getcsv($file[$current_index]);
                $post_title = addslashes($buffer[0]);
                $current_post_author = $buffer[1];
                $post_desc = addslashes($buffer[2]);
                $post_cat = array();
                $catids_arr = array();
                $post_cat = trim($buffer[3]);
                // comma seperated category name
                if ($post_cat) {
                    $post_cat_arr = explode(',', $post_cat);
                    for ($c = 0; $c < count($post_cat_arr); $c++) {
                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
                        if (!empty($buffer[5])) {
                            if (in_array($buffer[5], geodir_get_posttypes())) {
                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
                                    $catids_arr[] = $cat->slug;
                                } else {
                                    if (get_term_by('slug', $catid, $p_taxonomy[0])) {
                                        $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
                                        $catids_arr[] = $cat->slug;
                                    } else {
                                        $ret = wp_insert_term($catid, $p_taxonomy[0]);
                                        if ($ret && !is_wp_error($ret)) {
                                            if (get_term_by('name', $catid, $p_taxonomy[0])) {
                                                $cat = get_term_by('name', $catid, $p_taxonomy[0]);
                                                $catids_arr[] = $cat->slug;
                                            } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
                                                $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
                                                $catids_arr[] = $cat->slug;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (!$catids_arr) {
                    $catids_arr[] = 1;
                }
                $post_tags = trim($buffer[4]);
                // comma seperated tags
                $tag_arr = '';
                if ($post_tags) {
                    $tag_arr = explode(',', $post_tags);
                }
                $table = $plugin_prefix . $buffer[5] . '_detail';
                // check table in database
                $error = '';
                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
                    $invalid_post_type++;
                    continue;
                }
                if ($post_title != '') {
                    $menu_order = 0;
                    $image_folder_name = 'uplaod/';
                    $image_names = array();
                    for ($c = 5; $c < count($customKeyarray); $c++) {
                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
                        if ($customKeyarray[$c] == 'IMAGE') {
                            $buffer[$c] = trim($buffer[$c]);
                            if (!empty($buffer[$c])) {
                                $image_names[] = $buffer[$c];
                            }
                        }
                        if ($customKeyarray[$c] == 'alive_days') {
                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
                                $submitdata = date('Y-m-d');
                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
                            } else {
                                $gd_post_info['expire_date'] = 'Never';
                            }
                        }
                        if ($customKeyarray[$c] == 'post_city') {
                            $post_city = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_region') {
                            $post_region = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_country') {
                            $post_country = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_latitude') {
                            $post_latitude = addslashes($buffer[$c]);
                        }
                        if ($customKeyarray[$c] == 'post_longitude') {
                            $post_longitude = addslashes($buffer[$c]);
                        }
                        // Post status
                        if ($customKeyarray[$c] == 'post_status') {
                            $post_status = sanitize_key($buffer[$c]);
                        }
                    }
                    /* ================ before array create ============== */
                    $location_result = geodir_get_default_location();
                    if (!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '' || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
                        $blank_address++;
                        continue;
                    } else {
                        if ($location_result->location_id == 0) {
                            if (geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city) || geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region) || geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country)) {
                                $address_invalid++;
                                continue;
                            }
                        }
                    }
                    // Default post status
                    $default_status = 'publish';
                    $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
                    $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
                    $my_post['post_title'] = $post_title;
                    $my_post['post_content'] = $post_desc;
                    $my_post['post_type'] = addslashes($buffer[5]);
                    $my_post['post_author'] = $current_post_author;
                    $my_post['post_status'] = $post_status;
                    $my_post['post_category'] = $catids_arr;
                    $my_post['post_tags'] = $tag_arr;
                    $gd_post_info['post_tags'] = $tag_arr;
                    $gd_post_info['post_title'] = $post_title;
                    $gd_post_info['post_status'] = $post_status;
                    $gd_post_info['submit_time'] = time();
                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
                    $last_postid = wp_insert_post($my_post);
                    $countpost++;
                    // Check if we need to save post location as new location
                    if ($location_result->location_id > 0) {
                        if (isset($post_city) && isset($post_region)) {
                            $request_info['post_location'] = array('city' => $post_city, 'region' => $post_region, 'country' => $post_country, 'geo_lat' => $post_latitude, 'geo_lng' => $post_longitude);
                            $post_location_info = $request_info['post_location'];
                            if ($location_id = geodir_add_new_location($post_location_info)) {
                                $post_location_id = $location_id;
                            }
                        } else {
                            $post_location_id = 0;
                        }
                    } else {
                        $post_location_id = 0;
                    }
                    /* ------- get default package info ----- */
                    $payment_info = array();
                    $package_info = array();
                    $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]);
                    $package_id = '';
                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
                        $package_id = $gd_post_info['package_id'];
                    }
                    if (!empty($package_info)) {
                        $payment_info['package_id'] = $package_info['pid'];
                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
                        } else {
                            $payment_info['expire_date'] = 'Never';
                        }
                        $gd_post_info = array_merge($gd_post_info, $payment_info);
                    }
                    $gd_post_info['post_location_id'] = $post_location_id;
                    $post_type = get_post_type($last_postid);
                    $table = $plugin_prefix . $post_type . '_detail';
                    geodir_save_post_info($last_postid, $gd_post_info);
                    if (!empty($image_names)) {
                        $upload_files++;
                        $menu_order = 1;
                        foreach ($image_names as $image_name) {
                            $img_name_arr = explode('.', $image_name);
                            $uploads = wp_upload_dir();
                            $sub_dir = $uploads['subdir'];
                            $arr_file_type = wp_check_filetype($image_name);
                            $uploaded_file_type = $arr_file_type['type'];
                            $attachment = array();
                            $attachment['post_id'] = $last_postid;
                            $attachment['title'] = $img_name_arr[0];
                            $attachment['content'] = '';
                            $attachment['file'] = $sub_dir . '/' . $image_name;
                            $attachment['mime_type'] = $uploaded_file_type;
                            $attachment['menu_order'] = $menu_order;
                            $attachment['is_featured'] = 0;
                            $attachment_set = '';
                            foreach ($attachment as $key => $val) {
                                if ($val != '') {
                                    $attachment_set .= $key . " = '" . $val . "', ";
                                }
                            }
                            $attachment_set = trim($attachment_set, ", ");
                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
                            if ($menu_order == 1) {
                                $post_type = get_post_type($last_postid);
                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
                            }
                            $menu_order++;
                        }
                    }
                    $gd_post_info['package_id'] = $package_id;
                    /** This action is documented in geodirectory-functions/post-functions.php */
                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
                    if (!empty($buffer[5])) {
                        if (in_array($buffer[5], geodir_get_posttypes())) {
                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
                        }
                    }
                } else {
                    $invalid_title++;
                }
            }
        }
    }
    $return['rowcount'] = $countpost;
    $return['invalidcount'] = $address_invalid;
    $return['blank_address'] = $blank_address;
    $return['upload_files'] = $upload_files;
    $return['invalid_post_type'] = $invalid_post_type;
    $return['invalid_title'] = $invalid_title;
    $return['total_records'] = $total_records;
    echo json_encode($return);
    exit;
}
コード例 #16
0
    /**
     * Back-end listing slider widget settings form.
     *
     * @since 1.0.0
     * @since 1.5.1 Declare function public.
     *
     * @param array $instance Previously saved values from database.
     */
    public function form($instance)
    {
        //widgetform in backend
        $instance = wp_parse_args((array) $instance, array('title' => '', 'post_type' => '', 'category' => '', 'post_number' => '5', 'max_show' => '1', 'slide_width' => '', 'show_title' => '', 'slideshow' => '', 'animationLoop' => '', 'directionNav' => '', 'slideshowSpeed' => 5000, 'animationSpeed' => 600, 'animation' => '', 'list_sort' => 'latest', 'show_featured_only' => ''));
        $title = strip_tags($instance['title']);
        $post_type = strip_tags($instance['post_type']);
        $category = strip_tags($instance['category']);
        $post_number = strip_tags($instance['post_number']);
        $max_show = strip_tags($instance['max_show']);
        $slide_width = strip_tags($instance['slide_width']);
        $show_title = $instance['show_title'];
        $slideshow = $instance['slideshow'];
        $animationLoop = $instance['animationLoop'];
        $directionNav = $instance['directionNav'];
        $slideshowSpeed = $instance['slideshowSpeed'];
        $animationSpeed = $instance['animationSpeed'];
        $animation = $instance['animation'];
        $list_sort = $instance['list_sort'];
        $show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false;
        $sort_fields = array();
        $sort_fields[] = array('field' => 'latest', 'label' => __('Latest', 'geodirectory'));
        $sort_fields[] = array('field' => 'featured', 'label' => __('Featured', 'geodirectory'));
        $sort_fields[] = array('field' => 'high_review', 'label' => __('Review', 'geodirectory'));
        $sort_fields[] = array('field' => 'high_rating', 'label' => __('Rating', 'geodirectory'));
        $sort_fields[] = array('field' => 'random', 'label' => __('Random', 'geodirectory'));
        ?>

        <p>
            <label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'geodirectory');
        ?>

                <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($title);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('post_type');
        ?>
"><?php 
        _e('Post Type:', 'geodirectory');
        ?>

                <?php 
        $postypes = geodir_get_posttypes();
        ?>

                <select class="widefat" id="<?php 
        echo $this->get_field_id('post_type');
        ?>
"
                        name="<?php 
        echo $this->get_field_name('post_type');
        ?>
"
                        onchange="geodir_change_category_list(this.value)">

                    <?php 
        foreach ($postypes as $postypes_obj) {
            ?>

                        <option <?php 
            if ($post_type == $postypes_obj) {
                echo 'selected="selected"';
            }
            ?>
 value="<?php 
            echo $postypes_obj;
            ?>
"><?php 
            $extvalue = explode('_', $postypes_obj);
            echo ucfirst($extvalue[1]);
            ?>
</option>

                    <?php 
        }
        ?>

                </select>
            </label>
        </p>


        <p>
            <label
                for="<?php 
        echo $this->get_field_id('category');
        ?>
"><?php 
        _e('Post Category:', 'geodirectory');
        ?>

                <?php 
        $category_taxonomy = geodir_get_taxonomies('gd_place');
        $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
        ?>

                <select class="widefat" id="<?php 
        echo $this->get_field_id('category');
        ?>
"
                        name="<?php 
        echo $this->get_field_name('category');
        ?>
">
                    <option <?php 
        if ($category == '0') {
            echo 'selected="selected"';
        }
        ?>
 value="0"><?php 
        _e('All', 'geodirectory');
        ?>
</option>
                    <?php 
        foreach ($categories as $category_obj) {
            ?>

                        <option <?php 
            if ($category == $category_obj->term_id) {
                echo 'selected="selected"';
            }
            ?>
                            value="<?php 
            echo $category_obj->term_id;
            ?>
"><?php 
            echo ucfirst($category_obj->name);
            ?>
</option>

                    <?php 
        }
        ?>

                </select>
            </label>
        </p>
        <p>
            <label
                for="<?php 
        echo $this->get_field_id('list_sort');
        ?>
"><?php 
        _e('Sort by:', 'geodirectory');
        ?>
</label>
            <select class="widefat" id="<?php 
        echo $this->get_field_id('list_sort');
        ?>
"
                    name="<?php 
        echo $this->get_field_name('list_sort');
        ?>
">
                <?php 
        foreach ($sort_fields as $sort_field) {
            ?>
                    <option
                        value="<?php 
            echo $sort_field['field'];
            ?>
" <?php 
            echo $list_sort == $sort_field['field'] ? 'selected="selected"' : '';
            ?>
><?php 
            echo $sort_field['label'];
            ?>
</option>
                <?php 
        }
        ?>
            </select>
        </p>
        <p>
            <label
                for="<?php 
        echo $this->get_field_id('post_number');
        ?>
"><?php 
        _e('Number of posts(total):', 'geodirectory');
        ?>
                <input class="widefat" id="<?php 
        echo $this->get_field_id('post_number');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('post_number');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($post_number);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('max_show');
        ?>
"><?php 
        _e('Number of posts(shown at one time, requires a slide width to be set):', 'geodirectory');
        ?>
                <input class="widefat" id="<?php 
        echo $this->get_field_id('max_show');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('max_show');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($max_show);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('slide_width');
        ?>
"><?php 
        _e('Slide width(leave blank unless showing more than one slide at a time, ex: 210):', 'geodirectory');
        ?>
                <input class="widefat" id="<?php 
        echo $this->get_field_id('slide_width');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('slide_width');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($slide_width);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('animation');
        ?>
"><?php 
        _e('Animation:', 'geodirectory');
        ?>

                <select class="widefat" id="<?php 
        echo $this->get_field_id('animation');
        ?>
"
                        name="<?php 
        echo $this->get_field_name('animation');
        ?>
">
                    <option <?php 
        if ($animation == 'slide') {
            echo 'selected="selected"';
        }
        ?>
 value="slide">Slide
                    </option>
                    <option <?php 
        if ($animation == 'fade') {
            echo 'selected="selected"';
        }
        ?>
 value="fade">Fade
                    </option>
                </select>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('slideshowSpeed');
        ?>
"><?php 
        _e('Slide Show Speed: (milliseconds)', 'geodirectory');
        ?>

                <input class="widefat" id="<?php 
        echo $this->get_field_id('slideshowSpeed');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('slideshowSpeed');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($slideshowSpeed);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('animationSpeed');
        ?>
"><?php 
        _e('Animation Speed: (milliseconds)', 'geodirectory');
        ?>

                <input class="widefat" id="<?php 
        echo $this->get_field_id('animationSpeed');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('animationSpeed');
        ?>
" type="text"
                       value="<?php 
        echo esc_attr($animationSpeed);
        ?>
"/>
            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('slideshow');
        ?>
"><?php 
        _e('SlideShow:', 'geodirectory');
        ?>

                <input type="checkbox" <?php 
        if ($slideshow) {
            echo 'checked="checked"';
        }
        ?>
 id="<?php 
        echo $this->get_field_id('slideshow');
        ?>
" value="1"
                       name="<?php 
        echo $this->get_field_name('slideshow');
        ?>
"/>

            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('animationLoop');
        ?>
"><?php 
        _e('AnimationLoop:', 'geodirectory');
        ?>

                <input type="checkbox" <?php 
        if ($animationLoop) {
            echo 'checked="checked"';
        }
        ?>
 id="<?php 
        echo $this->get_field_id('animationLoop');
        ?>
" value="1"
                       name="<?php 
        echo $this->get_field_name('animationLoop');
        ?>
"/>

            </label>
        </p>

        <p>
            <label
                for="<?php 
        echo $this->get_field_id('directionNav');
        ?>
"><?php 
        _e('DirectionNav:', 'geodirectory');
        ?>

                <input type="checkbox" <?php 
        if ($directionNav) {
            echo 'checked="checked"';
        }
        ?>
 id="<?php 
        echo $this->get_field_id('directionNav');
        ?>
" value="1"
                       name="<?php 
        echo $this->get_field_name('directionNav');
        ?>
"/>

            </label>
        </p>


        <p>
            <label
                for="<?php 
        echo $this->get_field_id('show_title');
        ?>
"><?php 
        _e('Show Title:', 'geodirectory');
        ?>

                <input type="checkbox" <?php 
        if ($show_title) {
            echo 'checked="checked"';
        }
        ?>
 id="<?php 
        echo $this->get_field_id('show_title');
        ?>
" value="1"
                       name="<?php 
        echo $this->get_field_name('show_title');
        ?>
"/>

            </label>
        </p>
        <p>
            <label
                for="<?php 
        echo $this->get_field_id('show_featured_only');
        ?>
"><?php 
        _e('Show only featured listings:', 'geodirectory');
        ?>
                <input type="checkbox" id="<?php 
        echo $this->get_field_id('show_featured_only');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('show_featured_only');
        ?>
" <?php 
        if ($show_featured_only) {
            echo 'checked="checked"';
        }
        ?>
                       value="1"/>
            </label>
        </p>
        <script type="text/javascript">
            function geodir_change_category_list(post_type, selected) {

                var ajax_url = '<?php 
        echo geodir_get_ajax_url();
        ?>
'

                var myurl = ajax_url + "&geodir_ajax=admin_ajax&ajax_action=get_cat_dl&post_type=" + post_type + "&selected=" + selected;

                jQuery.ajax({
                    type: "GET",
                    url: myurl,
                    success: function (data) {
                        jQuery('#<?php 
        echo $this->get_field_id('category');
        ?>
').html(data);
                    }
                });

            }

            <?php 
        if (is_active_widget(false, false, $this->id_base, true)) {
            ?>
            var post_type = jQuery('#<?php 
            echo $this->get_field_id('post_type');
            ?>
').val();

            geodir_change_category_list(post_type, '<?php 
            echo $category;
            ?>
');
            <?php 
        }
        ?>

        </script>


    <?php 
    }
コード例 #17
0
        public function form($instance)
        {
            $instance = wp_parse_args((array) $instance, array('title' => '', 'hood_post_type' => '', 'hood_category' => '', 'category_title' => '', 'list_sort' => '', 'list_order' => '', 'post_number' => '5', 'layout' => 'gridview_onehalf', 'add_location_filter' => '1', 'character_count' => '20'));
            $title = strip_tags($instance['title']);
            $hood_post_type = strip_tags($instance['hood_post_type']);
            $hood_category = strip_tags($instance['hood_category']);
            $category_title = strip_tags($instance['category_title']);
            $list_sort = strip_tags($instance['list_sort']);
            $list_order = strip_tags($instance['list_order']);
            $post_number = strip_tags($instance['post_number']);
            $layout = strip_tags($instance['layout']);
            $add_location_filter = strip_tags($instance['add_location_filter']);
            $character_count = $instance['character_count'];
            ?>
			
			<p>
				<label for="<?php 
            echo $this->get_field_id('title');
            ?>
"><?php 
            _e('Title:', GEODIRLOCATION_TEXTDOMAIN);
            ?>
				
					<input class="widefat" id="<?php 
            echo $this->get_field_id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
" type="text" value="<?php 
            echo esc_attr($title);
            ?>
" />
				</label>
			</p>
			
			<p>
					<label for="<?php 
            echo $this->get_field_id('hood_post_type');
            ?>
"><?php 
            _e('Post Type:', GEODIRLOCATION_TEXTDOMAIN);
            ?>
			
					<?php 
            $postypes = geodir_get_posttypes();
            ?>
			
					<select class="widefat" id="<?php 
            echo $this->get_field_id('hood_post_type');
            ?>
" name="<?php 
            echo $this->get_field_name('hood_post_type');
            ?>
" onchange="geodir_change_hood_category_list(this)">
						
			<?php 
            foreach ($postypes as $postypes_obj) {
                ?>
							
									<option <?php 
                if ($hood_post_type == $postypes_obj) {
                    echo 'selected="selected"';
                }
                ?>
 value="<?php 
                echo $postypes_obj;
                ?>
"><?php 
                $extvalue = explode('_', $postypes_obj);
                echo ucfirst($extvalue[1]);
                ?>
</option>
							
			<?php 
            }
            ?>
							
					</select>
					</label>
			</p>
			
			<p id="hood_post_categories">
				<label for="<?php 
            echo $this->get_field_id('hood_category');
            ?>
"><?php 
            _e('Post Category:', GEODIRLOCATION_TEXTDOMAIN);
            ?>
			
			<?php 
            $hood_post_type = $hood_post_type != '' ? $hood_post_type : 'gd_place';
            $category_taxonomy = geodir_get_taxonomies($hood_post_type);
            $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
            ?>
			
				<select class="widefat" id="<?php 
            echo $this->get_field_id('hood_category');
            ?>
" name="<?php 
            echo $this->get_field_name('hood_category');
            ?>
" onchange="jQuery('#<?php 
            echo $this->get_field_id('category_title');
            ?>
').val(jQuery('#<?php 
            echo $this->get_field_id('hood_category');
            ?>
 option:selected').text());" >
					
					<option <?php 
            if ($hood_category == '0') {
                echo 'selected="selected"';
            }
            ?>
 value="0"><?php 
            _e('All', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
					
					<?php 
            foreach ($categories as $category_obj) {
                ?>
					
					<option <?php 
                if ($hood_category == $category_obj->term_id) {
                    echo 'selected="selected"';
                }
                ?>
 value="<?php 
                echo $category_obj->term_id;
                ?>
"><?php 
                echo ucfirst($category_obj->name);
                ?>
</option>
						
					<?php 
            }
            ?>
						
				</select>
			 <input type="hidden" name="<?php 
            echo $this->get_field_name('category_title');
            ?>
" id="<?php 
            echo $this->get_field_id('category_title');
            ?>
" value="<?php 
            if ($category_title != '') {
                echo $category_title;
            } else {
                echo __('All', GEODIRLOCATION_TEXTDOMAIN);
            }
            ?>
" />
				</label>
			</p>
			
			<p>
				<label for="<?php 
            echo $this->get_field_id('list_sort');
            ?>
"><?php 
            _e('Sort by:', GEODIRLOCATION_TEXTDOMAIN);
            ?>
					
				 <select class="widefat" id="<?php 
            echo $this->get_field_id('list_sort');
            ?>
" name="<?php 
            echo $this->get_field_name('list_sort');
            ?>
">
							<option <?php 
            if ($list_sort == 'latest') {
                echo 'selected="selected"';
            }
            ?>
 value="latest"><?php 
            _e('Latest', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
							 <option <?php 
            if ($list_sort == 'featured') {
                echo 'selected="selected"';
            }
            ?>
 value="featured"><?php 
            _e('Featured', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
							<option <?php 
            if ($list_sort == 'high_review') {
                echo 'selected="selected"';
            }
            ?>
 value="high_review"><?php 
            _e('Review', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
							<option <?php 
            if ($list_sort == 'high_rating') {
                echo 'selected="selected"';
            }
            ?>
 value="high_rating"><?php 
            _e('Rating', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>	
					</select>
					</label>
			</p>
							
			<p>
			
				<label for="<?php 
            echo $this->get_field_id('post_number');
            ?>
"><?php 
            _e('Number of posts:', GEODIRLOCATION_TEXTDOMAIN);
            ?>
				
				<input class="widefat" id="<?php 
            echo $this->get_field_id('post_number');
            ?>
" name="<?php 
            echo $this->get_field_name('post_number');
            ?>
" type="text" value="<?php 
            echo esc_attr($post_number);
            ?>
" />
				</label>
			</p>
							
			<p>
				<label for="<?php 
            echo $this->get_field_id('layout');
            ?>
">
			<?php 
            _e('Layout:', GEODIRLOCATION_TEXTDOMAIN);
            ?>
					<select class="widefat" id="<?php 
            echo $this->get_field_id('layout');
            ?>
" name="<?php 
            echo $this->get_field_name('layout');
            ?>
">
						<option <?php 
            if ($layout == 'gridview_onehalf') {
                echo 'selected="selected"';
            }
            ?>
 value="gridview_onehalf"><?php 
            _e('Grid View (Two Columns)', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
              <option <?php 
            if ($layout == 'gridview_onethird') {
                echo 'selected="selected"';
            }
            ?>
 value="gridview_onethird"><?php 
            _e('Grid View (Three Columns)', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
							<option <?php 
            if ($layout == 'gridview_onefourth') {
                echo 'selected="selected"';
            }
            ?>
 value="gridview_onefourth"><?php 
            _e('Grid View (Four Columns)', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
							<option <?php 
            if ($layout == 'gridview_onefifth') {
                echo 'selected="selected"';
            }
            ?>
 value="gridview_onefifth"><?php 
            _e('Grid View (Five Columns)', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
							<option <?php 
            if ($layout == 'list') {
                echo 'selected="selected"';
            }
            ?>
 value="list"><?php 
            _e('List view', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>
					</select>    
					</label>
			</p>
			
			<p>
            <label for="<?php 
            echo $this->get_field_id('character_count');
            ?>
"><?php 
            _e('Post Content excerpt character count :', GEODIRLOCATION_TEXTDOMAIN);
            ?>
 
            <input class="widefat" id="<?php 
            echo $this->get_field_id('character_count');
            ?>
" name="<?php 
            echo $this->get_field_name('character_count');
            ?>
" type="text" value="<?php 
            echo esc_attr($character_count);
            ?>
" />
            </label>
        </p>
							
			<p style="display:none;">
					<label for="<?php 
            echo $this->get_field_id('add_location_filter');
            ?>
">
			<?php 
            _e('Enable Location Filter:', GEODIRLOCATION_TEXTDOMAIN);
            ?>
						<input type="checkbox" id="<?php 
            echo $this->get_field_id('add_location_filter');
            ?>
" name="<?php 
            echo $this->get_field_name('add_location_filter');
            ?>
" <?php 
            if ($add_location_filter) {
                echo 'checked="checked"';
            }
            ?>
  value="1"  />
						</label>
				</p>
			
			<script type="text/javascript">
				function geodir_change_hood_category_list(obj,selected){
				
					var ajax_url = '<?php 
            echo geodir_get_ajax_url();
            ?>
'
					
					var hood_post_type = obj.value;
					
					var myurl = ajax_url+"&geodir_ajax=admin_ajax&ajax_action=get_cat_dl&post_type="+hood_post_type+"&selected="+selected;
					
					jQuery.ajax({
						type: "GET",
						url: myurl,
						success: function(data){
							
							jQuery(obj).closest('form').find('#hood_post_categories select').html(data);
							
						}
					});
					
					}
					
					<?php 
            if (is_active_widget(false, false, $this->id_base, true)) {
                ?>
					var hood_post_type = jQuery('#<?php 
                echo $this->get_field_id('hood_post_type');
                ?>
').val();
					
					<?php 
            }
            ?>
			
			</script>
	
			<?php 
        }
コード例 #18
0
/**
 * Add the location variables in session.
 *
 * @since 1.0.0
 *
 * @param object $wp The WordPress object.
 */
function geodir_set_location_var_in_session_in_core($wp)
{
    //$wp->geodir_query_vars = $wp->query_vars ;
    // this code will determine when a user wants to switch location
    // Query Vars will have page_id parameter
    // check if query var has page_id and that page id is location page
    geodir_set_is_geodir_page($wp);
    if (!get_option('geodir_set_as_home')) {
        if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
            if ('page' == get_option('show_on_front')) {
                $wp->query_vars['page_id'] = get_option('page_on_front');
            }
        }
    }
    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
        $gd_country = '';
        $gd_region = '';
        $gd_city = '';
        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') {
            $gd_country = urldecode($wp->query_vars['gd_country']);
        }
        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') {
            $gd_region = urldecode($wp->query_vars['gd_region']);
        }
        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') {
            $gd_city = urldecode($wp->query_vars['gd_city']);
        }
        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
            $default_location = geodir_get_default_location();
            if (get_option('geodir_add_location_url')) {
                if (get_option('geodir_show_location_url') != 'all') {
                    if ($gd_region == '') {
                        if (isset($_SESSION['gd_region'])) {
                            $gd_region = $_SESSION['gd_region'];
                        } else {
                            $gd_region = $default_location->region_slug;
                        }
                    }
                    if ($gd_city == '') {
                        if (isset($_SESSION['gd_city'])) {
                            $gd_city = $_SESSION['gd_city'];
                        } else {
                            $gd_city = $default_location->city_slug;
                        }
                        $base_location_link = geodir_get_location_link('base');
                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
                        exit;
                    }
                }
            }
            $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => '');
            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
            if (!empty($location_array)) {
                $_SESSION['gd_multi_location'] = 1;
                $_SESSION['gd_country'] = $gd_country;
                $_SESSION['gd_region'] = $gd_region;
                $_SESSION['gd_city'] = $gd_city;
                $wp->query_vars['gd_country'] = $gd_country;
                $wp->query_vars['gd_region'] = $gd_region;
                $wp->query_vars['gd_city'] = $gd_city;
            } else {
                unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']);
            }
        } else {
            unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']);
        }
    } else {
        if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
            if (!is_admin()) {
                $requested_post_type = $wp->query_vars['post_type'];
                // check if this post type is geodirectory post types
                $post_type_array = geodir_get_posttypes();
                if (in_array($requested_post_type, $post_type_array)) {
                    // now u can apply geodirectory related manipulation.
                }
            }
        } else {
            // check if a geodirectory taxonomy is set
            $gd_country = '';
            $gd_region = '';
            $gd_city = '';
            $is_geodir_taxonomy = false;
            $is_geodir_taxonomy_term = false;
            // the last term is real geodirectory taxonomy term or not
            $is_geodir_location_found = false;
            $geodir_taxonomy = '';
            $geodir_post_type = '';
            $geodir_term = '';
            $geodir_set_location_session = true;
            $geodir_taxonomis = geodir_get_taxonomies('', true);
            foreach ($geodir_taxonomis as $taxonomy) {
                if (array_key_exists($taxonomy, $wp->query_vars)) {
                    $is_geodir_taxonomy = true;
                    $geodir_taxonomy = $taxonomy;
                    $geodir_post_type = str_replace('category', '', $taxonomy);
                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
                    $geodir_term = $wp->query_vars[$geodir_taxonomy];
                    break;
                }
            }
            // now get an array of all terms seperated by '/'
            $geodir_terms = explode('/', $geodir_term);
            $geodir_last_term = end($geodir_terms);
            if ($is_geodir_taxonomy) {
                $wp->query_vars['post_type'] = $geodir_post_type;
                // now check if last term is a post of geodirectory post types
                $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type));
                if (empty($geodir_post)) {
                    $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type, 'post_status' => 'draft', 'suppress_filters' => false));
                }
                if (!empty($geodir_post)) {
                    if ($geodir_post[0]->post_status != 'publish') {
                        foreach ($wp->query_vars as $key => $vars) {
                            unset($wp->query_vars[$key]);
                        }
                        $wp->query_vars['error'] = '404';
                        // set it as 404 if post exists but its status is not published yet
                    } else {
                        //$wp->query_vars[$geodir_taxonomy] = str_replace( '/'.$geodir_last_term , ''  , $geodir_term);
                        $wp->query_vars[$geodir_post_type] = $geodir_last_term;
                        $wp->query_vars['name'] = $geodir_last_term;
                    }
                    $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
                    if (!$post_title_replace_count) {
                        $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
                    }
                    $geodir_terms = explode('/', $geodir_term);
                    $geodir_last_term = end($geodir_terms);
                    $geodir_set_location_session = false;
                    //return ;
                }
                $geodir_location_terms = '';
                // if last term is not a post then check if last term is a term of the specific texonomy or not
                if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
                    $is_geodir_taxonomy_term = true;
                    $geodir_set_location_session = false;
                }
                // now check if there is location parts in the url or not
                if (get_option('geodir_add_location_url')) {
                    $default_location = geodir_get_default_location();
                    if (get_option('geodir_show_location_url') == 'all') {
                        if (count($geodir_terms) >= 3) {
                            $gd_country = urldecode($geodir_terms[0]);
                            $gd_region = urldecode($geodir_terms[1]);
                            $gd_city = urldecode($geodir_terms[2]);
                        } else {
                            if (count($geodir_terms) >= 2) {
                                $gd_country = urldecode($geodir_terms[0]);
                                $gd_region = urldecode($geodir_terms[1]);
                            } else {
                                if (count($geodir_terms) >= 1) {
                                    $gd_country = urldecode($geodir_terms[0]);
                                }
                            }
                        }
                        if (strtolower($default_location->country_slug) == strtolower($gd_country) && strtolower($default_location->region_slug) == strtolower($gd_region) && strtolower($default_location->city_slug) == strtolower($gd_city)) {
                            $is_geodir_location_found = true;
                        }
                        // if location has not been found for country , region and city then search for country and region only
                        if (!$is_geodir_location_found) {
                            $gd_city = '';
                            if (strtolower($default_location->country_slug) == strtolower($gd_country) && strtolower($default_location->region_slug) == strtolower($gd_region)) {
                                $is_geodir_location_found = true;
                            }
                        }
                        // if location has not been found for country , region  then search for country only
                        if (!$is_geodir_location_found) {
                            $gd_city = '';
                            $gd_region = '';
                            if (strtolower($default_location->country_slug) == strtolower($gd_country)) {
                                $is_geodir_location_found = true;
                            }
                        }
                    } else {
                        $gd_city = $geodir_terms[0];
                        if (strtolower($default_location->city_slug) == strtolower($gd_city)) {
                            $is_geodir_location_found = true;
                            $gd_region = $default_location->region_slug;
                            $gd_country = $default_location->country_slug;
                        }
                    }
                    // if locaton still not found then clear location related session variables
                    if ($is_geodir_location_found && $geodir_set_location_session) {
                        $_SESSION['gd_multi_location'] = 1;
                        $_SESSION['gd_country'] = $gd_country;
                        $_SESSION['gd_region'] = $gd_region;
                        $_SESSION['gd_city'] = $gd_city;
                    }
                    if (get_option('geodir_show_location_url') != 'all') {
                        $gd_country = '';
                        $gd_region = '';
                    }
                    if ($is_geodir_location_found) {
                        $wp->query_vars['gd_country'] = $gd_country;
                        $wp->query_vars['gd_region'] = $gd_region;
                        $wp->query_vars['gd_city'] = $gd_city;
                    } else {
                        $gd_country = '';
                        $gd_region = '';
                        $gd_city = '';
                    }
                }
                $wp->query_vars[$geodir_taxonomy] = $geodir_term;
                // eliminate location related terms from taxonomy term
                if ($gd_country != '') {
                    $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
                }
                if ($gd_region != '') {
                    $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
                }
                if ($gd_city != '') {
                    $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
                }
                $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
                $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
                $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
                if ($wp->query_vars[$geodir_taxonomy] == '') {
                    unset($wp->query_vars[$geodir_taxonomy]);
                } else {
                    if (!$is_geodir_taxonomy_term) {
                        foreach ($wp->query_vars as $key => $vars) {
                            unset($wp->query_vars[$key]);
                        }
                        $wp->query_vars['error'] = '404';
                    }
                }
            }
        }
    }
    if (isset($_SESSION['gd_multi_location']) && $_SESSION['gd_multi_location'] == 1) {
        $wp->query_vars['gd_country'] = $_SESSION['gd_country'];
        $wp->query_vars['gd_region'] = $_SESSION['gd_region'];
        $wp->query_vars['gd_city'] = $_SESSION['gd_city'];
    }
    // now check if there is location parts in the url or not
    if (get_option('geodir_add_location_url')) {
        if (get_option('geodir_show_location_url') != 'all') {
            if (isset($wp->query_vars['gd_country'])) {
                $wp->query_vars['gd_country'] = '';
            }
            if (isset($wp->query_vars['gd_region'])) {
                $wp->query_vars['gd_region'] = '';
            }
        }
    } else {
        if (isset($wp->query_vars['gd_country'])) {
            $wp->query_vars['gd_country'] = '';
        }
        if (isset($wp->query_vars['gd_region'])) {
            $wp->query_vars['gd_region'] = '';
        }
        if (isset($wp->query_vars['gd_city'])) {
            $wp->query_vars['gd_city'] = '';
        }
    }
}
コード例 #19
0
ファイル: general_functions.php プロジェクト: bangjojo/wp
/**
 * Count reviews by terms.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @param bool $force_update Force update option value?. Default.false.
 * @return array Term array data.
 */
function geodir_count_reviews_by_terms($force_update = false)
{
    /**
     * Filter review count option data.
     *
     * @since 1.0.0
     * @param bool $force_update Force update option value?. Default.false.
     */
    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update);
    if (!empty($option_data)) {
        return $option_data;
    }
    $option_data = get_option('geodir_global_review_count');
    if (!$option_data or $force_update) {
        $post_types = geodir_get_posttypes();
        $term_array = array();
        foreach ($post_types as $post_type) {
            $taxonomy = geodir_get_taxonomies($post_type);
            $taxonomy = $taxonomy[0];
            $args = array('hide_empty' => false);
            $terms = get_terms($taxonomy, $args);
            foreach ($terms as $term) {
                $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
                $children = get_term_children($term->term_id, $taxonomy);
                /*if ( is_array( $children ) ) {
                			foreach ( $children as $child_id ) {
                				$child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
                				$count = $count + $child_count;
                			}
                		}*/
                $term_array[$term->term_id] = $count;
            }
        }
        update_option('geodir_global_review_count', $term_array);
        //clear cache
        wp_cache_delete('geodir_global_review_count');
        return $term_array;
    } else {
        return $option_data;
    }
}
コード例 #20
0
}
?>

            <?php 
switch ($field_type) {
    case 'taxonomy':
        ?>
                    <tr>
                        <td><strong><?php 
        _e('Select taxonomy:', GEODIRECTORY_TEXTDOMAIN);
        ?>
</strong></td>
                        <td align="left">
                            <select name="htmlvar_name" id="htmlvar_name">
                                <?php 
        $gd_taxonomy = geodir_get_taxonomies($post_type);
        foreach ($gd_taxonomy as $gd_tax) {
            ?>
                                    <option <?php 
            if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) {
                echo 'selected="selected"';
            }
            ?>
 id="<?php 
            echo $gd_tax;
            ?>
"><?php 
            echo $gd_tax;
            ?>
</option><?php 
        }
コード例 #21
0
/**
 * Returns All post categories from all GD post types.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @return array Returns post categories as an array.
 */
function geodir_home_map_cats_key_value_array()
{
    $post_types = geodir_get_posttypes('object');
    $return = array();
    if (!empty($post_types)) {
        foreach ($post_types as $key => $post_type) {
            $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
            $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
            $taxonomies = geodir_get_taxonomies($key);
            $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
            $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
            if (!empty($cat_terms)) {
                $return['optgroup_start-' . $key] = $post_type_name;
                foreach ($cat_terms as $cat_term) {
                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
                }
                $return['optgroup_end-' . $key] = $post_type_name;
            }
        }
    }
    return $return;
}
コード例 #22
0
ファイル: listing_filters.php プロジェクト: bangjojo/wp
/**
 * Listing search where filter.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @global string $plugin_prefix Geodirectory plugin table prefix.
 * @global string $table Listing table name.
 * @param string $where The where query string.
 * @return string Modified where query string.
 */
function searching_filter_where($where)
{
    global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA;
    global $search_term;
    $search_term = 'OR';
    $search_term = 'AND';
    $geodir_custom_search = '';
    $category_search_range = '';
    if (is_single() && get_query_var('post_type')) {
        return $where;
    }
    if (is_tax()) {
        return $where;
    }
    $s = trim($s);
    $where = '';
    $better_search_terms = '';
    $better_search = array();
    if (!empty($s_SA)) {
        foreach ($s_SA as $s_term) {
            //$s_term = esc_attr($s_term);
            //$better_search[] = " OR $wpdb->posts.post_title LIKE\"%$s_term%\" ";
            $better_search[] = " OR ( {$wpdb->posts}.post_title LIKE \"{$s_term}\" OR {$wpdb->posts}.post_title LIKE \"{$s_term}%\" OR {$wpdb->posts}.post_title LIKE \"% {$s_term}%\" ) ";
        }
    }
    if (is_array($better_search)) {
        $better_search_terms = implode(' ', $better_search);
    }
    $better_search_terms = '';
    if (isset($_REQUEST['stype'])) {
        $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype']));
    } else {
        $post_types = 'gd_place';
    }
    if ($s != '') {
        $keywords = explode(" ", $s);
        if (is_array($keywords) && ($klimit = get_option('geodir_search_word_limit'))) {
            foreach ($keywords as $kkey => $kword) {
                if (mb_strlen($kword, 'UTF-8') <= $klimit) {
                    unset($keywords[$kkey]);
                }
            }
        }
        if (!empty($keywords)) {
            foreach ($keywords as $keyword) {
                $keyword = trim($keyword);
                if ($keyword != '') {
                    //$better_search_terms .= ' OR ' . $wpdb->posts . '.post_title LIKE "%' . $adv_search_val . '%"';
                    $better_search_terms .= ' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )';
                }
            }
        }
    }
    /* get taxonomy */
    $taxonomies = geodir_get_taxonomies($post_types, true);
    if ($taxonomies) {
        $taxonomies = implode("','", $taxonomies);
        $taxonomies = "'" . $taxonomies . "'";
    } else {
        $taxonomies = '';
    }
    $content_where = $terms_where = '';
    if ($s != '') {
        /**
         * Filter the search query content where values.
         *
         * @since 1.5.0
         * @package GeoDirectory
         * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\") "`.
         */
        $content_where = apply_filters("geodir_search_content_where", " OR ({$wpdb->posts}.post_content LIKE \"{$s}\" OR {$wpdb->posts}.post_content LIKE \"{$s}%\" OR {$wpdb->posts}.post_content LIKE \"% {$s}%\") ");
        /**
         * Filter the search query term values.
         *
         * @since 1.5.0
         * @package GeoDirectory
         * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`.
         */
        $terms_where = apply_filters("geodir_search_terms_where", " AND ({$wpdb->terms}.name LIKE \"{$s}\" OR {$wpdb->terms}.name LIKE \"{$s}%\" OR {$wpdb->terms}.name LIKE \"% {$s}%\" OR {$wpdb->terms}.name IN ({$s_A})) ");
    }
    if ($snear != '') {
        if (isset($_SESSION['near_me_range']) && is_numeric($_SESSION['near_me_range']) && !isset($_REQUEST['sdist'])) {
            $dist = $_SESSION['near_me_range'];
        }
        $lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69);
        $lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69);
        $lat1 = $mylat - $dist / 69;
        $lat2 = $mylat + $dist / 69;
        $rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : '';
        $rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : '';
        $rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : '';
        $rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : '';
        $where .= " AND ( ( {$wpdb->posts}.post_title LIKE \"{$s}\" {$better_search_terms})\n\t\t\t                    {$content_where} \n\t\t\t\t\t\t\t\tOR ({$wpdb->posts}.ID IN( \n\t\t\t\t\t\t\t\t\t\tSELECT {$wpdb->term_relationships}.object_id as post_id \n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->term_taxonomy},  {$wpdb->terms}, {$wpdb->term_relationships} \n\t\t\t\t\t\t\t\t\t\tWHERE {$wpdb->term_taxonomy}.term_id =  {$wpdb->terms}.term_id\n\t\t\t\t\t\t\t\t\t\tAND {$wpdb->term_relationships}.term_taxonomy_id =  {$wpdb->term_taxonomy}.term_taxonomy_id\n\t\t\t\t\t\t\t\t\t\tAND {$wpdb->term_taxonomy}.taxonomy in ({$taxonomies})\n\t\t\t\t\t\t\t\t\t\t{$terms_where} \n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t)\n\t\t\t\t\t\tAND {$wpdb->posts}.post_type in ('{$post_types}')\n\t\t\t\t\t\tAND ({$wpdb->posts}.post_status = 'publish')\n\t\t\t\t\t\tAND ( " . $table . ".post_latitude between {$rlat1} and {$rlat2} )\n\t\t\t\t\t\tAND ( " . $table . ".post_longitude between {$rlon1} and {$rlon2} ) ";
        if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
            $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
            $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS({$mylat}) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS({$mylat}) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(({$mylon} - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
        }
    } else {
        $where .= " AND (\t( {$wpdb->posts}.post_title LIKE \"{$s}\" {$better_search_terms})\n                            {$content_where}  \n\t\t\t\t\t\t\tOR ( {$wpdb->posts}.ID IN(\t\n\t\t\t\t\t\t\t\t\tSELECT {$wpdb->term_relationships}.object_id as post_id                     \n\t\t\t\t\t\t\t\t\tFROM {$wpdb->term_taxonomy},  {$wpdb->terms}, {$wpdb->term_relationships}\n\t\t\t\t\t\t\t\tWHERE {$wpdb->term_taxonomy}.term_id =  {$wpdb->terms}.term_id\n\t\t\t\t\t\t\t\tAND {$wpdb->term_relationships}.term_taxonomy_id =  {$wpdb->term_taxonomy}.term_taxonomy_id\n\t\t\t\t\t\t\t\tAND {$wpdb->term_taxonomy}.taxonomy in ( {$taxonomies} )\n\t\t\t\t\t\t\t\t{$terms_where} \n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) \n\t\t\t\t\t) \n\t\t\t\tAND {$wpdb->posts}.post_type in ('{$post_types}') \n\t\t\t\tAND ({$wpdb->posts}.post_status = 'publish') ";
    }
    ########### WPML ###########
    if (function_exists('icl_object_id')) {
        $lang_code = ICL_LANGUAGE_CODE;
        if ($lang_code && $post_types) {
            $where .= " AND icl_t.language_code = '" . $lang_code . "' AND icl_t.element_type IN('post_" . $post_types . "') ";
        }
    }
    ########### WPML ###########
    return $where;
}
コード例 #23
0
ファイル: cat_meta.php プロジェクト: bangjojo/wp
            $my_meta->addCheckbox($prefix.'cat_exclude_rating',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory')));
            $my_meta->addCheckbox($prefix.'cat_exclude_reviews',array('name'=> __('<b>Exclude</b> Reviews sort option','geodirectory')));
    
            // Include sort options
            $my_meta->addCheckbox($prefix.'cat_include_random',array('name'=> __('Include Random sort option','geodirectory')));
            $my_meta->addCheckbox($prefix.'cat_include_newest',array('name'=> __('Include Newest/Oldest sort option','geodirectory')));
            $my_meta->addCheckbox($prefix.'cat_include_az',array('name'=> __('Include Alphabetical sort option','geodirectory')));
    
            }*/
    //Finish Meta Box Decleration
    $my_meta->Finish();
}
##############################################################
############## LETS ADD CUSTOM COLUMN HERE ###################
##############################################################
$gd_taxonomies = geodir_get_taxonomies();
if (!empty($gd_taxonomies)) {
    foreach ($gd_taxonomies as $gd_taxonomy) {
        add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2);
        add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3);
    }
}
function addCat_column($columns)
{
    // only edit the columns on the current taxonomy
    /*if ( !isset($_GET['taxonomy']) && !in_array($_GET['taxonomy'],geodir_get_taxonomies()) )
      return $columns;
      */
    if ($posts = $columns['description']) {
        unset($columns['description']);
    }
コード例 #24
0
/**
 * Insert term count for a location.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 *
 * @param $location_name
 * @param string $location_type Location type. Possible values 'gd_city','gd_region','gd_country'.
 * @param string $count_type Count type. Possible values are 'review_count', 'term_count'.
 * @param null $row_id
 * @param array $loc {
 *    Attributes of the location array.
 *
 *    @type string $gd_country The country slug.
 *    @type string $gd_region The region slug.
 *    @type string $gd_city The city slug.
 *
 * }
 * @return array
 */
function geodir_insert_term_count_by_loc($location_name, $location_type, $count_type, $row_id = null, $loc)
{
    global $wpdb;
    $post_types = geodir_get_posttypes();
    $term_array = array();
    foreach ($post_types as $post_type) {
        $taxonomy = geodir_get_taxonomies($post_type);
        $taxonomy = $taxonomy[0];
        $args = array('hide_empty' => false, 'gd_no_loop' => true);
        $terms = get_terms($taxonomy, $args);
        foreach ($terms as $term) {
            $count = geodir_filter_listings_where_set_loc($term->term_id, $taxonomy, $post_type, $location_type, $loc, $count_type);
            $term_array[$term->term_id] = $count;
        }
    }
    $data = serialize($term_array);
    if ($row_id) {
        $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_TERM_META . " set\n                " . $count_type . " = %s WHERE id=" . $row_id . "", array($data)));
    } else {
        $wpdb->query($wpdb->prepare("INSERT into " . GEODIR_TERM_META . " set\n                location_type = %s,\n                location_name = %s,\n                " . $count_type . " = %s", array($location_type, $location_name, $data)));
    }
    return $term_array;
}