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

266 lines 11.3 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 public static function trigger_load_hook( $hooks = 'load_hooks' ) {
12 $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) );
13
14 $trigger_hooks = $hooks;
15 $hooks = (array) $hooks;
16
17 if ( 'load_hooks' == $trigger_hooks ) {
18 if ( is_admin() ) {
19 $hooks[] = 'load_admin_hooks';
20 if ( defined( 'DOING_AJAX' ) ) {
21 $hooks[] = 'load_ajax_hooks';
22 $hooks[] = 'load_form_hooks';
23 }
24 }
25
26 if ( is_multisite() ) {
27 $hooks[] = 'load_multisite_hooks';
28 }
29 } else {
30 // Make sure the hooks are only triggered once.
31 add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' );
32 }
33 unset( $trigger_hooks );
34
35 // Instansiate Controllers.
36 foreach ( $controllers as $c ) {
37 foreach ( $hooks as $hook ) {
38 if ( is_callable( array( $c, $hook ) ) ) {
39 call_user_func( array( $c, $hook ) );
40 }
41 unset( $hook );
42 }
43 unset( $c );
44 }
45
46 }
47
48 public static function trigger_load_form_hooks() {
49 self::trigger_load_hook( 'load_form_hooks' );
50 }
51
52 public static function load_hooks() {
53 add_action( 'rest_api_init', 'FrmAppController::create_rest_routes', 0 );
54 add_action( 'plugins_loaded', 'FrmAppController::load_lang' );
55 add_filter( 'widget_text', 'do_shortcode' );
56
57 // Entries controller.
58 add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 );
59 add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 );
60
61 // Form Actions Controller.
62 add_action( 'init', 'FrmFormActionsController::register_post_types', 1 );
63 add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 );
64
65 // Forms Controller.
66 add_action( 'widgets_init', 'FrmFormsController::register_widgets' );
67 add_action( 'init', 'FrmFormsController::front_head' );
68 add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 );
69 add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 );
70 add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' );
71 add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 );
72
73 add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' );
74
75 // Form Shortcodes.
76 add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' );
77
78 // Styles Controller.
79 add_action( 'init', 'FrmStylesController::register_post_types', 0 );
80 add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' );
81 add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 );
82 add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' );
83
84 // Simple Blocks Controller.
85 add_action( 'init', 'FrmSimpleBlocksController::register_simple_form_block' );
86
87 add_filter( 'cron_schedules', 'FrmUsageController::add_schedules' );
88 add_action( 'formidable_send_usage', 'FrmUsageController::send_snapshot' );
89
90 /**
91 * Make name field work with View.
92 * FrmProContent::replace_single_shortcode() applies this filter like 'frm_keep_' . $field->type . '_value_array'
93 */
94 add_filter( 'frm_keep_name_value_array', '__return_true' );
95
96 // Elementor.
97 add_action( 'elementor/widgets/widgets_registered', 'FrmElementorController::register_elementor_hooks' );
98 }
99
100 public static function load_admin_hooks() {
101 add_action( 'admin_menu', 'FrmAppController::menu', 1 );
102 add_filter( 'admin_body_class', 'FrmAppController::add_admin_class', 999 );
103 add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
104 add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' );
105 add_action( 'admin_init', 'FrmAppController::admin_init', 11 );
106 add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
107 add_filter( 'admin_footer_text', 'FrmAppController::set_footer_text' );
108 add_action( 'wp_ajax_frm_dismiss_review', 'FrmAppController::dismiss_review' );
109
110 // Addons Controller.
111 add_action( 'admin_menu', 'FrmAddonsController::menu', 100 );
112 add_filter( 'pre_set_site_transient_update_plugins', 'FrmAddonsController::check_update' );
113 add_action( 'frm_page_footer', 'FrmAppHelper::renewal_message' );
114
115 // Entries Controller.
116 add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
117 add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 );
118 add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 );
119 add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 );
120
121 // Form Actions Controller.
122 if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
123 add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' );
124 add_action( 'frm_add_form_style_tab_options', 'FrmFormsController::add_form_style_tab_options' );
125 }
126 add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 );
127
128 // Forms Controller.
129 add_action( 'admin_menu', 'FrmFormsController::menu', 10 );
130 add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
131 add_action( 'frm_after_field_options', 'FrmFormsController::logic_tip' );
132
133 add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 );
134 add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' );
135
136 // Elementor.
137 add_action( 'elementor/editor/footer', 'FrmElementorController::admin_init' );
138
139 add_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
140 add_action( 'et_pb_admin_excluded_shortcodes', 'FrmFormsController::prevent_divi_conflict' );
141
142 // Forms Model.
143 add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 );
144
145 // Inbox Controller.
146 add_action( 'admin_menu', 'FrmInboxController::menu', 50 );
147
148 // Settings Controller.
149 add_action( 'admin_menu', 'FrmSettingsController::menu', 45 );
150 add_action( 'frm_before_settings', 'FrmSettingsController::license_box' );
151 add_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' );
152 add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' );
153 add_action( 'wp_ajax_frm_page_search', 'FrmSettingsController::page_search' );
154
155 // Styles Controller.
156 add_action( 'admin_menu', 'FrmStylesController::menu', 14 );
157 add_action( 'admin_init', 'FrmStylesController::admin_init' );
158
159 // XML Controller.
160 add_action( 'admin_menu', 'FrmXMLController::menu', 41 );
161
162 // Simple Blocks Controller.
163 add_action( 'enqueue_block_editor_assets', 'FrmSimpleBlocksController::block_editor_assets' );
164
165 add_action( 'admin_init', 'FrmUsageController::schedule_send' );
166
167 FrmSMTPController::load_hooks();
168 FrmWelcomeController::load_hooks();
169 new FrmPluginSearch();
170 }
171
172 public static function load_ajax_hooks() {
173 add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' );
174 add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
175 add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
176
177 // Addons.
178 add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' );
179 add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' );
180 add_action( 'wp_ajax_frm_activate_addon', 'FrmAddonsController::ajax_activate_addon' );
181 add_action( 'wp_ajax_frm_connect', 'FrmAddonsController::connect_pro' );
182 add_action( 'wp_ajax_frm_install_addon', 'FrmAddonsController::ajax_install_addon' );
183
184 // Fields Controller.
185 add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' );
186 add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' );
187 add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' );
188 add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' );
189 add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' );
190
191 // Form Actions Controller.
192 add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' );
193 add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
194
195 // Forms Controller.
196 add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
197 add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
198 add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
199 add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
200 add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
201 add_action( 'wp_ajax_frm_forms_trash', 'FrmFormsController::ajax_trash' );
202 add_action( 'wp_ajax_frm_install_form', 'FrmFormsController::build_new_form' );
203 add_action( 'wp_ajax_frm_build_template', 'FrmFormsController::build_template' );
204 add_action( 'wp_ajax_frm_create_page_with_shortcode', 'FrmFormsController::create_page_with_shortcode' );
205 add_action( 'wp_ajax_get_page_dropdown', 'FrmFormsController::get_page_dropdown' );
206
207 add_action( 'wp_ajax_frm_dismiss_migrator', 'FrmFormMigratorsHelper::dismiss_migrator' );
208
209 // Inbox.
210 add_action( 'wp_ajax_frm_inbox_dismiss', 'FrmInboxController::dismiss_message' );
211
212 // Settings.
213 add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' );
214
215 // Styles Controller.
216 add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' );
217 add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' );
218 add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' );
219 add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' );
220 add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' );
221 add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
222
223 // XML Controller.
224 add_action( 'wp_ajax_frm_install_template', 'FrmXMLController::install_template' );
225 add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
226 add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
227 add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
228
229 // Templates API.
230 add_action( 'wp_ajax_template_api_signup', 'FrmFormTemplateApi::signup' );
231 }
232
233 public static function load_form_hooks() {
234 // Fields Controller.
235 add_filter( 'frm_field_type', 'FrmFieldsController::change_type' );
236 add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' );
237 add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 );
238 add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' );
239
240 // Forms Controller.
241 add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' );
242
243 // Styles Controller.
244 add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
245 }
246
247 public static function load_view_hooks() {
248 // Hooks go here when a view is loaded.
249 }
250
251 public static function load_multisite_hooks() {
252 add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' );
253
254 // Drop tables when mu site is deleted.
255 add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
256 }
257
258 /**
259 * @deprecated 5.0.06 use FrmElementorController::register_elementor_hooks directly.
260 */
261 public static function register_elementor_hooks() {
262 _deprecated_function( __FUNCTION__, '5.0.06', 'FrmElementorController::register_elementor_hooks' );
263 FrmElementorController::register_elementor_hooks();
264 }
265 }
266