@@ -69,7 +69,7 @@ |
||
69 | 69 | * @uses api_request() |
70 | 70 | * |
71 | 71 | * @param array $_transient_data Update array build by WordPress. |
72 | - * @return array Modified update array with custom plugin data. |
|
72 | + * @return stdClass Modified update array with custom plugin data. |
|
73 | 73 | */ |
74 | 74 | public function check_update( $_transient_data ) { |
75 | 75 |
@@ -15,23 +15,23 @@ discard block |
||
15 | 15 | * @version 1.6.3 |
16 | 16 | */ |
17 | 17 | class FrmEDD_SL_Plugin_Updater { |
18 | - private $api_url = ''; |
|
19 | - private $api_data = array(); |
|
20 | - private $name = ''; |
|
21 | - private $slug = ''; |
|
22 | - private $version = ''; |
|
23 | - |
|
24 | - /** |
|
25 | - * Class constructor. |
|
26 | - * |
|
27 | - * @uses plugin_basename() |
|
28 | - * @uses hook() |
|
29 | - * |
|
30 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
31 | - * @param string $_plugin_file Path to the plugin file. |
|
32 | - * @param array $_api_data Optional data to send with API calls. |
|
33 | - */ |
|
34 | - public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
18 | + private $api_url = ''; |
|
19 | + private $api_data = array(); |
|
20 | + private $name = ''; |
|
21 | + private $slug = ''; |
|
22 | + private $version = ''; |
|
23 | + |
|
24 | + /** |
|
25 | + * Class constructor. |
|
26 | + * |
|
27 | + * @uses plugin_basename() |
|
28 | + * @uses hook() |
|
29 | + * |
|
30 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
31 | + * @param string $_plugin_file Path to the plugin file. |
|
32 | + * @param array $_api_data Optional data to send with API calls. |
|
33 | + */ |
|
34 | + public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
35 | 35 | global $frm_edd_plugin_data; |
36 | 36 | |
37 | 37 | $this->api_url = trailingslashit( $_api_url ); |
@@ -44,159 +44,159 @@ discard block |
||
44 | 44 | |
45 | 45 | // Set up hooks. |
46 | 46 | $this->init(); |
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Set up WordPress filters to hook into WP's update process. |
|
51 | - * |
|
52 | - * @uses add_filter() |
|
53 | - * |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function init() { |
|
57 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
58 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Set up WordPress filters to hook into WP's update process. |
|
51 | + * |
|
52 | + * @uses add_filter() |
|
53 | + * |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function init() { |
|
57 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
58 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
59 | 59 | add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
64 | - * |
|
65 | - * This function dives into the update API just when WordPress creates its update array, |
|
66 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
67 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
68 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
69 | - * |
|
70 | - * @uses api_request() |
|
71 | - * |
|
72 | - * @param array $_transient_data Update array build by WordPress. |
|
73 | - * @return array Modified update array with custom plugin data. |
|
74 | - */ |
|
75 | - public function check_update( $_transient_data ) { |
|
76 | - |
|
77 | - global $pagenow; |
|
78 | - |
|
79 | - if ( ! is_object( $_transient_data ) ) { |
|
80 | - $_transient_data = new stdClass; |
|
81 | - } |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
64 | + * |
|
65 | + * This function dives into the update API just when WordPress creates its update array, |
|
66 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
67 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
68 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
69 | + * |
|
70 | + * @uses api_request() |
|
71 | + * |
|
72 | + * @param array $_transient_data Update array build by WordPress. |
|
73 | + * @return array Modified update array with custom plugin data. |
|
74 | + */ |
|
75 | + public function check_update( $_transient_data ) { |
|
76 | + |
|
77 | + global $pagenow; |
|
78 | + |
|
79 | + if ( ! is_object( $_transient_data ) ) { |
|
80 | + $_transient_data = new stdClass; |
|
81 | + } |
|
82 | 82 | |
83 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
83 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | 84 | |
85 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
85 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | 86 | |
87 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
87 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | 88 | |
89 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
89 | + if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
90 | 90 | |
91 | 91 | if ( empty( $version_info->plugin ) ) { |
92 | 92 | $version_info->plugin = $this->name; |
93 | 93 | } |
94 | 94 | |
95 | - $_transient_data->response[ $this->name ] = $version_info; |
|
96 | - |
|
97 | - } |
|
98 | - |
|
99 | - $_transient_data->last_checked = time(); |
|
100 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
101 | - |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - return $_transient_data; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Updates information on the "View version x.x details" page with custom data. |
|
110 | - * |
|
111 | - * @uses api_request() |
|
112 | - * |
|
113 | - * @param mixed $_data |
|
114 | - * @param string $_action |
|
115 | - * @param object $_args |
|
116 | - * @return object $_data |
|
117 | - */ |
|
118 | - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
119 | - |
|
120 | - if ( $_action != 'plugin_information' ) { |
|
95 | + $_transient_data->response[ $this->name ] = $version_info; |
|
121 | 96 | |
122 | - return $_data; |
|
97 | + } |
|
123 | 98 | |
124 | - } |
|
99 | + $_transient_data->last_checked = time(); |
|
100 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
125 | 101 | |
126 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
102 | + } |
|
103 | + } |
|
127 | 104 | |
128 | - return $_data; |
|
105 | + return $_transient_data; |
|
106 | + } |
|
129 | 107 | |
130 | - } |
|
108 | + /** |
|
109 | + * Updates information on the "View version x.x details" page with custom data. |
|
110 | + * |
|
111 | + * @uses api_request() |
|
112 | + * |
|
113 | + * @param mixed $_data |
|
114 | + * @param string $_action |
|
115 | + * @param object $_args |
|
116 | + * @return object $_data |
|
117 | + */ |
|
118 | + public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
131 | 119 | |
132 | - $to_send = array( |
|
133 | - 'slug' => $this->slug, |
|
134 | - 'is_ssl' => is_ssl(), |
|
135 | - 'fields' => array( |
|
136 | - 'banners' => false, // These will be supported soon hopefully |
|
137 | - 'reviews' => false, |
|
138 | - ), |
|
139 | - ); |
|
120 | + if ( $_action != 'plugin_information' ) { |
|
140 | 121 | |
141 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
122 | + return $_data; |
|
142 | 123 | |
143 | - if ( false !== $api_response ) { |
|
144 | - $_data = $api_response; |
|
145 | - } |
|
124 | + } |
|
146 | 125 | |
147 | - return $_data; |
|
148 | - } |
|
126 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
149 | 127 | |
128 | + return $_data; |
|
150 | 129 | |
151 | - /** |
|
152 | - * Disable SSL verification in order to prevent download update failures |
|
153 | - * |
|
154 | - * @param array $args |
|
155 | - * @param string $url |
|
156 | - * @return object $array |
|
157 | - */ |
|
158 | - public function http_request_args( $args, $url ) { |
|
159 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
160 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
161 | - $args['sslverify'] = false; |
|
162 | - } |
|
163 | - return $args; |
|
164 | - } |
|
130 | + } |
|
165 | 131 | |
166 | - /** |
|
167 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
168 | - * |
|
169 | - * @uses get_bloginfo() |
|
170 | - * @uses wp_remote_post() |
|
171 | - * @uses is_wp_error() |
|
172 | - * |
|
173 | - * @param string $_action The requested action. |
|
174 | - * @param array $_data Parameters for the API action. |
|
175 | - * @return false|object |
|
176 | - */ |
|
177 | - private function api_request( $_action, $_data ) { |
|
132 | + $to_send = array( |
|
133 | + 'slug' => $this->slug, |
|
134 | + 'is_ssl' => is_ssl(), |
|
135 | + 'fields' => array( |
|
136 | + 'banners' => false, // These will be supported soon hopefully |
|
137 | + 'reviews' => false, |
|
138 | + ), |
|
139 | + ); |
|
178 | 140 | |
179 | - global $wp_version; |
|
141 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
180 | 142 | |
181 | - $data = array_merge( $this->api_data, $_data ); |
|
143 | + if ( false !== $api_response ) { |
|
144 | + $_data = $api_response; |
|
145 | + } |
|
182 | 146 | |
183 | - if ( $data['slug'] != $this->slug ) { |
|
184 | - return; |
|
147 | + return $_data; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Disable SSL verification in order to prevent download update failures |
|
153 | + * |
|
154 | + * @param array $args |
|
155 | + * @param string $url |
|
156 | + * @return object $array |
|
157 | + */ |
|
158 | + public function http_request_args( $args, $url ) { |
|
159 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
160 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
161 | + $args['sslverify'] = false; |
|
162 | + } |
|
163 | + return $args; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
168 | + * |
|
169 | + * @uses get_bloginfo() |
|
170 | + * @uses wp_remote_post() |
|
171 | + * @uses is_wp_error() |
|
172 | + * |
|
173 | + * @param string $_action The requested action. |
|
174 | + * @param array $_data Parameters for the API action. |
|
175 | + * @return false|object |
|
176 | + */ |
|
177 | + private function api_request( $_action, $_data ) { |
|
178 | + |
|
179 | + global $wp_version; |
|
180 | + |
|
181 | + $data = array_merge( $this->api_data, $_data ); |
|
182 | + |
|
183 | + if ( $data['slug'] != $this->slug ) { |
|
184 | + return; |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( $this->api_url == home_url() ) { |
|
188 | - return false; // Don't allow a plugin to ping itself |
|
189 | - } |
|
187 | + if ( $this->api_url == home_url() ) { |
|
188 | + return false; // Don't allow a plugin to ping itself |
|
189 | + } |
|
190 | 190 | |
191 | - $api_params = array( |
|
192 | - 'edd_action' => 'get_version', |
|
193 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
194 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
195 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
196 | - 'slug' => $data['slug'], |
|
197 | - 'author' => $data['author'], |
|
198 | - 'url' => home_url(), |
|
199 | - ); |
|
191 | + $api_params = array( |
|
192 | + 'edd_action' => 'get_version', |
|
193 | + 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
194 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
195 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
196 | + 'slug' => $data['slug'], |
|
197 | + 'author' => $data['author'], |
|
198 | + 'url' => home_url(), |
|
199 | + ); |
|
200 | 200 | |
201 | 201 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $api_params['license'] . $this->version ) . '_' . $api_params['edd_action'] ); |
202 | 202 | $cached_response = get_transient( $cache_key ); |
@@ -205,24 +205,24 @@ discard block |
||
205 | 205 | return $cached_response; |
206 | 206 | } |
207 | 207 | |
208 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
208 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
209 | 209 | |
210 | - if ( ! is_wp_error( $request ) ) { |
|
211 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
212 | - } |
|
210 | + if ( ! is_wp_error( $request ) ) { |
|
211 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
212 | + } |
|
213 | 213 | |
214 | - if ( $request && isset( $request->sections ) ) { |
|
215 | - $request->sections = maybe_unserialize( $request->sections ); |
|
214 | + if ( $request && isset( $request->sections ) ) { |
|
215 | + $request->sections = maybe_unserialize( $request->sections ); |
|
216 | 216 | set_transient( $cache_key, $request, DAY_IN_SECONDS ); |
217 | - } else { |
|
218 | - $request = false; |
|
217 | + } else { |
|
218 | + $request = false; |
|
219 | 219 | set_transient( $cache_key, 0, DAY_IN_SECONDS ); |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - return $request; |
|
223 | - } |
|
222 | + return $request; |
|
223 | + } |
|
224 | 224 | |
225 | - public function show_changelog() { |
|
225 | + public function show_changelog() { |
|
226 | 226 | |
227 | 227 | global $frm_edd_plugin_data; |
228 | 228 | |
@@ -278,5 +278,5 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | exit; |
281 | - } |
|
281 | + } |
|
282 | 282 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->slug = basename( $_plugin_file, '.php' ); |
41 | 41 | $this->version = $_api_data['version']; |
42 | 42 | |
43 | - $frm_edd_plugin_data[ $this->slug ] = $this->api_data; |
|
43 | + $frm_edd_plugin_data[$this->slug] = $this->api_data; |
|
44 | 44 | |
45 | 45 | // Set up hooks. |
46 | 46 | $this->init(); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $_transient_data = new stdClass; |
81 | 81 | } |
82 | 82 | |
83 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
83 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[$this->name] ) ) { |
|
84 | 84 | |
85 | 85 | $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
86 | 86 | |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | $version_info->plugin = $this->name; |
93 | 93 | } |
94 | 94 | |
95 | - $_transient_data->response[ $this->name ] = $version_info; |
|
95 | + $_transient_data->response[$this->name] = $version_info; |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | 99 | $_transient_data->last_checked = time(); |
100 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
100 | + $_transient_data->checked[$this->name] = $this->version; |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | wp_die( __( 'You do not have permission to install plugin updates', 'formidable' ), __( 'Error', 'formidable' ), array( 'response' => 403 ) ); |
243 | 243 | } |
244 | 244 | |
245 | - $data = $frm_edd_plugin_data[ $_REQUEST['slug'] ]; |
|
245 | + $data = $frm_edd_plugin_data[$_REQUEST['slug']]; |
|
246 | 246 | $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' ); |
247 | 247 | $version_info = get_transient( $cache_key ); |
248 | 248 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | } |
275 | 275 | |
276 | - if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { |
|
276 | + if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { |
|
277 | 277 | echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>'; |
278 | 278 | } |
279 | 279 |
@@ -17,6 +17,6 @@ |
||
17 | 17 | </ul> |
18 | 18 | |
19 | 19 | <?php if ( $form && $title == 'show' ) { ?> |
20 | - <input id="title" type="text" value="<?php echo esc_attr( $form->name == '' ? __( '(no title)') : $form->name ) ?>" readonly="readonly" disabled="disabled" /> |
|
20 | + <input id="title" type="text" value="<?php echo esc_attr( $form->name == '' ? __( '(no title)' ) : $form->name ) ?>" readonly="readonly" disabled="disabled" /> |
|
21 | 21 | <?php } ?> |
22 | 22 | </div> |
@@ -7,16 +7,16 @@ |
||
7 | 7 | continue; |
8 | 8 | } |
9 | 9 | |
10 | - if ( isset( $plugin_names[ $addon['info']['slug'] ] ) ) { |
|
11 | - $installed = is_dir( WP_PLUGIN_DIR . '/' . $plugin_names[ $addon['info']['slug'] ] ); |
|
10 | + if ( isset( $plugin_names[$addon['info']['slug']] ) ) { |
|
11 | + $installed = is_dir( WP_PLUGIN_DIR . '/' . $plugin_names[$addon['info']['slug']] ); |
|
12 | 12 | } else { |
13 | - $installed = isset( $installed_addons[ $addon['info']['slug'] ] ) || is_dir( WP_PLUGIN_DIR . '/formidable-' . $addon['info']['slug'] ); |
|
13 | + $installed = isset( $installed_addons[$addon['info']['slug']] ) || is_dir( WP_PLUGIN_DIR . '/formidable-' . $addon['info']['slug'] ); |
|
14 | 14 | } |
15 | 15 | $has_thumbnail = ! empty( $addon['info']['thumbnail'] ); |
16 | 16 | $addon['info']['link'] = $addon['info']['link'] . $append_affiliate; |
17 | 17 | |
18 | 18 | ?> |
19 | - <div class="plugin-card <?php echo esc_attr( $has_thumbnail ? '' : 'frm-no-thumb') ?>"> |
|
19 | + <div class="plugin-card <?php echo esc_attr( $has_thumbnail ? '' : 'frm-no-thumb' ) ?>"> |
|
20 | 20 | <div class="plugin-card-top"> |
21 | 21 | <div class="name column-name"> |
22 | 22 | <h3> |
@@ -3,7 +3,7 @@ |
||
3 | 3 | class FrmAddonsController { |
4 | 4 | |
5 | 5 | public static function menu() { |
6 | - add_submenu_page( 'formidable', 'Formidable | '. __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' ); |
|
6 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' ); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | public static function list_addons() { |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | class FrmAppController { |
4 | 4 | |
5 | 5 | public static function menu() { |
6 | - FrmAppHelper::maybe_add_permissions(); |
|
7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
8 | - return; |
|
9 | - } |
|
6 | + FrmAppHelper::maybe_add_permissions(); |
|
7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
8 | + return; |
|
9 | + } |
|
10 | 10 | |
11 | - $frm_settings = FrmAppHelper::get_settings(); |
|
12 | - add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
|
13 | - } |
|
11 | + $frm_settings = FrmAppHelper::get_settings(); |
|
12 | + add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
|
13 | + } |
|
14 | 14 | |
15 | 15 | private static function get_menu_position() { |
16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,39 +19,39 @@ discard block |
||
19 | 19 | return $pos; |
20 | 20 | } |
21 | 21 | |
22 | - public static function load_wp_admin_style() { |
|
23 | - FrmAppHelper::load_font_style(); |
|
24 | - } |
|
22 | + public static function load_wp_admin_style() { |
|
23 | + FrmAppHelper::load_font_style(); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
27 | - global $pagenow, $frm_vars; |
|
27 | + global $pagenow, $frm_vars; |
|
28 | 28 | |
29 | 29 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
30 | - if ( empty( $show_nav ) ) { |
|
31 | - return; |
|
32 | - } |
|
30 | + if ( empty( $show_nav ) ) { |
|
31 | + return; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | $current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); |
35 | 35 | if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) { |
36 | 36 | $current_page = 'frm_display'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $form ) { |
|
39 | + if ( $form ) { |
|
40 | 40 | FrmForm::maybe_get_form( $form ); |
41 | 41 | |
42 | - if ( is_object( $form ) ) { |
|
43 | - $id = $form->id; |
|
44 | - } |
|
45 | - } |
|
42 | + if ( is_object( $form ) ) { |
|
43 | + $id = $form->id; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - if ( ! isset( $id ) ) { |
|
48 | - $form = $id = false; |
|
49 | - } |
|
47 | + if ( ! isset( $id ) ) { |
|
48 | + $form = $id = false; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | $nav_items = self::get_form_nav_items( $id ); |
52 | 52 | |
53 | - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
54 | - } |
|
53 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | private static function get_form_nav_items( $id ) { |
57 | 57 | $nav_items = array( |
@@ -82,26 +82,26 @@ discard block |
||
82 | 82 | return $nav_items; |
83 | 83 | } |
84 | 84 | |
85 | - // Adds a settings link to the plugins page |
|
86 | - public static function settings_link( $links ) { |
|
85 | + // Adds a settings link to the plugins page |
|
86 | + public static function settings_link( $links ) { |
|
87 | 87 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
88 | - array_unshift( $links, $settings ); |
|
88 | + array_unshift( $links, $settings ); |
|
89 | 89 | |
90 | - return $links; |
|
91 | - } |
|
90 | + return $links; |
|
91 | + } |
|
92 | 92 | |
93 | - public static function pro_get_started_headline() { |
|
94 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
95 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
96 | - return; |
|
97 | - } |
|
93 | + public static function pro_get_started_headline() { |
|
94 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
95 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
96 | + return; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
100 | - FrmAppHelper::load_admin_wide_js(); |
|
100 | + FrmAppHelper::load_admin_wide_js(); |
|
101 | 101 | |
102 | - // user is authorized, but running free version |
|
103 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
104 | - ?> |
|
102 | + // user is authorized, but running free version |
|
103 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
104 | + ?> |
|
105 | 105 | <div class="error" class="frm_previous_install"> |
106 | 106 | <?php |
107 | 107 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | ) ); ?> |
114 | 114 | </div> |
115 | 115 | <?php |
116 | - } |
|
117 | - } |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * If there are CURL problems on this server, wp_remote_post won't work for installing |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - public static function admin_js() { |
|
159 | + public static function admin_js() { |
|
160 | 160 | $version = FrmAppHelper::plugin_version(); |
161 | 161 | FrmAppHelper::load_admin_wide_js( false ); |
162 | 162 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
168 | 168 | ), $version, true ); |
169 | 169 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
170 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
170 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
171 | 171 | |
172 | 172 | // load multselect js |
173 | 173 | wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true ); |
@@ -178,78 +178,78 @@ discard block |
||
178 | 178 | global $pagenow; |
179 | 179 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
180 | 180 | |
181 | - wp_enqueue_script( 'admin-widgets' ); |
|
182 | - wp_enqueue_style( 'widgets' ); |
|
183 | - wp_enqueue_script( 'formidable' ); |
|
184 | - wp_enqueue_script( 'formidable_admin' ); |
|
181 | + wp_enqueue_script( 'admin-widgets' ); |
|
182 | + wp_enqueue_style( 'widgets' ); |
|
183 | + wp_enqueue_script( 'formidable' ); |
|
184 | + wp_enqueue_script( 'formidable_admin' ); |
|
185 | 185 | FrmAppHelper::localize_script( 'admin' ); |
186 | 186 | |
187 | - wp_enqueue_style( 'formidable-admin' ); |
|
188 | - add_thickbox(); |
|
187 | + wp_enqueue_style( 'formidable-admin' ); |
|
188 | + add_thickbox(); |
|
189 | 189 | |
190 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
190 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
191 | 191 | |
192 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
193 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
194 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
192 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
193 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
194 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
195 | 195 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
196 | 196 | $post = get_post( absint( $_REQUEST['post'] ) ); |
197 | - if ( ! $post ) { |
|
198 | - return; |
|
199 | - } |
|
200 | - $post_type = $post->post_type; |
|
201 | - } else { |
|
202 | - return; |
|
203 | - } |
|
204 | - |
|
205 | - if ( $post_type == 'frm_display' ) { |
|
206 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
207 | - wp_enqueue_script( 'formidable_admin' ); |
|
208 | - wp_enqueue_style( 'formidable-admin' ); |
|
197 | + if ( ! $post ) { |
|
198 | + return; |
|
199 | + } |
|
200 | + $post_type = $post->post_type; |
|
201 | + } else { |
|
202 | + return; |
|
203 | + } |
|
204 | + |
|
205 | + if ( $post_type == 'frm_display' ) { |
|
206 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
207 | + wp_enqueue_script( 'formidable_admin' ); |
|
208 | + wp_enqueue_style( 'formidable-admin' ); |
|
209 | 209 | FrmAppHelper::localize_script( 'admin' ); |
210 | - } |
|
211 | - } else if ( $pagenow == 'widgets.php' ) { |
|
212 | - FrmAppHelper::load_admin_wide_js(); |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - public static function wp_admin_body_class( $classes ) { |
|
217 | - global $wp_version; |
|
218 | - //we need this class everywhere in the admin for the menu |
|
219 | - if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
220 | - $classes .= ' frm_38_trigger'; |
|
221 | - } |
|
222 | - |
|
223 | - return $classes; |
|
224 | - } |
|
225 | - |
|
226 | - public static function load_lang() { |
|
227 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Filter shortcodes in text widgets |
|
232 | - */ |
|
233 | - public static function widget_text_filter( $content ) { |
|
234 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
235 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
236 | - } |
|
237 | - |
|
238 | - public static function widget_text_filter_callback( $matches ) { |
|
239 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
240 | - return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
241 | - } |
|
242 | - |
|
243 | - public static function front_head() { |
|
244 | - if ( is_multisite() ) { |
|
245 | - $old_db_version = get_option( 'frm_db_version' ); |
|
246 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
247 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
248 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
249 | - self::install( $old_db_version ); |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
210 | + } |
|
211 | + } else if ( $pagenow == 'widgets.php' ) { |
|
212 | + FrmAppHelper::load_admin_wide_js(); |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + public static function wp_admin_body_class( $classes ) { |
|
217 | + global $wp_version; |
|
218 | + //we need this class everywhere in the admin for the menu |
|
219 | + if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
220 | + $classes .= ' frm_38_trigger'; |
|
221 | + } |
|
222 | + |
|
223 | + return $classes; |
|
224 | + } |
|
225 | + |
|
226 | + public static function load_lang() { |
|
227 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Filter shortcodes in text widgets |
|
232 | + */ |
|
233 | + public static function widget_text_filter( $content ) { |
|
234 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
235 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
236 | + } |
|
237 | + |
|
238 | + public static function widget_text_filter_callback( $matches ) { |
|
239 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
240 | + return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
241 | + } |
|
242 | + |
|
243 | + public static function front_head() { |
|
244 | + if ( is_multisite() ) { |
|
245 | + $old_db_version = get_option( 'frm_db_version' ); |
|
246 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
247 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
248 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
249 | + self::install( $old_db_version ); |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | 253 | |
254 | 254 | public static function localize_script( $location ) { |
255 | 255 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -309,72 +309,72 @@ discard block |
||
309 | 309 | wp_die(); |
310 | 310 | } |
311 | 311 | |
312 | - public static function activation_install() { |
|
313 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
314 | - FrmFormActionsController::actions_init(); |
|
315 | - self::install(); |
|
316 | - } |
|
312 | + public static function activation_install() { |
|
313 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
314 | + FrmFormActionsController::actions_init(); |
|
315 | + self::install(); |
|
316 | + } |
|
317 | 317 | |
318 | - public static function install( $old_db_version = false ) { |
|
319 | - $frmdb = new FrmDb(); |
|
320 | - $frmdb->upgrade( $old_db_version ); |
|
321 | - } |
|
318 | + public static function install( $old_db_version = false ) { |
|
319 | + $frmdb = new FrmDb(); |
|
320 | + $frmdb->upgrade( $old_db_version ); |
|
321 | + } |
|
322 | 322 | |
323 | - public static function uninstall() { |
|
324 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
323 | + public static function uninstall() { |
|
324 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
325 | 325 | |
326 | - if ( current_user_can( 'administrator' ) ) { |
|
327 | - $frmdb = new FrmDb(); |
|
328 | - $frmdb->uninstall(); |
|
326 | + if ( current_user_can( 'administrator' ) ) { |
|
327 | + $frmdb = new FrmDb(); |
|
328 | + $frmdb->uninstall(); |
|
329 | 329 | |
330 | 330 | //disable the plugin and redirect after uninstall so the tables don't get added right back |
331 | 331 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
332 | 332 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
333 | - } else { |
|
334 | - $frm_settings = FrmAppHelper::get_settings(); |
|
335 | - wp_die( $frm_settings->admin_permission ); |
|
336 | - } |
|
337 | - wp_die(); |
|
338 | - } |
|
339 | - |
|
340 | - public static function drop_tables( $tables ) { |
|
341 | - global $wpdb; |
|
342 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
343 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
344 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
345 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
346 | - return $tables; |
|
347 | - } |
|
348 | - |
|
349 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
350 | - public static function page_route( $content ) { |
|
351 | - global $post; |
|
352 | - |
|
353 | - $frm_settings = FrmAppHelper::get_settings(); |
|
354 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
355 | - $content = FrmFormsController::page_preview(); |
|
356 | - } |
|
357 | - |
|
358 | - return $content; |
|
359 | - } |
|
360 | - |
|
361 | - public static function deauthorize() { |
|
362 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
363 | - |
|
364 | - delete_option( 'frmpro-credentials' ); |
|
365 | - delete_option( 'frmpro-authorized' ); |
|
366 | - delete_site_option( 'frmpro-credentials' ); |
|
367 | - delete_site_option( 'frmpro-authorized' ); |
|
368 | - wp_die(); |
|
369 | - } |
|
370 | - |
|
371 | - public static function get_form_shortcode( $atts ) { |
|
372 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
373 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
374 | - } |
|
375 | - |
|
376 | - public static function get_postbox_class() { |
|
377 | - _deprecated_function( __FUNCTION__, '2.0' ); |
|
378 | - return 'postbox-container'; |
|
379 | - } |
|
333 | + } else { |
|
334 | + $frm_settings = FrmAppHelper::get_settings(); |
|
335 | + wp_die( $frm_settings->admin_permission ); |
|
336 | + } |
|
337 | + wp_die(); |
|
338 | + } |
|
339 | + |
|
340 | + public static function drop_tables( $tables ) { |
|
341 | + global $wpdb; |
|
342 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
343 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
344 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
345 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
346 | + return $tables; |
|
347 | + } |
|
348 | + |
|
349 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
350 | + public static function page_route( $content ) { |
|
351 | + global $post; |
|
352 | + |
|
353 | + $frm_settings = FrmAppHelper::get_settings(); |
|
354 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
355 | + $content = FrmFormsController::page_preview(); |
|
356 | + } |
|
357 | + |
|
358 | + return $content; |
|
359 | + } |
|
360 | + |
|
361 | + public static function deauthorize() { |
|
362 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
363 | + |
|
364 | + delete_option( 'frmpro-credentials' ); |
|
365 | + delete_option( 'frmpro-authorized' ); |
|
366 | + delete_site_option( 'frmpro-credentials' ); |
|
367 | + delete_site_option( 'frmpro-authorized' ); |
|
368 | + wp_die(); |
|
369 | + } |
|
370 | + |
|
371 | + public static function get_form_shortcode( $atts ) { |
|
372 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
373 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
374 | + } |
|
375 | + |
|
376 | + public static function get_postbox_class() { |
|
377 | + _deprecated_function( __FUNCTION__, '2.0' ); |
|
378 | + return 'postbox-container'; |
|
379 | + } |
|
380 | 380 | } |
@@ -42,51 +42,51 @@ discard block |
||
42 | 42 | |
43 | 43 | if ( $f->type == 'data' ) { |
44 | 44 | //get all fields from linked form |
45 | - if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
46 | - $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
47 | - if ( ! in_array( $linked_form, $linked_forms ) ) { |
|
48 | - $linked_forms[] = $linked_form; |
|
45 | + if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
46 | + $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
47 | + if ( ! in_array( $linked_form, $linked_forms ) ) { |
|
48 | + $linked_forms[] = $linked_form; |
|
49 | 49 | $linked_fields = FrmField::getAll( array( 'fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form ) ); |
50 | - $ldfe = ''; |
|
50 | + $ldfe = ''; |
|
51 | 51 | if ( $linked_fields ) { |
52 | 52 | foreach ( $linked_fields as $linked_field ) { |
53 | - FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
|
54 | - |
|
55 | - $ldfe = $linked_field->id; |
|
56 | - unset($linked_field); |
|
57 | - } |
|
58 | - } |
|
59 | - } |
|
60 | - } |
|
61 | - $dfe = $f->id; |
|
62 | - } |
|
63 | - unset($f); |
|
64 | - } |
|
65 | - } ?> |
|
53 | + FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
|
54 | + |
|
55 | + $ldfe = $linked_field->id; |
|
56 | + unset($linked_field); |
|
57 | + } |
|
58 | + } |
|
59 | + } |
|
60 | + } |
|
61 | + $dfe = $f->id; |
|
62 | + } |
|
63 | + unset($f); |
|
64 | + } |
|
65 | + } ?> |
|
66 | 66 | </ul> |
67 | 67 | |
68 | 68 | <?php _e( 'Helpers', 'formidable' ) ?>: |
69 | 69 | <ul class="frm_code_list"> |
70 | 70 | <?php |
71 | - $col = 'one'; |
|
71 | + $col = 'one'; |
|
72 | 72 | foreach ( $entry_shortcodes as $skey => $sname ) { |
73 | 73 | if ( empty( $skey ) ) { |
74 | - $col = 'one'; |
|
75 | - echo '<li class="clear frm_block"></li>'; |
|
76 | - continue; |
|
77 | - } |
|
78 | - ?> |
|
74 | + $col = 'one'; |
|
75 | + echo '<li class="clear frm_block"></li>'; |
|
76 | + continue; |
|
77 | + } |
|
78 | + ?> |
|
79 | 79 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
80 | 80 | <a href="javascript:void(0)" class="frmbutton button <?php |
81 | 81 | echo ( in_array( $skey, array( 'siteurl', 'sitename', 'entry_count' ) ) ) ? 'show_before_content show_after_content' : ''; |
82 | - echo ( strpos( $skey, 'default-' ) === 0 ) ? 'hide_frm_not_email_subject' : ''; |
|
83 | - ?> frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ) ?></a> |
|
82 | + echo ( strpos( $skey, 'default-' ) === 0 ) ? 'hide_frm_not_email_subject' : ''; |
|
83 | + ?> frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ) ?></a> |
|
84 | 84 | </li> |
85 | 85 | <?php |
86 | - $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
87 | - unset($skey, $sname); |
|
88 | - } |
|
89 | - ?> |
|
86 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
87 | + unset($skey, $sname); |
|
88 | + } |
|
89 | + ?> |
|
90 | 90 | </ul> |
91 | 91 | </div> |
92 | 92 | |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | <ul class="alignleft"><li><?php _e( 'Fields from your form', 'formidable' ) ?>:</li></ul> |
100 | 100 | <ul class="frm_code_list frm_full_width"> |
101 | 101 | <?php if ( ! empty( $fields ) ) { |
102 | - foreach ( $fields as $f ) { |
|
102 | + foreach ( $fields as $f ) { |
|
103 | 103 | if ( FrmField::is_no_save_field( $f->type ) || ( $f->type == 'data' && ( ! isset( $f->field_options['data_type'] ) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '' ) ) ) { |
104 | - continue; |
|
105 | - } |
|
106 | - ?> |
|
104 | + continue; |
|
105 | + } |
|
106 | + ?> |
|
107 | 107 | <li> |
108 | 108 | <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a> |
109 | 109 | <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a> |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | </li> |
112 | 112 | <?php |
113 | 113 | |
114 | - if ( $f->type == 'user_id' ) { |
|
115 | - $uid = $f; |
|
116 | - } else if ( $f->type == 'file' ) { |
|
117 | - $file = $f; |
|
118 | - } |
|
119 | - unset($f); |
|
120 | - } |
|
121 | - } ?> |
|
114 | + if ( $f->type == 'user_id' ) { |
|
115 | + $uid = $f; |
|
116 | + } else if ( $f->type == 'file' ) { |
|
117 | + $file = $f; |
|
118 | + } |
|
119 | + unset($f); |
|
120 | + } |
|
121 | + } ?> |
|
122 | 122 | </ul> |
123 | 123 | |
124 | 124 | <p class="howto"><?php _e( 'Click a button below to insert sample logic into your view', 'formidable' ) ?></p> |
125 | 125 | <ul class="frm_code_list"> |
126 | 126 | <?php |
127 | - $col = 'one'; |
|
127 | + $col = 'one'; |
|
128 | 128 | foreach ( $cond_shortcodes as $skey => $sname ) { |
129 | - ?> |
|
129 | + ?> |
|
130 | 130 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
131 | 131 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if 125 <?php echo esc_attr($skey) ?>][/if 125"><?php echo esc_html( $sname ) ?></a> |
132 | 132 | </li> |
133 | 133 | <?php |
134 | - $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
135 | - unset($skey, $sname); |
|
136 | - } |
|
137 | - ?> |
|
134 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
135 | + unset($skey, $sname); |
|
136 | + } |
|
137 | + ?> |
|
138 | 138 | </ul> |
139 | 139 | </div> |
140 | 140 | <?php } ?> |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | <div id="frm-adv-info-tab" class="tabs-panel"> |
143 | 143 | <ul class="frm_code_list"> |
144 | 144 | <?php |
145 | - $col = 'one'; |
|
145 | + $col = 'one'; |
|
146 | 146 | foreach ( $adv_shortcodes as $skey => $sname ) { |
147 | - ?> |
|
147 | + ?> |
|
148 | 148 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
149 | 149 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="'. esc_attr( $sname['title'] ) .'"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
150 | 150 | </li> |
151 | 151 | <?php |
152 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
153 | - unset($skey, $sname); |
|
154 | - } |
|
155 | - ?> |
|
152 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
153 | + unset($skey, $sname); |
|
154 | + } |
|
155 | + ?> |
|
156 | 156 | <?php if ( isset($file) ) { ?> |
157 | 157 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
158 | 158 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | <div class="clear"></div> |
170 | 170 | <?php |
171 | 171 | |
172 | - if ( isset($uid) && ! empty($user_fields) ) { |
|
173 | - $col = 'one'; ?> |
|
172 | + if ( isset($uid) && ! empty($user_fields) ) { |
|
173 | + $col = 'one'; ?> |
|
174 | 174 | <p class="howto"><?php _e( 'Insert user information', 'formidable' ) ?></p> |
175 | 175 | <ul class="frm_code_list"> |
176 | 176 | <?php foreach ( $user_fields as $uk => $uf ) { ?> |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $uid->id . ' show="' . $uk . '"' ) ?>"><?php echo esc_html( $uf ) ?></a> |
179 | 179 | </li> |
180 | 180 | <?php |
181 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
182 | - unset($uf, $uk); |
|
183 | - } |
|
184 | - unset($uid); ?> |
|
181 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
182 | + unset($uf, $uk); |
|
183 | + } |
|
184 | + unset($uid); ?> |
|
185 | 185 | </ul> |
186 | 186 | <?php } |
187 | 187 | |
188 | - if ( isset($repeat_field) ) { ?> |
|
188 | + if ( isset($repeat_field) ) { ?> |
|
189 | 189 | <div class="clear"></div> |
190 | 190 | <p class="howto"><?php _e( 'Repeating field options', 'formidable' ) ?></p> |
191 | 191 | <ul class="frm_code_list"> |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | </li> |
195 | 195 | </ul> |
196 | 196 | <?php |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - if ( isset($dfe) ) { ?> |
|
199 | + if ( isset($dfe) ) { ?> |
|
200 | 200 | |
201 | 201 | <div class="clear"></div> |
202 | 202 | <p class="howto"><?php _e( 'Dynamic field options', 'formidable' ) ?></p> |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | </div> |
216 | 216 | |
217 | 217 | <?php |
218 | - if ( $settings_tab ) { |
|
219 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
220 | - } |
|
221 | - ?> |
|
218 | + if ( $settings_tab ) { |
|
219 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
220 | + } |
|
221 | + ?> |
|
222 | 222 | </div> |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | |
43 | 43 | if ( $f->type == 'data' ) { |
44 | 44 | //get all fields from linked form |
45 | - if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
46 | - $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
45 | + if ( isset( $f->field_options['form_select'] ) && is_numeric( $f->field_options['form_select'] ) ) { |
|
46 | + $linked_form = FrmDb::get_var( $wpdb->prefix . 'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
47 | 47 | if ( ! in_array( $linked_form, $linked_forms ) ) { |
48 | 48 | $linked_forms[] = $linked_form; |
49 | 49 | $linked_fields = FrmField::getAll( array( 'fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form ) ); |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
54 | 54 | |
55 | 55 | $ldfe = $linked_field->id; |
56 | - unset($linked_field); |
|
56 | + unset( $linked_field ); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | $dfe = $f->id; |
62 | 62 | } |
63 | - unset($f); |
|
63 | + unset( $f ); |
|
64 | 64 | } |
65 | 65 | } ?> |
66 | 66 | </ul> |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | </li> |
85 | 85 | <?php |
86 | 86 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
87 | - unset($skey, $sname); |
|
87 | + unset( $skey, $sname ); |
|
88 | 88 | } |
89 | 89 | ?> |
90 | 90 | </ul> |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | ?> |
107 | 107 | <li> |
108 | 108 | <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a> |
109 | - <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a> |
|
110 | - <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr($f->id) ?>"><?php echo FrmAppHelper::truncate($f->name, 60) ?></a> |
|
109 | + <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate( $f->field_key, 10 ) ?>]</a> |
|
110 | + <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr( $f->id ) ?>"><?php echo FrmAppHelper::truncate( $f->name, 60 ) ?></a> |
|
111 | 111 | </li> |
112 | 112 | <?php |
113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } else if ( $f->type == 'file' ) { |
117 | 117 | $file = $f; |
118 | 118 | } |
119 | - unset($f); |
|
119 | + unset( $f ); |
|
120 | 120 | } |
121 | 121 | } ?> |
122 | 122 | </ul> |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | foreach ( $cond_shortcodes as $skey => $sname ) { |
129 | 129 | ?> |
130 | 130 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
131 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if 125 <?php echo esc_attr($skey) ?>][/if 125"><?php echo esc_html( $sname ) ?></a> |
|
131 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if 125 <?php echo esc_attr( $skey ) ?>][/if 125"><?php echo esc_html( $sname ) ?></a> |
|
132 | 132 | </li> |
133 | 133 | <?php |
134 | 134 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
135 | - unset($skey, $sname); |
|
135 | + unset( $skey, $sname ); |
|
136 | 136 | } |
137 | 137 | ?> |
138 | 138 | </ul> |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | foreach ( $adv_shortcodes as $skey => $sname ) { |
147 | 147 | ?> |
148 | 148 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
149 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="'. esc_attr( $sname['title'] ) .'"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
|
149 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="' . esc_attr( $sname['title'] ) . '"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
|
150 | 150 | </li> |
151 | 151 | <?php |
152 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
153 | - unset($skey, $sname); |
|
152 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
153 | + unset( $skey, $sname ); |
|
154 | 154 | } |
155 | 155 | ?> |
156 | - <?php if ( isset($file) ) { ?> |
|
156 | + <?php if ( isset( $file ) ) { ?> |
|
157 | 157 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
158 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
|
158 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
|
159 | 159 | </li> |
160 | - <li class="frm_col_<?php echo $col = (($col == 'one') ? 'two' : 'one') ?>"> |
|
161 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
160 | + <li class="frm_col_<?php echo $col = ( ( $col == 'one' ) ? 'two' : 'one' ) ?>"> |
|
161 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
162 | 162 | </li> |
163 | - <li class="frm_col_<?php echo $col = (($col == 'one') ? 'two' : 'one') ?>"> |
|
164 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=label"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
163 | + <li class="frm_col_<?php echo $col = ( ( $col == 'one' ) ? 'two' : 'one' ) ?>"> |
|
164 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show=label"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
165 | 165 | </li> |
166 | 166 | <?php } ?> |
167 | 167 | </ul> |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | <div class="clear"></div> |
170 | 170 | <?php |
171 | 171 | |
172 | - if ( isset($uid) && ! empty($user_fields) ) { |
|
172 | + if ( isset( $uid ) && ! empty( $user_fields ) ) { |
|
173 | 173 | $col = 'one'; ?> |
174 | 174 | <p class="howto"><?php _e( 'Insert user information', 'formidable' ) ?></p> |
175 | 175 | <ul class="frm_code_list"> |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $uid->id . ' show="' . $uk . '"' ) ?>"><?php echo esc_html( $uf ) ?></a> |
179 | 179 | </li> |
180 | 180 | <?php |
181 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
182 | - unset($uf, $uk); |
|
181 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
182 | + unset( $uf, $uk ); |
|
183 | 183 | } |
184 | - unset($uid); ?> |
|
184 | + unset( $uid ); ?> |
|
185 | 185 | </ul> |
186 | 186 | <?php } |
187 | 187 | |
188 | - if ( isset($repeat_field) ) { ?> |
|
188 | + if ( isset( $repeat_field ) ) { ?> |
|
189 | 189 | <div class="clear"></div> |
190 | 190 | <p class="howto"><?php _e( 'Repeating field options', 'formidable' ) ?></p> |
191 | 191 | <ul class="frm_code_list"> |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | <?php |
197 | 197 | } |
198 | 198 | |
199 | - if ( isset($dfe) ) { ?> |
|
199 | + if ( isset( $dfe ) ) { ?> |
|
200 | 200 | |
201 | 201 | <div class="clear"></div> |
202 | 202 | <p class="howto"><?php _e( 'Dynamic field options', 'formidable' ) ?></p> |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | <li class="frm_col_one"> |
205 | 205 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="created-at"' ) ?>"><?php _e( 'Creation Date', 'formidable' ) ?></a> |
206 | 206 | </li> |
207 | - <?php if ( isset($ldfe) ) { ?> |
|
207 | + <?php if ( isset( $ldfe ) ) { ?> |
|
208 | 208 | <li class="frm_col_two"> |
209 | 209 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="' . $ldfe . '"' ) ?>"><?php _e( 'Field From Entry', 'formidable' ) ?></a> |
210 | 210 | </li> |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | <?php |
218 | 218 | if ( $settings_tab ) { |
219 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
219 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/mb_html_tab.php' ); |
|
220 | 220 | } |
221 | 221 | ?> |
222 | 222 | </div> |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmCSVExportHelper{ |
|
3 | +class FrmCSVExportHelper { |
|
4 | 4 | protected static $separator = ', '; |
5 | 5 | protected static $column_separator = ','; |
6 | 6 | protected static $line_break = 'return'; |
@@ -235,50 +235,50 @@ discard block |
||
235 | 235 | return $line; |
236 | 236 | } |
237 | 237 | |
238 | - $convmap = false; |
|
238 | + $convmap = false; |
|
239 | 239 | |
240 | 240 | switch ( self::$to_encoding ) { |
241 | - case 'macintosh': |
|
241 | + case 'macintosh': |
|
242 | 242 | // this map was derived from the differences between the MacRoman and UTF-8 Charsets |
243 | 243 | // Reference: |
244 | 244 | // - http://www.alanwood.net/demos/macroman.html |
245 | - $convmap = array( |
|
246 | - 256, 304, 0, 0xffff, |
|
247 | - 306, 337, 0, 0xffff, |
|
248 | - 340, 375, 0, 0xffff, |
|
249 | - 377, 401, 0, 0xffff, |
|
250 | - 403, 709, 0, 0xffff, |
|
251 | - 712, 727, 0, 0xffff, |
|
252 | - 734, 936, 0, 0xffff, |
|
253 | - 938, 959, 0, 0xffff, |
|
254 | - 961, 8210, 0, 0xffff, |
|
255 | - 8213, 8215, 0, 0xffff, |
|
256 | - 8219, 8219, 0, 0xffff, |
|
257 | - 8227, 8229, 0, 0xffff, |
|
258 | - 8231, 8239, 0, 0xffff, |
|
259 | - 8241, 8248, 0, 0xffff, |
|
260 | - 8251, 8259, 0, 0xffff, |
|
261 | - 8261, 8363, 0, 0xffff, |
|
262 | - 8365, 8481, 0, 0xffff, |
|
263 | - 8483, 8705, 0, 0xffff, |
|
264 | - 8707, 8709, 0, 0xffff, |
|
265 | - 8711, 8718, 0, 0xffff, |
|
266 | - 8720, 8720, 0, 0xffff, |
|
267 | - 8722, 8729, 0, 0xffff, |
|
268 | - 8731, 8733, 0, 0xffff, |
|
269 | - 8735, 8746, 0, 0xffff, |
|
270 | - 8748, 8775, 0, 0xffff, |
|
271 | - 8777, 8799, 0, 0xffff, |
|
272 | - 8801, 8803, 0, 0xffff, |
|
273 | - 8806, 9673, 0, 0xffff, |
|
274 | - 9675, 63742, 0, 0xffff, |
|
275 | - 63744, 64256, 0, 0xffff, |
|
276 | - ); |
|
277 | - break; |
|
278 | - case 'ISO-8859-1': |
|
279 | - $convmap = array( 256, 10000, 0, 0xffff ); |
|
280 | - break; |
|
281 | - } |
|
245 | + $convmap = array( |
|
246 | + 256, 304, 0, 0xffff, |
|
247 | + 306, 337, 0, 0xffff, |
|
248 | + 340, 375, 0, 0xffff, |
|
249 | + 377, 401, 0, 0xffff, |
|
250 | + 403, 709, 0, 0xffff, |
|
251 | + 712, 727, 0, 0xffff, |
|
252 | + 734, 936, 0, 0xffff, |
|
253 | + 938, 959, 0, 0xffff, |
|
254 | + 961, 8210, 0, 0xffff, |
|
255 | + 8213, 8215, 0, 0xffff, |
|
256 | + 8219, 8219, 0, 0xffff, |
|
257 | + 8227, 8229, 0, 0xffff, |
|
258 | + 8231, 8239, 0, 0xffff, |
|
259 | + 8241, 8248, 0, 0xffff, |
|
260 | + 8251, 8259, 0, 0xffff, |
|
261 | + 8261, 8363, 0, 0xffff, |
|
262 | + 8365, 8481, 0, 0xffff, |
|
263 | + 8483, 8705, 0, 0xffff, |
|
264 | + 8707, 8709, 0, 0xffff, |
|
265 | + 8711, 8718, 0, 0xffff, |
|
266 | + 8720, 8720, 0, 0xffff, |
|
267 | + 8722, 8729, 0, 0xffff, |
|
268 | + 8731, 8733, 0, 0xffff, |
|
269 | + 8735, 8746, 0, 0xffff, |
|
270 | + 8748, 8775, 0, 0xffff, |
|
271 | + 8777, 8799, 0, 0xffff, |
|
272 | + 8801, 8803, 0, 0xffff, |
|
273 | + 8806, 9673, 0, 0xffff, |
|
274 | + 9675, 63742, 0, 0xffff, |
|
275 | + 63744, 64256, 0, 0xffff, |
|
276 | + ); |
|
277 | + break; |
|
278 | + case 'ISO-8859-1': |
|
279 | + $convmap = array( 256, 10000, 0, 0xffff ); |
|
280 | + break; |
|
281 | + } |
|
282 | 282 | |
283 | 283 | if ( is_array( $convmap ) ) { |
284 | 284 | $line = mb_encode_numericentity( $line, $convmap, self::$charset ); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | return self::escape_csv( $line ); |
292 | - } |
|
292 | + } |
|
293 | 293 | |
294 | 294 | /** |
295 | 295 | * Escape a " in a csv with another " |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmCSVExportHelper{ |
|
3 | +class FrmCSVExportHelper { |
|
4 | 4 | protected static $separator = ', '; |
5 | 5 | protected static $column_separator = ','; |
6 | 6 | protected static $line_break = 'return'; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | header( 'Content-Description: File Transfer' ); |
64 | 64 | header( 'Content-Disposition: attachment; filename="' . esc_attr( $filename ) . '"' ); |
65 | 65 | header( 'Content-Type: text/csv; charset=' . self::$charset, true ); |
66 | - header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date('Y' ) ) ) . ' GMT' ); |
|
66 | + header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date( 'Y' ) ) ) . ' GMT' ); |
|
67 | 67 | header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
68 | 68 | header( 'Cache-Control: no-cache, must-revalidate' ); |
69 | 69 | header( 'Pragma: no-cache' ); |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | private static function csv_headings( &$headings ) { |
88 | 88 | foreach ( self::$fields as $col ) { |
89 | 89 | if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] && ! in_array( $col->type, array( 'user_id', 'file', 'data', 'date' ) ) ) { |
90 | - $headings[ $col->id . '_label' ] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
90 | + $headings[$col->id . '_label'] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
91 | 91 | } |
92 | 92 | |
93 | - $headings[ $col->id ] = strip_tags( $col->name ); |
|
93 | + $headings[$col->id] = strip_tags( $col->name ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if ( self::$comment_count ) { |
97 | - for ( $i = 0; $i < self::$comment_count; $i++ ) { |
|
98 | - $headings[ 'comment' . $i ] = __( 'Comment', 'formidable' ); |
|
99 | - $headings[ 'comment_user_id' . $i ] = __( 'Comment User', 'formidable' ); |
|
100 | - $headings[ 'comment_created_at' . $i ] = __( 'Comment Date', 'formidable' ); |
|
97 | + for ( $i = 0; $i < self::$comment_count; $i ++ ) { |
|
98 | + $headings['comment' . $i] = __( 'Comment', 'formidable' ); |
|
99 | + $headings['comment_user_id' . $i] = __( 'Comment User', 'formidable' ); |
|
100 | + $headings['comment_created_at' . $i] = __( 'Comment Date', 'formidable' ); |
|
101 | 101 | } |
102 | - unset($i); |
|
102 | + unset( $i ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $headings['created_at'] = __( 'Timestamp', 'formidable' ); |
@@ -146,45 +146,45 @@ discard block |
||
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
150 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = array(); |
|
151 | - } else if ( ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
149 | + if ( ! isset( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
150 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = array(); |
|
151 | + } else if ( ! is_array( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
152 | 152 | // if the data is here, it should be an array but if this field has collected data |
153 | 153 | // both while inside and outside of the repeating section, it's possible this is a string |
154 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = (array) $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ]; |
|
154 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = (array) $entries[self::$entry->parent_item_id]->metas[$meta_id]; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | //add the repeated values |
158 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ][] = $meta_value; |
|
158 | + $entries[self::$entry->parent_item_id]->metas[$meta_id][] = $meta_value; |
|
159 | 159 | } |
160 | - $entries[ self::$entry->parent_item_id ]->metas += self::$entry->metas; |
|
160 | + $entries[self::$entry->parent_item_id]->metas += self::$entry->metas; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // add the embedded form id |
164 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) { |
|
165 | - $entries[ self::$entry->parent_item_id ]->embedded_fields = array(); |
|
164 | + if ( ! isset( $entries[self::$entry->parent_item_id]->embedded_fields ) ) { |
|
165 | + $entries[self::$entry->parent_item_id]->embedded_fields = array(); |
|
166 | 166 | } |
167 | - $entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id; |
|
167 | + $entries[self::$entry->parent_item_id]->embedded_fields[self::$entry->id] = self::$entry->form_id; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | private static function add_field_values_to_csv( &$row ) { |
171 | 171 | foreach ( self::$fields as $col ) { |
172 | - $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false; |
|
172 | + $field_value = isset( self::$entry->metas[$col->id] ) ? self::$entry->metas[$col->id] : false; |
|
173 | 173 | |
174 | 174 | $field_value = maybe_unserialize( $field_value ); |
175 | - $field_value = apply_filters( 'frm_csv_value', $field_value, array( 'field' => $col, 'entry' => self::$entry, 'separator' => self::$separator, ) ); |
|
175 | + $field_value = apply_filters( 'frm_csv_value', $field_value, array( 'field' => $col, 'entry' => self::$entry, 'separator' => self::$separator,) ); |
|
176 | 176 | |
177 | 177 | if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] ) { |
178 | 178 | $sep_value = FrmEntriesHelper::display_value( $field_value, $col, array( |
179 | 179 | 'type' => $col->type, 'post_id' => self::$entry->post_id, 'show_icon' => false, |
180 | 180 | 'entry_id' => self::$entry->id, 'sep' => self::$separator, |
181 | - 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ self::$entry->id ] ) ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0, |
|
181 | + 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[self::$entry->id] ) ) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0, |
|
182 | 182 | ) ); |
183 | - $row[ $col->id . '_label' ] = $sep_value; |
|
183 | + $row[$col->id . '_label'] = $sep_value; |
|
184 | 184 | unset( $sep_value ); |
185 | 185 | } |
186 | 186 | |
187 | - $row[ $col->id ] = $field_value; |
|
187 | + $row[$col->id] = $field_value; |
|
188 | 188 | |
189 | 189 | unset( $col, $field_value ); |
190 | 190 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | $col_count = count( $rows ); |
206 | 206 | $this_col = 0; |
207 | 207 | foreach ( $rows as $k => $row ) { |
208 | - $this_col++; |
|
208 | + $this_col ++; |
|
209 | 209 | |
210 | - if ( ! isset( self::$headings[ $k ] ) ) { |
|
210 | + if ( ! isset( self::$headings[$k] ) ) { |
|
211 | 211 | // this column has been removed from the csv, so skip it |
212 | 212 | continue; |
213 | 213 | } |
@@ -87,9 +87,9 @@ |
||
87 | 87 | } else if ( $form->is_template ) { |
88 | 88 | echo ' ' . __( '(template)', 'formidable' ); |
89 | 89 | } |
90 | - ?></option> |
|
90 | + ?></option> |
|
91 | 91 | <?php |
92 | - } ?> |
|
92 | + } ?> |
|
93 | 93 | </select> |
94 | 94 | <p class="howto"><?php _e( 'Hold down the CTRL/Command button to select multiple forms', 'formidable' ); ?></p> |
95 | 95 | </td> |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | <div class="frmicon icon32"><br/></div> |
3 | 3 | <h2><?php _e( 'Import/Export', 'formidable' ); ?></h2> |
4 | 4 | |
5 | - <?php include(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); ?> |
|
5 | + <?php include( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
|
6 | 6 | <div id="poststuff" class="metabox-holder"> |
7 | 7 | <div id="post-body"> |
8 | 8 | <div id="post-body-content"> |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | <div class="postbox "> |
11 | 11 | <h3 class="hndle"><span><?php _e( 'Import', 'formidable' ) ?></span></h3> |
12 | 12 | <div class="inside"> |
13 | - <p class="howto"><?php echo apply_filters('frm_upload_instructions1', __( 'Upload your Formidable XML file to import forms into this site. If your imported form key and creation date match a form on your site, that form will be updated.', 'formidable' )) ?></p> |
|
13 | + <p class="howto"><?php echo apply_filters( 'frm_upload_instructions1', __( 'Upload your Formidable XML file to import forms into this site. If your imported form key and creation date match a form on your site, that form will be updated.', 'formidable' ) ) ?></p> |
|
14 | 14 | <br/> |
15 | 15 | <form enctype="multipart/form-data" method="post"> |
16 | 16 | <input type="hidden" name="frm_action" value="import_xml" /> |
17 | - <?php wp_nonce_field('import-xml-nonce', 'import-xml'); ?> |
|
18 | - <p><label><?php echo apply_filters('frm_upload_instructions2', __( 'Choose a Formidable XML file', 'formidable' )) ?> (<?php printf(__( 'Maximum size: %s', 'formidable' ), ini_get('upload_max_filesize')) ?>)</label> |
|
17 | + <?php wp_nonce_field( 'import-xml-nonce', 'import-xml' ); ?> |
|
18 | + <p><label><?php echo apply_filters( 'frm_upload_instructions2', __( 'Choose a Formidable XML file', 'formidable' ) ) ?> (<?php printf( __( 'Maximum size: %s', 'formidable' ), ini_get( 'upload_max_filesize' ) ) ?>)</label> |
|
19 | 19 | <input type="file" name="frm_import_file" size="25" /> |
20 | 20 | </p> |
21 | 21 | |
22 | - <?php do_action('frm_csv_opts', $forms) ?> |
|
22 | + <?php do_action( 'frm_csv_opts', $forms ) ?> |
|
23 | 23 | |
24 | 24 | <p class="submit"> |
25 | 25 | <input type="submit" value="<?php esc_attr_e( 'Upload file and import', 'formidable' ) ?>" class="button-primary" /> |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | <div class="inside with_frm_style"> |
35 | 35 | <form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" id="frm_export_xml"> |
36 | 36 | <input type="hidden" name="action" value="frm_export_xml" /> |
37 | - <?php wp_nonce_field('export-xml-nonce', 'export-xml'); ?> |
|
37 | + <?php wp_nonce_field( 'export-xml-nonce', 'export-xml' ); ?> |
|
38 | 38 | |
39 | 39 | <table class="form-table"> |
40 | 40 | <tr class="form-field"> |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | <td> |
43 | 43 | <select name="format"> |
44 | 44 | <?php foreach ( $export_format as $t => $type ) { ?> |
45 | - <option value="<?php echo esc_attr( $t ) ?>" data-support="<?php echo esc_attr( $type['support'] ) ?>" <?php echo isset( $type['count'] ) ? 'data-count="'. esc_attr( $type['count'] ) .'"' : ''; ?>><?php echo isset( $type['name'] ) ? $type['name'] : $t ?></option> |
|
45 | + <option value="<?php echo esc_attr( $t ) ?>" data-support="<?php echo esc_attr( $type['support'] ) ?>" <?php echo isset( $type['count'] ) ? 'data-count="' . esc_attr( $type['count'] ) . '"' : ''; ?>><?php echo isset( $type['name'] ) ? $type['name'] : $t ?></option> |
|
46 | 46 | <?php } ?> |
47 | 47 | </select> |
48 | 48 |
@@ -12,127 +12,127 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public static $plug_version = '2.0.19b3'; |
14 | 14 | |
15 | - /** |
|
16 | - * @since 1.07.02 |
|
17 | - * |
|
18 | - * @param none |
|
19 | - * @return string The version of this plugin |
|
20 | - */ |
|
21 | - public static function plugin_version() { |
|
22 | - return self::$plug_version; |
|
23 | - } |
|
24 | - |
|
25 | - public static function plugin_folder() { |
|
26 | - return basename(self::plugin_path()); |
|
27 | - } |
|
28 | - |
|
29 | - public static function plugin_path() { |
|
30 | - return dirname(dirname(dirname(__FILE__))); |
|
31 | - } |
|
32 | - |
|
33 | - public static function plugin_url() { |
|
34 | - //prevously FRM_URL constant |
|
35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
36 | - } |
|
15 | + /** |
|
16 | + * @since 1.07.02 |
|
17 | + * |
|
18 | + * @param none |
|
19 | + * @return string The version of this plugin |
|
20 | + */ |
|
21 | + public static function plugin_version() { |
|
22 | + return self::$plug_version; |
|
23 | + } |
|
24 | + |
|
25 | + public static function plugin_folder() { |
|
26 | + return basename(self::plugin_path()); |
|
27 | + } |
|
28 | + |
|
29 | + public static function plugin_path() { |
|
30 | + return dirname(dirname(dirname(__FILE__))); |
|
31 | + } |
|
32 | + |
|
33 | + public static function plugin_url() { |
|
34 | + //prevously FRM_URL constant |
|
35 | + return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | public static function relative_plugin_url() { |
39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * @return string Site URL |
|
44 | - */ |
|
45 | - public static function site_url() { |
|
46 | - return site_url(); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Get the name of this site |
|
51 | - * Used for [sitename] shortcode |
|
52 | - * |
|
53 | - * @since 2.0 |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public static function site_name() { |
|
57 | - return get_option('blogname'); |
|
58 | - } |
|
42 | + /** |
|
43 | + * @return string Site URL |
|
44 | + */ |
|
45 | + public static function site_url() { |
|
46 | + return site_url(); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Get the name of this site |
|
51 | + * Used for [sitename] shortcode |
|
52 | + * |
|
53 | + * @since 2.0 |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public static function site_name() { |
|
57 | + return get_option('blogname'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | public static function affiliate() { |
61 | 61 | return ''; |
62 | 62 | } |
63 | 63 | |
64 | - /** |
|
65 | - * Get the Formidable settings |
|
66 | - * |
|
67 | - * @since 2.0 |
|
68 | - * |
|
69 | - * @param None |
|
70 | - * @return FrmSettings $frm_setings |
|
71 | - */ |
|
72 | - public static function get_settings() { |
|
73 | - global $frm_settings; |
|
74 | - if ( empty($frm_settings) ) { |
|
75 | - $frm_settings = new FrmSettings(); |
|
76 | - } |
|
77 | - return $frm_settings; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Show a message in place of pro features |
|
82 | - * |
|
83 | - * @since 2.0 |
|
84 | - */ |
|
64 | + /** |
|
65 | + * Get the Formidable settings |
|
66 | + * |
|
67 | + * @since 2.0 |
|
68 | + * |
|
69 | + * @param None |
|
70 | + * @return FrmSettings $frm_setings |
|
71 | + */ |
|
72 | + public static function get_settings() { |
|
73 | + global $frm_settings; |
|
74 | + if ( empty($frm_settings) ) { |
|
75 | + $frm_settings = new FrmSettings(); |
|
76 | + } |
|
77 | + return $frm_settings; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Show a message in place of pro features |
|
82 | + * |
|
83 | + * @since 2.0 |
|
84 | + */ |
|
85 | 85 | public static function update_message( $features, $class = '' ) { |
86 | 86 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
87 | - } |
|
88 | - |
|
89 | - public static function pro_is_installed() { |
|
90 | - return apply_filters('frm_pro_installed', false); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Check for certain page in Formidable settings |
|
95 | - * |
|
96 | - * @since 2.0 |
|
97 | - * |
|
98 | - * @param string $page The name of the page to check |
|
99 | - * @return boolean |
|
100 | - */ |
|
87 | + } |
|
88 | + |
|
89 | + public static function pro_is_installed() { |
|
90 | + return apply_filters('frm_pro_installed', false); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Check for certain page in Formidable settings |
|
95 | + * |
|
96 | + * @since 2.0 |
|
97 | + * |
|
98 | + * @param string $page The name of the page to check |
|
99 | + * @return boolean |
|
100 | + */ |
|
101 | 101 | public static function is_admin_page( $page = 'formidable' ) { |
102 | - global $pagenow; |
|
102 | + global $pagenow; |
|
103 | 103 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
104 | - if ( $pagenow ) { |
|
104 | + if ( $pagenow ) { |
|
105 | 105 | return $pagenow == 'admin.php' && $get_page == $page; |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | 108 | return is_admin() && $get_page == $page; |
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Check for the form preview page |
|
113 | - * |
|
114 | - * @since 2.0 |
|
115 | - * |
|
116 | - * @param None |
|
117 | - * @return boolean |
|
118 | - */ |
|
119 | - public static function is_preview_page() { |
|
120 | - global $pagenow; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Check for the form preview page |
|
113 | + * |
|
114 | + * @since 2.0 |
|
115 | + * |
|
116 | + * @param None |
|
117 | + * @return boolean |
|
118 | + */ |
|
119 | + public static function is_preview_page() { |
|
120 | + global $pagenow; |
|
121 | 121 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
122 | 122 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Check for ajax except the form preview page |
|
127 | - * |
|
128 | - * @since 2.0 |
|
129 | - * |
|
130 | - * @param None |
|
131 | - * @return boolean |
|
132 | - */ |
|
133 | - public static function doing_ajax() { |
|
134 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
135 | - } |
|
125 | + /** |
|
126 | + * Check for ajax except the form preview page |
|
127 | + * |
|
128 | + * @since 2.0 |
|
129 | + * |
|
130 | + * @param None |
|
131 | + * @return boolean |
|
132 | + */ |
|
133 | + public static function doing_ajax() { |
|
134 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @since 2.0.8 |
@@ -142,101 +142,101 @@ discard block |
||
142 | 142 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Check if on an admin page |
|
147 | - * |
|
148 | - * @since 2.0 |
|
149 | - * |
|
150 | - * @param None |
|
151 | - * @return boolean |
|
152 | - */ |
|
153 | - public static function is_admin() { |
|
154 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Check if value contains blank value or empty array |
|
159 | - * |
|
160 | - * @since 2.0 |
|
161 | - * @param $value - value to check |
|
162 | - * @return boolean |
|
163 | - */ |
|
164 | - public static function is_empty_value( $value, $empty = '' ) { |
|
165 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
166 | - } |
|
167 | - |
|
168 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
169 | - return ! self::is_empty_value( $value, $empty ); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Get any value from the $_SERVER |
|
174 | - * |
|
175 | - * @since 2.0 |
|
176 | - * @param string $value |
|
177 | - * @return string |
|
178 | - */ |
|
145 | + /** |
|
146 | + * Check if on an admin page |
|
147 | + * |
|
148 | + * @since 2.0 |
|
149 | + * |
|
150 | + * @param None |
|
151 | + * @return boolean |
|
152 | + */ |
|
153 | + public static function is_admin() { |
|
154 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Check if value contains blank value or empty array |
|
159 | + * |
|
160 | + * @since 2.0 |
|
161 | + * @param $value - value to check |
|
162 | + * @return boolean |
|
163 | + */ |
|
164 | + public static function is_empty_value( $value, $empty = '' ) { |
|
165 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
166 | + } |
|
167 | + |
|
168 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
169 | + return ! self::is_empty_value( $value, $empty ); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Get any value from the $_SERVER |
|
174 | + * |
|
175 | + * @since 2.0 |
|
176 | + * @param string $value |
|
177 | + * @return string |
|
178 | + */ |
|
179 | 179 | public static function get_server_value( $value ) { |
180 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Check for the IP address in several places |
|
185 | - * Used by [ip] shortcode |
|
186 | - * |
|
187 | - * @return string The IP address of the current user |
|
188 | - */ |
|
189 | - public static function get_ip_address() { |
|
180 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * Check for the IP address in several places |
|
185 | + * Used by [ip] shortcode |
|
186 | + * |
|
187 | + * @return string The IP address of the current user |
|
188 | + */ |
|
189 | + public static function get_ip_address() { |
|
190 | 190 | $ip = ''; |
191 | - foreach ( array( |
|
192 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
193 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
194 | - ) as $key ) { |
|
195 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
196 | - continue; |
|
197 | - } |
|
198 | - |
|
199 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
200 | - $ip = trim($ip); // just to be safe |
|
201 | - |
|
202 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
203 | - return $ip; |
|
204 | - } |
|
205 | - } |
|
206 | - } |
|
191 | + foreach ( array( |
|
192 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
193 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
194 | + ) as $key ) { |
|
195 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
196 | + continue; |
|
197 | + } |
|
198 | + |
|
199 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
200 | + $ip = trim($ip); // just to be safe |
|
201 | + |
|
202 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
203 | + return $ip; |
|
204 | + } |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | 208 | return sanitize_text_field( $ip ); |
209 | - } |
|
209 | + } |
|
210 | 210 | |
211 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
212 | - if ( strpos($param, '[') ) { |
|
213 | - $params = explode('[', $param); |
|
214 | - $param = $params[0]; |
|
215 | - } |
|
211 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
212 | + if ( strpos($param, '[') ) { |
|
213 | + $params = explode('[', $param); |
|
214 | + $param = $params[0]; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | if ( $src == 'get' ) { |
218 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
219 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
220 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
221 | - } |
|
218 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
219 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
220 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
221 | + } |
|
222 | 222 | self::sanitize_value( $sanitize, $value ); |
223 | 223 | } else { |
224 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
225 | - } |
|
224 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
228 | - foreach ( $params as $k => $p ) { |
|
229 | - if ( ! $k || ! is_array($value) ) { |
|
230 | - continue; |
|
231 | - } |
|
228 | + foreach ( $params as $k => $p ) { |
|
229 | + if ( ! $k || ! is_array($value) ) { |
|
230 | + continue; |
|
231 | + } |
|
232 | 232 | |
233 | - $p = trim($p, ']'); |
|
234 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
235 | - } |
|
236 | - } |
|
233 | + $p = trim($p, ']'); |
|
234 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
235 | + } |
|
236 | + } |
|
237 | 237 | |
238 | - return $value; |
|
239 | - } |
|
238 | + return $value; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | /** |
242 | 242 | * |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
259 | 259 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
260 | - } |
|
260 | + } |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
295 | - * |
|
296 | - * @since 2.0.8 |
|
297 | - * @param string $value |
|
298 | - * @return string $value |
|
299 | - */ |
|
294 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
295 | + * |
|
296 | + * @since 2.0.8 |
|
297 | + * @param string $value |
|
298 | + * @return string $value |
|
299 | + */ |
|
300 | 300 | public static function preserve_backslashes( $value ) { |
301 | 301 | // If backslashes have already been added, don't add them again |
302 | 302 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -315,14 +315,14 @@ discard block |
||
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
319 | - $temp_values = $values; |
|
320 | - foreach ( $temp_values as $k => $val ) { |
|
321 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
318 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
319 | + $temp_values = $values; |
|
320 | + foreach ( $temp_values as $k => $val ) { |
|
321 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
322 | 322 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
323 | - } |
|
324 | - } |
|
325 | - } |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | 327 | public static function sanitize_array( &$values ) { |
328 | 328 | $temp_values = $values; |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public static function kses( $value, $allowed = array() ) { |
339 | 339 | $html = array( |
340 | - 'a' => array( |
|
340 | + 'a' => array( |
|
341 | 341 | 'href' => array(), |
342 | 342 | 'title' => array(), |
343 | 343 | 'id' => array(), |
344 | 344 | 'class' => array(), |
345 | - ), |
|
345 | + ), |
|
346 | 346 | ); |
347 | 347 | |
348 | 348 | $allowed_html = array(); |
@@ -353,176 +353,176 @@ discard block |
||
353 | 353 | return wp_kses( $value, $allowed_html ); |
354 | 354 | } |
355 | 355 | |
356 | - /** |
|
357 | - * Used when switching the action for a bulk action |
|
358 | - * @since 2.0 |
|
359 | - */ |
|
360 | - public static function remove_get_action() { |
|
361 | - if ( ! isset($_GET) ) { |
|
362 | - return; |
|
363 | - } |
|
356 | + /** |
|
357 | + * Used when switching the action for a bulk action |
|
358 | + * @since 2.0 |
|
359 | + */ |
|
360 | + public static function remove_get_action() { |
|
361 | + if ( ! isset($_GET) ) { |
|
362 | + return; |
|
363 | + } |
|
364 | 364 | |
365 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
366 | - if ( ! empty( $new_action ) ) { |
|
365 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
366 | + if ( ! empty( $new_action ) ) { |
|
367 | 367 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Check the WP query for a parameter |
|
373 | - * |
|
374 | - * @since 2.0 |
|
375 | - * @return string|array |
|
376 | - */ |
|
377 | - public static function get_query_var( $value, $param ) { |
|
378 | - if ( $value != '' ) { |
|
379 | - return $value; |
|
380 | - } |
|
381 | - |
|
382 | - global $wp_query; |
|
383 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
384 | - $value = $wp_query->query_vars[ $param ]; |
|
385 | - } |
|
386 | - |
|
387 | - return $value; |
|
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * @param string $type |
|
392 | - */ |
|
393 | - public static function trigger_hook_load( $type, $object = null ) { |
|
394 | - // only load the form hooks once |
|
395 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
396 | - if ( ! $hooks_loaded ) { |
|
397 | - do_action('frm_load_'. $type .'_hooks'); |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * Check cache before fetching values and saving to cache |
|
403 | - * |
|
404 | - * @since 2.0 |
|
405 | - * |
|
406 | - * @param string $cache_key The unique name for this cache |
|
407 | - * @param string $group The name of the cache group |
|
408 | - * @param string $query If blank, don't run a db call |
|
409 | - * @param string $type The wpdb function to use with this query |
|
410 | - * @return mixed $results The cache or query results |
|
411 | - */ |
|
412 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
413 | - $results = wp_cache_get($cache_key, $group); |
|
414 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
415 | - return $results; |
|
416 | - } |
|
417 | - |
|
418 | - if ( 'get_posts' == $type ) { |
|
419 | - $results = get_posts($query); |
|
420 | - } else { |
|
421 | - global $wpdb; |
|
422 | - $results = $wpdb->{$type}($query); |
|
423 | - } |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Check the WP query for a parameter |
|
373 | + * |
|
374 | + * @since 2.0 |
|
375 | + * @return string|array |
|
376 | + */ |
|
377 | + public static function get_query_var( $value, $param ) { |
|
378 | + if ( $value != '' ) { |
|
379 | + return $value; |
|
380 | + } |
|
381 | + |
|
382 | + global $wp_query; |
|
383 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
384 | + $value = $wp_query->query_vars[ $param ]; |
|
385 | + } |
|
386 | + |
|
387 | + return $value; |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * @param string $type |
|
392 | + */ |
|
393 | + public static function trigger_hook_load( $type, $object = null ) { |
|
394 | + // only load the form hooks once |
|
395 | + $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
396 | + if ( ! $hooks_loaded ) { |
|
397 | + do_action('frm_load_'. $type .'_hooks'); |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * Check cache before fetching values and saving to cache |
|
403 | + * |
|
404 | + * @since 2.0 |
|
405 | + * |
|
406 | + * @param string $cache_key The unique name for this cache |
|
407 | + * @param string $group The name of the cache group |
|
408 | + * @param string $query If blank, don't run a db call |
|
409 | + * @param string $type The wpdb function to use with this query |
|
410 | + * @return mixed $results The cache or query results |
|
411 | + */ |
|
412 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
413 | + $results = wp_cache_get($cache_key, $group); |
|
414 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
415 | + return $results; |
|
416 | + } |
|
417 | + |
|
418 | + if ( 'get_posts' == $type ) { |
|
419 | + $results = get_posts($query); |
|
420 | + } else { |
|
421 | + global $wpdb; |
|
422 | + $results = $wpdb->{$type}($query); |
|
423 | + } |
|
424 | 424 | |
425 | 425 | if ( ! self::prevent_caching() ) { |
426 | 426 | wp_cache_set( $cache_key, $results, $group, $time ); |
427 | 427 | } |
428 | 428 | |
429 | - return $results; |
|
430 | - } |
|
429 | + return $results; |
|
430 | + } |
|
431 | 431 | |
432 | - /** |
|
433 | - * Data that should be stored for a long time can be stored in a transient. |
|
434 | - * First check the cache, then check the transient |
|
435 | - * @since 2.0 |
|
436 | - * @return mixed The cached value or false |
|
437 | - */ |
|
432 | + /** |
|
433 | + * Data that should be stored for a long time can be stored in a transient. |
|
434 | + * First check the cache, then check the transient |
|
435 | + * @since 2.0 |
|
436 | + * @return mixed The cached value or false |
|
437 | + */ |
|
438 | 438 | public static function check_cache_and_transient( $cache_key ) { |
439 | - // check caching layer first |
|
440 | - $results = self::check_cache( $cache_key ); |
|
441 | - if ( $results ) { |
|
442 | - return $results; |
|
443 | - } |
|
444 | - |
|
445 | - // then check the transient |
|
446 | - $results = get_transient($cache_key); |
|
447 | - if ( $results ) { |
|
448 | - wp_cache_set($cache_key, $results); |
|
449 | - } |
|
450 | - |
|
451 | - return $results; |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * @since 2.0 |
|
456 | - * @param string $cache_key |
|
457 | - */ |
|
439 | + // check caching layer first |
|
440 | + $results = self::check_cache( $cache_key ); |
|
441 | + if ( $results ) { |
|
442 | + return $results; |
|
443 | + } |
|
444 | + |
|
445 | + // then check the transient |
|
446 | + $results = get_transient($cache_key); |
|
447 | + if ( $results ) { |
|
448 | + wp_cache_set($cache_key, $results); |
|
449 | + } |
|
450 | + |
|
451 | + return $results; |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * @since 2.0 |
|
456 | + * @param string $cache_key |
|
457 | + */ |
|
458 | 458 | public static function delete_cache_and_transient( $cache_key ) { |
459 | - delete_transient($cache_key); |
|
460 | - wp_cache_delete($cache_key); |
|
461 | - } |
|
462 | - |
|
463 | - /** |
|
464 | - * Delete all caching in a single group |
|
465 | - * |
|
466 | - * @since 2.0 |
|
467 | - * |
|
468 | - * @param string $group The name of the cache group |
|
469 | - * @return boolean True or False |
|
470 | - */ |
|
459 | + delete_transient($cache_key); |
|
460 | + wp_cache_delete($cache_key); |
|
461 | + } |
|
462 | + |
|
463 | + /** |
|
464 | + * Delete all caching in a single group |
|
465 | + * |
|
466 | + * @since 2.0 |
|
467 | + * |
|
468 | + * @param string $group The name of the cache group |
|
469 | + * @return boolean True or False |
|
470 | + */ |
|
471 | 471 | public static function cache_delete_group( $group ) { |
472 | - global $wp_object_cache; |
|
473 | - |
|
474 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
475 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
476 | - wp_cache_delete($k, $group); |
|
477 | - } |
|
478 | - return true; |
|
479 | - } |
|
480 | - |
|
481 | - return false; |
|
482 | - } |
|
483 | - |
|
484 | - /** |
|
485 | - * Check a value from a shortcode to see if true or false. |
|
486 | - * True when value is 1, true, 'true', 'yes' |
|
487 | - * |
|
488 | - * @since 1.07.10 |
|
489 | - * |
|
490 | - * @param string $value The value to compare |
|
491 | - * @return boolean True or False |
|
492 | - */ |
|
472 | + global $wp_object_cache; |
|
473 | + |
|
474 | + if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
475 | + foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
476 | + wp_cache_delete($k, $group); |
|
477 | + } |
|
478 | + return true; |
|
479 | + } |
|
480 | + |
|
481 | + return false; |
|
482 | + } |
|
483 | + |
|
484 | + /** |
|
485 | + * Check a value from a shortcode to see if true or false. |
|
486 | + * True when value is 1, true, 'true', 'yes' |
|
487 | + * |
|
488 | + * @since 1.07.10 |
|
489 | + * |
|
490 | + * @param string $value The value to compare |
|
491 | + * @return boolean True or False |
|
492 | + */ |
|
493 | 493 | public static function is_true( $value ) { |
494 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
495 | - } |
|
494 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
495 | + } |
|
496 | 496 | |
497 | - /** |
|
498 | - * Used to filter shortcode in text widgets |
|
499 | - */ |
|
500 | - public static function widget_text_filter_callback( $matches ) { |
|
501 | - return do_shortcode( $matches[0] ); |
|
502 | - } |
|
497 | + /** |
|
498 | + * Used to filter shortcode in text widgets |
|
499 | + */ |
|
500 | + public static function widget_text_filter_callback( $matches ) { |
|
501 | + return do_shortcode( $matches[0] ); |
|
502 | + } |
|
503 | 503 | |
504 | 504 | public static function load_scripts( $scripts ) { |
505 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
506 | - foreach ( (array) $scripts as $s ) { |
|
507 | - wp_enqueue_script($s); |
|
508 | - } |
|
509 | - } |
|
505 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
506 | + foreach ( (array) $scripts as $s ) { |
|
507 | + wp_enqueue_script($s); |
|
508 | + } |
|
509 | + } |
|
510 | 510 | |
511 | 511 | public static function load_styles( $styles ) { |
512 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
513 | - foreach ( (array) $styles as $s ) { |
|
514 | - wp_enqueue_style($s); |
|
515 | - } |
|
516 | - } |
|
512 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
513 | + foreach ( (array) $styles as $s ) { |
|
514 | + wp_enqueue_style($s); |
|
515 | + } |
|
516 | + } |
|
517 | 517 | |
518 | - public static function get_pages() { |
|
518 | + public static function get_pages() { |
|
519 | 519 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
520 | - } |
|
520 | + } |
|
521 | 521 | |
522 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
523 | - $pages = self::get_pages(); |
|
522 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
523 | + $pages = self::get_pages(); |
|
524 | 524 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
525 | - ?> |
|
525 | + ?> |
|
526 | 526 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
527 | 527 | <option value=""> </option> |
528 | 528 | <?php foreach ( $pages as $page ) { ?> |
@@ -532,107 +532,107 @@ discard block |
||
532 | 532 | <?php } ?> |
533 | 533 | </select> |
534 | 534 | <?php |
535 | - } |
|
535 | + } |
|
536 | 536 | |
537 | 537 | public static function post_edit_link( $post_id ) { |
538 | - $post = get_post($post_id); |
|
539 | - if ( $post ) { |
|
540 | - return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
541 | - } |
|
542 | - return ''; |
|
543 | - } |
|
538 | + $post = get_post($post_id); |
|
539 | + if ( $post ) { |
|
540 | + return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
541 | + } |
|
542 | + return ''; |
|
543 | + } |
|
544 | 544 | |
545 | 545 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
546 | - ?> |
|
546 | + ?> |
|
547 | 547 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
548 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
549 | - ?> class="frm_multiselect"> |
|
548 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
549 | + ?> class="frm_multiselect"> |
|
550 | 550 | <?php self::roles_options($capability); ?> |
551 | 551 | </select> |
552 | 552 | <?php |
553 | - } |
|
553 | + } |
|
554 | 554 | |
555 | 555 | public static function roles_options( $capability ) { |
556 | - global $frm_vars; |
|
557 | - if ( isset($frm_vars['editable_roles']) ) { |
|
558 | - $editable_roles = $frm_vars['editable_roles']; |
|
559 | - } else { |
|
560 | - $editable_roles = get_editable_roles(); |
|
561 | - $frm_vars['editable_roles'] = $editable_roles; |
|
562 | - } |
|
563 | - |
|
564 | - foreach ( $editable_roles as $role => $details ) { |
|
565 | - $name = translate_user_role($details['name'] ); ?> |
|
556 | + global $frm_vars; |
|
557 | + if ( isset($frm_vars['editable_roles']) ) { |
|
558 | + $editable_roles = $frm_vars['editable_roles']; |
|
559 | + } else { |
|
560 | + $editable_roles = get_editable_roles(); |
|
561 | + $frm_vars['editable_roles'] = $editable_roles; |
|
562 | + } |
|
563 | + |
|
564 | + foreach ( $editable_roles as $role => $details ) { |
|
565 | + $name = translate_user_role($details['name'] ); ?> |
|
566 | 566 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
567 | 567 | <?php |
568 | - unset($role, $details); |
|
569 | - } |
|
570 | - } |
|
568 | + unset($role, $details); |
|
569 | + } |
|
570 | + } |
|
571 | 571 | |
572 | 572 | public static function frm_capabilities( $type = 'auto' ) { |
573 | - $cap = array( |
|
574 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
575 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
576 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
577 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
578 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
579 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
580 | - ); |
|
573 | + $cap = array( |
|
574 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
575 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
576 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
577 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
578 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
579 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
580 | + ); |
|
581 | 581 | |
582 | 582 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
583 | - return $cap; |
|
584 | - } |
|
583 | + return $cap; |
|
584 | + } |
|
585 | 585 | |
586 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
587 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
588 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
589 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
586 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
587 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
588 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
589 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
590 | 590 | |
591 | - return $cap; |
|
592 | - } |
|
591 | + return $cap; |
|
592 | + } |
|
593 | 593 | |
594 | 594 | public static function user_has_permission( $needed_role ) { |
595 | - if ( $needed_role == '-1' ) { |
|
596 | - return false; |
|
595 | + if ( $needed_role == '-1' ) { |
|
596 | + return false; |
|
597 | 597 | } |
598 | 598 | |
599 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
600 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
601 | - return true; |
|
602 | - } |
|
599 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
600 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
601 | + return true; |
|
602 | + } |
|
603 | 603 | |
604 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
605 | - foreach ( $roles as $role ) { |
|
604 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
605 | + foreach ( $roles as $role ) { |
|
606 | 606 | if ( current_user_can( $role ) ) { |
607 | - return true; |
|
607 | + return true; |
|
608 | 608 | } |
609 | - if ( $role == $needed_role ) { |
|
610 | - break; |
|
609 | + if ( $role == $needed_role ) { |
|
610 | + break; |
|
611 | 611 | } |
612 | - } |
|
613 | - return false; |
|
614 | - } |
|
615 | - |
|
616 | - /** |
|
617 | - * Make sure administrators can see Formidable menu |
|
618 | - * |
|
619 | - * @since 2.0 |
|
620 | - */ |
|
621 | - public static function maybe_add_permissions() { |
|
612 | + } |
|
613 | + return false; |
|
614 | + } |
|
615 | + |
|
616 | + /** |
|
617 | + * Make sure administrators can see Formidable menu |
|
618 | + * |
|
619 | + * @since 2.0 |
|
620 | + */ |
|
621 | + public static function maybe_add_permissions() { |
|
622 | 622 | self::force_capability( 'frm_view_entries' ); |
623 | 623 | |
624 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
625 | - return; |
|
626 | - } |
|
624 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
625 | + return; |
|
626 | + } |
|
627 | 627 | |
628 | 628 | $user_id = get_current_user_id(); |
629 | 629 | $user = new WP_User( $user_id ); |
630 | - $frm_roles = self::frm_capabilities(); |
|
631 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
630 | + $frm_roles = self::frm_capabilities(); |
|
631 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
632 | 632 | $user->add_cap( $frm_role ); |
633 | - unset($frm_role, $frm_role_description); |
|
634 | - } |
|
635 | - } |
|
633 | + unset($frm_role, $frm_role_description); |
|
634 | + } |
|
635 | + } |
|
636 | 636 | |
637 | 637 | /** |
638 | 638 | * Make sure admins have permission to see the menu items |
@@ -648,28 +648,28 @@ discard block |
||
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | - /** |
|
652 | - * Check if the user has permision for action. |
|
653 | - * Return permission message and stop the action if no permission |
|
654 | - * @since 2.0 |
|
655 | - * @param string $permission |
|
656 | - */ |
|
651 | + /** |
|
652 | + * Check if the user has permision for action. |
|
653 | + * Return permission message and stop the action if no permission |
|
654 | + * @since 2.0 |
|
655 | + * @param string $permission |
|
656 | + */ |
|
657 | 657 | public static function permission_check( $permission, $show_message = 'show' ) { |
658 | - $permission_error = self::permission_nonce_error($permission); |
|
659 | - if ( $permission_error !== false ) { |
|
660 | - if ( 'hide' == $show_message ) { |
|
661 | - $permission_error = ''; |
|
662 | - } |
|
663 | - wp_die($permission_error); |
|
664 | - } |
|
665 | - } |
|
666 | - |
|
667 | - /** |
|
668 | - * Check user permission and nonce |
|
669 | - * @since 2.0 |
|
670 | - * @param string $permission |
|
671 | - * @return false|string The permission message or false if allowed |
|
672 | - */ |
|
658 | + $permission_error = self::permission_nonce_error($permission); |
|
659 | + if ( $permission_error !== false ) { |
|
660 | + if ( 'hide' == $show_message ) { |
|
661 | + $permission_error = ''; |
|
662 | + } |
|
663 | + wp_die($permission_error); |
|
664 | + } |
|
665 | + } |
|
666 | + |
|
667 | + /** |
|
668 | + * Check user permission and nonce |
|
669 | + * @since 2.0 |
|
670 | + * @param string $permission |
|
671 | + * @return false|string The permission message or false if allowed |
|
672 | + */ |
|
673 | 673 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
674 | 674 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
675 | 675 | $frm_settings = self::get_settings(); |
@@ -677,75 +677,75 @@ discard block |
||
677 | 677 | } |
678 | 678 | |
679 | 679 | $error = false; |
680 | - if ( empty($nonce_name) ) { |
|
681 | - return $error; |
|
682 | - } |
|
680 | + if ( empty($nonce_name) ) { |
|
681 | + return $error; |
|
682 | + } |
|
683 | 683 | |
684 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
685 | - $frm_settings = self::get_settings(); |
|
686 | - $error = $frm_settings->admin_permission; |
|
687 | - } |
|
684 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
685 | + $frm_settings = self::get_settings(); |
|
686 | + $error = $frm_settings->admin_permission; |
|
687 | + } |
|
688 | 688 | |
689 | - return $error; |
|
690 | - } |
|
689 | + return $error; |
|
690 | + } |
|
691 | 691 | |
692 | - public static function checked( $values, $current ) { |
|
692 | + public static function checked( $values, $current ) { |
|
693 | 693 | if ( self::check_selected( $values, $current ) ) { |
694 | - echo ' checked="checked"'; |
|
694 | + echo ' checked="checked"'; |
|
695 | 695 | } |
696 | - } |
|
696 | + } |
|
697 | 697 | |
698 | 698 | public static function check_selected( $values, $current ) { |
699 | - $values = self::recursive_function_map( $values, 'trim' ); |
|
700 | - $current = trim($current); |
|
701 | - |
|
702 | - return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
703 | - } |
|
704 | - |
|
705 | - /** |
|
706 | - * Check if current field option is an "other" option |
|
707 | - * |
|
708 | - * @since 2.0 |
|
709 | - * |
|
710 | - * @param string $opt_key |
|
711 | - * @return boolean Returns true if current field option is an "Other" option |
|
712 | - */ |
|
713 | - public static function is_other_opt( $opt_key ) { |
|
714 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
715 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
716 | - } |
|
717 | - |
|
718 | - /** |
|
719 | - * Get value that belongs in "Other" text box |
|
720 | - * |
|
721 | - * @since 2.0 |
|
722 | - * |
|
723 | - * @param string $opt_key |
|
724 | - * @param array $field |
|
725 | - * @return string $other_val |
|
726 | - */ |
|
727 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
699 | + $values = self::recursive_function_map( $values, 'trim' ); |
|
700 | + $current = trim($current); |
|
701 | + |
|
702 | + return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
703 | + } |
|
704 | + |
|
705 | + /** |
|
706 | + * Check if current field option is an "other" option |
|
707 | + * |
|
708 | + * @since 2.0 |
|
709 | + * |
|
710 | + * @param string $opt_key |
|
711 | + * @return boolean Returns true if current field option is an "Other" option |
|
712 | + */ |
|
713 | + public static function is_other_opt( $opt_key ) { |
|
714 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
715 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
716 | + } |
|
717 | + |
|
718 | + /** |
|
719 | + * Get value that belongs in "Other" text box |
|
720 | + * |
|
721 | + * @since 2.0 |
|
722 | + * |
|
723 | + * @param string $opt_key |
|
724 | + * @param array $field |
|
725 | + * @return string $other_val |
|
726 | + */ |
|
727 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
728 | 728 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
729 | 729 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
730 | - } |
|
731 | - |
|
732 | - /** |
|
733 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
734 | - * Intended for front-end use |
|
735 | - * |
|
736 | - * @since 2.0 |
|
737 | - * |
|
738 | - * @param array $field |
|
739 | - * @param boolean $other_opt |
|
740 | - * @param string $checked |
|
741 | - * @param array $args should include opt_key and field name |
|
742 | - * @return string $other_val |
|
743 | - */ |
|
744 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
730 | + } |
|
731 | + |
|
732 | + /** |
|
733 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
734 | + * Intended for front-end use |
|
735 | + * |
|
736 | + * @since 2.0 |
|
737 | + * |
|
738 | + * @param array $field |
|
739 | + * @param boolean $other_opt |
|
740 | + * @param string $checked |
|
741 | + * @param array $args should include opt_key and field name |
|
742 | + * @return string $other_val |
|
743 | + */ |
|
744 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
745 | 745 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
746 | 746 | $args['field'] = $field; |
747 | 747 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
748 | - } |
|
748 | + } |
|
749 | 749 | |
750 | 750 | public static function recursive_function_map( $value, $function ) { |
751 | 751 | if ( is_array( $value ) ) { |
@@ -775,334 +775,334 @@ discard block |
||
775 | 775 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
776 | 776 | } |
777 | 777 | |
778 | - /** |
|
779 | - * Flatten a multi-dimensional array |
|
780 | - */ |
|
778 | + /** |
|
779 | + * Flatten a multi-dimensional array |
|
780 | + */ |
|
781 | 781 | public static function array_flatten( $array, $keys = 'keep' ) { |
782 | - $return = array(); |
|
783 | - foreach ( $array as $key => $value ) { |
|
784 | - if ( is_array($value) ) { |
|
782 | + $return = array(); |
|
783 | + foreach ( $array as $key => $value ) { |
|
784 | + if ( is_array($value) ) { |
|
785 | 785 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
786 | - } else { |
|
786 | + } else { |
|
787 | 787 | if ( $keys == 'keep' ) { |
788 | 788 | $return[ $key ] = $value; |
789 | 789 | } else { |
790 | 790 | $return[] = $value; |
791 | 791 | } |
792 | - } |
|
793 | - } |
|
794 | - return $return; |
|
795 | - } |
|
796 | - |
|
797 | - public static function esc_textarea( $text ) { |
|
798 | - $safe_text = str_replace('"', '"', $text); |
|
799 | - $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
800 | - return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
801 | - } |
|
802 | - |
|
803 | - /** |
|
804 | - * Add auto paragraphs to text areas |
|
805 | - * @since 2.0 |
|
806 | - */ |
|
792 | + } |
|
793 | + } |
|
794 | + return $return; |
|
795 | + } |
|
796 | + |
|
797 | + public static function esc_textarea( $text ) { |
|
798 | + $safe_text = str_replace('"', '"', $text); |
|
799 | + $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
800 | + return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
801 | + } |
|
802 | + |
|
803 | + /** |
|
804 | + * Add auto paragraphs to text areas |
|
805 | + * @since 2.0 |
|
806 | + */ |
|
807 | 807 | public static function use_wpautop( $content ) { |
808 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
809 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
810 | - } |
|
811 | - return $content; |
|
812 | - } |
|
808 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
809 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
810 | + } |
|
811 | + return $content; |
|
812 | + } |
|
813 | 813 | |
814 | 814 | public static function replace_quotes( $val ) { |
815 | - //Replace double quotes |
|
815 | + //Replace double quotes |
|
816 | 816 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
817 | - //Replace single quotes |
|
818 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
819 | - return $val; |
|
820 | - } |
|
821 | - |
|
822 | - /** |
|
823 | - * @since 2.0 |
|
824 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
825 | - */ |
|
826 | - public static function jquery_ui_base_url() { |
|
827 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
828 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
829 | - return $url; |
|
830 | - } |
|
831 | - |
|
832 | - /** |
|
833 | - * @param string $handle |
|
834 | - */ |
|
817 | + //Replace single quotes |
|
818 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
819 | + return $val; |
|
820 | + } |
|
821 | + |
|
822 | + /** |
|
823 | + * @since 2.0 |
|
824 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
825 | + */ |
|
826 | + public static function jquery_ui_base_url() { |
|
827 | + $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
828 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
829 | + return $url; |
|
830 | + } |
|
831 | + |
|
832 | + /** |
|
833 | + * @param string $handle |
|
834 | + */ |
|
835 | 835 | public static function script_version( $handle ) { |
836 | - global $wp_scripts; |
|
837 | - if ( ! $wp_scripts ) { |
|
838 | - return false; |
|
839 | - } |
|
836 | + global $wp_scripts; |
|
837 | + if ( ! $wp_scripts ) { |
|
838 | + return false; |
|
839 | + } |
|
840 | 840 | |
841 | - $ver = 0; |
|
841 | + $ver = 0; |
|
842 | 842 | |
843 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
844 | - return $ver; |
|
845 | - } |
|
843 | + if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
844 | + return $ver; |
|
845 | + } |
|
846 | 846 | |
847 | - $query = $wp_scripts->registered[ $handle ]; |
|
848 | - if ( is_object( $query ) ) { |
|
849 | - $ver = $query->ver; |
|
850 | - } |
|
847 | + $query = $wp_scripts->registered[ $handle ]; |
|
848 | + if ( is_object( $query ) ) { |
|
849 | + $ver = $query->ver; |
|
850 | + } |
|
851 | 851 | |
852 | - return $ver; |
|
853 | - } |
|
852 | + return $ver; |
|
853 | + } |
|
854 | 854 | |
855 | 855 | public static function js_redirect( $url ) { |
856 | 856 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
857 | - } |
|
857 | + } |
|
858 | 858 | |
859 | 859 | public static function get_user_id_param( $user_id ) { |
860 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
861 | - return $user_id; |
|
862 | - } |
|
860 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
861 | + return $user_id; |
|
862 | + } |
|
863 | 863 | |
864 | 864 | if ( $user_id == 'current' ) { |
865 | - $user_ID = get_current_user_id(); |
|
866 | - $user_id = $user_ID; |
|
865 | + $user_ID = get_current_user_id(); |
|
866 | + $user_id = $user_ID; |
|
867 | 867 | } else { |
868 | - if ( is_email($user_id) ) { |
|
869 | - $user = get_user_by('email', $user_id); |
|
870 | - } else { |
|
871 | - $user = get_user_by('login', $user_id); |
|
872 | - } |
|
868 | + if ( is_email($user_id) ) { |
|
869 | + $user = get_user_by('email', $user_id); |
|
870 | + } else { |
|
871 | + $user = get_user_by('login', $user_id); |
|
872 | + } |
|
873 | 873 | |
874 | - if ( $user ) { |
|
875 | - $user_id = $user->ID; |
|
876 | - } |
|
877 | - unset($user); |
|
878 | - } |
|
874 | + if ( $user ) { |
|
875 | + $user_id = $user->ID; |
|
876 | + } |
|
877 | + unset($user); |
|
878 | + } |
|
879 | 879 | |
880 | - return $user_id; |
|
881 | - } |
|
880 | + return $user_id; |
|
881 | + } |
|
882 | 882 | |
883 | 883 | public static function get_file_contents( $filename, $atts = array() ) { |
884 | - if ( ! is_file($filename) ) { |
|
885 | - return false; |
|
886 | - } |
|
887 | - |
|
888 | - extract($atts); |
|
889 | - ob_start(); |
|
890 | - include($filename); |
|
891 | - $contents = ob_get_contents(); |
|
892 | - ob_end_clean(); |
|
893 | - return $contents; |
|
894 | - } |
|
895 | - |
|
896 | - /** |
|
897 | - * @param string $table_name |
|
898 | - * @param string $column |
|
899 | - */ |
|
900 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) { |
|
901 | - global $wpdb; |
|
902 | - |
|
903 | - $key = ''; |
|
904 | - |
|
905 | - if ( ! empty( $name ) ) { |
|
906 | - $key = sanitize_key($name); |
|
907 | - } |
|
884 | + if ( ! is_file($filename) ) { |
|
885 | + return false; |
|
886 | + } |
|
887 | + |
|
888 | + extract($atts); |
|
889 | + ob_start(); |
|
890 | + include($filename); |
|
891 | + $contents = ob_get_contents(); |
|
892 | + ob_end_clean(); |
|
893 | + return $contents; |
|
894 | + } |
|
895 | + |
|
896 | + /** |
|
897 | + * @param string $table_name |
|
898 | + * @param string $column |
|
899 | + */ |
|
900 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) { |
|
901 | + global $wpdb; |
|
902 | + |
|
903 | + $key = ''; |
|
904 | + |
|
905 | + if ( ! empty( $name ) ) { |
|
906 | + $key = sanitize_key($name); |
|
907 | + } |
|
908 | 908 | |
909 | 909 | if ( empty( $key ) ) { |
910 | - $max_slug_value = pow(36, $num_chars); |
|
911 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
912 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
913 | - } |
|
910 | + $max_slug_value = pow(36, $num_chars); |
|
911 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
912 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
913 | + } |
|
914 | 914 | |
915 | 915 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
916 | - $key = $key .'a'; |
|
917 | - } |
|
916 | + $key = $key .'a'; |
|
917 | + } |
|
918 | 918 | |
919 | 919 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
920 | 920 | |
921 | - if ( $key_check || is_numeric($key_check) ) { |
|
922 | - $suffix = 2; |
|
921 | + if ( $key_check || is_numeric($key_check) ) { |
|
922 | + $suffix = 2; |
|
923 | 923 | do { |
924 | 924 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
925 | 925 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
926 | 926 | $suffix++; |
927 | 927 | } while ($key_check || is_numeric($key_check)); |
928 | 928 | $key = $alt_post_name; |
929 | - } |
|
930 | - return $key; |
|
931 | - } |
|
932 | - |
|
933 | - /** |
|
934 | - * Editing a Form or Entry |
|
935 | - * @param string $table |
|
936 | - * @return bool|array |
|
937 | - */ |
|
938 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
939 | - if ( ! $record ) { |
|
940 | - return false; |
|
941 | - } |
|
942 | - |
|
943 | - global $frm_vars; |
|
944 | - |
|
945 | - if ( empty($post_values) ) { |
|
946 | - $post_values = stripslashes_deep($_POST); |
|
947 | - } |
|
929 | + } |
|
930 | + return $key; |
|
931 | + } |
|
932 | + |
|
933 | + /** |
|
934 | + * Editing a Form or Entry |
|
935 | + * @param string $table |
|
936 | + * @return bool|array |
|
937 | + */ |
|
938 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
939 | + if ( ! $record ) { |
|
940 | + return false; |
|
941 | + } |
|
942 | + |
|
943 | + global $frm_vars; |
|
944 | + |
|
945 | + if ( empty($post_values) ) { |
|
946 | + $post_values = stripslashes_deep($_POST); |
|
947 | + } |
|
948 | 948 | |
949 | 949 | $values = array( 'id' => $record->id, 'fields' => array() ); |
950 | 950 | |
951 | 951 | foreach ( array( 'name', 'description' ) as $var ) { |
952 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
953 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
954 | - unset($var, $default_val); |
|
955 | - } |
|
956 | - |
|
957 | - $values['description'] = self::use_wpautop($values['description']); |
|
958 | - $frm_settings = self::get_settings(); |
|
959 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
960 | - |
|
961 | - foreach ( (array) $fields as $field ) { |
|
962 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
963 | - if ( ! $is_form_builder ) { |
|
964 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
965 | - } |
|
952 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
953 | + $values[ $var ] = self::get_param( $var, $default_val ); |
|
954 | + unset($var, $default_val); |
|
955 | + } |
|
956 | + |
|
957 | + $values['description'] = self::use_wpautop($values['description']); |
|
958 | + $frm_settings = self::get_settings(); |
|
959 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
960 | + |
|
961 | + foreach ( (array) $fields as $field ) { |
|
962 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
963 | + if ( ! $is_form_builder ) { |
|
964 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
965 | + } |
|
966 | 966 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
967 | 967 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
968 | - } |
|
968 | + } |
|
969 | 969 | |
970 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
970 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
971 | 971 | |
972 | - if ( $table == 'entries' ) { |
|
973 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
974 | - } else if ( $table == 'forms' ) { |
|
975 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
976 | - } |
|
972 | + if ( $table == 'entries' ) { |
|
973 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
974 | + } else if ( $table == 'forms' ) { |
|
975 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
976 | + } |
|
977 | 977 | |
978 | - return $values; |
|
979 | - } |
|
978 | + return $values; |
|
979 | + } |
|
980 | 980 | |
981 | 981 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
982 | - $post_values = $args['post_values']; |
|
983 | - |
|
984 | - if ( $args['default'] ) { |
|
985 | - $meta_value = $field->default_value; |
|
986 | - } else { |
|
987 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
988 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
989 | - $field->field_options['custom_field'] = ''; |
|
990 | - } |
|
982 | + $post_values = $args['post_values']; |
|
983 | + |
|
984 | + if ( $args['default'] ) { |
|
985 | + $meta_value = $field->default_value; |
|
986 | + } else { |
|
987 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
988 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
989 | + $field->field_options['custom_field'] = ''; |
|
990 | + } |
|
991 | 991 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
992 | - } else { |
|
992 | + } else { |
|
993 | 993 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
994 | - } |
|
995 | - } |
|
996 | - |
|
997 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
998 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
999 | - |
|
1000 | - $field_array = array( |
|
1001 | - 'id' => $field->id, |
|
1002 | - 'value' => $new_value, |
|
1003 | - 'default_value' => $field->default_value, |
|
1004 | - 'name' => $field->name, |
|
1005 | - 'description' => $field->description, |
|
1006 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1007 | - 'options' => $field->options, |
|
1008 | - 'required' => $field->required, |
|
1009 | - 'field_key' => $field->field_key, |
|
1010 | - 'field_order' => $field->field_order, |
|
1011 | - 'form_id' => $field->form_id, |
|
994 | + } |
|
995 | + } |
|
996 | + |
|
997 | + $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
998 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
999 | + |
|
1000 | + $field_array = array( |
|
1001 | + 'id' => $field->id, |
|
1002 | + 'value' => $new_value, |
|
1003 | + 'default_value' => $field->default_value, |
|
1004 | + 'name' => $field->name, |
|
1005 | + 'description' => $field->description, |
|
1006 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1007 | + 'options' => $field->options, |
|
1008 | + 'required' => $field->required, |
|
1009 | + 'field_key' => $field->field_key, |
|
1010 | + 'field_order' => $field->field_order, |
|
1011 | + 'form_id' => $field->form_id, |
|
1012 | 1012 | 'parent_form_id' => $args['parent_form_id'], |
1013 | - ); |
|
1013 | + ); |
|
1014 | 1014 | |
1015 | - $args['field_type'] = $field_type; |
|
1016 | - self::fill_field_opts($field, $field_array, $args); |
|
1015 | + $args['field_type'] = $field_type; |
|
1016 | + self::fill_field_opts($field, $field_array, $args); |
|
1017 | 1017 | |
1018 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1018 | + $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1019 | 1019 | |
1020 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1021 | - $field_array['unique_msg'] = ''; |
|
1022 | - } |
|
1020 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1021 | + $field_array['unique_msg'] = ''; |
|
1022 | + } |
|
1023 | 1023 | |
1024 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
1024 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
1025 | 1025 | |
1026 | - $values['fields'][ $field->id ] = $field_array; |
|
1027 | - } |
|
1026 | + $values['fields'][ $field->id ] = $field_array; |
|
1027 | + } |
|
1028 | 1028 | |
1029 | 1029 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1030 | - $post_values = $args['post_values']; |
|
1031 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1032 | - |
|
1033 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1034 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1035 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1036 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1037 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1038 | - if ( $args['field_type'] == 'captcha' ) { |
|
1039 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1040 | - } else { |
|
1041 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1042 | - } |
|
1043 | - } |
|
1044 | - } |
|
1045 | - |
|
1046 | - if ( $field_array['custom_html'] == '' ) { |
|
1047 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1048 | - } |
|
1049 | - } |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * @param string $table |
|
1053 | - */ |
|
1030 | + $post_values = $args['post_values']; |
|
1031 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1032 | + |
|
1033 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1034 | + $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1035 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1036 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1037 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1038 | + if ( $args['field_type'] == 'captcha' ) { |
|
1039 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1040 | + } else { |
|
1041 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1042 | + } |
|
1043 | + } |
|
1044 | + } |
|
1045 | + |
|
1046 | + if ( $field_array['custom_html'] == '' ) { |
|
1047 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1048 | + } |
|
1049 | + } |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * @param string $table |
|
1053 | + */ |
|
1054 | 1054 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
1055 | - if ( $table == 'entries' ) { |
|
1056 | - $form = $record->form_id; |
|
1055 | + if ( $table == 'entries' ) { |
|
1056 | + $form = $record->form_id; |
|
1057 | 1057 | FrmForm::maybe_get_form( $form ); |
1058 | - } else { |
|
1059 | - $form = $record; |
|
1060 | - } |
|
1058 | + } else { |
|
1059 | + $form = $record; |
|
1060 | + } |
|
1061 | 1061 | |
1062 | - if ( ! $form ) { |
|
1063 | - return; |
|
1064 | - } |
|
1062 | + if ( ! $form ) { |
|
1063 | + return; |
|
1064 | + } |
|
1065 | 1065 | |
1066 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1066 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1067 | 1067 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1068 | 1068 | |
1069 | - if ( ! is_array($form->options) ) { |
|
1070 | - return; |
|
1071 | - } |
|
1069 | + if ( ! is_array($form->options) ) { |
|
1070 | + return; |
|
1071 | + } |
|
1072 | 1072 | |
1073 | - foreach ( $form->options as $opt => $value ) { |
|
1074 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1075 | - } |
|
1073 | + foreach ( $form->options as $opt => $value ) { |
|
1074 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1075 | + } |
|
1076 | 1076 | |
1077 | - self::fill_form_defaults($post_values, $values); |
|
1078 | - } |
|
1077 | + self::fill_form_defaults($post_values, $values); |
|
1078 | + } |
|
1079 | 1079 | |
1080 | - /** |
|
1081 | - * Set to POST value or default |
|
1082 | - */ |
|
1080 | + /** |
|
1081 | + * Set to POST value or default |
|
1082 | + */ |
|
1083 | 1083 | private static function fill_form_defaults( $post_values, array &$values ) { |
1084 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1084 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1085 | 1085 | |
1086 | - foreach ( $form_defaults as $opt => $default ) { |
|
1087 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1086 | + foreach ( $form_defaults as $opt => $default ) { |
|
1087 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1088 | 1088 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
1089 | - } |
|
1089 | + } |
|
1090 | 1090 | |
1091 | - unset($opt, $defaut); |
|
1092 | - } |
|
1091 | + unset($opt, $defaut); |
|
1092 | + } |
|
1093 | 1093 | |
1094 | - if ( ! isset($values['custom_style']) ) { |
|
1095 | - $frm_settings = self::get_settings(); |
|
1094 | + if ( ! isset($values['custom_style']) ) { |
|
1095 | + $frm_settings = self::get_settings(); |
|
1096 | 1096 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1097 | - } |
|
1097 | + } |
|
1098 | 1098 | |
1099 | 1099 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1100 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1101 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1102 | - } |
|
1103 | - unset($h); |
|
1104 | - } |
|
1105 | - } |
|
1100 | + if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1101 | + $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1102 | + } |
|
1103 | + unset($h); |
|
1104 | + } |
|
1105 | + } |
|
1106 | 1106 | |
1107 | 1107 | public static function get_meta_value( $field_id, $entry ) { |
1108 | 1108 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' ); |
@@ -1110,69 +1110,69 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | public static function insert_opt_html( $args ) { |
1113 | - $class = ''; |
|
1114 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1115 | - $class .= 'show_frm_not_email_to'; |
|
1116 | - } |
|
1117 | - ?> |
|
1113 | + $class = ''; |
|
1114 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1115 | + $class .= 'show_frm_not_email_to'; |
|
1116 | + } |
|
1117 | + ?> |
|
1118 | 1118 | <li> |
1119 | 1119 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
1120 | 1120 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
1121 | 1121 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
1122 | 1122 | </li> |
1123 | 1123 | <?php |
1124 | - } |
|
1124 | + } |
|
1125 | 1125 | |
1126 | - public static function get_us_states() { |
|
1127 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1128 | - return FrmFieldsHelper::get_us_states(); |
|
1129 | - } |
|
1126 | + public static function get_us_states() { |
|
1127 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1128 | + return FrmFieldsHelper::get_us_states(); |
|
1129 | + } |
|
1130 | 1130 | |
1131 | - public static function get_countries() { |
|
1132 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1133 | - return FrmFieldsHelper::get_countries(); |
|
1134 | - } |
|
1131 | + public static function get_countries() { |
|
1132 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1133 | + return FrmFieldsHelper::get_countries(); |
|
1134 | + } |
|
1135 | 1135 | |
1136 | 1136 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
1137 | - if ( is_array( $str ) ) { |
|
1138 | - return; |
|
1137 | + if ( is_array( $str ) ) { |
|
1138 | + return; |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | - $length = (int) $length; |
|
1141 | + $length = (int) $length; |
|
1142 | 1142 | $str = wp_strip_all_tags( $str ); |
1143 | 1143 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
1144 | 1144 | |
1145 | 1145 | if ( $length == 0 ) { |
1146 | - return ''; |
|
1147 | - } else if ( $length <= 10 ) { |
|
1146 | + return ''; |
|
1147 | + } else if ( $length <= 10 ) { |
|
1148 | 1148 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1149 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1150 | - } |
|
1149 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
1150 | + } |
|
1151 | 1151 | |
1152 | - $sub = ''; |
|
1153 | - $len = 0; |
|
1152 | + $sub = ''; |
|
1153 | + $len = 0; |
|
1154 | 1154 | |
1155 | 1155 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1156 | 1156 | |
1157 | 1157 | foreach ( $words as $word ) { |
1158 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1158 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
1159 | 1159 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1160 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1161 | - break; |
|
1162 | - } |
|
1160 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
1161 | + break; |
|
1162 | + } |
|
1163 | 1163 | |
1164 | - $sub .= $part; |
|
1164 | + $sub .= $part; |
|
1165 | 1165 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1166 | 1166 | |
1167 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1168 | - break; |
|
1169 | - } |
|
1167 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1168 | + break; |
|
1169 | + } |
|
1170 | 1170 | |
1171 | - unset($total_len, $word); |
|
1172 | - } |
|
1171 | + unset($total_len, $word); |
|
1172 | + } |
|
1173 | 1173 | |
1174 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1175 | - } |
|
1174 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
1175 | + } |
|
1176 | 1176 | |
1177 | 1177 | public static function mb_function( $function_names, $args ) { |
1178 | 1178 | $mb_function_name = $function_names[0]; |
@@ -1184,18 +1184,18 @@ discard block |
||
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1187 | - if ( empty($date) ) { |
|
1188 | - return $date; |
|
1189 | - } |
|
1187 | + if ( empty($date) ) { |
|
1188 | + return $date; |
|
1189 | + } |
|
1190 | 1190 | |
1191 | - if ( empty($date_format) ) { |
|
1192 | - $date_format = get_option('date_format'); |
|
1193 | - } |
|
1191 | + if ( empty($date_format) ) { |
|
1192 | + $date_format = get_option('date_format'); |
|
1193 | + } |
|
1194 | 1194 | |
1195 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1196 | - $frmpro_settings = new FrmProSettings(); |
|
1197 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1198 | - } |
|
1195 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1196 | + $frmpro_settings = new FrmProSettings(); |
|
1197 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1198 | + } |
|
1199 | 1199 | |
1200 | 1200 | $formatted = self::get_localized_date( $date_format, $date ); |
1201 | 1201 | |
@@ -1204,8 +1204,8 @@ discard block |
||
1204 | 1204 | $formatted .= self::add_time_to_date( $time_format, $date ); |
1205 | 1205 | } |
1206 | 1206 | |
1207 | - return $formatted; |
|
1208 | - } |
|
1207 | + return $formatted; |
|
1208 | + } |
|
1209 | 1209 | |
1210 | 1210 | private static function add_time_to_date( $time_format, $date ) { |
1211 | 1211 | if ( empty( $time_format ) ) { |
@@ -1229,117 +1229,117 @@ discard block |
||
1229 | 1229 | return date_i18n( $date_format, strtotime( $date ) ); |
1230 | 1230 | } |
1231 | 1231 | |
1232 | - /** |
|
1233 | - * @return string The time ago in words |
|
1234 | - */ |
|
1235 | - public static function human_time_diff( $from, $to = '' ) { |
|
1236 | - if ( empty($to) ) { |
|
1237 | - $to = time(); |
|
1238 | - } |
|
1239 | - |
|
1240 | - // Array of time period chunks |
|
1241 | - $chunks = array( |
|
1242 | - array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ), |
|
1243 | - array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ), |
|
1244 | - array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ), |
|
1245 | - array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ), |
|
1246 | - array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ), |
|
1247 | - array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ), |
|
1248 | - array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ), |
|
1249 | - ); |
|
1250 | - |
|
1251 | - // Difference in seconds |
|
1252 | - $diff = (int) ($to - $from); |
|
1253 | - |
|
1254 | - // Something went wrong with date calculation and we ended up with a negative date. |
|
1232 | + /** |
|
1233 | + * @return string The time ago in words |
|
1234 | + */ |
|
1235 | + public static function human_time_diff( $from, $to = '' ) { |
|
1236 | + if ( empty($to) ) { |
|
1237 | + $to = time(); |
|
1238 | + } |
|
1239 | + |
|
1240 | + // Array of time period chunks |
|
1241 | + $chunks = array( |
|
1242 | + array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ), |
|
1243 | + array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ), |
|
1244 | + array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ), |
|
1245 | + array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ), |
|
1246 | + array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ), |
|
1247 | + array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ), |
|
1248 | + array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ), |
|
1249 | + ); |
|
1250 | + |
|
1251 | + // Difference in seconds |
|
1252 | + $diff = (int) ($to - $from); |
|
1253 | + |
|
1254 | + // Something went wrong with date calculation and we ended up with a negative date. |
|
1255 | 1255 | if ( $diff < 1 ) { |
1256 | 1256 | return '0 ' . __( 'seconds', 'formidable' ); |
1257 | - } |
|
1257 | + } |
|
1258 | 1258 | |
1259 | - /** |
|
1260 | - * We only want to output one chunks of time here, eg: |
|
1261 | - * x years |
|
1262 | - * xx months |
|
1263 | - * so there's only one bit of calculation below: |
|
1264 | - */ |
|
1259 | + /** |
|
1260 | + * We only want to output one chunks of time here, eg: |
|
1261 | + * x years |
|
1262 | + * xx months |
|
1263 | + * so there's only one bit of calculation below: |
|
1264 | + */ |
|
1265 | 1265 | |
1266 | - $count = 0; |
|
1266 | + $count = 0; |
|
1267 | 1267 | |
1268 | - //Step one: the first chunk |
|
1268 | + //Step one: the first chunk |
|
1269 | 1269 | for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) { |
1270 | - $seconds = $chunks[ $i ][0]; |
|
1271 | - |
|
1272 | - // Finding the biggest chunk (if the chunk fits, break) |
|
1273 | - if ( ( $count = floor($diff / $seconds) ) != 0 ) { |
|
1274 | - break; |
|
1275 | - } |
|
1276 | - } |
|
1277 | - |
|
1278 | - // Set output var |
|
1279 | - $output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2]; |
|
1280 | - |
|
1281 | - if ( ! (int) trim( $output ) ) { |
|
1282 | - $output = '0 ' . __( 'seconds', 'formidable' ); |
|
1283 | - } |
|
1284 | - |
|
1285 | - return $output; |
|
1286 | - } |
|
1287 | - |
|
1288 | - /** |
|
1289 | - * Added for < WP 4.0 compatability |
|
1290 | - * |
|
1291 | - * @since 1.07.10 |
|
1292 | - * |
|
1293 | - * @param string $term The value to escape |
|
1294 | - * @return string The escaped value |
|
1295 | - */ |
|
1270 | + $seconds = $chunks[ $i ][0]; |
|
1271 | + |
|
1272 | + // Finding the biggest chunk (if the chunk fits, break) |
|
1273 | + if ( ( $count = floor($diff / $seconds) ) != 0 ) { |
|
1274 | + break; |
|
1275 | + } |
|
1276 | + } |
|
1277 | + |
|
1278 | + // Set output var |
|
1279 | + $output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2]; |
|
1280 | + |
|
1281 | + if ( ! (int) trim( $output ) ) { |
|
1282 | + $output = '0 ' . __( 'seconds', 'formidable' ); |
|
1283 | + } |
|
1284 | + |
|
1285 | + return $output; |
|
1286 | + } |
|
1287 | + |
|
1288 | + /** |
|
1289 | + * Added for < WP 4.0 compatability |
|
1290 | + * |
|
1291 | + * @since 1.07.10 |
|
1292 | + * |
|
1293 | + * @param string $term The value to escape |
|
1294 | + * @return string The escaped value |
|
1295 | + */ |
|
1296 | 1296 | public static function esc_like( $term ) { |
1297 | - global $wpdb; |
|
1298 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1297 | + global $wpdb; |
|
1298 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
1299 | 1299 | // WP 4.0 |
1300 | - $term = $wpdb->esc_like( $term ); |
|
1301 | - } else { |
|
1302 | - $term = like_escape( $term ); |
|
1303 | - } |
|
1300 | + $term = $wpdb->esc_like( $term ); |
|
1301 | + } else { |
|
1302 | + $term = like_escape( $term ); |
|
1303 | + } |
|
1304 | 1304 | |
1305 | - return $term; |
|
1306 | - } |
|
1305 | + return $term; |
|
1306 | + } |
|
1307 | 1307 | |
1308 | - /** |
|
1309 | - * @param string $order_query |
|
1310 | - */ |
|
1308 | + /** |
|
1309 | + * @param string $order_query |
|
1310 | + */ |
|
1311 | 1311 | public static function esc_order( $order_query ) { |
1312 | - if ( empty($order_query) ) { |
|
1313 | - return ''; |
|
1314 | - } |
|
1315 | - |
|
1316 | - // remove ORDER BY before santizing |
|
1317 | - $order_query = strtolower($order_query); |
|
1318 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1319 | - $order_query = str_replace('order by', '', $order_query); |
|
1320 | - } |
|
1321 | - |
|
1322 | - $order_query = explode(' ', trim($order_query)); |
|
1323 | - |
|
1324 | - $order_fields = array( |
|
1325 | - 'id', 'form_key', 'name', 'description', |
|
1326 | - 'parent_form_id', 'logged_in', 'is_template', |
|
1327 | - 'default_template', 'status', 'created_at', |
|
1328 | - ); |
|
1329 | - |
|
1330 | - $order = trim(trim(reset($order_query), ',')); |
|
1331 | - if ( ! in_array($order, $order_fields) ) { |
|
1332 | - return ''; |
|
1333 | - } |
|
1334 | - |
|
1335 | - $order_by = ''; |
|
1336 | - if ( count($order_query) > 1 ) { |
|
1312 | + if ( empty($order_query) ) { |
|
1313 | + return ''; |
|
1314 | + } |
|
1315 | + |
|
1316 | + // remove ORDER BY before santizing |
|
1317 | + $order_query = strtolower($order_query); |
|
1318 | + if ( strpos($order_query, 'order by') !== false ) { |
|
1319 | + $order_query = str_replace('order by', '', $order_query); |
|
1320 | + } |
|
1321 | + |
|
1322 | + $order_query = explode(' ', trim($order_query)); |
|
1323 | + |
|
1324 | + $order_fields = array( |
|
1325 | + 'id', 'form_key', 'name', 'description', |
|
1326 | + 'parent_form_id', 'logged_in', 'is_template', |
|
1327 | + 'default_template', 'status', 'created_at', |
|
1328 | + ); |
|
1329 | + |
|
1330 | + $order = trim(trim(reset($order_query), ',')); |
|
1331 | + if ( ! in_array($order, $order_fields) ) { |
|
1332 | + return ''; |
|
1333 | + } |
|
1334 | + |
|
1335 | + $order_by = ''; |
|
1336 | + if ( count($order_query) > 1 ) { |
|
1337 | 1337 | $order_by = end( $order_query ); |
1338 | 1338 | self::esc_order_by( $order_by ); |
1339 | - } |
|
1339 | + } |
|
1340 | 1340 | |
1341 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
1342 | - } |
|
1341 | + return ' ORDER BY '. $order . ' '. $order_by; |
|
1342 | + } |
|
1343 | 1343 | |
1344 | 1344 | /** |
1345 | 1345 | * Make sure this is ordering by either ASC or DESC |
@@ -1351,183 +1351,183 @@ discard block |
||
1351 | 1351 | } |
1352 | 1352 | } |
1353 | 1353 | |
1354 | - /** |
|
1355 | - * @param string $limit |
|
1356 | - */ |
|
1354 | + /** |
|
1355 | + * @param string $limit |
|
1356 | + */ |
|
1357 | 1357 | public static function esc_limit( $limit ) { |
1358 | - if ( empty($limit) ) { |
|
1359 | - return ''; |
|
1360 | - } |
|
1361 | - |
|
1362 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1363 | - if ( is_numeric($limit) ) { |
|
1364 | - return ' LIMIT '. $limit; |
|
1365 | - } |
|
1366 | - |
|
1367 | - $limit = explode(',', trim($limit)); |
|
1368 | - foreach ( $limit as $k => $l ) { |
|
1369 | - if ( is_numeric( $l ) ) { |
|
1370 | - $limit[ $k ] = $l; |
|
1371 | - } |
|
1372 | - } |
|
1373 | - |
|
1374 | - $limit = implode(',', $limit); |
|
1375 | - return ' LIMIT '. $limit; |
|
1376 | - } |
|
1377 | - |
|
1378 | - /** |
|
1379 | - * Get an array of values ready to go through $wpdb->prepare |
|
1380 | - * @since 2.0 |
|
1381 | - */ |
|
1382 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
1383 | - $placeholders = array_fill(0, count($array), $type); |
|
1384 | - return implode(', ', $placeholders); |
|
1385 | - } |
|
1386 | - |
|
1387 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1388 | - if ( empty($where) ) { |
|
1389 | - return ''; |
|
1390 | - } |
|
1358 | + if ( empty($limit) ) { |
|
1359 | + return ''; |
|
1360 | + } |
|
1361 | + |
|
1362 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1363 | + if ( is_numeric($limit) ) { |
|
1364 | + return ' LIMIT '. $limit; |
|
1365 | + } |
|
1366 | + |
|
1367 | + $limit = explode(',', trim($limit)); |
|
1368 | + foreach ( $limit as $k => $l ) { |
|
1369 | + if ( is_numeric( $l ) ) { |
|
1370 | + $limit[ $k ] = $l; |
|
1371 | + } |
|
1372 | + } |
|
1373 | + |
|
1374 | + $limit = implode(',', $limit); |
|
1375 | + return ' LIMIT '. $limit; |
|
1376 | + } |
|
1377 | + |
|
1378 | + /** |
|
1379 | + * Get an array of values ready to go through $wpdb->prepare |
|
1380 | + * @since 2.0 |
|
1381 | + */ |
|
1382 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
1383 | + $placeholders = array_fill(0, count($array), $type); |
|
1384 | + return implode(', ', $placeholders); |
|
1385 | + } |
|
1386 | + |
|
1387 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1388 | + if ( empty($where) ) { |
|
1389 | + return ''; |
|
1390 | + } |
|
1391 | 1391 | |
1392 | 1392 | if ( is_array( $where ) ) { |
1393 | - global $wpdb; |
|
1394 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1393 | + global $wpdb; |
|
1394 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1395 | 1395 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
1396 | 1396 | } else { |
1397 | - $where = $starts_with . $where; |
|
1398 | - } |
|
1397 | + $where = $starts_with . $where; |
|
1398 | + } |
|
1399 | 1399 | |
1400 | - return $where; |
|
1401 | - } |
|
1400 | + return $where; |
|
1401 | + } |
|
1402 | 1402 | |
1403 | - // Pagination Methods |
|
1403 | + // Pagination Methods |
|
1404 | 1404 | |
1405 | - /** |
|
1406 | - * @param integer $current_p |
|
1407 | - */ |
|
1405 | + /** |
|
1406 | + * @param integer $current_p |
|
1407 | + */ |
|
1408 | 1408 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
1409 | 1409 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
1410 | 1410 | } |
1411 | 1411 | |
1412 | - /** |
|
1413 | - * @param integer $current_p |
|
1414 | - */ |
|
1415 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1416 | - if ( $current_p == 1 ) { |
|
1417 | - return 1; |
|
1418 | - } else { |
|
1419 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1420 | - } |
|
1421 | - } |
|
1422 | - |
|
1423 | - /** |
|
1424 | - * @param string $table_name |
|
1425 | - */ |
|
1426 | - public static function &getRecordCount( $where = '', $table_name ) { |
|
1427 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1428 | - $count = FrmDb::get_count( $table_name, $where ); |
|
1429 | - return $count; |
|
1430 | - } |
|
1431 | - |
|
1432 | - public static function get_referer_info() { |
|
1433 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1434 | - return self::get_server_value('HTTP_REFERER'); |
|
1435 | - } |
|
1412 | + /** |
|
1413 | + * @param integer $current_p |
|
1414 | + */ |
|
1415 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1416 | + if ( $current_p == 1 ) { |
|
1417 | + return 1; |
|
1418 | + } else { |
|
1419 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1420 | + } |
|
1421 | + } |
|
1422 | + |
|
1423 | + /** |
|
1424 | + * @param string $table_name |
|
1425 | + */ |
|
1426 | + public static function &getRecordCount( $where = '', $table_name ) { |
|
1427 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1428 | + $count = FrmDb::get_count( $table_name, $where ); |
|
1429 | + return $count; |
|
1430 | + } |
|
1431 | + |
|
1432 | + public static function get_referer_info() { |
|
1433 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1434 | + return self::get_server_value('HTTP_REFERER'); |
|
1435 | + } |
|
1436 | 1436 | |
1437 | 1437 | /** |
1438 | 1438 | * @return array |
1439 | 1439 | */ |
1440 | 1440 | public static function json_to_array( $json_vars ) { |
1441 | - $vars = array(); |
|
1442 | - foreach ( $json_vars as $jv ) { |
|
1443 | - $jv_name = explode('[', $jv['name']); |
|
1444 | - $last = count($jv_name) - 1; |
|
1445 | - foreach ( $jv_name as $p => $n ) { |
|
1446 | - $name = trim($n, ']'); |
|
1447 | - if ( ! isset($l1) ) { |
|
1448 | - $l1 = $name; |
|
1449 | - } |
|
1450 | - |
|
1451 | - if ( ! isset($l2) ) { |
|
1452 | - $l2 = $name; |
|
1453 | - } |
|
1454 | - |
|
1455 | - if ( ! isset($l3) ) { |
|
1456 | - $l3 = $name; |
|
1457 | - } |
|
1458 | - |
|
1459 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1460 | - |
|
1461 | - switch ( $p ) { |
|
1462 | - case 0: |
|
1463 | - $l1 = $name; |
|
1464 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1465 | - break; |
|
1466 | - |
|
1467 | - case 1: |
|
1468 | - $l2 = $name; |
|
1469 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1470 | - break; |
|
1471 | - |
|
1472 | - case 2: |
|
1473 | - $l3 = $name; |
|
1474 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1475 | - break; |
|
1476 | - |
|
1477 | - case 3: |
|
1478 | - $l4 = $name; |
|
1479 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1480 | - break; |
|
1481 | - } |
|
1482 | - |
|
1483 | - unset($this_val, $n); |
|
1484 | - } |
|
1485 | - |
|
1486 | - unset($last, $jv); |
|
1487 | - } |
|
1488 | - |
|
1489 | - return $vars; |
|
1490 | - } |
|
1491 | - |
|
1492 | - /** |
|
1493 | - * @param string $name |
|
1494 | - * @param string $l1 |
|
1495 | - */ |
|
1496 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1497 | - if ( $name == '' ) { |
|
1498 | - $vars[] = $val; |
|
1499 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1500 | - $vars[ $l1 ] = $val; |
|
1501 | - } |
|
1502 | - } |
|
1441 | + $vars = array(); |
|
1442 | + foreach ( $json_vars as $jv ) { |
|
1443 | + $jv_name = explode('[', $jv['name']); |
|
1444 | + $last = count($jv_name) - 1; |
|
1445 | + foreach ( $jv_name as $p => $n ) { |
|
1446 | + $name = trim($n, ']'); |
|
1447 | + if ( ! isset($l1) ) { |
|
1448 | + $l1 = $name; |
|
1449 | + } |
|
1450 | + |
|
1451 | + if ( ! isset($l2) ) { |
|
1452 | + $l2 = $name; |
|
1453 | + } |
|
1454 | + |
|
1455 | + if ( ! isset($l3) ) { |
|
1456 | + $l3 = $name; |
|
1457 | + } |
|
1458 | + |
|
1459 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1460 | + |
|
1461 | + switch ( $p ) { |
|
1462 | + case 0: |
|
1463 | + $l1 = $name; |
|
1464 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1465 | + break; |
|
1466 | + |
|
1467 | + case 1: |
|
1468 | + $l2 = $name; |
|
1469 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1470 | + break; |
|
1471 | + |
|
1472 | + case 2: |
|
1473 | + $l3 = $name; |
|
1474 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1475 | + break; |
|
1476 | + |
|
1477 | + case 3: |
|
1478 | + $l4 = $name; |
|
1479 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1480 | + break; |
|
1481 | + } |
|
1482 | + |
|
1483 | + unset($this_val, $n); |
|
1484 | + } |
|
1485 | + |
|
1486 | + unset($last, $jv); |
|
1487 | + } |
|
1488 | + |
|
1489 | + return $vars; |
|
1490 | + } |
|
1491 | + |
|
1492 | + /** |
|
1493 | + * @param string $name |
|
1494 | + * @param string $l1 |
|
1495 | + */ |
|
1496 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1497 | + if ( $name == '' ) { |
|
1498 | + $vars[] = $val; |
|
1499 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1500 | + $vars[ $l1 ] = $val; |
|
1501 | + } |
|
1502 | + } |
|
1503 | 1503 | |
1504 | 1504 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
1505 | - $tooltips = array( |
|
1506 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1507 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1508 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1509 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1510 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1511 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1512 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1513 | - ); |
|
1514 | - |
|
1515 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1516 | - return; |
|
1517 | - } |
|
1518 | - |
|
1519 | - if ( 'open' == $class ) { |
|
1520 | - echo ' frm_help"'; |
|
1521 | - } else { |
|
1522 | - echo ' class="frm_help"'; |
|
1523 | - } |
|
1524 | - |
|
1525 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1526 | - |
|
1527 | - if ( 'open' != $class ) { |
|
1528 | - echo '"'; |
|
1529 | - } |
|
1530 | - } |
|
1505 | + $tooltips = array( |
|
1506 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1507 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1508 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1509 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1510 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1511 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1512 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1513 | + ); |
|
1514 | + |
|
1515 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
1516 | + return; |
|
1517 | + } |
|
1518 | + |
|
1519 | + if ( 'open' == $class ) { |
|
1520 | + echo ' frm_help"'; |
|
1521 | + } else { |
|
1522 | + echo ' class="frm_help"'; |
|
1523 | + } |
|
1524 | + |
|
1525 | + echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1526 | + |
|
1527 | + if ( 'open' != $class ) { |
|
1528 | + echo '"'; |
|
1529 | + } |
|
1530 | + } |
|
1531 | 1531 | |
1532 | 1532 | /** |
1533 | 1533 | * Add the current_page class to that page in the form nav |
@@ -1543,35 +1543,35 @@ discard block |
||
1543 | 1543 | } |
1544 | 1544 | } |
1545 | 1545 | |
1546 | - /** |
|
1547 | - * Prepare and json_encode post content |
|
1548 | - * |
|
1549 | - * @since 2.0 |
|
1550 | - * |
|
1551 | - * @param array $post_content |
|
1552 | - * @return string $post_content ( json encoded array ) |
|
1553 | - */ |
|
1554 | - public static function prepare_and_encode( $post_content ) { |
|
1555 | - //Loop through array to strip slashes and add only the needed ones |
|
1546 | + /** |
|
1547 | + * Prepare and json_encode post content |
|
1548 | + * |
|
1549 | + * @since 2.0 |
|
1550 | + * |
|
1551 | + * @param array $post_content |
|
1552 | + * @return string $post_content ( json encoded array ) |
|
1553 | + */ |
|
1554 | + public static function prepare_and_encode( $post_content ) { |
|
1555 | + //Loop through array to strip slashes and add only the needed ones |
|
1556 | 1556 | foreach ( $post_content as $key => $val ) { |
1557 | 1557 | // Replace problematic characters (like ") |
1558 | 1558 | $val = str_replace( '"', '"', $val ); |
1559 | 1559 | |
1560 | 1560 | self::prepare_action_slashes( $val, $key, $post_content ); |
1561 | - unset( $key, $val ); |
|
1562 | - } |
|
1561 | + unset( $key, $val ); |
|
1562 | + } |
|
1563 | 1563 | |
1564 | - // json_encode the array |
|
1565 | - $post_content = json_encode( $post_content ); |
|
1564 | + // json_encode the array |
|
1565 | + $post_content = json_encode( $post_content ); |
|
1566 | 1566 | |
1567 | - // add extra slashes for \r\n since WP strips them |
|
1567 | + // add extra slashes for \r\n since WP strips them |
|
1568 | 1568 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
1569 | 1569 | |
1570 | - // allow for " |
|
1571 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
1570 | + // allow for " |
|
1571 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
1572 | 1572 | |
1573 | - return $post_content; |
|
1574 | - } |
|
1573 | + return $post_content; |
|
1574 | + } |
|
1575 | 1575 | |
1576 | 1576 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1577 | 1577 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1639,64 +1639,64 @@ discard block |
||
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | public static function maybe_json_decode( $string ) { |
1642 | - if ( is_array($string) ) { |
|
1643 | - return $string; |
|
1644 | - } |
|
1642 | + if ( is_array($string) ) { |
|
1643 | + return $string; |
|
1644 | + } |
|
1645 | 1645 | |
1646 | - $new_string = json_decode($string, true); |
|
1647 | - if ( function_exists('json_last_error') ) { |
|
1646 | + $new_string = json_decode($string, true); |
|
1647 | + if ( function_exists('json_last_error') ) { |
|
1648 | 1648 | // php 5.3+ |
1649 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1650 | - $string = $new_string; |
|
1651 | - } |
|
1652 | - } else if ( isset($new_string) ) { |
|
1649 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1650 | + $string = $new_string; |
|
1651 | + } |
|
1652 | + } else if ( isset($new_string) ) { |
|
1653 | 1653 | // php < 5.3 fallback |
1654 | - $string = $new_string; |
|
1655 | - } |
|
1656 | - return $string; |
|
1657 | - } |
|
1658 | - |
|
1659 | - /** |
|
1660 | - * @since 1.07.10 |
|
1661 | - * |
|
1662 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
1663 | - * @return echo The javascript to open and highlight the Formidable menu |
|
1664 | - */ |
|
1654 | + $string = $new_string; |
|
1655 | + } |
|
1656 | + return $string; |
|
1657 | + } |
|
1658 | + |
|
1659 | + /** |
|
1660 | + * @since 1.07.10 |
|
1661 | + * |
|
1662 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
1663 | + * @return echo The javascript to open and highlight the Formidable menu |
|
1664 | + */ |
|
1665 | 1665 | public static function maybe_highlight_menu( $post_type ) { |
1666 | - global $post, $pagenow; |
|
1666 | + global $post, $pagenow; |
|
1667 | 1667 | |
1668 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1669 | - return; |
|
1670 | - } |
|
1668 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1669 | + return; |
|
1670 | + } |
|
1671 | 1671 | |
1672 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1673 | - return; |
|
1674 | - } |
|
1672 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
1673 | + return; |
|
1674 | + } |
|
1675 | 1675 | |
1676 | - self::load_admin_wide_js(); |
|
1677 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1678 | - } |
|
1676 | + self::load_admin_wide_js(); |
|
1677 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1678 | + } |
|
1679 | 1679 | |
1680 | - /** |
|
1681 | - * Load the JS file on non-Formidable pages in the admin area |
|
1682 | - * @since 2.0 |
|
1683 | - */ |
|
1680 | + /** |
|
1681 | + * Load the JS file on non-Formidable pages in the admin area |
|
1682 | + * @since 2.0 |
|
1683 | + */ |
|
1684 | 1684 | public static function load_admin_wide_js( $load = true ) { |
1685 | - $version = FrmAppHelper::plugin_version(); |
|
1685 | + $version = FrmAppHelper::plugin_version(); |
|
1686 | 1686 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
1687 | 1687 | |
1688 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1688 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1689 | 1689 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
1690 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1690 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1691 | 1691 | 'url' => FrmAppHelper::plugin_url(), |
1692 | 1692 | 'loading' => __( 'Loading…' ), |
1693 | 1693 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
1694 | - ) ); |
|
1694 | + ) ); |
|
1695 | 1695 | |
1696 | 1696 | if ( $load ) { |
1697 | 1697 | wp_enqueue_script( 'formidable_admin_global' ); |
1698 | 1698 | } |
1699 | - } |
|
1699 | + } |
|
1700 | 1700 | |
1701 | 1701 | /** |
1702 | 1702 | * @since 2.0.9 |
@@ -1705,9 +1705,9 @@ discard block |
||
1705 | 1705 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - /** |
|
1709 | - * @param string $location |
|
1710 | - */ |
|
1708 | + /** |
|
1709 | + * @param string $location |
|
1710 | + */ |
|
1711 | 1711 | public static function localize_script( $location ) { |
1712 | 1712 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
1713 | 1713 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1757,81 +1757,81 @@ discard block |
||
1757 | 1757 | } |
1758 | 1758 | } |
1759 | 1759 | |
1760 | - /** |
|
1761 | - * @since 1.07.10 |
|
1762 | - * |
|
1763 | - * @param float $min_version The version the add-on requires |
|
1764 | - * @return echo The message on the plugins listing page |
|
1765 | - */ |
|
1760 | + /** |
|
1761 | + * @since 1.07.10 |
|
1762 | + * |
|
1763 | + * @param float $min_version The version the add-on requires |
|
1764 | + * @return echo The message on the plugins listing page |
|
1765 | + */ |
|
1766 | 1766 | public static function min_version_notice( $min_version ) { |
1767 | - $frm_version = self::plugin_version(); |
|
1767 | + $frm_version = self::plugin_version(); |
|
1768 | 1768 | |
1769 | - // check if Formidable meets minimum requirements |
|
1770 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1771 | - return; |
|
1772 | - } |
|
1769 | + // check if Formidable meets minimum requirements |
|
1770 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1771 | + return; |
|
1772 | + } |
|
1773 | 1773 | |
1774 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1774 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1775 | 1775 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
1776 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1777 | - '</div></td></tr>'; |
|
1778 | - } |
|
1779 | - |
|
1780 | - public static function locales( $type = 'date' ) { |
|
1781 | - $locales = array( |
|
1782 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1783 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1784 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1785 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1786 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1787 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1788 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1789 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1790 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1791 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1792 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1793 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1794 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1795 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1796 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1797 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1798 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1799 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1800 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1801 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1802 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1803 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1804 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1805 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1806 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1807 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1808 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1809 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1810 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1811 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1812 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1813 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1814 | - ); |
|
1815 | - |
|
1816 | - if ( $type == 'captcha' ) { |
|
1817 | - // remove the languages unavailable for the captcha |
|
1818 | - $unset = array( |
|
1819 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1820 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1821 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1822 | - ); |
|
1823 | - } else { |
|
1824 | - // remove the languages unavailable for the datepicker |
|
1825 | - $unset = array( |
|
1826 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1827 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1828 | - 'es-419', 'tr', |
|
1829 | - ); |
|
1830 | - } |
|
1831 | - |
|
1832 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1833 | - $locales = apply_filters('frm_locales', $locales); |
|
1834 | - |
|
1835 | - return $locales; |
|
1836 | - } |
|
1776 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1777 | + '</div></td></tr>'; |
|
1778 | + } |
|
1779 | + |
|
1780 | + public static function locales( $type = 'date' ) { |
|
1781 | + $locales = array( |
|
1782 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1783 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1784 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1785 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1786 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1787 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1788 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1789 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1790 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1791 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1792 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1793 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1794 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1795 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1796 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1797 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1798 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1799 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1800 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1801 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1802 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1803 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1804 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1805 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1806 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1807 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1808 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1809 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1810 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1811 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1812 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1813 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1814 | + ); |
|
1815 | + |
|
1816 | + if ( $type == 'captcha' ) { |
|
1817 | + // remove the languages unavailable for the captcha |
|
1818 | + $unset = array( |
|
1819 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1820 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1821 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1822 | + ); |
|
1823 | + } else { |
|
1824 | + // remove the languages unavailable for the datepicker |
|
1825 | + $unset = array( |
|
1826 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1827 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1828 | + 'es-419', 'tr', |
|
1829 | + ); |
|
1830 | + } |
|
1831 | + |
|
1832 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
1833 | + $locales = apply_filters('frm_locales', $locales); |
|
1834 | + |
|
1835 | + return $locales; |
|
1836 | + } |
|
1837 | 1837 | } |
@@ -57,6 +57,9 @@ discard block |
||
57 | 57 | return get_option('blogname'); |
58 | 58 | } |
59 | 59 | |
60 | + /** |
|
61 | + * @param string $url |
|
62 | + */ |
|
60 | 63 | public static function make_affiliate_url( $url ) { |
61 | 64 | $affiliate_id = apply_filters( 'frm_affiliate_link', '' ); |
62 | 65 | $allowed_affiliates = array('Mojo'); |
@@ -752,6 +755,9 @@ discard block |
||
752 | 755 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
753 | 756 | } |
754 | 757 | |
758 | + /** |
|
759 | + * @param string $function |
|
760 | + */ |
|
755 | 761 | public static function recursive_function_map( $value, $function ) { |
756 | 762 | if ( is_array( $value ) ) { |
757 | 763 | $original_function = $function; |
@@ -1179,6 +1185,9 @@ discard block |
||
1179 | 1185 | return $sub . (($len < $original_len) ? $continue : ''); |
1180 | 1186 | } |
1181 | 1187 | |
1188 | + /** |
|
1189 | + * @param string[] $function_names |
|
1190 | + */ |
|
1182 | 1191 | public static function mb_function( $function_names, $args ) { |
1183 | 1192 | $mb_function_name = $function_names[0]; |
1184 | 1193 | $function_name = $function_names[1]; |
@@ -1212,6 +1221,9 @@ discard block |
||
1212 | 1221 | return $formatted; |
1213 | 1222 | } |
1214 | 1223 | |
1224 | + /** |
|
1225 | + * @param string $time_format |
|
1226 | + */ |
|
1215 | 1227 | private static function add_time_to_date( $time_format, $date ) { |
1216 | 1228 | if ( empty( $time_format ) ) { |
1217 | 1229 | $time_format = get_option('time_format'); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function plugin_folder() { |
26 | - return basename(self::plugin_path()); |
|
26 | + return basename( self::plugin_path() ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function plugin_path() { |
30 | - return dirname(dirname(dirname(__FILE__))); |
|
30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public static function plugin_url() { |
34 | 34 | //prevously FRM_URL constant |
35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
35 | + return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public static function relative_plugin_url() { |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public static function site_name() { |
57 | - return get_option('blogname'); |
|
57 | + return get_option( 'blogname' ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function make_affiliate_url( $url ) { |
61 | 61 | $affiliate_id = apply_filters( 'frm_affiliate_link', '' ); |
62 | - $allowed_affiliates = array('Mojo'); |
|
62 | + $allowed_affiliates = array( 'Mojo' ); |
|
63 | 63 | if ( in_array( $affiliate_id, $allowed_affiliates ) ) { |
64 | 64 | $url .= '?aff=' . $affiliate_id; |
65 | 65 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public static function get_settings() { |
78 | 78 | global $frm_settings; |
79 | - if ( empty($frm_settings) ) { |
|
79 | + if ( empty( $frm_settings ) ) { |
|
80 | 80 | $frm_settings = new FrmSettings(); |
81 | 81 | } |
82 | 82 | return $frm_settings; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | public static function pro_is_installed() { |
95 | - return apply_filters('frm_pro_installed', false); |
|
95 | + return apply_filters( 'frm_pro_installed', false ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @return boolean |
137 | 137 | */ |
138 | 138 | public static function doing_ajax() { |
139 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
139 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @return boolean |
157 | 157 | */ |
158 | 158 | public static function is_admin() { |
159 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
159 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return string |
183 | 183 | */ |
184 | 184 | public static function get_server_value( $value ) { |
185 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
185 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
198 | 198 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
199 | 199 | ) as $key ) { |
200 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
200 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
201 | 201 | continue; |
202 | 202 | } |
203 | 203 | |
204 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
205 | - $ip = trim($ip); // just to be safe |
|
204 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
205 | + $ip = trim( $ip ); // just to be safe |
|
206 | 206 | |
207 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
207 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
208 | 208 | return $ip; |
209 | 209 | } |
210 | 210 | } |
@@ -214,15 +214,15 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
217 | - if ( strpos($param, '[') ) { |
|
218 | - $params = explode('[', $param); |
|
217 | + if ( strpos( $param, '[' ) ) { |
|
218 | + $params = explode( '[', $param ); |
|
219 | 219 | $param = $params[0]; |
220 | 220 | } |
221 | 221 | |
222 | 222 | if ( $src == 'get' ) { |
223 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
224 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
225 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
223 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
224 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
225 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); |
|
226 | 226 | } |
227 | 227 | self::sanitize_value( $sanitize, $value ); |
228 | 228 | } else { |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | |
232 | 232 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
233 | 233 | foreach ( $params as $k => $p ) { |
234 | - if ( ! $k || ! is_array($value) ) { |
|
234 | + if ( ! $k || ! is_array( $value ) ) { |
|
235 | 235 | continue; |
236 | 236 | } |
237 | 237 | |
238 | - $p = trim($p, ']'); |
|
239 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
238 | + $p = trim( $p, ']' ); |
|
239 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
@@ -278,16 +278,16 @@ discard block |
||
278 | 278 | |
279 | 279 | $value = $args['default']; |
280 | 280 | if ( $args['type'] == 'get' ) { |
281 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
282 | - $value = $_GET[ $args['param'] ]; |
|
281 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
282 | + $value = $_GET[$args['param']]; |
|
283 | 283 | } |
284 | 284 | } else if ( $args['type'] == 'post' ) { |
285 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
286 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
285 | + if ( isset( $_POST[$args['param']] ) ) { |
|
286 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
287 | 287 | } |
288 | 288 | } else { |
289 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
290 | - $value = $_REQUEST[ $args['param'] ]; |
|
289 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
290 | + $value = $_REQUEST[$args['param']]; |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | public static function sanitize_request( $sanitize_method, &$values ) { |
324 | 324 | $temp_values = $values; |
325 | 325 | foreach ( $temp_values as $k => $val ) { |
326 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
327 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
326 | + if ( isset( $sanitize_method[$k] ) ) { |
|
327 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public static function sanitize_array( &$values ) { |
333 | 333 | $temp_values = $values; |
334 | 334 | foreach ( $temp_values as $k => $val ) { |
335 | - $values[ $k ] = wp_kses_post( $val ); |
|
335 | + $values[$k] = wp_kses_post( $val ); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | $allowed_html = array(); |
354 | 354 | foreach ( $allowed as $a ) { |
355 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
355 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return wp_kses( $value, $allowed_html ); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @since 2.0 |
364 | 364 | */ |
365 | 365 | public static function remove_get_action() { |
366 | - if ( ! isset($_GET) ) { |
|
366 | + if ( ! isset( $_GET ) ) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | global $wp_query; |
388 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
389 | - $value = $wp_query->query_vars[ $param ]; |
|
388 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
389 | + $value = $wp_query->query_vars[$param]; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | return $value; |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public static function trigger_hook_load( $type, $object = null ) { |
399 | 399 | // only load the form hooks once |
400 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
400 | + $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
|
401 | 401 | if ( ! $hooks_loaded ) { |
402 | - do_action('frm_load_'. $type .'_hooks'); |
|
402 | + do_action( 'frm_load_' . $type . '_hooks' ); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -415,16 +415,16 @@ discard block |
||
415 | 415 | * @return mixed $results The cache or query results |
416 | 416 | */ |
417 | 417 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
418 | - $results = wp_cache_get($cache_key, $group); |
|
419 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
418 | + $results = wp_cache_get( $cache_key, $group ); |
|
419 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
420 | 420 | return $results; |
421 | 421 | } |
422 | 422 | |
423 | 423 | if ( 'get_posts' == $type ) { |
424 | - $results = get_posts($query); |
|
424 | + $results = get_posts( $query ); |
|
425 | 425 | } else { |
426 | 426 | global $wpdb; |
427 | - $results = $wpdb->{$type}($query); |
|
427 | + $results = $wpdb->{$type}( $query ); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | if ( ! self::prevent_caching() ) { |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | } |
449 | 449 | |
450 | 450 | // then check the transient |
451 | - $results = get_transient($cache_key); |
|
451 | + $results = get_transient( $cache_key ); |
|
452 | 452 | if ( $results ) { |
453 | - wp_cache_set($cache_key, $results); |
|
453 | + wp_cache_set( $cache_key, $results ); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | return $results; |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * @param string $cache_key |
462 | 462 | */ |
463 | 463 | public static function delete_cache_and_transient( $cache_key ) { |
464 | - delete_transient($cache_key); |
|
465 | - wp_cache_delete($cache_key); |
|
464 | + delete_transient( $cache_key ); |
|
465 | + wp_cache_delete( $cache_key ); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -476,9 +476,9 @@ discard block |
||
476 | 476 | public static function cache_delete_group( $group ) { |
477 | 477 | global $wp_object_cache; |
478 | 478 | |
479 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
480 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
481 | - wp_cache_delete($k, $group); |
|
479 | + if ( isset( $wp_object_cache->cache[$group] ) ) { |
|
480 | + foreach ( $wp_object_cache->cache[$group] as $k => $v ) { |
|
481 | + wp_cache_delete( $k, $group ); |
|
482 | 482 | } |
483 | 483 | return true; |
484 | 484 | } |
@@ -509,29 +509,29 @@ discard block |
||
509 | 509 | public static function load_scripts( $scripts ) { |
510 | 510 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
511 | 511 | foreach ( (array) $scripts as $s ) { |
512 | - wp_enqueue_script($s); |
|
512 | + wp_enqueue_script( $s ); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | 516 | public static function load_styles( $styles ) { |
517 | 517 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
518 | 518 | foreach ( (array) $styles as $s ) { |
519 | - wp_enqueue_style($s); |
|
519 | + wp_enqueue_style( $s ); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | 523 | public static function get_pages() { |
524 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
524 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
528 | 528 | $pages = self::get_pages(); |
529 | 529 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
530 | 530 | ?> |
531 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
531 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
532 | 532 | <option value=""> </option> |
533 | 533 | <?php foreach ( $pages as $page ) { ?> |
534 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
534 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
535 | 535 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
536 | 536 | </option> |
537 | 537 | <?php } ?> |
@@ -540,26 +540,26 @@ discard block |
||
540 | 540 | } |
541 | 541 | |
542 | 542 | public static function post_edit_link( $post_id ) { |
543 | - $post = get_post($post_id); |
|
543 | + $post = get_post( $post_id ); |
|
544 | 544 | if ( $post ) { |
545 | - return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
545 | + return '<a href="' . esc_url( admin_url( 'post.php' ) . '?post=' . $post_id . '&action=edit' ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
|
546 | 546 | } |
547 | 547 | return ''; |
548 | 548 | } |
549 | 549 | |
550 | 550 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
551 | 551 | ?> |
552 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
552 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
553 | 553 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
554 | 554 | ?> class="frm_multiselect"> |
555 | - <?php self::roles_options($capability); ?> |
|
555 | + <?php self::roles_options( $capability ); ?> |
|
556 | 556 | </select> |
557 | 557 | <?php |
558 | 558 | } |
559 | 559 | |
560 | 560 | public static function roles_options( $capability ) { |
561 | 561 | global $frm_vars; |
562 | - if ( isset($frm_vars['editable_roles']) ) { |
|
562 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
563 | 563 | $editable_roles = $frm_vars['editable_roles']; |
564 | 564 | } else { |
565 | 565 | $editable_roles = get_editable_roles(); |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | foreach ( $editable_roles as $role => $details ) { |
570 | - $name = translate_user_role($details['name'] ); ?> |
|
571 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
570 | + $name = translate_user_role( $details['name'] ); ?> |
|
571 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
572 | 572 | <?php |
573 | - unset($role, $details); |
|
573 | + unset( $role, $details ); |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | public static function maybe_add_permissions() { |
627 | 627 | self::force_capability( 'frm_view_entries' ); |
628 | 628 | |
629 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
629 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $frm_roles = self::frm_capabilities(); |
636 | 636 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
637 | 637 | $user->add_cap( $frm_role ); |
638 | - unset($frm_role, $frm_role_description); |
|
638 | + unset( $frm_role, $frm_role_description ); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -660,12 +660,12 @@ discard block |
||
660 | 660 | * @param string $permission |
661 | 661 | */ |
662 | 662 | public static function permission_check( $permission, $show_message = 'show' ) { |
663 | - $permission_error = self::permission_nonce_error($permission); |
|
663 | + $permission_error = self::permission_nonce_error( $permission ); |
|
664 | 664 | if ( $permission_error !== false ) { |
665 | 665 | if ( 'hide' == $show_message ) { |
666 | 666 | $permission_error = ''; |
667 | 667 | } |
668 | - wp_die($permission_error); |
|
668 | + wp_die( $permission_error ); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | |
@@ -682,11 +682,11 @@ discard block |
||
682 | 682 | } |
683 | 683 | |
684 | 684 | $error = false; |
685 | - if ( empty($nonce_name) ) { |
|
685 | + if ( empty( $nonce_name ) ) { |
|
686 | 686 | return $error; |
687 | 687 | } |
688 | 688 | |
689 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
689 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
690 | 690 | $frm_settings = self::get_settings(); |
691 | 691 | $error = $frm_settings->admin_permission; |
692 | 692 | } |
@@ -702,9 +702,9 @@ discard block |
||
702 | 702 | |
703 | 703 | public static function check_selected( $values, $current ) { |
704 | 704 | $values = self::recursive_function_map( $values, 'trim' ); |
705 | - $current = trim($current); |
|
705 | + $current = trim( $current ); |
|
706 | 706 | |
707 | - return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
707 | + return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | } else { |
766 | 766 | foreach ( $value as $k => $v ) { |
767 | 767 | if ( ! is_array( $v ) ) { |
768 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
768 | + $value[$k] = call_user_func( $original_function, $v ); |
|
769 | 769 | } |
770 | 770 | } |
771 | 771 | } |
@@ -786,11 +786,11 @@ discard block |
||
786 | 786 | public static function array_flatten( $array, $keys = 'keep' ) { |
787 | 787 | $return = array(); |
788 | 788 | foreach ( $array as $key => $value ) { |
789 | - if ( is_array($value) ) { |
|
789 | + if ( is_array( $value ) ) { |
|
790 | 790 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
791 | 791 | } else { |
792 | 792 | if ( $keys == 'keep' ) { |
793 | - $return[ $key ] = $value; |
|
793 | + $return[$key] = $value; |
|
794 | 794 | } else { |
795 | 795 | $return[] = $value; |
796 | 796 | } |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | } |
801 | 801 | |
802 | 802 | public static function esc_textarea( $text ) { |
803 | - $safe_text = str_replace('"', '"', $text); |
|
803 | + $safe_text = str_replace( '"', '"', $text ); |
|
804 | 804 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
805 | 805 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
806 | 806 | } |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @since 2.0 |
811 | 811 | */ |
812 | 812 | public static function use_wpautop( $content ) { |
813 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
814 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
813 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
814 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
815 | 815 | } |
816 | 816 | return $content; |
817 | 817 | } |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | * @return string The base Google APIS url for the current version of jQuery UI |
830 | 830 | */ |
831 | 831 | public static function jquery_ui_base_url() { |
832 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
833 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
832 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
833 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
834 | 834 | return $url; |
835 | 835 | } |
836 | 836 | |
@@ -845,11 +845,11 @@ discard block |
||
845 | 845 | |
846 | 846 | $ver = 0; |
847 | 847 | |
848 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
848 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
849 | 849 | return $ver; |
850 | 850 | } |
851 | 851 | |
852 | - $query = $wp_scripts->registered[ $handle ]; |
|
852 | + $query = $wp_scripts->registered[$handle]; |
|
853 | 853 | if ( is_object( $query ) ) { |
854 | 854 | $ver = $query->ver; |
855 | 855 | } |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | } |
863 | 863 | |
864 | 864 | public static function get_user_id_param( $user_id ) { |
865 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
865 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
866 | 866 | return $user_id; |
867 | 867 | } |
868 | 868 | |
@@ -870,29 +870,29 @@ discard block |
||
870 | 870 | $user_ID = get_current_user_id(); |
871 | 871 | $user_id = $user_ID; |
872 | 872 | } else { |
873 | - if ( is_email($user_id) ) { |
|
874 | - $user = get_user_by('email', $user_id); |
|
873 | + if ( is_email( $user_id ) ) { |
|
874 | + $user = get_user_by( 'email', $user_id ); |
|
875 | 875 | } else { |
876 | - $user = get_user_by('login', $user_id); |
|
876 | + $user = get_user_by( 'login', $user_id ); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | if ( $user ) { |
880 | 880 | $user_id = $user->ID; |
881 | 881 | } |
882 | - unset($user); |
|
882 | + unset( $user ); |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | return $user_id; |
886 | 886 | } |
887 | 887 | |
888 | 888 | public static function get_file_contents( $filename, $atts = array() ) { |
889 | - if ( ! is_file($filename) ) { |
|
889 | + if ( ! is_file( $filename ) ) { |
|
890 | 890 | return false; |
891 | 891 | } |
892 | 892 | |
893 | - extract($atts); |
|
893 | + extract( $atts ); |
|
894 | 894 | ob_start(); |
895 | - include($filename); |
|
895 | + include( $filename ); |
|
896 | 896 | $contents = ob_get_contents(); |
897 | 897 | ob_end_clean(); |
898 | 898 | return $contents; |
@@ -908,28 +908,28 @@ discard block |
||
908 | 908 | $key = ''; |
909 | 909 | |
910 | 910 | if ( ! empty( $name ) ) { |
911 | - $key = sanitize_key($name); |
|
911 | + $key = sanitize_key( $name ); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | if ( empty( $key ) ) { |
915 | - $max_slug_value = pow(36, $num_chars); |
|
915 | + $max_slug_value = pow( 36, $num_chars ); |
|
916 | 916 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
917 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
917 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
918 | 918 | } |
919 | 919 | |
920 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
921 | - $key = $key .'a'; |
|
920 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
921 | + $key = $key . 'a'; |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
925 | 925 | |
926 | - if ( $key_check || is_numeric($key_check) ) { |
|
926 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
927 | 927 | $suffix = 2; |
928 | 928 | do { |
929 | 929 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
930 | 930 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
931 | - $suffix++; |
|
932 | - } while ($key_check || is_numeric($key_check)); |
|
931 | + $suffix ++; |
|
932 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
933 | 933 | $key = $alt_post_name; |
934 | 934 | } |
935 | 935 | return $key; |
@@ -947,32 +947,32 @@ discard block |
||
947 | 947 | |
948 | 948 | global $frm_vars; |
949 | 949 | |
950 | - if ( empty($post_values) ) { |
|
951 | - $post_values = stripslashes_deep($_POST); |
|
950 | + if ( empty( $post_values ) ) { |
|
951 | + $post_values = stripslashes_deep( $_POST ); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | $values = array( 'id' => $record->id, 'fields' => array() ); |
955 | 955 | |
956 | 956 | foreach ( array( 'name', 'description' ) as $var ) { |
957 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
958 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
959 | - unset($var, $default_val); |
|
957 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
958 | + $values[$var] = self::get_param( $var, $default_val ); |
|
959 | + unset( $var, $default_val ); |
|
960 | 960 | } |
961 | 961 | |
962 | - $values['description'] = self::use_wpautop($values['description']); |
|
962 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
963 | 963 | $frm_settings = self::get_settings(); |
964 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
964 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
965 | 965 | |
966 | 966 | foreach ( (array) $fields as $field ) { |
967 | 967 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
968 | 968 | if ( ! $is_form_builder ) { |
969 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
969 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
970 | 970 | } |
971 | 971 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
972 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
972 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
973 | 973 | } |
974 | 974 | |
975 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
975 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
976 | 976 | |
977 | 977 | if ( $table == 'entries' ) { |
978 | 978 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -989,8 +989,8 @@ discard block |
||
989 | 989 | if ( $args['default'] ) { |
990 | 990 | $meta_value = $field->default_value; |
991 | 991 | } else { |
992 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
993 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
992 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
993 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
994 | 994 | $field->field_options['custom_field'] = ''; |
995 | 995 | } |
996 | 996 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | |
1002 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
1003 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1002 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1003 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1004 | 1004 | |
1005 | 1005 | $field_array = array( |
1006 | 1006 | 'id' => $field->id, |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | 'default_value' => $field->default_value, |
1009 | 1009 | 'name' => $field->name, |
1010 | 1010 | 'description' => $field->description, |
1011 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1011 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1012 | 1012 | 'options' => $field->options, |
1013 | 1013 | 'required' => $field->required, |
1014 | 1014 | 'field_key' => $field->field_key, |
@@ -1018,38 +1018,38 @@ discard block |
||
1018 | 1018 | ); |
1019 | 1019 | |
1020 | 1020 | $args['field_type'] = $field_type; |
1021 | - self::fill_field_opts($field, $field_array, $args); |
|
1021 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1022 | 1022 | |
1023 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1023 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] ); |
|
1024 | 1024 | |
1025 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1025 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1026 | 1026 | $field_array['unique_msg'] = ''; |
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | $field_array = array_merge( $field->field_options, $field_array ); |
1030 | 1030 | |
1031 | - $values['fields'][ $field->id ] = $field_array; |
|
1031 | + $values['fields'][$field->id] = $field_array; |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1035 | 1035 | $post_values = $args['post_values']; |
1036 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1036 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1037 | 1037 | |
1038 | 1038 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1039 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1040 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1041 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1042 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1039 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
1040 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1041 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1042 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1043 | 1043 | if ( $args['field_type'] == 'captcha' ) { |
1044 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1044 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1045 | 1045 | } else { |
1046 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1046 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1047 | 1047 | } |
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | if ( $field_array['custom_html'] == '' ) { |
1052 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1052 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1053 | 1053 | } |
1054 | 1054 | } |
1055 | 1055 | |
@@ -1068,18 +1068,18 @@ discard block |
||
1068 | 1068 | return; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1071 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1072 | 1072 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1073 | 1073 | |
1074 | - if ( ! is_array($form->options) ) { |
|
1074 | + if ( ! is_array( $form->options ) ) { |
|
1075 | 1075 | return; |
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | foreach ( $form->options as $opt => $value ) { |
1079 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1079 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | - self::fill_form_defaults($post_values, $values); |
|
1082 | + self::fill_form_defaults( $post_values, $values ); |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | /** |
@@ -1089,23 +1089,23 @@ discard block |
||
1089 | 1089 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1090 | 1090 | |
1091 | 1091 | foreach ( $form_defaults as $opt => $default ) { |
1092 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1093 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1092 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1093 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - unset($opt, $defaut); |
|
1096 | + unset( $opt, $defaut ); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | - if ( ! isset($values['custom_style']) ) { |
|
1099 | + if ( ! isset( $values['custom_style'] ) ) { |
|
1100 | 1100 | $frm_settings = self::get_settings(); |
1101 | 1101 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1105 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1106 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1105 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1106 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1107 | 1107 | } |
1108 | - unset($h); |
|
1108 | + unset( $h ); |
|
1109 | 1109 | } |
1110 | 1110 | } |
1111 | 1111 | |
@@ -1121,9 +1121,9 @@ discard block |
||
1121 | 1121 | } |
1122 | 1122 | ?> |
1123 | 1123 | <li> |
1124 | - <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1125 | - <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
|
1126 | - <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
|
1124 | + <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1125 | + <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a> |
|
1126 | + <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a> |
|
1127 | 1127 | </li> |
1128 | 1128 | <?php |
1129 | 1129 | } |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | return ''; |
1152 | 1152 | } else if ( $length <= 10 ) { |
1153 | 1153 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1154 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1154 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | $sub = ''; |
@@ -1160,23 +1160,23 @@ discard block |
||
1160 | 1160 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1161 | 1161 | |
1162 | 1162 | foreach ( $words as $word ) { |
1163 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1163 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
1164 | 1164 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1165 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1165 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1166 | 1166 | break; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | $sub .= $part; |
1170 | 1170 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1171 | 1171 | |
1172 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1172 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1173 | 1173 | break; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - unset($total_len, $word); |
|
1176 | + unset( $total_len, $word ); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1179 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | public static function mb_function( $function_names, $args ) { |
@@ -1189,17 +1189,17 @@ discard block |
||
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1192 | - if ( empty($date) ) { |
|
1192 | + if ( empty( $date ) ) { |
|
1193 | 1193 | return $date; |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - if ( empty($date_format) ) { |
|
1197 | - $date_format = get_option('date_format'); |
|
1196 | + if ( empty( $date_format ) ) { |
|
1197 | + $date_format = get_option( 'date_format' ); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1200 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1201 | 1201 | $frmpro_settings = new FrmProSettings(); |
1202 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1202 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | |
1215 | 1215 | private static function add_time_to_date( $time_format, $date ) { |
1216 | 1216 | if ( empty( $time_format ) ) { |
1217 | - $time_format = get_option('time_format'); |
|
1217 | + $time_format = get_option( 'time_format' ); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | $trimmed_format = trim( $time_format ); |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * @return string The time ago in words |
1239 | 1239 | */ |
1240 | 1240 | public static function human_time_diff( $from, $to = '' ) { |
1241 | - if ( empty($to) ) { |
|
1241 | + if ( empty( $to ) ) { |
|
1242 | 1242 | $to = time(); |
1243 | 1243 | } |
1244 | 1244 | |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | ); |
1255 | 1255 | |
1256 | 1256 | // Difference in seconds |
1257 | - $diff = (int) ($to - $from); |
|
1257 | + $diff = (int) ( $to - $from ); |
|
1258 | 1258 | |
1259 | 1259 | // Something went wrong with date calculation and we ended up with a negative date. |
1260 | 1260 | if ( $diff < 1 ) { |
@@ -1271,17 +1271,17 @@ discard block |
||
1271 | 1271 | $count = 0; |
1272 | 1272 | |
1273 | 1273 | //Step one: the first chunk |
1274 | - for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) { |
|
1275 | - $seconds = $chunks[ $i ][0]; |
|
1274 | + for ( $i = 0, $j = count( $chunks ); $i < $j; $i ++ ) { |
|
1275 | + $seconds = $chunks[$i][0]; |
|
1276 | 1276 | |
1277 | 1277 | // Finding the biggest chunk (if the chunk fits, break) |
1278 | - if ( ( $count = floor($diff / $seconds) ) != 0 ) { |
|
1278 | + if ( ( $count = floor( $diff / $seconds ) ) != 0 ) { |
|
1279 | 1279 | break; |
1280 | 1280 | } |
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | // Set output var |
1284 | - $output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2]; |
|
1284 | + $output = ( 1 == $count ) ? '1 ' . $chunks[$i][1] : $count . ' ' . $chunks[$i][2]; |
|
1285 | 1285 | |
1286 | 1286 | if ( ! (int) trim( $output ) ) { |
1287 | 1287 | $output = '0 ' . __( 'seconds', 'formidable' ); |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | */ |
1301 | 1301 | public static function esc_like( $term ) { |
1302 | 1302 | global $wpdb; |
1303 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1303 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1304 | 1304 | // WP 4.0 |
1305 | 1305 | $term = $wpdb->esc_like( $term ); |
1306 | 1306 | } else { |
@@ -1314,17 +1314,17 @@ discard block |
||
1314 | 1314 | * @param string $order_query |
1315 | 1315 | */ |
1316 | 1316 | public static function esc_order( $order_query ) { |
1317 | - if ( empty($order_query) ) { |
|
1317 | + if ( empty( $order_query ) ) { |
|
1318 | 1318 | return ''; |
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | // remove ORDER BY before santizing |
1322 | - $order_query = strtolower($order_query); |
|
1323 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1324 | - $order_query = str_replace('order by', '', $order_query); |
|
1322 | + $order_query = strtolower( $order_query ); |
|
1323 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1324 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1325 | 1325 | } |
1326 | 1326 | |
1327 | - $order_query = explode(' ', trim($order_query)); |
|
1327 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1328 | 1328 | |
1329 | 1329 | $order_fields = array( |
1330 | 1330 | 'id', 'form_key', 'name', 'description', |
@@ -1332,18 +1332,18 @@ discard block |
||
1332 | 1332 | 'default_template', 'status', 'created_at', |
1333 | 1333 | ); |
1334 | 1334 | |
1335 | - $order = trim(trim(reset($order_query), ',')); |
|
1336 | - if ( ! in_array($order, $order_fields) ) { |
|
1335 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1336 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1337 | 1337 | return ''; |
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | $order_by = ''; |
1341 | - if ( count($order_query) > 1 ) { |
|
1341 | + if ( count( $order_query ) > 1 ) { |
|
1342 | 1342 | $order_by = end( $order_query ); |
1343 | 1343 | self::esc_order_by( $order_by ); |
1344 | 1344 | } |
1345 | 1345 | |
1346 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
1346 | + return ' ORDER BY ' . $order . ' ' . $order_by; |
|
1347 | 1347 | } |
1348 | 1348 | |
1349 | 1349 | /** |
@@ -1360,24 +1360,24 @@ discard block |
||
1360 | 1360 | * @param string $limit |
1361 | 1361 | */ |
1362 | 1362 | public static function esc_limit( $limit ) { |
1363 | - if ( empty($limit) ) { |
|
1363 | + if ( empty( $limit ) ) { |
|
1364 | 1364 | return ''; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1368 | - if ( is_numeric($limit) ) { |
|
1369 | - return ' LIMIT '. $limit; |
|
1367 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1368 | + if ( is_numeric( $limit ) ) { |
|
1369 | + return ' LIMIT ' . $limit; |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | - $limit = explode(',', trim($limit)); |
|
1372 | + $limit = explode( ',', trim( $limit ) ); |
|
1373 | 1373 | foreach ( $limit as $k => $l ) { |
1374 | 1374 | if ( is_numeric( $l ) ) { |
1375 | - $limit[ $k ] = $l; |
|
1375 | + $limit[$k] = $l; |
|
1376 | 1376 | } |
1377 | 1377 | } |
1378 | 1378 | |
1379 | - $limit = implode(',', $limit); |
|
1380 | - return ' LIMIT '. $limit; |
|
1379 | + $limit = implode( ',', $limit ); |
|
1380 | + return ' LIMIT ' . $limit; |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | /** |
@@ -1385,12 +1385,12 @@ discard block |
||
1385 | 1385 | * @since 2.0 |
1386 | 1386 | */ |
1387 | 1387 | public static function prepare_array_values( $array, $type = '%s' ) { |
1388 | - $placeholders = array_fill(0, count($array), $type); |
|
1389 | - return implode(', ', $placeholders); |
|
1388 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1389 | + return implode( ', ', $placeholders ); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1393 | - if ( empty($where) ) { |
|
1393 | + if ( empty( $where ) ) { |
|
1394 | 1394 | return ''; |
1395 | 1395 | } |
1396 | 1396 | |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | |
1437 | 1437 | public static function get_referer_info() { |
1438 | 1438 | _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
1439 | - return self::get_server_value('HTTP_REFERER'); |
|
1439 | + return self::get_server_value( 'HTTP_REFERER' ); |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | /** |
@@ -1445,19 +1445,19 @@ discard block |
||
1445 | 1445 | public static function json_to_array( $json_vars ) { |
1446 | 1446 | $vars = array(); |
1447 | 1447 | foreach ( $json_vars as $jv ) { |
1448 | - $jv_name = explode('[', $jv['name']); |
|
1449 | - $last = count($jv_name) - 1; |
|
1448 | + $jv_name = explode( '[', $jv['name'] ); |
|
1449 | + $last = count( $jv_name ) - 1; |
|
1450 | 1450 | foreach ( $jv_name as $p => $n ) { |
1451 | - $name = trim($n, ']'); |
|
1452 | - if ( ! isset($l1) ) { |
|
1451 | + $name = trim( $n, ']' ); |
|
1452 | + if ( ! isset( $l1 ) ) { |
|
1453 | 1453 | $l1 = $name; |
1454 | 1454 | } |
1455 | 1455 | |
1456 | - if ( ! isset($l2) ) { |
|
1456 | + if ( ! isset( $l2 ) ) { |
|
1457 | 1457 | $l2 = $name; |
1458 | 1458 | } |
1459 | 1459 | |
1460 | - if ( ! isset($l3) ) { |
|
1460 | + if ( ! isset( $l3 ) ) { |
|
1461 | 1461 | $l3 = $name; |
1462 | 1462 | } |
1463 | 1463 | |
@@ -1471,24 +1471,24 @@ discard block |
||
1471 | 1471 | |
1472 | 1472 | case 1: |
1473 | 1473 | $l2 = $name; |
1474 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1474 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1475 | 1475 | break; |
1476 | 1476 | |
1477 | 1477 | case 2: |
1478 | 1478 | $l3 = $name; |
1479 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1479 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1480 | 1480 | break; |
1481 | 1481 | |
1482 | 1482 | case 3: |
1483 | 1483 | $l4 = $name; |
1484 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1484 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1485 | 1485 | break; |
1486 | 1486 | } |
1487 | 1487 | |
1488 | - unset($this_val, $n); |
|
1488 | + unset( $this_val, $n ); |
|
1489 | 1489 | } |
1490 | 1490 | |
1491 | - unset($last, $jv); |
|
1491 | + unset( $last, $jv ); |
|
1492 | 1492 | } |
1493 | 1493 | |
1494 | 1494 | return $vars; |
@@ -1501,8 +1501,8 @@ discard block |
||
1501 | 1501 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1502 | 1502 | if ( $name == '' ) { |
1503 | 1503 | $vars[] = $val; |
1504 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1505 | - $vars[ $l1 ] = $val; |
|
1504 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1505 | + $vars[$l1] = $val; |
|
1506 | 1506 | } |
1507 | 1507 | } |
1508 | 1508 | |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
1518 | 1518 | ); |
1519 | 1519 | |
1520 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1520 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1521 | 1521 | return; |
1522 | 1522 | } |
1523 | 1523 | |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | echo ' class="frm_help"'; |
1528 | 1528 | } |
1529 | 1529 | |
1530 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1530 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1531 | 1531 | |
1532 | 1532 | if ( 'open' != $class ) { |
1533 | 1533 | echo '"'; |
@@ -1579,13 +1579,13 @@ discard block |
||
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1582 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1582 | + if ( ! isset( $post_content[$key] ) ) { |
|
1583 | 1583 | return; |
1584 | 1584 | } |
1585 | 1585 | |
1586 | 1586 | if ( is_array( $val ) ) { |
1587 | 1587 | foreach ( $val as $k1 => $v1 ) { |
1588 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1588 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1589 | 1589 | unset( $k1, $v1 ); |
1590 | 1590 | } |
1591 | 1591 | } else { |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | $val = stripslashes( $val ); |
1594 | 1594 | |
1595 | 1595 | // Add backslashes before double quotes and forward slashes only |
1596 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1596 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1597 | 1597 | } |
1598 | 1598 | } |
1599 | 1599 | |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1611 | 1611 | |
1612 | 1612 | if ( empty( $settings['ID'] ) ) { |
1613 | - unset( $settings['ID']); |
|
1613 | + unset( $settings['ID'] ); |
|
1614 | 1614 | } |
1615 | 1615 | |
1616 | 1616 | // delete all caches for this group |
@@ -1644,17 +1644,17 @@ discard block |
||
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | public static function maybe_json_decode( $string ) { |
1647 | - if ( is_array($string) ) { |
|
1647 | + if ( is_array( $string ) ) { |
|
1648 | 1648 | return $string; |
1649 | 1649 | } |
1650 | 1650 | |
1651 | - $new_string = json_decode($string, true); |
|
1652 | - if ( function_exists('json_last_error') ) { |
|
1651 | + $new_string = json_decode( $string, true ); |
|
1652 | + if ( function_exists( 'json_last_error' ) ) { |
|
1653 | 1653 | // php 5.3+ |
1654 | 1654 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1655 | 1655 | $string = $new_string; |
1656 | 1656 | } |
1657 | - } else if ( isset($new_string) ) { |
|
1657 | + } else if ( isset( $new_string ) ) { |
|
1658 | 1658 | // php < 5.3 fallback |
1659 | 1659 | $string = $new_string; |
1660 | 1660 | } |
@@ -1670,11 +1670,11 @@ discard block |
||
1670 | 1670 | public static function maybe_highlight_menu( $post_type ) { |
1671 | 1671 | global $post, $pagenow; |
1672 | 1672 | |
1673 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1673 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1674 | 1674 | return; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1677 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1678 | 1678 | return; |
1679 | 1679 | } |
1680 | 1680 | |
@@ -1772,11 +1772,11 @@ discard block |
||
1772 | 1772 | $frm_version = self::plugin_version(); |
1773 | 1773 | |
1774 | 1774 | // check if Formidable meets minimum requirements |
1775 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1775 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1776 | 1776 | return; |
1777 | 1777 | } |
1778 | 1778 | |
1779 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1779 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1780 | 1780 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
1781 | 1781 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1782 | 1782 | '</div></td></tr>'; |
@@ -1784,38 +1784,38 @@ discard block |
||
1784 | 1784 | |
1785 | 1785 | public static function locales( $type = 'date' ) { |
1786 | 1786 | $locales = array( |
1787 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1788 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1789 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1787 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1788 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1789 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1790 | 1790 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1791 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1792 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1791 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1792 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1793 | 1793 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1794 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1795 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1794 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1795 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1796 | 1796 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1797 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1797 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1798 | 1798 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1799 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1799 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1800 | 1800 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1801 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1801 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1802 | 1802 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1803 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1804 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1805 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1806 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1807 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1803 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1804 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1805 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1806 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1807 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1808 | 1808 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1809 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1809 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1810 | 1810 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1811 | 1811 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1812 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1812 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1813 | 1813 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1814 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1814 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1815 | 1815 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1816 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1817 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1818 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1816 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1817 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1818 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1819 | 1819 | ); |
1820 | 1820 | |
1821 | 1821 | if ( $type == 'captcha' ) { |
@@ -1834,8 +1834,8 @@ discard block |
||
1834 | 1834 | ); |
1835 | 1835 | } |
1836 | 1836 | |
1837 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1838 | - $locales = apply_filters('frm_locales', $locales); |
|
1837 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1838 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1839 | 1839 | |
1840 | 1840 | return $locales; |
1841 | 1841 | } |