@@ -1,90 +1,90 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmHooksController { |
4 | - /** |
|
5 | - * Trigger plugin-wide hook loading |
|
6 | - */ |
|
7 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | - |
|
10 | - $trigger_hooks = $hooks; |
|
11 | - $hooks = (array) $hooks; |
|
12 | - |
|
13 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | - if ( is_admin() ) { |
|
15 | - $hooks[] = 'load_admin_hooks'; |
|
16 | - if ( defined( 'DOING_AJAX' ) ) { |
|
17 | - $hooks[] = 'load_ajax_hooks'; |
|
18 | - $hooks[] = 'load_form_hooks'; |
|
19 | - } |
|
20 | - } |
|
21 | - |
|
22 | - if ( is_multisite() ) { |
|
23 | - $hooks[] = 'load_multisite_hooks'; |
|
24 | - } |
|
25 | - } else { |
|
26 | - // Make sure the hooks are only triggered once |
|
27 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | - } |
|
29 | - unset( $trigger_hooks ); |
|
30 | - |
|
31 | - // Instansiate Controllers |
|
32 | - foreach ( $controllers as $c ) { |
|
33 | - foreach ( $hooks as $hook ) { |
|
4 | + /** |
|
5 | + * Trigger plugin-wide hook loading |
|
6 | + */ |
|
7 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | + |
|
10 | + $trigger_hooks = $hooks; |
|
11 | + $hooks = (array) $hooks; |
|
12 | + |
|
13 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | + if ( is_admin() ) { |
|
15 | + $hooks[] = 'load_admin_hooks'; |
|
16 | + if ( defined( 'DOING_AJAX' ) ) { |
|
17 | + $hooks[] = 'load_ajax_hooks'; |
|
18 | + $hooks[] = 'load_form_hooks'; |
|
19 | + } |
|
20 | + } |
|
21 | + |
|
22 | + if ( is_multisite() ) { |
|
23 | + $hooks[] = 'load_multisite_hooks'; |
|
24 | + } |
|
25 | + } else { |
|
26 | + // Make sure the hooks are only triggered once |
|
27 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | + } |
|
29 | + unset( $trigger_hooks ); |
|
30 | + |
|
31 | + // Instansiate Controllers |
|
32 | + foreach ( $controllers as $c ) { |
|
33 | + foreach ( $hooks as $hook ) { |
|
34 | 34 | call_user_func( array( $c, $hook ) ); |
35 | 35 | unset( $hook ); |
36 | - } |
|
36 | + } |
|
37 | 37 | unset( $c ); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | - public static function trigger_load_form_hooks() { |
|
43 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | - } |
|
42 | + public static function trigger_load_form_hooks() { |
|
43 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | public static function load_hooks() { |
47 | - if ( ! is_admin() ) { |
|
48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | - } |
|
47 | + if ( ! is_admin() ) { |
|
48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | + } |
|
50 | 50 | |
51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
53 | 53 | |
54 | - // Entries controller |
|
55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
58 | - add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
54 | + // Entries controller |
|
55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
58 | + add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
59 | 59 | |
60 | - // Form Actions Controller |
|
61 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
60 | + // Form Actions Controller |
|
61 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
62 | 62 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
63 | 63 | |
64 | - // Forms Controller |
|
65 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
64 | + // Forms Controller |
|
65 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
66 | 66 | add_action( 'init', 'FrmFormsController::front_head' ); |
67 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
68 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
69 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
67 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
68 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
69 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
70 | 70 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
71 | 71 | |
72 | 72 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
73 | 73 | |
74 | - // Form Shortcodes |
|
75 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
74 | + // Form Shortcodes |
|
75 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
76 | 76 | |
77 | - // Styles Controller |
|
78 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
79 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
80 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
81 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
82 | - } |
|
77 | + // Styles Controller |
|
78 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
79 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
80 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
81 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
82 | + } |
|
83 | 83 | |
84 | 84 | public static function load_admin_hooks() { |
85 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
86 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
87 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
85 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
86 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
87 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
88 | 88 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
89 | 89 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
90 | 90 | register_activation_hook( FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::activation_install' ); |
@@ -92,122 +92,122 @@ discard block |
||
92 | 92 | // Addons Controller |
93 | 93 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
94 | 94 | |
95 | - // Entries Controller |
|
96 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
97 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
98 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
99 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
100 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
95 | + // Entries Controller |
|
96 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
97 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
98 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
99 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
100 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
101 | 101 | |
102 | - // Fields Controller |
|
103 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
102 | + // Fields Controller |
|
103 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
104 | 104 | |
105 | - // Form Actions Controller |
|
106 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
107 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
108 | - } |
|
109 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
105 | + // Form Actions Controller |
|
106 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
107 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
108 | + } |
|
109 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
110 | 110 | |
111 | - // Forms Controller |
|
112 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
113 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
111 | + // Forms Controller |
|
112 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
113 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
114 | 114 | |
115 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
116 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
115 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
116 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
117 | 117 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
118 | 118 | |
119 | - // Forms Model |
|
120 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
119 | + // Forms Model |
|
120 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
121 | 121 | |
122 | - // Settings Controller |
|
123 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
124 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
122 | + // Settings Controller |
|
123 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
124 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
125 | 125 | |
126 | - // Styles Controller |
|
127 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
128 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
126 | + // Styles Controller |
|
127 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
128 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
129 | 129 | |
130 | - // XML Controller |
|
131 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
132 | - } |
|
130 | + // XML Controller |
|
131 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | public static function load_ajax_hooks() { |
135 | 135 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
136 | 136 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
137 | 137 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
138 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
139 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
138 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
139 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
140 | 140 | |
141 | 141 | // Addons |
142 | 142 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
143 | 143 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
144 | 144 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); |
145 | 145 | |
146 | - // Fields Controller |
|
147 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
148 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
149 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
150 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
151 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
152 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
153 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
154 | - add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
155 | - add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
156 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
157 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
158 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
159 | - |
|
160 | - // Form Actions Controller |
|
161 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
162 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
163 | - |
|
164 | - // Forms Controller |
|
146 | + // Fields Controller |
|
147 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
148 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
149 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
150 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
151 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
152 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
153 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
154 | + add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
155 | + add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
156 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
157 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
158 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
159 | + |
|
160 | + // Form Actions Controller |
|
161 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
162 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
163 | + |
|
164 | + // Forms Controller |
|
165 | 165 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
166 | 166 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
167 | 167 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
168 | 168 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
169 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
170 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
171 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
172 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
173 | - |
|
174 | - // Styles Controller |
|
175 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
176 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
177 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
178 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
169 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
170 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
171 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
172 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
173 | + |
|
174 | + // Styles Controller |
|
175 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
176 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
177 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
178 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
179 | 179 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
180 | 180 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
181 | 181 | |
182 | - // XML Controller |
|
182 | + // XML Controller |
|
183 | 183 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
184 | 184 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
185 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
186 | - } |
|
185 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
186 | + } |
|
187 | 187 | |
188 | 188 | public static function load_form_hooks() { |
189 | - // Fields Controller |
|
190 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
191 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
192 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
193 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
189 | + // Fields Controller |
|
190 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
191 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
192 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
193 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
194 | 194 | |
195 | 195 | // Forms Controller |
196 | 196 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
197 | 197 | |
198 | - // Styles Controller |
|
199 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
200 | - } |
|
198 | + // Styles Controller |
|
199 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
200 | + } |
|
201 | 201 | |
202 | 202 | public static function load_view_hooks() { |
203 | - // Hooks go here when a view is loaded |
|
204 | - } |
|
203 | + // Hooks go here when a view is loaded |
|
204 | + } |
|
205 | 205 | |
206 | 206 | public static function load_multisite_hooks() { |
207 | 207 | add_action( 'init', 'FrmAppController::front_head' ); |
208 | 208 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
209 | 209 | |
210 | - // drop tables when mu site is deleted |
|
211 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
212 | - } |
|
210 | + // drop tables when mu site is deleted |
|
211 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
212 | + } |
|
213 | 213 | } |
@@ -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( 'https://formidableforms.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( 'https://formidableforms.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,122 +222,122 @@ 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 | if ( ! $entry ) { |
342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,110 +345,110 @@ discard block |
||
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - $data = maybe_unserialize($entry->description); |
|
348 | + $data = maybe_unserialize($entry->description); |
|
349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
350 | 350 | $data = array( 'referrer' => $data ); |
351 | 351 | } |
352 | 352 | |
353 | 353 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
354 | - $to_emails = array(); |
|
354 | + $to_emails = array(); |
|
355 | 355 | |
356 | 356 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
357 | - } |
|
357 | + } |
|
358 | 358 | |
359 | - public static function destroy() { |
|
360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
359 | + public static function destroy() { |
|
360 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
361 | 361 | |
362 | 362 | $params = FrmForm::get_admin_params(); |
363 | 363 | |
364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
365 | - //unlink entry from post |
|
366 | - global $wpdb; |
|
364 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
365 | + //unlink entry from post |
|
366 | + global $wpdb; |
|
367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
368 | - } |
|
368 | + } |
|
369 | 369 | |
370 | - $message = ''; |
|
371 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
372 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
373 | - } |
|
370 | + $message = ''; |
|
371 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
372 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
373 | + } |
|
374 | 374 | |
375 | - self::display_list( $message ); |
|
376 | - } |
|
375 | + self::display_list( $message ); |
|
376 | + } |
|
377 | 377 | |
378 | - public static function destroy_all() { |
|
379 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
380 | - $frm_settings = FrmAppHelper::get_settings(); |
|
381 | - wp_die( $frm_settings->admin_permission ); |
|
382 | - } |
|
378 | + public static function destroy_all() { |
|
379 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
380 | + $frm_settings = FrmAppHelper::get_settings(); |
|
381 | + wp_die( $frm_settings->admin_permission ); |
|
382 | + } |
|
383 | 383 | |
384 | - global $wpdb; |
|
384 | + global $wpdb; |
|
385 | 385 | $params = FrmForm::get_admin_params(); |
386 | - $message = ''; |
|
387 | - $errors = array(); |
|
388 | - $form_id = (int) $params['form']; |
|
386 | + $message = ''; |
|
387 | + $errors = array(); |
|
388 | + $form_id = (int) $params['form']; |
|
389 | 389 | |
390 | - if ( $form_id ) { |
|
391 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
390 | + if ( $form_id ) { |
|
391 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
392 | 392 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
393 | 393 | |
394 | - if ( $action ) { |
|
395 | - // this action takes a while, so only trigger it if there are posts to delete |
|
396 | - foreach ( $entry_ids as $entry_id ) { |
|
397 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
398 | - unset( $entry_id ); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - $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 ) ); |
|
403 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
404 | - if ( $results ) { |
|
394 | + if ( $action ) { |
|
395 | + // this action takes a while, so only trigger it if there are posts to delete |
|
396 | + foreach ( $entry_ids as $entry_id ) { |
|
397 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
398 | + unset( $entry_id ); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + $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 ) ); |
|
403 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
404 | + if ( $results ) { |
|
405 | 405 | FrmEntry::clear_cache(); |
406 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
407 | - } |
|
408 | - } else { |
|
409 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
410 | - } |
|
411 | - |
|
412 | - self::display_list( $message, $errors ); |
|
413 | - } |
|
414 | - |
|
415 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
416 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
417 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
418 | - } |
|
419 | - |
|
420 | - public static function get_form( $filename, $form, $title, $description ) { |
|
421 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
422 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
423 | - } |
|
424 | - |
|
425 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
406 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
407 | + } |
|
408 | + } else { |
|
409 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
410 | + } |
|
411 | + |
|
412 | + self::display_list( $message, $errors ); |
|
413 | + } |
|
414 | + |
|
415 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
416 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
417 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
418 | + } |
|
419 | + |
|
420 | + public static function get_form( $filename, $form, $title, $description ) { |
|
421 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
422 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
423 | + } |
|
424 | + |
|
425 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
426 | 426 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
427 | 427 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
428 | - return; |
|
429 | - } |
|
428 | + return; |
|
429 | + } |
|
430 | 430 | |
431 | - global $frm_vars; |
|
431 | + global $frm_vars; |
|
432 | 432 | |
433 | 433 | $form = FrmForm::getOne( $form_id ); |
434 | - if ( ! $form ) { |
|
435 | - return; |
|
436 | - } |
|
434 | + if ( ! $form ) { |
|
435 | + return; |
|
436 | + } |
|
437 | 437 | |
438 | 438 | $params = FrmForm::get_params( $form ); |
439 | 439 | |
440 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
441 | - $frm_vars['form_params'] = array(); |
|
442 | - } |
|
440 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
441 | + $frm_vars['form_params'] = array(); |
|
442 | + } |
|
443 | 443 | $frm_vars['form_params'][ $form->id ] = $params; |
444 | 444 | |
445 | 445 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
446 | - return; |
|
447 | - } |
|
446 | + return; |
|
447 | + } |
|
448 | 448 | |
449 | - if ( $errors == '' && ! $ajax ) { |
|
449 | + if ( $errors == '' && ! $ajax ) { |
|
450 | 450 | $errors = FrmEntryValidate::validate( $_POST ); |
451 | - } |
|
451 | + } |
|
452 | 452 | |
453 | 453 | /** |
454 | 454 | * Use this filter to add trigger actions and add errors after |
@@ -459,54 +459,54 @@ discard block |
||
459 | 459 | |
460 | 460 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
461 | 461 | |
462 | - if ( empty( $errors ) ) { |
|
462 | + if ( empty( $errors ) ) { |
|
463 | 463 | $_POST['frm_skip_cookie'] = 1; |
464 | - if ( $params['action'] == 'create' ) { |
|
464 | + if ( $params['action'] == 'create' ) { |
|
465 | 465 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
466 | 466 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
467 | - } |
|
468 | - } |
|
467 | + } |
|
468 | + } |
|
469 | 469 | |
470 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
470 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
471 | 471 | unset( $_POST['frm_skip_cookie'] ); |
472 | - } |
|
473 | - } |
|
474 | - |
|
475 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
476 | - self::_delete_entry( $atts['id'], $form ); |
|
477 | - return $url; |
|
478 | - } |
|
479 | - |
|
480 | - //Delete entry if not redirected |
|
481 | - public static function delete_entry_after_save( $atts ) { |
|
482 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
483 | - } |
|
484 | - |
|
485 | - private static function _delete_entry( $entry_id, $form ) { |
|
486 | - if ( ! $form ) { |
|
487 | - return; |
|
488 | - } |
|
489 | - |
|
490 | - $form->options = maybe_unserialize( $form->options ); |
|
491 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
492 | - FrmEntry::destroy( $entry_id ); |
|
493 | - } |
|
494 | - } |
|
472 | + } |
|
473 | + } |
|
474 | + |
|
475 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
476 | + self::_delete_entry( $atts['id'], $form ); |
|
477 | + return $url; |
|
478 | + } |
|
479 | + |
|
480 | + //Delete entry if not redirected |
|
481 | + public static function delete_entry_after_save( $atts ) { |
|
482 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
483 | + } |
|
484 | + |
|
485 | + private static function _delete_entry( $entry_id, $form ) { |
|
486 | + if ( ! $form ) { |
|
487 | + return; |
|
488 | + } |
|
489 | + |
|
490 | + $form->options = maybe_unserialize( $form->options ); |
|
491 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
492 | + FrmEntry::destroy( $entry_id ); |
|
493 | + } |
|
494 | + } |
|
495 | 495 | |
496 | 496 | public static function show_entry_shortcode( $atts ) { |
497 | 497 | return FrmEntryFormat::show_entry( $atts ); |
498 | 498 | } |
499 | 499 | |
500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
501 | + $plain_text = add_filter('frm_plain_text_email', true); |
|
502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
503 | 503 | |
504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
505 | - return $value; |
|
506 | - } |
|
504 | + if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
505 | + return $value; |
|
506 | + } |
|
507 | 507 | |
508 | - return $value; |
|
509 | - } |
|
508 | + return $value; |
|
509 | + } |
|
510 | 510 | |
511 | 511 | public static function get_params( $form = null ) { |
512 | 512 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' ); |
@@ -514,15 +514,15 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | public static function entry_sidebar( $entry ) { |
517 | - $data = maybe_unserialize($entry->description); |
|
518 | - $date_format = get_option('date_format'); |
|
519 | - $time_format = get_option('time_format'); |
|
517 | + $data = maybe_unserialize($entry->description); |
|
518 | + $date_format = get_option('date_format'); |
|
519 | + $time_format = get_option('time_format'); |
|
520 | 520 | if ( isset( $data['browser'] ) ) { |
521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
522 | 522 | } |
523 | 523 | |
524 | 524 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
525 | - } |
|
525 | + } |
|
526 | 526 | |
527 | 527 | /*********************************************************************** |
528 | 528 | * Deprecated Functions |
@@ -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,7 +337,7 @@ discard block |
||
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - $entry = FrmEntry::getOne($id, true); |
|
340 | + $entry = FrmEntry::getOne( $id, true ); |
|
341 | 341 | if ( ! $entry ) { |
342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - $data = maybe_unserialize($entry->description); |
|
348 | + $data = maybe_unserialize( $entry->description ); |
|
349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
350 | 350 | $data = array( 'referrer' => $data ); |
351 | 351 | } |
@@ -357,11 +357,11 @@ discard block |
||
357 | 357 | } |
358 | 358 | |
359 | 359 | public static function destroy() { |
360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
360 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
361 | 361 | |
362 | 362 | $params = FrmForm::get_admin_params(); |
363 | 363 | |
364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
364 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
365 | 365 | //unlink entry from post |
366 | 366 | global $wpdb; |
367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | if ( ! isset( $frm_vars['form_params'] ) ) { |
441 | 441 | $frm_vars['form_params'] = array(); |
442 | 442 | } |
443 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
443 | + $frm_vars['form_params'][$form->id] = $params; |
|
444 | 444 | |
445 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
445 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
446 | 446 | return; |
447 | 447 | } |
448 | 448 | |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | */ |
458 | 458 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
459 | 459 | |
460 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
460 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
461 | 461 | |
462 | 462 | if ( empty( $errors ) ) { |
463 | 463 | $_POST['frm_skip_cookie'] = 1; |
464 | 464 | if ( $params['action'] == 'create' ) { |
465 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
466 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
465 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
466 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | } |
499 | 499 | |
500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
501 | + $plain_text = add_filter( 'frm_plain_text_email', true ); |
|
502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
503 | 503 | |
504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
504 | + if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) { |
|
505 | 505 | return $value; |
506 | 506 | } |
507 | 507 | |
@@ -514,9 +514,9 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | public static function entry_sidebar( $entry ) { |
517 | - $data = maybe_unserialize($entry->description); |
|
518 | - $date_format = get_option('date_format'); |
|
519 | - $time_format = get_option('time_format'); |
|
517 | + $data = maybe_unserialize( $entry->description ); |
|
518 | + $date_format = get_option( 'date_format' ); |
|
519 | + $time_format = get_option( 'time_format' ); |
|
520 | 520 | if ( isset( $data['browser'] ) ) { |
521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
522 | 522 | } |