PluginProbe
Flexmls® IDX Plugin / 2.3
Flexmls® IDX Plugin v2.3
4.0.1 4.0.0 3.18.2 trunk 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 2.0 2.1 2.2 2.3 2.3.1 2.3.2 2.3.3 2.4 2.4.1 2.4.2 3.0.0 3.0.1 3.0.10 3.0.11 All 157 releases
flexmls-idx / components / widget.php

widget.php in Flexmls® IDX Plugin 2.3, at components/widget.php

121 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 class fmcWidget extends WP_Widget {
5
6 function shortcode_form() {
7 global $fmc_widgets;
8
9 $widget_info = $fmc_widgets[ get_class($this) ];
10
11 $settings_content = $this->settings_form( array('_instance_type' => 'shortcode') );
12 $settings_content = $settings_content;
13
14 $response = array(
15 'title' => $widget_info['title'] .' widget',
16 'body' => flexmlsConnect::shortcode_header() . $settings_content . flexmlsConnect::shortcode_footer()
17 );
18
19 $js = new Moxiecode_JSON();
20 echo str_replace("\'", "'", $js->encode($response));
21 exit;
22
23 }
24
25
26 function cache_jelly($args, $instance, $type) {
27 global $fmc_widgets;
28
29 $widget_info = $fmc_widgets[ get_class($this) ];
30
31 $cache_item_name = md5(get_class($this) .'_'. serialize($instance) . $type);
32 $cache = get_transient('fmc_cache_'. $cache_item_name);
33
34 if (!empty($cache) && flexmlsConnect::cache_turned_on() == true) {
35 $return = $cache;
36 }
37 else {
38 $return = $this->jelly($args, $instance, $type);
39 $cache_set_result = set_transient('fmc_cache_'. $cache_item_name, $return, $widget_info['max_cache_time']);
40
41 // update transient item which tracks cache items
42 $cache_tracker = get_transient('fmc_cache_tracker');
43 $cache_tracker[ $cache_item_name ] = true;
44 set_transient('fmc_cache_tracker', $cache_tracker, 60*60*24*7);
45 }
46
47 return $return;
48
49 }
50
51
52 function form($instance) {
53 echo $this->settings_form($instance);
54 }
55
56
57 function shortcode_generate() {
58 global $fmc_widgets;
59
60 $widget_info = $fmc_widgets[ get_class($this) ];
61
62 $shortcode = "[{$widget_info['shortcode']}";
63
64 foreach ($_REQUEST as $k => $v) {
65 if ($k == "action") {
66 continue;
67 }
68 if (!empty($v)) {
69 $v = htmlentities(stripslashes($v), ENT_QUOTES);
70 $shortcode .= " {$k}=\"{$v}\"";
71 }
72 }
73
74 $shortcode .= "]";
75
76 $response = array(
77 'body' => $shortcode
78 );
79
80 $js = new Moxiecode_JSON();
81 echo $js->encode($response);
82 exit;
83
84 }
85
86
87 function get_field_id($val) {
88 $widget = $this->is_called_for_widget();
89 if ($widget) {
90 return parent::get_field_id($val);
91 }
92 else {
93 return "fmc_shortcode_field_{$val}";
94 }
95 }
96
97
98 function get_field_name($val) {
99 $widget = $this->is_called_for_widget();
100 if ($widget) {
101 return parent::get_field_name($val);
102 }
103 else {
104 return $val;
105 }
106 }
107
108
109 function is_called_for_widget() {
110 // find out what context this was called from
111 $backtrace = debug_backtrace();
112 if ($backtrace[3]['function'] == "shortcode_form") {
113 return false;
114 }
115 else {
116 return true;
117 }
118 }
119
120 }
121