PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.34
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.34
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.34, at classes/controllers/FrmHooksController.php

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