/** * Validate and parse the google map parameters. * * @since 1.0.0 * @since 1.5.2 Added TERRAIN map type. * * @param string $value Input value to validate measurement. * @return string The measurement valud in valid format. */ function gdsc_validate_map_args($params) { $params['width'] = gdsc_validate_measurements($params['width']); $params['height'] = gdsc_validate_measurements($params['height']); // Only accept our 4 maptypes. Otherwise, revert to the default. if (!in_array(strtoupper($params['maptype']), array('HYBRID', 'SATELLITE', 'ROADMAP', 'TERRAIN'))) { $params['maptype'] = 'ROADMAP'; } else { $params['maptype'] = strtoupper($params['maptype']); } // Zoom accepts a value between 1 and 19 $params['zoom'] = absint($params['zoom']); if (19 < $params['zoom']) { $params['zoom'] = '19'; } if (0 == $params['zoom']) { $params['zoom'] = '1'; } // Child_collapse must be boolean $params['child_collapse'] = gdsc_to_bool_val($params['child_collapse']); // Scrollwheel must be boolean $params['scrollwheel'] = gdsc_to_bool_val($params['scrollwheel']); // Scrollwheel must be boolean $params['autozoom'] = gdsc_to_bool_val($params['autozoom']); return $params; }
/** * 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; }
/** * The CPT categories widget shortcode. * * This implements the functionality of the CPT categories widget shortcode for displaying * all geodirectory categories. * * @since 1.5.5 * * @param array $atts { * Attributes of the shortcode. * * @type string $title The title of the widget displayed. * @type string $post_type Post type of listing. Default empty. * @type bool $hide_empty Hide empty categories? Default empty. * @type bool $show_count Show category count? Default empty. * @type bool $hide_icon Hide category icon? Default empty. * @type bool $cpt_left Show CPT on same line? Default empty. * @type string $sort_by Categories sort by. 'az' or 'count'. Default 'count'. * @type string|int $max_count Max no of sub-categories count. Default 'all'. * @type string|int $max_level Max level of sub-categories depth. Default 1. * @type string $before_widget HTML content to prepend to each widget's HTML output. * Default is an opening list item element. * @type string $after_widget HTML content to append to each widget's HTML output. * Default is a closing list item element. * @type string $before_title HTML content to prepend to the widget title when displayed. * Default is an opening h3 element. * @type string $after_title HTML content to append to the widget title when displayed. * Default is a closing h3 element. * } * @param string $content The enclosed content. Optional. * @return string HTML content to display CPT categories. */ function geodir_sc_cpt_categories_widget($atts, $content = '') { $defaults = array('title' => '', 'post_type' => '', 'hide_empty' => '', 'show_count' => '', 'hide_icon' => '', 'cpt_left' => '', 'sort_by' => 'count', 'max_count' => 'all', 'max_level' => '1', 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', 'after_widget' => '</section>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'); $params = shortcode_atts($defaults, $atts); /** * Validate our incoming params */ // Make sure we have an array $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); // Validate the checkboxes used on the widget $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); $params['show_count'] = gdsc_to_bool_val($params['show_count']); $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); if ($params['max_count'] != 'all') { $params['max_count'] = absint($params['max_count']); } if ($params['max_level'] != 'all') { $params['max_level'] = absint($params['max_level']); } $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; ob_start(); the_widget('geodir_cpt_categories_widget', $params, $params); $output = ob_get_contents(); ob_end_clean(); return $output; }