PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.26.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.26.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / controllers / FrmHooksController.php

FrmHooksController.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.26.1, at classes/controllers/FrmHooksController.php

366 lines 15.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 class FrmHooksController {
7
8 /**
9 * Trigger plugin-wide hook loading
10 *
11 * @param string $hooks
12 *
13 * @return void
14 */
15 public static function trigger_load_hook( $hooks = 'load_hooks' ) {
16 $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
17
18 $trigger_hooks = $hooks;
19 $hooks = (array) $hooks;
20
21 if ( 'load_hooks' == $trigger_hooks ) {
22 if ( is_admin() ) {
23 $hooks[] = 'load_admin_hooks';
24
25 if ( defined( 'DOING_AJAX' ) ) {
26 $hooks[] = 'load_ajax_hooks';
27 $hooks[] = 'load_form_hooks';
28 }
29 }
30
31 if ( is_multisite() ) {
32 $hooks[] = 'load_multisite_hooks';
33 }
34 } else {
35 // Make sure the hooks are only triggered once.
36 add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
37 }
38 unset( $trigger_hooks );
39
40 // Instantiate Controllers.
41 foreach ( $controllers as $c ) {
42 foreach ( $hooks as $hook ) {
43 if ( is_callable( array( $c, $hook ) ) ) {
44 call_user_func( array( $c, $hook ) );
45 }
46 unset( $hook );
47 }
48 unset( $c );
49 }
50 }
51
52 /**
53 * @return void
54 */
55 public static function trigger_load_form_hooks() {
56 self::trigger_load_hook( 'load_form_hooks' );
57 }
58
59 /**
60 * @return void
61 */
62 public static function load_hooks() {
63 // Use 0 so this gets triggered before FrmFormActionsController::register_post_types.
64 add_action( 'init', 'FrmAppController::load_lang', 0 );
65
66 add_action( 'rest_api_init', 'FrmAppController::create_rest_routes', 0 );
67 add_filter( 'widget_text', 'do_shortcode' );
68
69 // Entries controller.
70 add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
71 add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
72
73 // Form Actions Controller.
74 add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
75 add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 );
76 add_filter( 'pre_wpml_is_translated_post_type', 'FrmFormActionsController::prevent_wpml_translations', 10, 2 );
77
78 // Forms Controller.
79 add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
80 add_action( 'init', 'FrmFormsController::front_head' );
81 add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
82 add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
83 add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
84 add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 );
85 add_action( 'wp_footer', 'FrmHoneypot::maybe_print_honeypot_js', 99 );
86
87 add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );
88
89 // Form Shortcodes.
90 add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
91
92 // Styles Controller.
93 add_action( 'init', 'FrmStylesController::register_post_types', 0 );
94 add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
95 add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
96 add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
97
98 // Simple Blocks Controller.
99 add_action( 'init', 'FrmSimpleBlocksController::register_simple_form_block' );
100
101 add_filter( 'cron_schedules', 'FrmUsageController::add_schedules' );
102 add_action( 'formidable_send_usage', 'FrmUsageController::send_snapshot' );
103
104 /**
105 * Make name field work with View.
106 * FrmProContent::replace_single_shortcode() applies this filter like 'frm_keep_' . $field->type . '_value_array'
107 */
108 add_filter( 'frm_keep_name_value_array', '__return_true' );
109
110 // Elementor.
111 add_action( 'elementor/widgets/register', 'FrmElementorController::register_elementor_hooks' );
112
113 // Summary emails.
114 add_action( 'frm_daily_event', 'FrmEmailSummaryController::maybe_send_emails' );
115
116 FrmTransLiteHooksController::load_hooks();
117 FrmStrpLiteHooksController::load_hooks();
118 FrmSquareLiteHooksController::load_hooks();
119
120 // GDPR
121 add_filter( 'frm_is_field_required', 'FrmFieldGdpr::force_required_field', 10, 2 );
122 }
123
124 /**
125 * @return void
126 */
127 public static function load_admin_hooks() {
128 add_action( 'admin_menu', 'FrmAppController::menu', 1 );
129 add_filter( 'admin_body_class', 'FrmAppController::add_admin_class', 999 );
130 add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
131 add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
132 add_action( 'admin_enqueue_scripts', 'FrmAppController::admin_enqueue_scripts' );
133 add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
134 add_filter( 'admin_footer_text', 'FrmAppController::set_footer_text' );
135 add_action( 'admin_footer', 'FrmAppController::add_admin_footer_links' );
136 add_action( 'current_screen', 'FrmAppController::handle_current_screen' );
137
138 // Entries Controller.
139 add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
140 add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
141 add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
142 add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
143
144 // Form Actions Controller.
145 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
146 add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
147 }
148
149 add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
150
151 // Forms Controller.
152 add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
153 add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
154 add_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
155 add_filter( 'frm_fields_in_form_builder', 'FrmFormsController::update_form_builder_fields' );
156
157 add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
158 add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
159
160 // Elementor.
161 add_action( 'elementor/editor/footer', 'FrmElementorController::admin_init' );
162
163 add_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
164 add_action( 'et_pb_admin_excluded_shortcodes', 'FrmFormsController::prevent_divi_conflict' );
165
166 // Forms Model.
167 add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
168
169 // Settings Controller.
170 add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
171 add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
172 add_action( 'frm_after_settings_tabs', 'FrmSettingsController::settings_cta' );
173
174 // Styles Controller.
175 add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
176 add_action( 'plugins_loaded', 'FrmStylesController::plugins_loaded' );
177 add_action( 'admin_init', 'FrmStylesController::admin_init' );
178 // Use 11 so it happens after add_action( 'wp_default_styles', 'wp_default_styles' ); where edit.css is added.
179 add_action( 'wp_default_styles', 'FrmStylesController::disable_conflicting_wp_admin_css', 11 );
180
181 // XML Controller.
182 add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
183
184 // Simple Blocks Controller.
185 add_action( 'enqueue_block_editor_assets', 'FrmSimpleBlocksController::block_editor_assets' );
186 add_action( 'enqueue_block_assets', 'FrmSimpleBlocksController::block_assets' );
187
188 add_action( 'admin_init', 'FrmUsageController::schedule_send' );
189
190 // Applications Controller.
191 // Use the same priority as styles so Applications appear directly under Styles.
192 add_action( 'admin_menu', 'FrmApplicationsController::menu', 14 );
193 add_action( 'admin_enqueue_scripts', 'FrmApplicationsController::dequeue_scripts', 15 );
194
195 // CAPTCHA
196 add_filter( 'frm_setup_edit_field_vars', 'FrmFieldCaptcha::update_field_name' );
197
198 // From Templates.
199 FrmFormTemplatesController::load_admin_hooks();
200
201 // Cronjob.
202 add_action( 'admin_init', 'FrmCronController::schedule_events' );
203
204 // Cross sell.
205 add_action( 'admin_menu', 'FrmSalesApi::menu', 1000 );
206
207 // Deactivation feedback.
208 add_action( 'admin_enqueue_scripts', 'FrmDeactivationFeedbackController::enqueue_assets' );
209 add_action( 'admin_footer', 'FrmDeactivationFeedbackController::footer_html' );
210 add_action( 'deactivated_plugin', 'FrmDeactivationFeedbackController::set_feedback_expired_date' );
211
212 add_action( 'frm_email_styles_extra_settings', 'FrmEmailStylesController::show_upsell_settings' );
213
214 add_action( 'admin_init', 'FrmWelcomeTourController::admin_init' );
215
216 FrmDashboardController::load_admin_hooks();
217 FrmTransLiteHooksController::load_admin_hooks();
218 FrmStrpLiteHooksController::load_admin_hooks();
219 FrmSquareLiteHooksController::load_admin_hooks();
220 FrmSMTPController::load_hooks();
221 FrmOnboardingWizardController::load_admin_hooks();
222 FrmAddonsController::load_admin_hooks();
223 new FrmPluginSearch();
224 }
225
226 /**
227 * @return void
228 */
229 public static function load_ajax_hooks() {
230 add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' );
231 add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
232 add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
233
234 // Onboarding Wizard Controller.
235 add_action( 'wp_ajax_frm_onboarding_consent_tracking', 'FrmOnboardingWizardController::ajax_consent_tracking' );
236 add_action( 'wp_ajax_frm_onboarding_setup_usage_data', 'FrmOnboardingWizardController::setup_usage_data' );
237
238 // Addons.
239 add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
240 add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
241 add_action( 'wp_ajax_frm_activate_addon', 'FrmAddonsController::ajax_activate_addon' );
242 add_action( 'wp_ajax_frm_deactivate_addon', 'FrmAddonsController::ajax_deactivate_addon' );
243 add_action( 'wp_ajax_frm_install_addon', 'FrmAddonsController::ajax_install_addon' );
244 add_action( 'wp_ajax_frm_uninstall_addon', 'FrmAddonsController::ajax_uninstall_addon' );
245 // Plugin.
246 add_action( 'wp_ajax_frm_install_plugin', 'FrmInstallPlugin::ajax_install_plugin' );
247 add_action( 'wp_ajax_frm_check_plugin_activation', 'FrmInstallPlugin::ajax_check_plugin_activation' );
248
249 // Fields Controller.
250 add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
251 add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
252 add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
253 add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
254 add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
255
256 // Form Actions Controller.
257 add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
258 add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
259
260 // Forms Controller.
261 add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
262 add_action( 'wp_ajax_frm_rename_form', 'FrmFormsController::rename_form' );
263 add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
264 add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
265 add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
266 add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
267 add_action( 'wp_ajax_frm_forms_trash', 'FrmFormsController::ajax_trash' );
268 add_action( 'wp_ajax_frm_install_form', 'FrmFormsController::build_new_form' );
269 add_action( 'wp_ajax_frm_create_page_with_shortcode', 'FrmFormsController::create_page_with_shortcode' );
270 add_action( 'wp_ajax_get_page_dropdown', 'FrmFormsController::get_page_dropdown' );
271
272 add_action( 'wp_ajax_frm_dismiss_migrator', 'FrmFormMigratorsHelper::dismiss_migrator' );
273
274 // Form Templates Controller.
275 add_action( 'wp_ajax_frm_add_or_remove_favorite_template', 'FrmFormTemplatesController::ajax_add_or_remove_favorite' );
276 add_action( 'wp_ajax_frm_create_template', 'FrmFormTemplatesController::ajax_create_template' );
277 add_action( 'wp_ajax_frm_get_free_templates', 'FrmFormTemplatesController::ajax_get_free_templates' );
278
279 // Inbox.
280 add_action( 'wp_ajax_frm_inbox_dismiss', 'FrmInboxController::dismiss_message' );
281
282 // Settings.
283 add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' );
284 add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' );
285 add_action( 'wp_ajax_frm_page_search', 'FrmSettingsController::page_search' );
286
287 // Styles Controller.
288 add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
289 add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
290 add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
291 add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
292 add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' );
293 add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
294 add_action( 'wp_ajax_frm_rename_style', 'FrmStylesController::rename_style' );
295
296 // XML Controller.
297 add_action( 'wp_ajax_frm_install_template', 'FrmXMLController::install_template' );
298 add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
299 add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
300 add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
301
302 // Dashboard Controller.
303 add_action( 'wp_ajax_dashboard_ajax_action', 'FrmDashboardController::ajax_requests' );
304
305 // Submit with AJAX.
306 // Trigger before process_entry.
307 add_action( 'wp_loaded', 'FrmEntriesAJAXSubmitController::ajax_create', 5 );
308
309 // Track the flows usage data.
310 add_action( 'wp_ajax_frm_track_flows', 'FrmUsageController::ajax_track_flows' );
311
312 // Applications.
313 add_action( 'wp_ajax_frm_get_applications_data', 'FrmApplicationsController::get_applications_data' );
314
315 // Reviews.
316 add_action( 'wp_ajax_frm_dismiss_review', 'FrmAppController::dismiss_review' );
317 add_action( 'wp_ajax_frm_small_screen_proceed', 'FrmAppController::small_screen_proceed' );
318 add_action( 'wp_ajax_frm_sale_banner_dismiss', 'FrmSalesApi::dismiss_banner' );
319
320 add_action( 'wp_ajax_frm_email_style_preview', 'FrmEmailStylesController::ajax_preview' );
321 add_action( 'wp_ajax_frm_send_test_email', 'FrmEmailStylesController::ajax_send_test_email' );
322
323 // Welcome Tour.
324 add_action( 'wp_ajax_frm_mark_checklist_step_as_completed', 'FrmWelcomeTourController::ajax_mark_checklist_step_as_completed' );
325 add_action( 'wp_ajax_frm_dismiss_welcome_tour', 'FrmWelcomeTourController::ajax_dismiss_welcome_tour' );
326 }
327
328 /**
329 * @return void
330 */
331 public static function load_form_hooks() {
332 // Fields Controller.
333 add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
334 add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
335 add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
336 add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
337
338 // Forms Controller.
339 add_action( 'frm_form_classes', 'FrmFormsController::form_classes' );
340 add_filter( 'frm_submit_button_class', 'FrmFormsController::update_button_classes' );
341 add_filter( 'frm_back_button_class', 'FrmFormsController::update_button_classes' );
342
343 add_filter( 'frm_pre_display_form', 'FrmSubmitHelper::copy_submit_field_settings_to_form' );
344
345 // Styles Controller.
346 add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
347 }
348
349 /**
350 * @return void
351 */
352 public static function load_view_hooks() {
353 // Hooks go here when a view is loaded.
354 }
355
356 /**
357 * @return void
358 */
359 public static function load_multisite_hooks() {
360 add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
361
362 // Drop tables when mu site is deleted.
363 add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
364 }
365 }
366