PluginProbe
WP Directory Kit / 1.3.4
WP Directory Kit v1.3.4
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-wdk-listing-field-value-prefix.php

shortcode-wdk-listing-field-value-prefix.php in WP Directory Kit 1.3.4, at shortcodes/shortcode-wdk-listing-field-value-prefix.php

68 lines 2.1 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-listing-field-value-prefix], show latest listings in list view
9 * atts list:
10 *
11 * field_id (int) - field id
12 * post_id (int) - post_id
13 *
14 * Layout path :
15 * get_template_directory().'/wpdirectorykit/shortcodes/views/shortcode-latest-listings-list.php'
16 * WPDIRECTORYKIT_PATH.'shortcodes/views/shortcode-latest-listings-list.php'
17 */
18
19 add_shortcode('wdk-listing-field-value-prefix', 'shortcode_wdk_listing_field_value_prefix');
20 function shortcode_wdk_listing_field_value_prefix($atts, $content){
21 $atts = shortcode_atts(array(
22 'id'=>NULL,
23 'field_id'=>'',
24 'post_id'=>'',
25 'enable_html'=>'',
26 ), $atts);
27 $data = array();
28
29 /* settings from atts */
30 $data['settings'] = $atts;
31 $data['id_element'] = '';
32
33 /* load css/js */
34
35 $WMVC = &wdk_get_instance();
36 $WMVC->model('listingfield_m');
37 $WMVC->model('listing_m');
38 $WMVC->load_helper('listing');
39 global $wdk_listing_id;
40 $post_id = $wdk_listing_id;
41 if (!empty($data['settings']['post_id'])) {
42 $post_id = $data['settings']['post_id'];
43 }
44
45 $data['field_value'] = '';
46 $data['field_prefix'] = '';
47 $data['field_suffix'] = '';
48 if(!empty($data['settings']['field_id'])){
49 if(strpos($data['settings']['field_id'],'__') !== FALSE){
50 $data['settings']['field_id'] = substr($data['settings']['field_id'], strpos($data['settings']['field_id'],'__')+2);
51 }
52
53 $data['field_prefix'] = wdk_field_option ($data['settings']['field_id'], 'prefix');
54 $data['field_suffix'] = wdk_field_option ($data['settings']['field_id'], 'suffix');
55 }
56
57 $data['is_edit_mode']= false;
58
59 /* return false if no content */
60 if(wdk_field_value($data['settings']['field_id'], $post_id) == '')
61 return false;
62
63 $data['field_prefix'] = apply_filters( 'wpdirectorykit/listing/field/prefix', $data['field_prefix'], $data['settings']['field_id']);
64
65 return wdk_shortcodes_view('shortcode-wdk-listing-field-value-prefix', $data);
66 }
67
68 ?>