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

310 lines 12.8 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 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 // Instansiate 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 /**
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 add_action( 'rest_api_init', 'FrmAppController::create_rest_routes', 0 );
64 add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
65 add_filter( 'widget_text', 'do_shortcode' );
66
67 // Entries controller.
68 add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
69 add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
70
71 // Form Actions Controller.
72 add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
73 add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 );
74
75 // Forms Controller.
76 add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
77 add_action( 'init', 'FrmFormsController::front_head' );
78 add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
79 add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
80 add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
81 add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 );
82
83 add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );
84
85 // Form Shortcodes.
86 add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
87
88 // Styles Controller.
89 add_action( 'init', 'FrmStylesController::register_post_types', 0 );
90 add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
91 add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
92 add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
93
94 // Simple Blocks Controller.
95 add_action( 'init', 'FrmSimpleBlocksController::register_simple_form_block' );
96
97 add_filter( 'cron_schedules', 'FrmUsageController::add_schedules' );
98 add_action( 'formidable_send_usage', 'FrmUsageController::send_snapshot' );
99
100 /**
101 * Make name field work with View.
102 * FrmProContent::replace_single_shortcode() applies this filter like 'frm_keep_' . $field->type . '_value_array'
103 */
104 add_filter( 'frm_keep_name_value_array', '__return_true' );
105
106 // Elementor.
107 add_action( 'elementor/widgets/register', 'FrmElementorController::register_elementor_hooks' );
108 add_filter( 'frm_fields_in_form_builder', 'FrmFormsController::update_form_builder_fields', 10, 2 );
109 }
110
111 /**
112 * @return void
113 */
114 public static function load_admin_hooks() {
115 add_action( 'admin_menu', 'FrmAppController::menu', 1 );
116 add_filter( 'admin_body_class', 'FrmAppController::add_admin_class', 999 );
117 add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
118 add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
119 add_action( 'admin_enqueue_scripts', 'FrmAppController::admin_enqueue_scripts' );
120 add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
121 add_filter( 'admin_footer_text', 'FrmAppController::set_footer_text' );
122 add_action( 'admin_footer', 'FrmAppController::add_admin_footer_links' );
123 add_action( 'wp_ajax_frm_dismiss_review', 'FrmAppController::dismiss_review' );
124
125 // Addons Controller.
126 add_action( 'admin_menu', 'FrmAddonsController::menu', 100 );
127 add_filter( 'pre_set_site_transient_update_plugins', 'FrmAddonsController::check_update' );
128
129 // Entries Controller.
130 add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
131 add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
132 add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
133 add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
134
135 // Form Actions Controller.
136 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
137 add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
138 add_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
139 }
140 add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
141
142 // Forms Controller.
143 add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
144 add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
145 add_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
146
147 add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
148 add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
149
150 // Elementor.
151 add_action( 'elementor/editor/footer', 'FrmElementorController::admin_init' );
152
153 add_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
154 add_action( 'et_pb_admin_excluded_shortcodes', 'FrmFormsController::prevent_divi_conflict' );
155
156 // Forms Model.
157 add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
158
159 // Inbox Controller.
160 add_action( 'admin_menu', 'FrmInboxController::menu', 50 );
161
162 // Settings Controller.
163 add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
164 add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
165 add_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
166 add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' );
167 add_action( 'wp_ajax_frm_page_search', 'FrmSettingsController::page_search' );
168
169 // Styles Controller.
170 add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
171 add_action( 'plugins_loaded', 'FrmStylesController::plugins_loaded' );
172 add_action( 'admin_init', 'FrmStylesController::admin_init' );
173 add_action( 'wp_default_styles', 'FrmStylesController::disable_conflicting_wp_admin_css', 11 ); // Use 11 so it happens after add_action( 'wp_default_styles', 'wp_default_styles' ); where edit.css is added.
174
175 // XML Controller.
176 add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
177
178 // Simple Blocks Controller.
179 add_action( 'enqueue_block_editor_assets', 'FrmSimpleBlocksController::block_editor_assets' );
180
181 add_action( 'admin_init', 'FrmUsageController::schedule_send' );
182
183 // Applications Controller.
184 add_action( 'admin_menu', 'FrmApplicationsController::menu', 14 ); // Use the same priority as styles so Applications appear directly under Styles.
185 add_action( 'admin_enqueue_scripts', 'FrmApplicationsController::dequeue_scripts', 15 );
186 add_action( 'wp_ajax_frm_get_applications_data', 'FrmApplicationsController::get_applications_data' );
187
188 // CAPTCHA
189 add_filter( 'frm_setup_edit_field_vars', 'FrmFieldCaptcha::update_field_name' );
190
191 FrmSMTPController::load_hooks();
192 FrmWelcomeController::load_hooks();
193 new FrmPluginSearch();
194 }
195
196 /**
197 * @return void
198 */
199 public static function load_ajax_hooks() {
200 add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' );
201 add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
202 add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
203
204 // Addons.
205 add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
206 add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
207 add_action( 'wp_ajax_frm_activate_addon', 'FrmAddonsController::ajax_activate_addon' );
208 add_action( 'wp_ajax_frm_connect', 'FrmAddonsController::connect_pro' );
209 add_action( 'wp_ajax_frm_install_addon', 'FrmAddonsController::ajax_install_addon' );
210
211 // Fields Controller.
212 add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
213 add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
214 add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
215 add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
216 add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
217
218 // Form Actions Controller.
219 add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
220 add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
221
222 // Forms Controller.
223 add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
224 add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
225 add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
226 add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
227 add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
228 add_action( 'wp_ajax_frm_forms_trash', 'FrmFormsController::ajax_trash' );
229 add_action( 'wp_ajax_frm_install_form', 'FrmFormsController::build_new_form' );
230 add_action( 'wp_ajax_frm_build_template', 'FrmFormsController::build_template' );
231 add_action( 'wp_ajax_frm_create_page_with_shortcode', 'FrmFormsController::create_page_with_shortcode' );
232 add_action( 'wp_ajax_get_page_dropdown', 'FrmFormsController::get_page_dropdown' );
233
234 add_action( 'wp_ajax_frm_dismiss_migrator', 'FrmFormMigratorsHelper::dismiss_migrator' );
235
236 // Inbox.
237 add_action( 'wp_ajax_frm_inbox_dismiss', 'FrmInboxController::dismiss_message' );
238
239 // Settings.
240 add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' );
241
242 // Styles Controller.
243 add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
244 add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
245 add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
246 add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
247 add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' );
248 add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
249 add_action( 'wp_ajax_frm_rename_style', 'FrmStylesController::rename_style' );
250
251 // XML Controller.
252 add_action( 'wp_ajax_frm_install_template', 'FrmXMLController::install_template' );
253 add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
254 add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
255 add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
256
257 // Templates API.
258 add_action( 'wp_ajax_template_api_signup', 'FrmFormTemplateApi::signup' );
259
260 // Submit with AJAX.
261 add_action( 'wp_loaded', 'FrmEntriesAJAXSubmitController::ajax_create', 5 ); // Trigger before process_entry.
262 }
263
264 /**
265 * @return void
266 */
267 public static function load_form_hooks() {
268 // Fields Controller.
269 add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
270 add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
271 add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
272 add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
273
274 // Forms Controller.
275 add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' );
276 add_filter( 'frm_submit_button_class', 'FrmFormsController::update_button_classes' );
277 add_filter( 'frm_back_button_class', 'FrmFormsController::update_button_classes' );
278
279 // Styles Controller.
280 add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
281 }
282
283 /**
284 * @return void
285 */
286 public static function load_view_hooks() {
287 // Hooks go here when a view is loaded.
288 }
289
290 /**
291 * @return void
292 */
293 public static function load_multisite_hooks() {
294 add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
295
296 // Drop tables when mu site is deleted.
297 add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
298 }
299
300 /**
301 * @deprecated 5.0.06 use FrmElementorController::register_elementor_hooks directly.
302 *
303 * @return void
304 */
305 public static function register_elementor_hooks() {
306 _deprecated_function( __FUNCTION__, '5.0.06', 'FrmElementorController::register_elementor_hooks' );
307 FrmElementorController::register_elementor_hooks();
308 }
309 }
310