PluginProbe
WP Directory Kit / 1.3.1
WP Directory Kit v1.3.1
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / shortcodes / shortcode-latest-listings-list.php

shortcode-latest-listings-list.php in WP Directory Kit 1.3.1, at shortcodes/shortcode-latest-listings-list.php

89 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly.
5 }
6
7 /*
8 * Widget [wdk-latest-listings-list], show latest listings in list view
9 * atts list:
10 *
11 * custom_class (string) - custom css class
12 * order (string) - order by for results
13 * conf_query (string) - custom string query like field=xx&field_2=xxx
14 * limit (int) - limit listings, default 2
15 * only_is_featured (string), yes, if yes show only featured
16 * conf_custom_results (string) - like 1,2,3,4,5 where id is id of listing
17 *
18 * Layout path :
19 * get_template_directory().'/wpdirectorykit/shortcodes/views/shortcode-latest-listings-list.php'
20 * WPDIRECTORYKIT_PATH.'shortcodes/views/shortcode-latest-listings-list.php'
21 */
22
23 add_shortcode('wdk-latest-listings-list', 'shortcode_latest_listings_list');
24 function shortcode_latest_listings_list($atts, $content){
25 $atts = shortcode_atts(array(
26 'id'=>NULL,
27 'custom_class'=>'',
28 'order'=>'',
29 'conf_query'=>'',
30 'limit'=>'2',
31 'only_is_featured'=>'',
32 'conf_custom_results'=>'',
33 ), $atts);
34 $data = array();
35
36 /* settings from atts */
37 $data['settings'] = $atts;
38 $data['id_element'] = '';
39
40 $data['listings_count'] = 0;
41 $data['results'] = array();
42 $data['pagination_output'] = '';
43
44
45 /* load css/js */
46 wp_enqueue_style('wdk-listings-list');
47
48 $WMVC = &wdk_get_instance();
49 $WMVC->model('listingfield_m');
50 $WMVC->model('listing_m');
51 $WMVC->load_helper('listing');
52 $columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by','is_featured', 'address');
53 $external_columns = array('location_id', 'category_id', 'post_title');
54
55 if(!empty($data['settings']['conf_custom_results'])) {
56 /* where in */
57 if(!empty($listings_ids)){
58 $WMVC->db->where( $WMVC->db->prefix.'wdk_listings.post_id IN(' . $data['settings']['conf_custom_results'] . ')', null, false);
59 $data['results'] = $WMVC->listing_m->get();
60 }
61 } else {
62 $controller = 'listing';
63 $offset = NULL;
64 $original_GET = wmvc_xss_clean($_GET);
65 $_GET = array();
66
67 $_GET['order_by'] = $data['settings']['order'];
68
69 if(!empty($data['settings']['conf_query'])) {
70 $qr_string = trim($data['settings']['conf_query'],'?');
71 parse_str($qr_string, $_GET);
72 $_GET = array_map('trim', $_GET);
73 }
74 if($data['settings']['only_is_featured'] == 'yes') {
75 $_GET['is_featured'] = 'on';
76 }
77
78 wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns);
79 $data['results'] = $WMVC->listing_m->get_pagination($data['settings']['limit'], $offset, array('is_activated' => 1,'is_approved'=>1));
80
81 }
82
83 if(isset($original_GET))
84 $_GET = $original_GET;
85
86 return wdk_shortcodes_view('shortcode-latest-listings-list', $data);;
87 }
88
89 ?>