@@ -121,6 +121,9 @@ |
||
121 | 121 | $stylesheet_urls['formidable'] = $url; |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $version |
|
126 | + */ |
|
124 | 127 | private static function get_css_version( $css_key, $version ) { |
125 | 128 | if ( 'formidable' == $css_key ) { |
126 | 129 | $this_version = get_option( 'frm_last_style_update' ); |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmStylesController { |
4 | - public static $post_type = 'frm_styles'; |
|
5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
6 | - |
|
7 | - public static function load_pro_hooks() { |
|
8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | - FrmProStylesController::load_pro_hooks(); |
|
10 | - } |
|
11 | - } |
|
12 | - |
|
13 | - public static function register_post_types() { |
|
14 | - register_post_type( self::$post_type, array( |
|
15 | - 'label' => __( 'Styles', 'formidable' ), |
|
16 | - 'public' => false, |
|
17 | - 'show_ui' => false, |
|
18 | - 'capability_type' => 'page', |
|
4 | + public static $post_type = 'frm_styles'; |
|
5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
6 | + |
|
7 | + public static function load_pro_hooks() { |
|
8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | + FrmProStylesController::load_pro_hooks(); |
|
10 | + } |
|
11 | + } |
|
12 | + |
|
13 | + public static function register_post_types() { |
|
14 | + register_post_type( self::$post_type, array( |
|
15 | + 'label' => __( 'Styles', 'formidable' ), |
|
16 | + 'public' => false, |
|
17 | + 'show_ui' => false, |
|
18 | + 'capability_type' => 'page', |
|
19 | 19 | 'capabilities' => array( |
20 | 20 | 'edit_post' => 'frm_change_settings', |
21 | 21 | 'edit_posts' => 'frm_change_settings', |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | 'delete_posts' => 'frm_change_settings', |
26 | 26 | 'read_private_posts' => 'read_private_posts', |
27 | 27 | ), |
28 | - 'supports' => array( |
|
28 | + 'supports' => array( |
|
29 | 29 | 'title', |
30 | - ), |
|
31 | - 'has_archive' => false, |
|
32 | - 'labels' => array( |
|
30 | + ), |
|
31 | + 'has_archive' => false, |
|
32 | + 'labels' => array( |
|
33 | 33 | 'name' => __( 'Styles', 'formidable' ), |
34 | 34 | 'singular_name' => __( 'Style', 'formidable' ), |
35 | 35 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -37,31 +37,31 @@ discard block |
||
37 | 37 | 'add_new_item' => __( 'Create a New Style', 'formidable' ), |
38 | 38 | 'edit_item' => __( 'Edit Style', 'formidable' ), |
39 | 39 | ), |
40 | - ) ); |
|
41 | - } |
|
40 | + ) ); |
|
41 | + } |
|
42 | 42 | |
43 | - public static function menu() { |
|
43 | + public static function menu() { |
|
44 | 44 | add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - public static function admin_init() { |
|
48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | - return; |
|
50 | - } |
|
47 | + public static function admin_init() { |
|
48 | + if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | + return; |
|
50 | + } |
|
51 | 51 | |
52 | - self::load_pro_hooks(); |
|
53 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
52 | + self::load_pro_hooks(); |
|
53 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
54 | 54 | |
55 | - $version = FrmAppHelper::plugin_version(); |
|
55 | + $version = FrmAppHelper::plugin_version(); |
|
56 | 56 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
57 | 57 | |
58 | 58 | wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
59 | 59 | |
60 | - $style = apply_filters('frm_style_head', false); |
|
61 | - if ( $style ) { |
|
60 | + $style = apply_filters('frm_style_head', false); |
|
61 | + if ( $style ) { |
|
62 | 62 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
63 | - } |
|
64 | - } |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public static function enqueue_css( $register = 'enqueue' ) { |
67 | 67 | global $frm_vars; |
@@ -143,230 +143,230 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public static function new_style( $return = '' ) { |
146 | - self::load_styler('default'); |
|
147 | - } |
|
146 | + self::load_styler('default'); |
|
147 | + } |
|
148 | 148 | |
149 | 149 | public static function duplicate() { |
150 | 150 | self::load_styler('default'); |
151 | 151 | } |
152 | 152 | |
153 | 153 | public static function edit( $style_id = false, $message = '' ) { |
154 | - if ( ! $style_id ) { |
|
154 | + if ( ! $style_id ) { |
|
155 | 155 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
156 | - if ( empty($style_id) ) { |
|
157 | - $style_id = 'default'; |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - if ( 'default' == $style_id ) { |
|
162 | - $style = 'default'; |
|
163 | - } else { |
|
164 | - $frm_style = new FrmStyle($style_id); |
|
165 | - $style = $frm_style->get_one(); |
|
166 | - $style = $style->ID; |
|
167 | - } |
|
168 | - |
|
169 | - self::load_styler($style, $message); |
|
170 | - } |
|
171 | - |
|
172 | - public static function save() { |
|
173 | - $frm_style = new FrmStyle(); |
|
174 | - $message = ''; |
|
156 | + if ( empty($style_id) ) { |
|
157 | + $style_id = 'default'; |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + if ( 'default' == $style_id ) { |
|
162 | + $style = 'default'; |
|
163 | + } else { |
|
164 | + $frm_style = new FrmStyle($style_id); |
|
165 | + $style = $frm_style->get_one(); |
|
166 | + $style = $style->ID; |
|
167 | + } |
|
168 | + |
|
169 | + self::load_styler($style, $message); |
|
170 | + } |
|
171 | + |
|
172 | + public static function save() { |
|
173 | + $frm_style = new FrmStyle(); |
|
174 | + $message = ''; |
|
175 | 175 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
176 | 176 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
177 | 177 | |
178 | 178 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
179 | - $id = $frm_style->update($post_id); |
|
180 | - if ( empty($post_id) && ! empty($id) ) { |
|
181 | - // set the post id to the new style so it will be loaded for editing |
|
182 | - $post_id = reset($id); |
|
183 | - } |
|
184 | - // include the CSS that includes this style |
|
179 | + $id = $frm_style->update($post_id); |
|
180 | + if ( empty($post_id) && ! empty($id) ) { |
|
181 | + // set the post id to the new style so it will be loaded for editing |
|
182 | + $post_id = reset($id); |
|
183 | + } |
|
184 | + // include the CSS that includes this style |
|
185 | 185 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
186 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
187 | - } |
|
186 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
187 | + } |
|
188 | 188 | |
189 | - return self::edit($post_id, $message); |
|
190 | - } |
|
189 | + return self::edit($post_id, $message); |
|
190 | + } |
|
191 | 191 | |
192 | 192 | public static function load_styler( $style, $message = '' ) { |
193 | - global $frm_settings; |
|
193 | + global $frm_settings; |
|
194 | 194 | |
195 | - $frm_style = new FrmStyle(); |
|
196 | - $styles = $frm_style->get_all(); |
|
195 | + $frm_style = new FrmStyle(); |
|
196 | + $styles = $frm_style->get_all(); |
|
197 | 197 | |
198 | - if ( is_numeric($style) ) { |
|
199 | - $style = $styles[ $style ]; |
|
200 | - } else if ( 'default' == $style ) { |
|
201 | - $style = $frm_style->get_default_style($styles); |
|
202 | - } |
|
198 | + if ( is_numeric($style) ) { |
|
199 | + $style = $styles[ $style ]; |
|
200 | + } else if ( 'default' == $style ) { |
|
201 | + $style = $frm_style->get_default_style($styles); |
|
202 | + } |
|
203 | 203 | |
204 | - self::add_meta_boxes(); |
|
204 | + self::add_meta_boxes(); |
|
205 | 205 | |
206 | 206 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * @param string $message |
211 | 211 | * @param array|object $forms |
212 | 212 | */ |
213 | 213 | private static function manage( $message = '', $forms = array() ) { |
214 | - $frm_style = new FrmStyle(); |
|
215 | - $styles = $frm_style->get_all(); |
|
216 | - $default_style = $frm_style->get_default_style($styles); |
|
214 | + $frm_style = new FrmStyle(); |
|
215 | + $styles = $frm_style->get_all(); |
|
216 | + $default_style = $frm_style->get_default_style($styles); |
|
217 | 217 | |
218 | - if ( empty($forms) ) { |
|
219 | - $forms = FrmForm::get_published_forms(); |
|
220 | - } |
|
218 | + if ( empty($forms) ) { |
|
219 | + $forms = FrmForm::get_published_forms(); |
|
220 | + } |
|
221 | 221 | |
222 | 222 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | - private static function manage_styles() { |
|
225 | + private static function manage_styles() { |
|
226 | 226 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
227 | 227 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
228 | - return self::manage(); |
|
229 | - } |
|
228 | + return self::manage(); |
|
229 | + } |
|
230 | 230 | |
231 | - global $wpdb; |
|
231 | + global $wpdb; |
|
232 | 232 | |
233 | 233 | $forms = FrmForm::get_published_forms(); |
234 | - foreach ( $forms as $form ) { |
|
235 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
236 | - continue; |
|
237 | - } |
|
234 | + foreach ( $forms as $form ) { |
|
235 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
236 | + continue; |
|
237 | + } |
|
238 | 238 | |
239 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
239 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
240 | 240 | |
241 | 241 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
242 | - unset($form); |
|
243 | - } |
|
242 | + unset($form); |
|
243 | + } |
|
244 | 244 | |
245 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
246 | - return self::manage($message, $forms); |
|
247 | - } |
|
245 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
246 | + return self::manage($message, $forms); |
|
247 | + } |
|
248 | 248 | |
249 | - public static function custom_css( $message = '', $style = null ) { |
|
250 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
251 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
252 | - wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
249 | + public static function custom_css( $message = '', $style = null ) { |
|
250 | + wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
251 | + wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
252 | + wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
253 | 253 | |
254 | - if ( ! isset($style) ) { |
|
255 | - $frm_style = new FrmStyle(); |
|
256 | - $style = $frm_style->get_default_style(); |
|
257 | - } |
|
254 | + if ( ! isset($style) ) { |
|
255 | + $frm_style = new FrmStyle(); |
|
256 | + $style = $frm_style->get_default_style(); |
|
257 | + } |
|
258 | 258 | |
259 | 259 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' ); |
260 | - } |
|
260 | + } |
|
261 | 261 | |
262 | - public static function save_css() { |
|
263 | - $frm_style = new FrmStyle(); |
|
262 | + public static function save_css() { |
|
263 | + $frm_style = new FrmStyle(); |
|
264 | 264 | |
265 | - $message = ''; |
|
265 | + $message = ''; |
|
266 | 266 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
267 | 267 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
268 | 268 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
269 | - $frm_style->update($post_id); |
|
270 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
271 | - } |
|
269 | + $frm_style->update($post_id); |
|
270 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
271 | + } |
|
272 | 272 | |
273 | - return self::custom_css($message); |
|
274 | - } |
|
273 | + return self::custom_css($message); |
|
274 | + } |
|
275 | 275 | |
276 | - public static function route() { |
|
276 | + public static function route() { |
|
277 | 277 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
278 | 278 | |
279 | - switch ( $action ) { |
|
280 | - case 'edit': |
|
281 | - case 'save': |
|
282 | - case 'manage': |
|
283 | - case 'manage_styles': |
|
284 | - case 'custom_css': |
|
285 | - case 'save_css': |
|
279 | + switch ( $action ) { |
|
280 | + case 'edit': |
|
281 | + case 'save': |
|
282 | + case 'manage': |
|
283 | + case 'manage_styles': |
|
284 | + case 'custom_css': |
|
285 | + case 'save_css': |
|
286 | 286 | return self::$action(); |
287 | - default: |
|
288 | - do_action( 'frm_style_action_route', $action ); |
|
289 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
290 | - return; |
|
291 | - } |
|
287 | + default: |
|
288 | + do_action( 'frm_style_action_route', $action ); |
|
289 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
290 | + return; |
|
291 | + } |
|
292 | 292 | |
293 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
294 | - return self::$action(); |
|
295 | - } |
|
293 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
294 | + return self::$action(); |
|
295 | + } |
|
296 | 296 | |
297 | - return self::edit(); |
|
298 | - } |
|
299 | - } |
|
297 | + return self::edit(); |
|
298 | + } |
|
299 | + } |
|
300 | 300 | |
301 | - public static function reset_styling() { |
|
301 | + public static function reset_styling() { |
|
302 | 302 | FrmAppHelper::permission_check('frm_change_settings'); |
303 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
303 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
304 | 304 | |
305 | - $frm_style = new FrmStyle(); |
|
306 | - $defaults = $frm_style->get_defaults(); |
|
305 | + $frm_style = new FrmStyle(); |
|
306 | + $defaults = $frm_style->get_defaults(); |
|
307 | 307 | |
308 | - echo json_encode( $defaults ); |
|
309 | - wp_die(); |
|
310 | - } |
|
308 | + echo json_encode( $defaults ); |
|
309 | + wp_die(); |
|
310 | + } |
|
311 | 311 | |
312 | - public static function change_styling() { |
|
313 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
312 | + public static function change_styling() { |
|
313 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
314 | 314 | |
315 | - $frm_style = new FrmStyle(); |
|
316 | - $defaults = $frm_style->get_defaults(); |
|
315 | + $frm_style = new FrmStyle(); |
|
316 | + $defaults = $frm_style->get_defaults(); |
|
317 | 317 | |
318 | - // remove the # from the colors |
|
319 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
320 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
321 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
322 | - } |
|
323 | - } |
|
318 | + // remove the # from the colors |
|
319 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
320 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
321 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
322 | + } |
|
323 | + } |
|
324 | 324 | |
325 | - echo '<style type="text/css">'; |
|
325 | + echo '<style type="text/css">'; |
|
326 | 326 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
327 | - echo '</style>'; |
|
328 | - wp_die(); |
|
329 | - } |
|
330 | - |
|
331 | - private static function add_meta_boxes() { |
|
332 | - |
|
333 | - // setup meta boxes |
|
334 | - $meta_boxes = array( |
|
335 | - 'general' => __( 'General', 'formidable' ), |
|
336 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
337 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
338 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
339 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
340 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
341 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
342 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
343 | - 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
344 | - 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
345 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
346 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
347 | - ); |
|
348 | - |
|
349 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
327 | + echo '</style>'; |
|
328 | + wp_die(); |
|
329 | + } |
|
330 | + |
|
331 | + private static function add_meta_boxes() { |
|
332 | + |
|
333 | + // setup meta boxes |
|
334 | + $meta_boxes = array( |
|
335 | + 'general' => __( 'General', 'formidable' ), |
|
336 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
337 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
338 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
339 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
340 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
341 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
342 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
343 | + 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
344 | + 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
345 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
346 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
347 | + ); |
|
348 | + |
|
349 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
350 | 350 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
351 | - unset($nicename, $name); |
|
352 | - } |
|
353 | - } |
|
351 | + unset($nicename, $name); |
|
352 | + } |
|
353 | + } |
|
354 | 354 | |
355 | 355 | public static function include_style_section( $atts, $sec ) { |
356 | - extract($atts); |
|
356 | + extract($atts); |
|
357 | 357 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
358 | 358 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' ); |
359 | - } |
|
359 | + } |
|
360 | 360 | |
361 | - public static function load_css() { |
|
362 | - header('Content-type: text/css'); |
|
361 | + public static function load_css() { |
|
362 | + header('Content-type: text/css'); |
|
363 | 363 | |
364 | - $frm_style = new FrmStyle(); |
|
365 | - $defaults = $frm_style->get_defaults(); |
|
364 | + $frm_style = new FrmStyle(); |
|
365 | + $defaults = $frm_style->get_defaults(); |
|
366 | 366 | |
367 | 367 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
368 | - wp_die(); |
|
369 | - } |
|
368 | + wp_die(); |
|
369 | + } |
|
370 | 370 | |
371 | 371 | public static function load_saved_css() { |
372 | 372 | $css = get_transient( 'frmpro_css' ); |
@@ -375,142 +375,142 @@ discard block |
||
375 | 375 | wp_die(); |
376 | 376 | } |
377 | 377 | |
378 | - /** |
|
379 | - * Check if the Formidable styling should be loaded, |
|
380 | - * then enqueue it for the footer |
|
381 | - * @since 2.0 |
|
382 | - */ |
|
383 | - public static function enqueue_style() { |
|
384 | - global $frm_vars; |
|
385 | - |
|
386 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
387 | - // the CSS has already been loaded |
|
388 | - return; |
|
389 | - } |
|
390 | - |
|
391 | - $frm_settings = FrmAppHelper::get_settings(); |
|
392 | - if ( $frm_settings->load_style != 'none' ) { |
|
393 | - wp_enqueue_style( 'formidable' ); |
|
394 | - $frm_vars['css_loaded'] = true; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - // Get the stylesheets for the form settings page |
|
399 | - public static function get_style_opts() { |
|
400 | - $frm_style = new FrmStyle(); |
|
401 | - $styles = $frm_style->get_all(); |
|
402 | - |
|
403 | - return $styles; |
|
404 | - } |
|
405 | - |
|
406 | - public static function get_form_style( $form = 'default' ) { |
|
407 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
408 | - |
|
409 | - if ( empty( $style ) || 1 == $style ) { |
|
410 | - $style = 'default'; |
|
411 | - } |
|
412 | - |
|
413 | - $frm_style = new FrmStyle( $style ); |
|
414 | - return $frm_style->get_one(); |
|
415 | - } |
|
416 | - |
|
417 | - /** |
|
418 | - * @param string $class |
|
419 | - * @param string $style |
|
420 | - */ |
|
378 | + /** |
|
379 | + * Check if the Formidable styling should be loaded, |
|
380 | + * then enqueue it for the footer |
|
381 | + * @since 2.0 |
|
382 | + */ |
|
383 | + public static function enqueue_style() { |
|
384 | + global $frm_vars; |
|
385 | + |
|
386 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
387 | + // the CSS has already been loaded |
|
388 | + return; |
|
389 | + } |
|
390 | + |
|
391 | + $frm_settings = FrmAppHelper::get_settings(); |
|
392 | + if ( $frm_settings->load_style != 'none' ) { |
|
393 | + wp_enqueue_style( 'formidable' ); |
|
394 | + $frm_vars['css_loaded'] = true; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + // Get the stylesheets for the form settings page |
|
399 | + public static function get_style_opts() { |
|
400 | + $frm_style = new FrmStyle(); |
|
401 | + $styles = $frm_style->get_all(); |
|
402 | + |
|
403 | + return $styles; |
|
404 | + } |
|
405 | + |
|
406 | + public static function get_form_style( $form = 'default' ) { |
|
407 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
408 | + |
|
409 | + if ( empty( $style ) || 1 == $style ) { |
|
410 | + $style = 'default'; |
|
411 | + } |
|
412 | + |
|
413 | + $frm_style = new FrmStyle( $style ); |
|
414 | + return $frm_style->get_one(); |
|
415 | + } |
|
416 | + |
|
417 | + /** |
|
418 | + * @param string $class |
|
419 | + * @param string $style |
|
420 | + */ |
|
421 | 421 | public static function get_form_style_class( $class, $style ) { |
422 | - if ( 1 == $style ) { |
|
423 | - $style = 'default'; |
|
424 | - } |
|
422 | + if ( 1 == $style ) { |
|
423 | + $style = 'default'; |
|
424 | + } |
|
425 | 425 | |
426 | - $frm_style = new FrmStyle($style); |
|
427 | - $style = $frm_style->get_one(); |
|
426 | + $frm_style = new FrmStyle($style); |
|
427 | + $style = $frm_style->get_one(); |
|
428 | 428 | |
429 | - if ( $style ) { |
|
429 | + if ( $style ) { |
|
430 | 430 | $class .= ' frm_style_' . $style->post_name; |
431 | - } |
|
431 | + } |
|
432 | 432 | |
433 | - return $class; |
|
434 | - } |
|
433 | + return $class; |
|
434 | + } |
|
435 | 435 | |
436 | - /** |
|
437 | - * @param string $val |
|
438 | - */ |
|
436 | + /** |
|
437 | + * @param string $val |
|
438 | + */ |
|
439 | 439 | public static function get_style_val( $val, $form = 'default' ) { |
440 | - $style = self::get_form_style($form); |
|
441 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
442 | - return $style->post_content[ $val ]; |
|
443 | - } |
|
444 | - } |
|
440 | + $style = self::get_form_style($form); |
|
441 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
442 | + return $style->post_content[ $val ]; |
|
443 | + } |
|
444 | + } |
|
445 | 445 | |
446 | 446 | public static function show_entry_styles( $default_styles ) { |
447 | - $frm_style = new FrmStyle('default'); |
|
448 | - $style = $frm_style->get_one(); |
|
449 | - |
|
450 | - if ( ! $style ) { |
|
451 | - return $default_styles; |
|
452 | - } |
|
453 | - |
|
454 | - foreach ( $default_styles as $name => $val ) { |
|
455 | - $setting = $name; |
|
456 | - if ( 'border_width' == $name ) { |
|
457 | - $setting = 'field_border_width'; |
|
458 | - } else if ( 'alt_bg_color' == $name ) { |
|
459 | - $setting = 'bg_color_active'; |
|
460 | - } |
|
461 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
462 | - unset($name, $val); |
|
463 | - } |
|
464 | - |
|
465 | - return $default_styles; |
|
466 | - } |
|
447 | + $frm_style = new FrmStyle('default'); |
|
448 | + $style = $frm_style->get_one(); |
|
449 | + |
|
450 | + if ( ! $style ) { |
|
451 | + return $default_styles; |
|
452 | + } |
|
453 | + |
|
454 | + foreach ( $default_styles as $name => $val ) { |
|
455 | + $setting = $name; |
|
456 | + if ( 'border_width' == $name ) { |
|
457 | + $setting = 'field_border_width'; |
|
458 | + } else if ( 'alt_bg_color' == $name ) { |
|
459 | + $setting = 'bg_color_active'; |
|
460 | + } |
|
461 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
462 | + unset($name, $val); |
|
463 | + } |
|
464 | + |
|
465 | + return $default_styles; |
|
466 | + } |
|
467 | 467 | |
468 | 468 | public static function &important_style( $important, $field ) { |
469 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
470 | - return $important; |
|
471 | - } |
|
469 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
470 | + return $important; |
|
471 | + } |
|
472 | 472 | |
473 | - /** |
|
474 | - * Fallback for WP < 3.6 |
|
475 | - */ |
|
476 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
477 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
478 | - return do_accordion_sections( $screen, $context, $object ); |
|
479 | - } |
|
473 | + /** |
|
474 | + * Fallback for WP < 3.6 |
|
475 | + */ |
|
476 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
477 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
478 | + return do_accordion_sections( $screen, $context, $object ); |
|
479 | + } |
|
480 | 480 | |
481 | - global $wp_meta_boxes; |
|
481 | + global $wp_meta_boxes; |
|
482 | 482 | |
483 | - $screen = 'formidable_page_formidable-styles'; |
|
484 | - $screen = convert_to_screen( $screen ); |
|
483 | + $screen = 'formidable_page_formidable-styles'; |
|
484 | + $screen = convert_to_screen( $screen ); |
|
485 | 485 | |
486 | - $page = $screen->id; |
|
486 | + $page = $screen->id; |
|
487 | 487 | |
488 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
489 | - ?> |
|
488 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
489 | + ?> |
|
490 | 490 | <div id="side-sortables" class="accordion-container"> |
491 | 491 | <?php |
492 | - $i = 0; |
|
493 | - $first_open = false; |
|
494 | - do { |
|
492 | + $i = 0; |
|
493 | + $first_open = false; |
|
494 | + do { |
|
495 | 495 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
496 | 496 | break; |
497 | 497 | } |
498 | 498 | |
499 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
500 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
501 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
502 | - if ( false == $box || ! $box['title'] ) { |
|
503 | - continue; |
|
499 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
500 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
501 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
502 | + if ( false == $box || ! $box['title'] ) { |
|
503 | + continue; |
|
504 | 504 | } |
505 | 505 | |
506 | - $i++; |
|
507 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
506 | + $i++; |
|
507 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
508 | 508 | |
509 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
510 | - $first_open = true; |
|
511 | - } |
|
509 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
510 | + $first_open = true; |
|
511 | + } |
|
512 | 512 | |
513 | - ?> |
|
513 | + ?> |
|
514 | 514 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
515 | 515 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
516 | 516 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -521,13 +521,13 @@ discard block |
||
521 | 521 | </div><!-- .accordion-section-content --> |
522 | 522 | </div><!-- .postbox --> |
523 | 523 | <?php |
524 | - } |
|
525 | - } |
|
526 | - } |
|
527 | - } while ( 0 ); |
|
528 | - ?> |
|
524 | + } |
|
525 | + } |
|
526 | + } |
|
527 | + } while ( 0 ); |
|
528 | + ?> |
|
529 | 529 | </div><!-- .accordion-container --> |
530 | 530 | <?php |
531 | - return $i; |
|
532 | - } |
|
531 | + return $i; |
|
532 | + } |
|
533 | 533 | } |
@@ -41,23 +41,23 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public static function menu() { |
44 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
|
44 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public static function admin_init() { |
48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
48 | + if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | self::load_pro_hooks(); |
53 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
53 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
54 | 54 | |
55 | 55 | $version = FrmAppHelper::plugin_version(); |
56 | 56 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
57 | 57 | |
58 | - wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
|
58 | + wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) ); |
|
59 | 59 | |
60 | - $style = apply_filters('frm_style_head', false); |
|
60 | + $style = apply_filters( 'frm_style_head', false ); |
|
61 | 61 | if ( $style ) { |
62 | 62 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
63 | 63 | } |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public static function new_style( $return = '' ) { |
146 | - self::load_styler('default'); |
|
146 | + self::load_styler( 'default' ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | public static function duplicate() { |
150 | - self::load_styler('default'); |
|
150 | + self::load_styler( 'default' ); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | public static function edit( $style_id = false, $message = '' ) { |
154 | 154 | if ( ! $style_id ) { |
155 | 155 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
156 | - if ( empty($style_id) ) { |
|
156 | + if ( empty( $style_id ) ) { |
|
157 | 157 | $style_id = 'default'; |
158 | 158 | } |
159 | 159 | } |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | if ( 'default' == $style_id ) { |
162 | 162 | $style = 'default'; |
163 | 163 | } else { |
164 | - $frm_style = new FrmStyle($style_id); |
|
164 | + $frm_style = new FrmStyle( $style_id ); |
|
165 | 165 | $style = $frm_style->get_one(); |
166 | 166 | $style = $style->ID; |
167 | 167 | } |
168 | 168 | |
169 | - self::load_styler($style, $message); |
|
169 | + self::load_styler( $style, $message ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public static function save() { |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
177 | 177 | |
178 | 178 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
179 | - $id = $frm_style->update($post_id); |
|
180 | - if ( empty($post_id) && ! empty($id) ) { |
|
179 | + $id = $frm_style->update( $post_id ); |
|
180 | + if ( empty( $post_id ) && ! empty( $id ) ) { |
|
181 | 181 | // set the post id to the new style so it will be loaded for editing |
182 | - $post_id = reset($id); |
|
182 | + $post_id = reset( $id ); |
|
183 | 183 | } |
184 | 184 | // include the CSS that includes this style |
185 | 185 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
186 | 186 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
187 | 187 | } |
188 | 188 | |
189 | - return self::edit($post_id, $message); |
|
189 | + return self::edit( $post_id, $message ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | public static function load_styler( $style, $message = '' ) { |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | $frm_style = new FrmStyle(); |
196 | 196 | $styles = $frm_style->get_all(); |
197 | 197 | |
198 | - if ( is_numeric($style) ) { |
|
199 | - $style = $styles[ $style ]; |
|
198 | + if ( is_numeric( $style ) ) { |
|
199 | + $style = $styles[$style]; |
|
200 | 200 | } else if ( 'default' == $style ) { |
201 | - $style = $frm_style->get_default_style($styles); |
|
201 | + $style = $frm_style->get_default_style( $styles ); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | self::add_meta_boxes(); |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | private static function manage( $message = '', $forms = array() ) { |
214 | 214 | $frm_style = new FrmStyle(); |
215 | 215 | $styles = $frm_style->get_all(); |
216 | - $default_style = $frm_style->get_default_style($styles); |
|
216 | + $default_style = $frm_style->get_default_style( $styles ); |
|
217 | 217 | |
218 | - if ( empty($forms) ) { |
|
218 | + if ( empty( $forms ) ) { |
|
219 | 219 | $forms = FrmForm::get_published_forms(); |
220 | 220 | } |
221 | 221 | |
@@ -232,26 +232,26 @@ discard block |
||
232 | 232 | |
233 | 233 | $forms = FrmForm::get_published_forms(); |
234 | 234 | foreach ( $forms as $form ) { |
235 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
235 | + if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) { |
|
236 | 236 | continue; |
237 | 237 | } |
238 | 238 | |
239 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
239 | + $form->options['custom_style'] = $_POST['style'][$form->id]; |
|
240 | 240 | |
241 | 241 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
242 | - unset($form); |
|
242 | + unset( $form ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | $message = __( 'Your form styles have been saved.', 'formidable' ); |
246 | - return self::manage($message, $forms); |
|
246 | + return self::manage( $message, $forms ); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | public static function custom_css( $message = '', $style = null ) { |
250 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
251 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
250 | + wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' ); |
|
251 | + wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' ); |
|
252 | 252 | wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
253 | 253 | |
254 | - if ( ! isset($style) ) { |
|
254 | + if ( ! isset( $style ) ) { |
|
255 | 255 | $frm_style = new FrmStyle(); |
256 | 256 | $style = $frm_style->get_default_style(); |
257 | 257 | } |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
267 | 267 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
268 | 268 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
269 | - $frm_style->update($post_id); |
|
269 | + $frm_style->update( $post_id ); |
|
270 | 270 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
271 | 271 | } |
272 | 272 | |
273 | - return self::custom_css($message); |
|
273 | + return self::custom_css( $message ); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | public static function route() { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | public static function reset_styling() { |
302 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
302 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
303 | 303 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
304 | 304 | |
305 | 305 | $frm_style = new FrmStyle(); |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | |
318 | 318 | // remove the # from the colors |
319 | 319 | foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
320 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
321 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
320 | + if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) { |
|
321 | + $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v ); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -348,18 +348,18 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach ( $meta_boxes as $nicename => $name ) { |
350 | 350 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
351 | - unset($nicename, $name); |
|
351 | + unset( $nicename, $name ); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | public static function include_style_section( $atts, $sec ) { |
356 | - extract($atts); |
|
356 | + extract( $atts ); |
|
357 | 357 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
358 | 358 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' ); |
359 | 359 | } |
360 | 360 | |
361 | 361 | public static function load_css() { |
362 | - header('Content-type: text/css'); |
|
362 | + header( 'Content-type: text/css' ); |
|
363 | 363 | |
364 | 364 | $frm_style = new FrmStyle(); |
365 | 365 | $defaults = $frm_style->get_defaults(); |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $style = 'default'; |
424 | 424 | } |
425 | 425 | |
426 | - $frm_style = new FrmStyle($style); |
|
426 | + $frm_style = new FrmStyle( $style ); |
|
427 | 427 | $style = $frm_style->get_one(); |
428 | 428 | |
429 | 429 | if ( $style ) { |
@@ -437,14 +437,14 @@ discard block |
||
437 | 437 | * @param string $val |
438 | 438 | */ |
439 | 439 | public static function get_style_val( $val, $form = 'default' ) { |
440 | - $style = self::get_form_style($form); |
|
441 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
442 | - return $style->post_content[ $val ]; |
|
440 | + $style = self::get_form_style( $form ); |
|
441 | + if ( $style && isset( $style->post_content[$val] ) ) { |
|
442 | + return $style->post_content[$val]; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | 446 | public static function show_entry_styles( $default_styles ) { |
447 | - $frm_style = new FrmStyle('default'); |
|
447 | + $frm_style = new FrmStyle( 'default' ); |
|
448 | 448 | $style = $frm_style->get_one(); |
449 | 449 | |
450 | 450 | if ( ! $style ) { |
@@ -458,15 +458,15 @@ discard block |
||
458 | 458 | } else if ( 'alt_bg_color' == $name ) { |
459 | 459 | $setting = 'bg_color_active'; |
460 | 460 | } |
461 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
462 | - unset($name, $val); |
|
461 | + $default_styles[$name] = $style->post_content[$setting]; |
|
462 | + unset( $name, $val ); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | return $default_styles; |
466 | 466 | } |
467 | 467 | |
468 | 468 | public static function &important_style( $important, $field ) { |
469 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
469 | + $important = self::get_style_val( 'important_style', $field['form_id'] ); |
|
470 | 470 | return $important; |
471 | 471 | } |
472 | 472 | |
@@ -492,18 +492,18 @@ discard block |
||
492 | 492 | $i = 0; |
493 | 493 | $first_open = false; |
494 | 494 | do { |
495 | - if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
495 | + if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) { |
|
496 | 496 | break; |
497 | 497 | } |
498 | 498 | |
499 | 499 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
500 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
501 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
500 | + if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
|
501 | + foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
502 | 502 | if ( false == $box || ! $box['title'] ) { |
503 | 503 | continue; |
504 | 504 | } |
505 | 505 | |
506 | - $i++; |
|
506 | + $i ++; |
|
507 | 507 | $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
508 | 508 | |
509 | 509 | if ( ! $first_open && empty( $hidden_class ) ) { |
@@ -7,10 +7,10 @@ |
||
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 | if ( $addon['info']['slug'] == 'formidable-pro' ) { |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | <tr> |
7 | 7 | <th></th> |
8 | 8 | <?php foreach ( $pro['pricing'] as $name => $price ) { |
9 | - $price_id++; |
|
9 | + $price_id ++; |
|
10 | 10 | if ( $name == 'smallbusiness' ) { |
11 | 11 | $name = 'Small Business'; |
12 | 12 | } ?> |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | <tr> |
51 | 51 | <th>Included AddOns</th> |
52 | 52 | <td>None</td> |
53 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Basic Addons</a></td> |
|
54 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td> |
|
55 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td> |
|
53 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Basic Addons</a></td> |
|
54 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Advanced Addons</a></td> |
|
55 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com/pricing/#addon-lists' ) ) ?>" target="_blank">Enterprise Addons</a></td> |
|
56 | 56 | </tr> |
57 | 57 | </tbody> |
58 | 58 | </table> |
@@ -275,7 +275,7 @@ |
||
275 | 275 | return $message; |
276 | 276 | } |
277 | 277 | |
278 | - public function manually_queue_update() { |
|
279 | - set_site_transient( 'update_plugins', null ); |
|
280 | - } |
|
278 | + public function manually_queue_update() { |
|
279 | + set_site_transient( 'update_plugins', null ); |
|
280 | + } |
|
281 | 281 | } |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | public function insert_installed_addon( $plugins ) { |
41 | - $plugins[ $this->plugin_slug ] = $this; |
|
41 | + $plugins[$this->plugin_slug] = $this; |
|
42 | 42 | return $plugins; |
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function get_addon( $plugin_slug ) { |
46 | 46 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
47 | 47 | $plugin = false; |
48 | - if ( isset( $plugins[ $plugin_slug ] ) ) { |
|
49 | - $plugin = $plugins[ $plugin_slug ]; |
|
48 | + if ( isset( $plugins[$plugin_slug] ) ) { |
|
49 | + $plugin = $plugins[$plugin_slug]; |
|
50 | 50 | } |
51 | 51 | return $plugin; |
52 | 52 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function show_license_message( $file, $plugin ) { |
99 | 99 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
100 | 100 | echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">'; |
101 | - echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
101 | + echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
102 | 102 | $id = sanitize_title( $plugin['Name'] ); |
103 | 103 | echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>'; |
104 | 104 | echo '</div></td></tr>'; |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | |
112 | 112 | if ( $this->is_current_version( $transient ) ) { |
113 | 113 | //make sure it doesn't show there is an update if plugin is up-to-date |
114 | - if ( isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
115 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
114 | + if ( isset( $transient->response[$this->plugin_folder] ) ) { |
|
115 | + unset( $transient->response[$this->plugin_folder] ); |
|
116 | 116 | } |
117 | - } else if ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
117 | + } else if ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) { |
|
118 | 118 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $this->license . $this->version ) . '_get_version' ); |
119 | 119 | $version_info = get_transient( $cache_key ); |
120 | 120 | if ( $version_info !== false && version_compare( $version_info->new_version, $this->version, '>' ) ) { |
121 | - $transient->response[ $this->plugin_folder ] = $version_info; |
|
121 | + $transient->response[$this->plugin_folder] = $version_info; |
|
122 | 122 | } else { |
123 | 123 | delete_transient( $cache_key ); |
124 | 124 | if ( ! $this->has_been_cleared() ) { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->manually_queue_update(); |
128 | 128 | } |
129 | 129 | |
130 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
130 | + unset( $transient->response[$this->plugin_folder] ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | private function is_current_version( $transient ) { |
138 | - if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) { |
|
138 | + if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | return true; |
145 | 145 | } |
146 | 146 | |
147 | - return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] == $transient->response[ $this->plugin_folder ]->new_version; |
|
147 | + return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] == $transient->response[$this->plugin_folder]->new_version; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | private function has_been_cleared() { |
151 | 151 | $last_cleared = get_option( 'frm_last_cleared' ); |
152 | - return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime('-5 minutes') ) ); |
|
152 | + return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) ) ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | private function cleared_plugins() { |
156 | - update_option( 'frm_last_cleared', date('Y-m-d H:i:s') ); |
|
156 | + update_option( 'frm_last_cleared', date( 'Y-m-d H:i:s' ) ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | public static function activate() { |
160 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
160 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
161 | 161 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
162 | 162 | |
163 | 163 | if ( ! isset( $_POST['license'] ) || empty( $_POST['license'] ) ) { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | public static function deactivate() { |
208 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
208 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
209 | 209 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
210 | 210 | |
211 | 211 | $plugin_slug = sanitize_text_field( $_POST['plugin'] ); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | $message = __( 'Your License Key was invalid', 'formidable' ); |
257 | 257 | if ( is_wp_error( $resp ) ) { |
258 | - $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>'); |
|
258 | + $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' ); |
|
259 | 259 | if ( is_wp_error( $resp ) ) { |
260 | 260 | $message .= ' ' . $resp->get_error_message(); |
261 | 261 | } |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_size') ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_size' ) ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_color') ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_color' ) ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_top') ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_top' ) ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_bottom') ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_bottom' ) ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_size') ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_size' ) ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_color') ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_color' ) ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_top') ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_top' ) ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_bottom') ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_bottom' ) ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
@@ -181,13 +181,13 @@ |
||
181 | 181 | ), |
182 | 182 | ); |
183 | 183 | $random = rand( 0, count( $tips ) - 1 ); |
184 | - $tip = $tips[ $random ]; |
|
184 | + $tip = $tips[$random]; |
|
185 | 185 | $tip['num'] = $random; |
186 | 186 | return $tip; |
187 | 187 | } |
188 | 188 | |
189 | 189 | public static function get_random_tip( $tips ) { |
190 | 190 | $random = rand( 0, count( $tips ) - 1 ); |
191 | - return $tips[ $random ]; |
|
191 | + return $tips[$random]; |
|
192 | 192 | } |
193 | 193 | } |
@@ -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 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
13 | - } |
|
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,28 +82,28 @@ 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() { |
|
93 | + public static function pro_get_started_headline() { |
|
94 | 94 | self::maybe_show_upgrade_bar(); |
95 | 95 | |
96 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
97 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
98 | - return; |
|
99 | - } |
|
96 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
97 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
98 | + return; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
102 | - FrmAppHelper::load_admin_wide_js(); |
|
102 | + FrmAppHelper::load_admin_wide_js(); |
|
103 | 103 | |
104 | - // user is authorized, but running free version |
|
105 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
106 | - ?> |
|
104 | + // user is authorized, but running free version |
|
105 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
106 | + ?> |
|
107 | 107 | <div class="error" class="frm_previous_install"> |
108 | 108 | <?php |
109 | 109 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | ) ); ?> |
116 | 116 | </div> |
117 | 117 | <?php |
118 | - } |
|
119 | - } |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | private static function maybe_show_upgrade_bar() { |
122 | 122 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | - public static function admin_js() { |
|
219 | + public static function admin_js() { |
|
220 | 220 | $version = FrmAppHelper::plugin_version(); |
221 | 221 | FrmAppHelper::load_admin_wide_js( false ); |
222 | 222 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
228 | 228 | ), $version, true ); |
229 | 229 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
230 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
230 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
231 | 231 | |
232 | 232 | // load multselect js |
233 | 233 | wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true ); |
@@ -238,79 +238,79 @@ discard block |
||
238 | 238 | global $pagenow; |
239 | 239 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
240 | 240 | |
241 | - wp_enqueue_script( 'admin-widgets' ); |
|
242 | - wp_enqueue_style( 'widgets' ); |
|
243 | - wp_enqueue_script( 'formidable' ); |
|
244 | - wp_enqueue_script( 'formidable_admin' ); |
|
241 | + wp_enqueue_script( 'admin-widgets' ); |
|
242 | + wp_enqueue_style( 'widgets' ); |
|
243 | + wp_enqueue_script( 'formidable' ); |
|
244 | + wp_enqueue_script( 'formidable_admin' ); |
|
245 | 245 | FrmAppHelper::localize_script( 'admin' ); |
246 | 246 | |
247 | - wp_enqueue_style( 'formidable-admin' ); |
|
247 | + wp_enqueue_style( 'formidable-admin' ); |
|
248 | 248 | FrmStylesController::enqueue_css( 'admin' ); |
249 | - add_thickbox(); |
|
249 | + add_thickbox(); |
|
250 | 250 | |
251 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
251 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
252 | 252 | |
253 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
254 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
255 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
253 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
254 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
255 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
256 | 256 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
257 | 257 | $post = get_post( absint( $_REQUEST['post'] ) ); |
258 | - if ( ! $post ) { |
|
259 | - return; |
|
260 | - } |
|
261 | - $post_type = $post->post_type; |
|
262 | - } else { |
|
263 | - return; |
|
264 | - } |
|
265 | - |
|
266 | - if ( $post_type == 'frm_display' ) { |
|
267 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
268 | - wp_enqueue_script( 'formidable_admin' ); |
|
269 | - wp_enqueue_style( 'formidable-admin' ); |
|
258 | + if ( ! $post ) { |
|
259 | + return; |
|
260 | + } |
|
261 | + $post_type = $post->post_type; |
|
262 | + } else { |
|
263 | + return; |
|
264 | + } |
|
265 | + |
|
266 | + if ( $post_type == 'frm_display' ) { |
|
267 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
268 | + wp_enqueue_script( 'formidable_admin' ); |
|
269 | + wp_enqueue_style( 'formidable-admin' ); |
|
270 | 270 | FrmAppHelper::localize_script( 'admin' ); |
271 | - } |
|
272 | - } else if ( $pagenow == 'widgets.php' ) { |
|
273 | - FrmAppHelper::load_admin_wide_js(); |
|
274 | - } |
|
275 | - } |
|
276 | - |
|
277 | - public static function wp_admin_body_class( $classes ) { |
|
278 | - global $wp_version; |
|
279 | - //we need this class everywhere in the admin for the menu |
|
280 | - if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
281 | - $classes .= ' frm_38_trigger'; |
|
282 | - } |
|
283 | - |
|
284 | - return $classes; |
|
285 | - } |
|
286 | - |
|
287 | - public static function load_lang() { |
|
288 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * Filter shortcodes in text widgets |
|
293 | - */ |
|
294 | - public static function widget_text_filter( $content ) { |
|
295 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
296 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
297 | - } |
|
298 | - |
|
299 | - public static function widget_text_filter_callback( $matches ) { |
|
300 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
301 | - return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
302 | - } |
|
303 | - |
|
304 | - public static function front_head() { |
|
305 | - if ( is_multisite() ) { |
|
306 | - $old_db_version = get_option( 'frm_db_version' ); |
|
307 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
308 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
309 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
310 | - self::install( $old_db_version ); |
|
311 | - } |
|
312 | - } |
|
313 | - } |
|
271 | + } |
|
272 | + } else if ( $pagenow == 'widgets.php' ) { |
|
273 | + FrmAppHelper::load_admin_wide_js(); |
|
274 | + } |
|
275 | + } |
|
276 | + |
|
277 | + public static function wp_admin_body_class( $classes ) { |
|
278 | + global $wp_version; |
|
279 | + //we need this class everywhere in the admin for the menu |
|
280 | + if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
281 | + $classes .= ' frm_38_trigger'; |
|
282 | + } |
|
283 | + |
|
284 | + return $classes; |
|
285 | + } |
|
286 | + |
|
287 | + public static function load_lang() { |
|
288 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * Filter shortcodes in text widgets |
|
293 | + */ |
|
294 | + public static function widget_text_filter( $content ) { |
|
295 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
296 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
297 | + } |
|
298 | + |
|
299 | + public static function widget_text_filter_callback( $matches ) { |
|
300 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
301 | + return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
302 | + } |
|
303 | + |
|
304 | + public static function front_head() { |
|
305 | + if ( is_multisite() ) { |
|
306 | + $old_db_version = get_option( 'frm_db_version' ); |
|
307 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
308 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
309 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
310 | + self::install( $old_db_version ); |
|
311 | + } |
|
312 | + } |
|
313 | + } |
|
314 | 314 | |
315 | 315 | public static function localize_script( $location ) { |
316 | 316 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -370,20 +370,20 @@ discard block |
||
370 | 370 | wp_die(); |
371 | 371 | } |
372 | 372 | |
373 | - public static function activation_install() { |
|
374 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
375 | - FrmFormActionsController::actions_init(); |
|
376 | - self::install(); |
|
377 | - } |
|
373 | + public static function activation_install() { |
|
374 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
375 | + FrmFormActionsController::actions_init(); |
|
376 | + self::install(); |
|
377 | + } |
|
378 | 378 | |
379 | - public static function install( $old_db_version = false ) { |
|
380 | - $frmdb = new FrmDb(); |
|
381 | - $frmdb->upgrade( $old_db_version ); |
|
382 | - } |
|
379 | + public static function install( $old_db_version = false ) { |
|
380 | + $frmdb = new FrmDb(); |
|
381 | + $frmdb->upgrade( $old_db_version ); |
|
382 | + } |
|
383 | 383 | |
384 | - public static function uninstall() { |
|
384 | + public static function uninstall() { |
|
385 | 385 | FrmAppHelper::permission_check('administrator'); |
386 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
386 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
387 | 387 | |
388 | 388 | $frmdb = new FrmDb(); |
389 | 389 | $frmdb->uninstall(); |
@@ -392,48 +392,48 @@ discard block |
||
392 | 392 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
393 | 393 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
394 | 394 | |
395 | - wp_die(); |
|
396 | - } |
|
395 | + wp_die(); |
|
396 | + } |
|
397 | 397 | |
398 | - public static function drop_tables( $tables ) { |
|
399 | - global $wpdb; |
|
400 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
401 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
402 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
403 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
404 | - return $tables; |
|
405 | - } |
|
398 | + public static function drop_tables( $tables ) { |
|
399 | + global $wpdb; |
|
400 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
401 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
402 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
403 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
404 | + return $tables; |
|
405 | + } |
|
406 | 406 | |
407 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
408 | - public static function page_route( $content ) { |
|
409 | - global $post; |
|
407 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
408 | + public static function page_route( $content ) { |
|
409 | + global $post; |
|
410 | 410 | |
411 | - $frm_settings = FrmAppHelper::get_settings(); |
|
412 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
413 | - $content = FrmFormsController::page_preview(); |
|
414 | - } |
|
411 | + $frm_settings = FrmAppHelper::get_settings(); |
|
412 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
413 | + $content = FrmFormsController::page_preview(); |
|
414 | + } |
|
415 | 415 | |
416 | - return $content; |
|
417 | - } |
|
416 | + return $content; |
|
417 | + } |
|
418 | 418 | |
419 | - public static function deauthorize() { |
|
419 | + public static function deauthorize() { |
|
420 | 420 | FrmAppHelper::permission_check('frm_change_settings'); |
421 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
422 | - |
|
423 | - delete_option( 'frmpro-credentials' ); |
|
424 | - delete_option( 'frmpro-authorized' ); |
|
425 | - delete_site_option( 'frmpro-credentials' ); |
|
426 | - delete_site_option( 'frmpro-authorized' ); |
|
427 | - wp_die(); |
|
428 | - } |
|
429 | - |
|
430 | - public static function get_form_shortcode( $atts ) { |
|
431 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
432 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
433 | - } |
|
434 | - |
|
435 | - public static function get_postbox_class() { |
|
436 | - _deprecated_function( __FUNCTION__, '2.0' ); |
|
437 | - return 'postbox-container'; |
|
438 | - } |
|
421 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
422 | + |
|
423 | + delete_option( 'frmpro-credentials' ); |
|
424 | + delete_option( 'frmpro-authorized' ); |
|
425 | + delete_site_option( 'frmpro-credentials' ); |
|
426 | + delete_site_option( 'frmpro-authorized' ); |
|
427 | + wp_die(); |
|
428 | + } |
|
429 | + |
|
430 | + public static function get_form_shortcode( $atts ) { |
|
431 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
432 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
433 | + } |
|
434 | + |
|
435 | + public static function get_postbox_class() { |
|
436 | + _deprecated_function( __FUNCTION__, '2.0' ); |
|
437 | + return 'postbox-container'; |
|
438 | + } |
|
439 | 439 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | <div class="update-nag frm-update-to-pro"> |
136 | 136 | <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> |
137 | 137 | <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> |
138 | - <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
138 | + <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
139 | 139 | </div> |
140 | 140 | <?php |
141 | 141 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | public static function uninstall() { |
388 | - FrmAppHelper::permission_check('administrator'); |
|
388 | + FrmAppHelper::permission_check( 'administrator' ); |
|
389 | 389 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
390 | 390 | |
391 | 391 | $frmdb = new FrmDb(); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | public static function deauthorize() { |
423 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
423 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
424 | 424 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
425 | 425 | |
426 | 426 | delete_option( 'frmpro-credentials' ); |
@@ -2,201 +2,201 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmEntriesController { |
4 | 4 | |
5 | - public static function menu() { |
|
5 | + public static function menu() { |
|
6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
7 | 7 | |
8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
8 | + add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
9 | 9 | |
10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
15 | - } |
|
16 | - } |
|
15 | + } |
|
16 | + } |
|
17 | 17 | |
18 | - /* Display in Back End */ |
|
19 | - public static function route() { |
|
18 | + /* Display in Back End */ |
|
19 | + public static function route() { |
|
20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
21 | 21 | |
22 | - switch ( $action ) { |
|
23 | - case 'show': |
|
24 | - case 'destroy': |
|
25 | - case 'destroy_all': |
|
26 | - return self::$action(); |
|
22 | + switch ( $action ) { |
|
23 | + case 'show': |
|
24 | + case 'destroy': |
|
25 | + case 'destroy_all': |
|
26 | + return self::$action(); |
|
27 | 27 | |
28 | - default: |
|
29 | - do_action( 'frm_entry_action_route', $action ); |
|
30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
31 | - return; |
|
32 | - } |
|
28 | + default: |
|
29 | + do_action( 'frm_entry_action_route', $action ); |
|
30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
31 | + return; |
|
32 | + } |
|
33 | 33 | |
34 | - return self::display_list(); |
|
35 | - } |
|
36 | - } |
|
34 | + return self::display_list(); |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
41 | - return $help; |
|
42 | - } |
|
39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
41 | + return $help; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
47 | - return $help; |
|
48 | - } |
|
47 | + return $help; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | unset( $action, $page ); |
51 | 51 | |
52 | - $screen->add_help_tab( array( |
|
53 | - 'id' => 'formidable-entries-tab', |
|
54 | - 'title' => __( 'Overview', 'formidable' ), |
|
52 | + $screen->add_help_tab( array( |
|
53 | + 'id' => 'formidable-entries-tab', |
|
54 | + 'title' => __( 'Overview', 'formidable' ), |
|
55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
56 | - )); |
|
56 | + )); |
|
57 | 57 | |
58 | - $screen->set_help_sidebar( |
|
58 | + $screen->set_help_sidebar( |
|
59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
60 | 60 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
61 | 61 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'http://formidablepro.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
62 | - ); |
|
62 | + ); |
|
63 | 63 | |
64 | - return $help; |
|
65 | - } |
|
64 | + return $help; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | public static function manage_columns( $columns ) { |
68 | - global $frm_vars, $wpdb; |
|
68 | + global $frm_vars, $wpdb; |
|
69 | 69 | $form_id = FrmForm::get_current_form_id(); |
70 | 70 | |
71 | 71 | $columns[ $form_id . '_id' ] = 'ID'; |
72 | 72 | $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
73 | 73 | |
74 | - if ( ! $form_id ) { |
|
75 | - return $columns; |
|
76 | - } |
|
74 | + if ( ! $form_id ) { |
|
75 | + return $columns; |
|
76 | + } |
|
77 | 77 | |
78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
78 | + $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
79 | 79 | |
80 | - foreach ( $form_cols as $form_col ) { |
|
80 | + foreach ( $form_cols as $form_col ) { |
|
81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
82 | - continue; |
|
83 | - } |
|
82 | + continue; |
|
83 | + } |
|
84 | 84 | |
85 | - if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
85 | + if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
86 | 86 | $sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] ); |
87 | 87 | |
88 | - if ( $sub_form_cols ) { |
|
89 | - foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
88 | + if ( $sub_form_cols ) { |
|
89 | + foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
91 | - unset( $sub_form_cols[ $k ] ); |
|
92 | - continue; |
|
93 | - } |
|
91 | + unset( $sub_form_cols[ $k ] ); |
|
92 | + continue; |
|
93 | + } |
|
94 | 94 | $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
95 | - unset($sub_form_col); |
|
96 | - } |
|
97 | - } |
|
98 | - unset($sub_form_cols); |
|
99 | - } else { |
|
100 | - $col_id = $form_col->field_key; |
|
101 | - if ( $form_col->form_id != $form_id ) { |
|
95 | + unset($sub_form_col); |
|
96 | + } |
|
97 | + } |
|
98 | + unset($sub_form_cols); |
|
99 | + } else { |
|
100 | + $col_id = $form_col->field_key; |
|
101 | + if ( $form_col->form_id != $form_id ) { |
|
102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
105 | + if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
106 | 106 | $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
107 | - } |
|
107 | + } |
|
108 | 108 | $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
109 | - } |
|
110 | - } |
|
109 | + } |
|
110 | + } |
|
111 | 111 | |
112 | 112 | $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
113 | 113 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
114 | 114 | $columns[ $form_id . '_ip' ] = 'IP'; |
115 | 115 | |
116 | - $frm_vars['cols'] = $columns; |
|
116 | + $frm_vars['cols'] = $columns; |
|
117 | 117 | |
118 | 118 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
119 | 119 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
120 | 120 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - return $columns; |
|
124 | - } |
|
123 | + return $columns; |
|
124 | + } |
|
125 | 125 | |
126 | 126 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
127 | 127 | $menu_name = FrmAppHelper::get_menu_name(); |
128 | 128 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
129 | 129 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
130 | - return $check; |
|
131 | - } |
|
130 | + return $check; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | if ( empty( $prev_value ) ) { |
134 | 134 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
135 | 135 | } |
136 | 136 | |
137 | - global $frm_vars; |
|
138 | - //add a check so we don't create a loop |
|
139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
137 | + global $frm_vars; |
|
138 | + //add a check so we don't create a loop |
|
139 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
140 | 140 | |
141 | - return $check; |
|
142 | - } |
|
141 | + return $check; |
|
142 | + } |
|
143 | 143 | |
144 | - //add hidden columns back from other forms |
|
144 | + //add hidden columns back from other forms |
|
145 | 145 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
146 | 146 | $menu_name = FrmAppHelper::get_menu_name(); |
147 | 147 | $sanitized = sanitize_title( $menu_name ); |
148 | 148 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
149 | 149 | if ( $meta_key != $this_page_name ) { |
150 | - return; |
|
151 | - } |
|
152 | - |
|
153 | - global $frm_vars; |
|
154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
155 | - return; //don't continue if there's no previous value |
|
156 | - } |
|
157 | - |
|
158 | - foreach ( $meta_value as $mk => $mv ) { |
|
159 | - //remove blank values |
|
160 | - if ( empty( $mv ) ) { |
|
161 | - unset( $meta_value[ $mk ] ); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - $cur_form_prefix = reset($meta_value); |
|
166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
167 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
168 | - $save = false; |
|
169 | - |
|
170 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
150 | + return; |
|
151 | + } |
|
152 | + |
|
153 | + global $frm_vars; |
|
154 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
155 | + return; //don't continue if there's no previous value |
|
156 | + } |
|
157 | + |
|
158 | + foreach ( $meta_value as $mk => $mv ) { |
|
159 | + //remove blank values |
|
160 | + if ( empty( $mv ) ) { |
|
161 | + unset( $meta_value[ $mk ] ); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + $cur_form_prefix = reset($meta_value); |
|
166 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
167 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
168 | + $save = false; |
|
169 | + |
|
170 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
171 | 171 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
172 | - //don't add blank cols or process included cols |
|
173 | - continue; |
|
174 | - } |
|
172 | + //don't add blank cols or process included cols |
|
173 | + continue; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | $form_prefix = explode( '_', $prev_hidden ); |
177 | - $form_prefix = $form_prefix[0]; |
|
178 | - if ( $form_prefix == $cur_form_prefix ) { |
|
179 | - //don't add back columns that are meant to be hidden |
|
180 | - continue; |
|
181 | - } |
|
177 | + $form_prefix = $form_prefix[0]; |
|
178 | + if ( $form_prefix == $cur_form_prefix ) { |
|
179 | + //don't add back columns that are meant to be hidden |
|
180 | + continue; |
|
181 | + } |
|
182 | 182 | |
183 | - $meta_value[] = $prev_hidden; |
|
184 | - $save = true; |
|
185 | - unset($form_prefix); |
|
186 | - } |
|
183 | + $meta_value[] = $prev_hidden; |
|
184 | + $save = true; |
|
185 | + unset($form_prefix); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | if ( $save ) { |
189 | - $user = wp_get_current_user(); |
|
189 | + $user = wp_get_current_user(); |
|
190 | 190 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
191 | - } |
|
192 | - } |
|
191 | + } |
|
192 | + } |
|
193 | 193 | |
194 | 194 | public static function save_per_page( $save, $option, $value ) { |
195 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
196 | - $save = (int) $value; |
|
197 | - } |
|
198 | - return $save; |
|
199 | - } |
|
195 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
196 | + $save = (int) $value; |
|
197 | + } |
|
198 | + return $save; |
|
199 | + } |
|
200 | 200 | |
201 | 201 | public static function sortable_columns() { |
202 | 202 | $form_id = FrmForm::get_current_form_id(); |
@@ -222,226 +222,226 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | public static function hidden_columns( $result ) { |
225 | - global $frm_vars; |
|
225 | + global $frm_vars; |
|
226 | 226 | |
227 | 227 | $form_id = FrmForm::get_current_form_id(); |
228 | 228 | |
229 | - $return = false; |
|
230 | - foreach ( (array) $result as $r ) { |
|
231 | - if ( ! empty( $r ) ) { |
|
232 | - $form_prefix = explode( '_', $r ); |
|
233 | - $form_prefix = $form_prefix[0]; |
|
229 | + $return = false; |
|
230 | + foreach ( (array) $result as $r ) { |
|
231 | + if ( ! empty( $r ) ) { |
|
232 | + $form_prefix = explode( '_', $r ); |
|
233 | + $form_prefix = $form_prefix[0]; |
|
234 | 234 | |
235 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
236 | - $return = true; |
|
237 | - break; |
|
238 | - } |
|
235 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
236 | + $return = true; |
|
237 | + break; |
|
238 | + } |
|
239 | 239 | |
240 | - unset($form_prefix); |
|
241 | - } |
|
242 | - } |
|
240 | + unset($form_prefix); |
|
241 | + } |
|
242 | + } |
|
243 | 243 | |
244 | - if ( $return ) { |
|
244 | + if ( $return ) { |
|
245 | 245 | return $result; |
246 | 246 | } |
247 | 247 | |
248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
249 | - $max_columns = 8; |
|
250 | - if ( $i <= $max_columns ) { |
|
248 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
249 | + $max_columns = 8; |
|
250 | + if ( $i <= $max_columns ) { |
|
251 | 251 | return $result; |
252 | 252 | } |
253 | 253 | |
254 | - global $frm_vars; |
|
255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
257 | - } |
|
254 | + global $frm_vars; |
|
255 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
256 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
257 | + } |
|
258 | 258 | |
259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
260 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
261 | - } else { |
|
262 | - $cols = $frm_vars['cols']; |
|
263 | - $cols = array_reverse($cols, true); |
|
259 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
260 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
261 | + } else { |
|
262 | + $cols = $frm_vars['cols']; |
|
263 | + $cols = array_reverse($cols, true); |
|
264 | 264 | |
265 | 265 | $result[] = $form_id . '_id'; |
266 | - $i--; |
|
266 | + $i--; |
|
267 | 267 | |
268 | 268 | $result[] = $form_id . '_item_key'; |
269 | - $i--; |
|
269 | + $i--; |
|
270 | 270 | |
271 | 271 | foreach ( $cols as $col_key => $col ) { |
272 | - if ( $i > $max_columns ) { |
|
272 | + if ( $i > $max_columns ) { |
|
273 | 273 | $result[] = $col_key; |
274 | 274 | } |
275 | - //remove some columns by default |
|
276 | - $i--; |
|
277 | - unset($col_key, $col); |
|
278 | - } |
|
279 | - } |
|
275 | + //remove some columns by default |
|
276 | + $i--; |
|
277 | + unset($col_key, $col); |
|
278 | + } |
|
279 | + } |
|
280 | 280 | |
281 | - return $result; |
|
282 | - } |
|
281 | + return $result; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | public static function display_list( $message = '', $errors = array() ) { |
285 | - global $wpdb, $frm_vars; |
|
285 | + global $wpdb, $frm_vars; |
|
286 | 286 | |
287 | 287 | $form = FrmForm::get_current_form(); |
288 | 288 | $params = FrmForm::get_admin_params( $form ); |
289 | 289 | |
290 | - if ( $form ) { |
|
291 | - $params['form'] = $form->id; |
|
292 | - $frm_vars['current_form'] = $form; |
|
290 | + if ( $form ) { |
|
291 | + $params['form'] = $form->id; |
|
292 | + $frm_vars['current_form'] = $form; |
|
293 | 293 | |
294 | - if ( 'trash' == $form->status ) { |
|
295 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
296 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
297 | - $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
298 | - unset( $time_to_delete, $delete_timestamp ); |
|
299 | - } |
|
294 | + if ( 'trash' == $form->status ) { |
|
295 | + $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
296 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
297 | + $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
298 | + unset( $time_to_delete, $delete_timestamp ); |
|
299 | + } |
|
300 | 300 | } |
301 | 301 | |
302 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
302 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
303 | 303 | |
304 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
304 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
305 | 305 | |
306 | - $pagenum = $wp_list_table->get_pagenum(); |
|
306 | + $pagenum = $wp_list_table->get_pagenum(); |
|
307 | 307 | |
308 | - $wp_list_table->prepare_items(); |
|
308 | + $wp_list_table->prepare_items(); |
|
309 | 309 | |
310 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
311 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
310 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
311 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
313 | - if ( headers_sent() ) { |
|
314 | - echo FrmAppHelper::js_redirect($url); |
|
315 | - } else { |
|
316 | - wp_redirect( esc_url_raw( $url ) ); |
|
317 | - } |
|
318 | - die(); |
|
319 | - } |
|
320 | - |
|
321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
322 | - $message = __( 'Your import is complete', 'formidable' ); |
|
323 | - } |
|
313 | + if ( headers_sent() ) { |
|
314 | + echo FrmAppHelper::js_redirect($url); |
|
315 | + } else { |
|
316 | + wp_redirect( esc_url_raw( $url ) ); |
|
317 | + } |
|
318 | + die(); |
|
319 | + } |
|
320 | + |
|
321 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
322 | + $message = __( 'Your import is complete', 'formidable' ); |
|
323 | + } |
|
324 | 324 | |
325 | 325 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
326 | - } |
|
326 | + } |
|
327 | 327 | |
328 | - /* Back End CRUD */ |
|
328 | + /* Back End CRUD */ |
|
329 | 329 | public static function show( $id = 0 ) { |
330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
330 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
331 | 331 | |
332 | - if ( ! $id ) { |
|
332 | + if ( ! $id ) { |
|
333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
334 | 334 | |
335 | - if ( ! $id ) { |
|
335 | + if ( ! $id ) { |
|
336 | 336 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
337 | - } |
|
338 | - } |
|
337 | + } |
|
338 | + } |
|
339 | 339 | |
340 | - $entry = FrmEntry::getOne($id, true); |
|
340 | + $entry = FrmEntry::getOne($id, true); |
|
341 | 341 | |
342 | - $data = maybe_unserialize($entry->description); |
|
342 | + $data = maybe_unserialize($entry->description); |
|
343 | 343 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
344 | 344 | $data = array( 'referrer' => $data ); |
345 | 345 | } |
346 | 346 | |
347 | 347 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
348 | - $to_emails = array(); |
|
348 | + $to_emails = array(); |
|
349 | 349 | |
350 | 350 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
351 | - } |
|
351 | + } |
|
352 | 352 | |
353 | - public static function destroy() { |
|
354 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
353 | + public static function destroy() { |
|
354 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
355 | 355 | |
356 | 356 | $params = FrmForm::get_admin_params(); |
357 | 357 | |
358 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
359 | - //unlink entry from post |
|
360 | - global $wpdb; |
|
358 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
359 | + //unlink entry from post |
|
360 | + global $wpdb; |
|
361 | 361 | $wpdb->update( $wpdb->prefix .'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
362 | - } |
|
362 | + } |
|
363 | 363 | |
364 | - $message = ''; |
|
365 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
366 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
367 | - } |
|
364 | + $message = ''; |
|
365 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
366 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
367 | + } |
|
368 | 368 | |
369 | - self::display_list( $message ); |
|
370 | - } |
|
369 | + self::display_list( $message ); |
|
370 | + } |
|
371 | 371 | |
372 | - public static function destroy_all() { |
|
373 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
374 | - $frm_settings = FrmAppHelper::get_settings(); |
|
375 | - wp_die( $frm_settings->admin_permission ); |
|
376 | - } |
|
372 | + public static function destroy_all() { |
|
373 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
374 | + $frm_settings = FrmAppHelper::get_settings(); |
|
375 | + wp_die( $frm_settings->admin_permission ); |
|
376 | + } |
|
377 | 377 | |
378 | - global $wpdb; |
|
378 | + global $wpdb; |
|
379 | 379 | $params = FrmForm::get_admin_params(); |
380 | - $message = ''; |
|
381 | - $errors = array(); |
|
382 | - $form_id = (int) $params['form']; |
|
380 | + $message = ''; |
|
381 | + $errors = array(); |
|
382 | + $form_id = (int) $params['form']; |
|
383 | 383 | |
384 | - if ( $form_id ) { |
|
385 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
384 | + if ( $form_id ) { |
|
385 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
386 | 386 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
387 | 387 | |
388 | - if ( $action ) { |
|
389 | - // this action takes a while, so only trigger it if there are posts to delete |
|
390 | - foreach ( $entry_ids as $entry_id ) { |
|
391 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
392 | - unset( $entry_id ); |
|
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
397 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
398 | - if ( $results ) { |
|
399 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
400 | - } |
|
401 | - } else { |
|
402 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
403 | - } |
|
404 | - |
|
405 | - self::display_list( $message, $errors ); |
|
406 | - } |
|
407 | - |
|
408 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
409 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
410 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
411 | - } |
|
412 | - |
|
413 | - public static function get_form( $filename, $form, $title, $description ) { |
|
414 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
415 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
416 | - } |
|
417 | - |
|
418 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
388 | + if ( $action ) { |
|
389 | + // this action takes a while, so only trigger it if there are posts to delete |
|
390 | + foreach ( $entry_ids as $entry_id ) { |
|
391 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
392 | + unset( $entry_id ); |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
397 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
398 | + if ( $results ) { |
|
399 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
400 | + } |
|
401 | + } else { |
|
402 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
403 | + } |
|
404 | + |
|
405 | + self::display_list( $message, $errors ); |
|
406 | + } |
|
407 | + |
|
408 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
409 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
410 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
411 | + } |
|
412 | + |
|
413 | + public static function get_form( $filename, $form, $title, $description ) { |
|
414 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
415 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
416 | + } |
|
417 | + |
|
418 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
419 | 419 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
420 | 420 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
421 | - return; |
|
422 | - } |
|
421 | + return; |
|
422 | + } |
|
423 | 423 | |
424 | - global $frm_vars; |
|
424 | + global $frm_vars; |
|
425 | 425 | |
426 | 426 | $form = FrmForm::getOne( $form_id ); |
427 | - if ( ! $form ) { |
|
428 | - return; |
|
429 | - } |
|
427 | + if ( ! $form ) { |
|
428 | + return; |
|
429 | + } |
|
430 | 430 | |
431 | 431 | $params = FrmForm::get_params( $form ); |
432 | 432 | |
433 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
434 | - $frm_vars['form_params'] = array(); |
|
435 | - } |
|
433 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
434 | + $frm_vars['form_params'] = array(); |
|
435 | + } |
|
436 | 436 | $frm_vars['form_params'][ $form->id ] = $params; |
437 | 437 | |
438 | 438 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
439 | - return; |
|
440 | - } |
|
439 | + return; |
|
440 | + } |
|
441 | 441 | |
442 | - if ( $errors == '' ) { |
|
442 | + if ( $errors == '' ) { |
|
443 | 443 | $errors = FrmEntryValidate::validate( $_POST ); |
444 | - } |
|
444 | + } |
|
445 | 445 | |
446 | 446 | /** |
447 | 447 | * Use this filter to add trigger actions and add errors after |
@@ -452,102 +452,102 @@ discard block |
||
452 | 452 | |
453 | 453 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
454 | 454 | |
455 | - if ( empty( $errors ) ) { |
|
455 | + if ( empty( $errors ) ) { |
|
456 | 456 | $_POST['frm_skip_cookie'] = 1; |
457 | - if ( $params['action'] == 'create' ) { |
|
457 | + if ( $params['action'] == 'create' ) { |
|
458 | 458 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
459 | 459 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
460 | - } |
|
461 | - } |
|
460 | + } |
|
461 | + } |
|
462 | 462 | |
463 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
463 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
464 | 464 | unset( $_POST['frm_skip_cookie'] ); |
465 | - } |
|
466 | - } |
|
467 | - |
|
468 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
469 | - self::_delete_entry( $atts['id'], $form ); |
|
470 | - return $url; |
|
471 | - } |
|
472 | - |
|
473 | - //Delete entry if not redirected |
|
474 | - public static function delete_entry_after_save( $atts ) { |
|
475 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
476 | - } |
|
477 | - |
|
478 | - private static function _delete_entry( $entry_id, $form ) { |
|
479 | - if ( ! $form ) { |
|
480 | - return; |
|
481 | - } |
|
482 | - |
|
483 | - $form->options = maybe_unserialize( $form->options ); |
|
484 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
485 | - FrmEntry::destroy( $entry_id ); |
|
486 | - } |
|
487 | - } |
|
465 | + } |
|
466 | + } |
|
467 | + |
|
468 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
469 | + self::_delete_entry( $atts['id'], $form ); |
|
470 | + return $url; |
|
471 | + } |
|
472 | + |
|
473 | + //Delete entry if not redirected |
|
474 | + public static function delete_entry_after_save( $atts ) { |
|
475 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
476 | + } |
|
477 | + |
|
478 | + private static function _delete_entry( $entry_id, $form ) { |
|
479 | + if ( ! $form ) { |
|
480 | + return; |
|
481 | + } |
|
482 | + |
|
483 | + $form->options = maybe_unserialize( $form->options ); |
|
484 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
485 | + FrmEntry::destroy( $entry_id ); |
|
486 | + } |
|
487 | + } |
|
488 | 488 | |
489 | 489 | public static function show_entry_shortcode( $atts ) { |
490 | 490 | return FrmEntryFormat::show_entry( $atts ); |
491 | 491 | } |
492 | 492 | |
493 | - public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) { |
|
494 | - $field = FrmField::getOne($meta->field_id); |
|
495 | - if ( ! $field ) { |
|
496 | - return $value; |
|
497 | - } |
|
493 | + public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) { |
|
494 | + $field = FrmField::getOne($meta->field_id); |
|
495 | + if ( ! $field ) { |
|
496 | + return $value; |
|
497 | + } |
|
498 | 498 | |
499 | - $value = self::filter_display_value($value, $field, $atts); |
|
500 | - return $value; |
|
501 | - } |
|
499 | + $value = self::filter_display_value($value, $field, $atts); |
|
500 | + return $value; |
|
501 | + } |
|
502 | 502 | |
503 | 503 | public static function &filter_shortcode_value( $value, $tag, $atts, $field ) { |
504 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
504 | + $plain_text = add_filter('frm_plain_text_email', true); |
|
505 | 505 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
506 | 506 | |
507 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
508 | - return $value; |
|
509 | - } |
|
507 | + if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
508 | + return $value; |
|
509 | + } |
|
510 | 510 | |
511 | - return self::filter_display_value($value, $field, $atts); |
|
512 | - } |
|
511 | + return self::filter_display_value($value, $field, $atts); |
|
512 | + } |
|
513 | 513 | |
514 | - public static function &filter_display_value( $value, $field, $atts = array() ) { |
|
515 | - $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false; |
|
514 | + public static function &filter_display_value( $value, $field, $atts = array() ) { |
|
515 | + $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false; |
|
516 | 516 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) { |
517 | - return $value; |
|
518 | - } |
|
519 | - |
|
520 | - $f_values = $f_labels = array(); |
|
521 | - |
|
522 | - foreach ( $field->options as $opt_key => $opt ) { |
|
523 | - if ( ! is_array($opt) ) { |
|
524 | - continue; |
|
525 | - } |
|
526 | - |
|
527 | - $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt); |
|
528 | - $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ]; |
|
529 | - if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) { |
|
530 | - unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] ); |
|
531 | - } |
|
532 | - unset($opt_key, $opt); |
|
533 | - } |
|
534 | - |
|
535 | - if ( ! empty($f_values) ) { |
|
536 | - foreach ( (array) $value as $v_key => $val ) { |
|
537 | - if ( in_array($val, $f_values) ) { |
|
538 | - $opt = array_search($val, $f_values); |
|
539 | - if ( is_array($value) ) { |
|
540 | - $value[ $v_key ] = $f_labels[ $opt ]; |
|
541 | - } else { |
|
542 | - $value = $f_labels[ $opt ]; |
|
543 | - } |
|
544 | - } |
|
545 | - unset($v_key, $val); |
|
546 | - } |
|
547 | - } |
|
548 | - |
|
549 | - return $value; |
|
550 | - } |
|
517 | + return $value; |
|
518 | + } |
|
519 | + |
|
520 | + $f_values = $f_labels = array(); |
|
521 | + |
|
522 | + foreach ( $field->options as $opt_key => $opt ) { |
|
523 | + if ( ! is_array($opt) ) { |
|
524 | + continue; |
|
525 | + } |
|
526 | + |
|
527 | + $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt); |
|
528 | + $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ]; |
|
529 | + if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) { |
|
530 | + unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] ); |
|
531 | + } |
|
532 | + unset($opt_key, $opt); |
|
533 | + } |
|
534 | + |
|
535 | + if ( ! empty($f_values) ) { |
|
536 | + foreach ( (array) $value as $v_key => $val ) { |
|
537 | + if ( in_array($val, $f_values) ) { |
|
538 | + $opt = array_search($val, $f_values); |
|
539 | + if ( is_array($value) ) { |
|
540 | + $value[ $v_key ] = $f_labels[ $opt ]; |
|
541 | + } else { |
|
542 | + $value = $f_labels[ $opt ]; |
|
543 | + } |
|
544 | + } |
|
545 | + unset($v_key, $val); |
|
546 | + } |
|
547 | + } |
|
548 | + |
|
549 | + return $value; |
|
550 | + } |
|
551 | 551 | |
552 | 552 | public static function get_params( $form = null ) { |
553 | 553 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' ); |
@@ -555,13 +555,13 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | public static function entry_sidebar( $entry ) { |
558 | - $data = maybe_unserialize($entry->description); |
|
559 | - $date_format = get_option('date_format'); |
|
560 | - $time_format = get_option('time_format'); |
|
558 | + $data = maybe_unserialize($entry->description); |
|
559 | + $date_format = get_option('date_format'); |
|
560 | + $time_format = get_option('time_format'); |
|
561 | 561 | if ( isset( $data['browser'] ) ) { |
562 | 562 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
563 | 563 | } |
564 | 564 | |
565 | 565 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
566 | - } |
|
566 | + } |
|
567 | 567 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | public static function menu() { |
6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
7 | 7 | |
8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
8 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
9 | 9 | |
10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | 'id' => 'formidable-entries-tab', |
54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
55 | 55 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
56 | - )); |
|
56 | + ) ); |
|
57 | 57 | |
58 | 58 | $screen->set_help_sidebar( |
59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | global $frm_vars, $wpdb; |
69 | 69 | $form_id = FrmForm::get_current_form_id(); |
70 | 70 | |
71 | - $columns[ $form_id . '_id' ] = 'ID'; |
|
72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
71 | + $columns[$form_id . '_id'] = 'ID'; |
|
72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
73 | 73 | |
74 | 74 | if ( ! $form_id ) { |
75 | 75 | return $columns; |
76 | 76 | } |
77 | 77 | |
78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
78 | + $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
79 | 79 | |
80 | 80 | foreach ( $form_cols as $form_col ) { |
81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
@@ -88,30 +88,30 @@ discard block |
||
88 | 88 | if ( $sub_form_cols ) { |
89 | 89 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
91 | - unset( $sub_form_cols[ $k ] ); |
|
91 | + unset( $sub_form_cols[$k] ); |
|
92 | 92 | continue; |
93 | 93 | } |
94 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
95 | - unset($sub_form_col); |
|
94 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
95 | + unset( $sub_form_col ); |
|
96 | 96 | } |
97 | 97 | } |
98 | - unset($sub_form_cols); |
|
98 | + unset( $sub_form_cols ); |
|
99 | 99 | } else { |
100 | 100 | $col_id = $form_col->field_key; |
101 | 101 | if ( $form_col->form_id != $form_id ) { |
102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
103 | 103 | } |
104 | 104 | |
105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
106 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
105 | + if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) { |
|
106 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
107 | 107 | } |
108 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
108 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
113 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
114 | - $columns[ $form_id . '_ip' ] = 'IP'; |
|
112 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
113 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
114 | + $columns[$form_id . '_ip'] = 'IP'; |
|
115 | 115 | |
116 | 116 | $frm_vars['cols'] = $columns; |
117 | 117 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | global $frm_vars; |
138 | 138 | //add a check so we don't create a loop |
139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
139 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
140 | 140 | |
141 | 141 | return $check; |
142 | 142 | } |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | global $frm_vars; |
154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
154 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
155 | 155 | return; //don't continue if there's no previous value |
156 | 156 | } |
157 | 157 | |
158 | 158 | foreach ( $meta_value as $mk => $mv ) { |
159 | 159 | //remove blank values |
160 | - if ( empty( $mv ) ) { |
|
161 | - unset( $meta_value[ $mk ] ); |
|
160 | + if ( empty( $mv ) ) { |
|
161 | + unset( $meta_value[$mk] ); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - $cur_form_prefix = reset($meta_value); |
|
166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
165 | + $cur_form_prefix = reset( $meta_value ); |
|
166 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
167 | 167 | $cur_form_prefix = $cur_form_prefix[0]; |
168 | 168 | $save = false; |
169 | 169 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $meta_value[] = $prev_hidden; |
184 | 184 | $save = true; |
185 | - unset($form_prefix); |
|
185 | + unset( $form_prefix ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | if ( $save ) { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | foreach ( $fields as $field ) { |
215 | 215 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
216 | 216 | // Can't sort on checkboxes because they are stored serialized, or post fields |
217 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
217 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | break; |
238 | 238 | } |
239 | 239 | |
240 | - unset($form_prefix); |
|
240 | + unset( $form_prefix ); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -245,36 +245,36 @@ discard block |
||
245 | 245 | return $result; |
246 | 246 | } |
247 | 247 | |
248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
248 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
249 | 249 | $max_columns = 8; |
250 | 250 | if ( $i <= $max_columns ) { |
251 | 251 | return $result; |
252 | 252 | } |
253 | 253 | |
254 | 254 | global $frm_vars; |
255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
255 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
256 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
257 | 257 | } |
258 | 258 | |
259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
259 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) { |
|
260 | 260 | $result = $frm_vars['current_form']->options['hidden_cols']; |
261 | 261 | } else { |
262 | 262 | $cols = $frm_vars['cols']; |
263 | - $cols = array_reverse($cols, true); |
|
263 | + $cols = array_reverse( $cols, true ); |
|
264 | 264 | |
265 | 265 | $result[] = $form_id . '_id'; |
266 | - $i--; |
|
266 | + $i --; |
|
267 | 267 | |
268 | 268 | $result[] = $form_id . '_item_key'; |
269 | - $i--; |
|
269 | + $i --; |
|
270 | 270 | |
271 | 271 | foreach ( $cols as $col_key => $col ) { |
272 | 272 | if ( $i > $max_columns ) { |
273 | 273 | $result[] = $col_key; |
274 | 274 | } |
275 | 275 | //remove some columns by default |
276 | - $i--; |
|
277 | - unset($col_key, $col); |
|
276 | + $i --; |
|
277 | + unset( $col_key, $col ); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
313 | 313 | if ( headers_sent() ) { |
314 | - echo FrmAppHelper::js_redirect($url); |
|
314 | + echo FrmAppHelper::js_redirect( $url ); |
|
315 | 315 | } else { |
316 | 316 | wp_redirect( esc_url_raw( $url ) ); |
317 | 317 | } |
318 | 318 | die(); |
319 | 319 | } |
320 | 320 | |
321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
321 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
322 | 322 | $message = __( 'Your import is complete', 'formidable' ); |
323 | 323 | } |
324 | 324 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | /* Back End CRUD */ |
329 | 329 | public static function show( $id = 0 ) { |
330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
330 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
331 | 331 | |
332 | 332 | if ( ! $id ) { |
333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - $entry = FrmEntry::getOne($id, true); |
|
340 | + $entry = FrmEntry::getOne( $id, true ); |
|
341 | 341 | |
342 | - $data = maybe_unserialize($entry->description); |
|
342 | + $data = maybe_unserialize( $entry->description ); |
|
343 | 343 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
344 | 344 | $data = array( 'referrer' => $data ); |
345 | 345 | } |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | public static function destroy() { |
354 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
354 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
355 | 355 | |
356 | 356 | $params = FrmForm::get_admin_params(); |
357 | 357 | |
358 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
358 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
359 | 359 | //unlink entry from post |
360 | 360 | global $wpdb; |
361 | 361 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | if ( ! isset( $frm_vars['form_params'] ) ) { |
434 | 434 | $frm_vars['form_params'] = array(); |
435 | 435 | } |
436 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
436 | + $frm_vars['form_params'][$form->id] = $params; |
|
437 | 437 | |
438 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
438 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
439 | 439 | return; |
440 | 440 | } |
441 | 441 | |
@@ -450,13 +450,13 @@ discard block |
||
450 | 450 | */ |
451 | 451 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
452 | 452 | |
453 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
453 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
454 | 454 | |
455 | 455 | if ( empty( $errors ) ) { |
456 | 456 | $_POST['frm_skip_cookie'] = 1; |
457 | 457 | if ( $params['action'] == 'create' ) { |
458 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
459 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
458 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
459 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
@@ -491,28 +491,28 @@ discard block |
||
491 | 491 | } |
492 | 492 | |
493 | 493 | public static function &filter_email_value( $value, $meta, $entry, $atts = array() ) { |
494 | - $field = FrmField::getOne($meta->field_id); |
|
494 | + $field = FrmField::getOne( $meta->field_id ); |
|
495 | 495 | if ( ! $field ) { |
496 | 496 | return $value; |
497 | 497 | } |
498 | 498 | |
499 | - $value = self::filter_display_value($value, $field, $atts); |
|
499 | + $value = self::filter_display_value( $value, $field, $atts ); |
|
500 | 500 | return $value; |
501 | 501 | } |
502 | 502 | |
503 | 503 | public static function &filter_shortcode_value( $value, $tag, $atts, $field ) { |
504 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
504 | + $plain_text = add_filter( 'frm_plain_text_email', true ); |
|
505 | 505 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
506 | 506 | |
507 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
507 | + if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) { |
|
508 | 508 | return $value; |
509 | 509 | } |
510 | 510 | |
511 | - return self::filter_display_value($value, $field, $atts); |
|
511 | + return self::filter_display_value( $value, $field, $atts ); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | public static function &filter_display_value( $value, $field, $atts = array() ) { |
515 | - $saved_value = ( isset($atts['saved_value']) && $atts['saved_value'] ) ? true : false; |
|
515 | + $saved_value = ( isset( $atts['saved_value'] ) && $atts['saved_value'] ) ? true : false; |
|
516 | 516 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'radio', 'select' ) ) || ! FrmField::is_option_true( $field, 'separate_value' ) || $saved_value ) { |
517 | 517 | return $value; |
518 | 518 | } |
@@ -520,29 +520,29 @@ discard block |
||
520 | 520 | $f_values = $f_labels = array(); |
521 | 521 | |
522 | 522 | foreach ( $field->options as $opt_key => $opt ) { |
523 | - if ( ! is_array($opt) ) { |
|
523 | + if ( ! is_array( $opt ) ) { |
|
524 | 524 | continue; |
525 | 525 | } |
526 | 526 | |
527 | - $f_labels[ $opt_key ] = isset( $opt['label'] ) ? $opt['label'] : reset($opt); |
|
528 | - $f_values[ $opt_key ] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[ $opt_key ]; |
|
529 | - if ( $f_labels[ $opt_key ] == $f_values[ $opt_key ] ) { |
|
530 | - unset( $f_values[ $opt_key ], $f_labels[ $opt_key ] ); |
|
527 | + $f_labels[$opt_key] = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
528 | + $f_values[$opt_key] = isset( $opt['value'] ) ? $opt['value'] : $f_labels[$opt_key]; |
|
529 | + if ( $f_labels[$opt_key] == $f_values[$opt_key] ) { |
|
530 | + unset( $f_values[$opt_key], $f_labels[$opt_key] ); |
|
531 | 531 | } |
532 | - unset($opt_key, $opt); |
|
532 | + unset( $opt_key, $opt ); |
|
533 | 533 | } |
534 | 534 | |
535 | - if ( ! empty($f_values) ) { |
|
535 | + if ( ! empty( $f_values ) ) { |
|
536 | 536 | foreach ( (array) $value as $v_key => $val ) { |
537 | - if ( in_array($val, $f_values) ) { |
|
538 | - $opt = array_search($val, $f_values); |
|
539 | - if ( is_array($value) ) { |
|
540 | - $value[ $v_key ] = $f_labels[ $opt ]; |
|
537 | + if ( in_array( $val, $f_values ) ) { |
|
538 | + $opt = array_search( $val, $f_values ); |
|
539 | + if ( is_array( $value ) ) { |
|
540 | + $value[$v_key] = $f_labels[$opt]; |
|
541 | 541 | } else { |
542 | - $value = $f_labels[ $opt ]; |
|
542 | + $value = $f_labels[$opt]; |
|
543 | 543 | } |
544 | 544 | } |
545 | - unset($v_key, $val); |
|
545 | + unset( $v_key, $val ); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
@@ -555,9 +555,9 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | public static function entry_sidebar( $entry ) { |
558 | - $data = maybe_unserialize($entry->description); |
|
559 | - $date_format = get_option('date_format'); |
|
560 | - $time_format = get_option('time_format'); |
|
558 | + $data = maybe_unserialize( $entry->description ); |
|
559 | + $date_format = get_option( 'date_format' ); |
|
560 | + $time_format = get_option( 'time_format' ); |
|
561 | 561 | if ( isset( $data['browser'] ) ) { |
562 | 562 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
563 | 563 | } |