1: <?php
2:
3: 4: 5:
6: class Quform_Dispatcher
7: {
8: 9: 10:
11: protected $container;
12:
13: 14: 15:
16: public function __construct(Quform_Container $container)
17: {
18: $this->container = $container;
19: }
20:
21: 22: 23: 24: 25:
26: public function bootstrap()
27: {
28:
29: add_action('init', array($this->container['themes'], 'registerCoreThemes'), 1);
30:
31:
32: add_action('init', array($this->container['upgrader'], 'upgradeCheck'), 3);
33:
34:
35: add_action('init', array($this->container['session'], 'start'), 5);
36: add_action('shutdown', array($this->container['session'], 'save'));
37: add_action('quform_session_gc', array($this->container['session'], 'gc'));
38:
39:
40: add_action('init', array($this->container['translations'], 'load'));
41:
42:
43: add_action('init', array($this->container['uploader'], 'upload'));
44: add_action('quform_upload_cleanup', array($this->container['uploader'], 'cleanup'));
45:
46:
47: add_action('wp_head', array($this->container['scriptLoader'], 'printHeadScripts'), 0);
48: add_action('wp_enqueue_scripts', array($this->container['scriptLoader'], 'enqueue'));
49:
50:
51: add_action('quform_pre_send_notification', array('Quform_Notification', 'addAltBody'), 15, 3);
52:
53:
54: add_action('wp_loaded', array($this->container['formController'], 'process'));
55: add_action('wp_ajax_quform_support_page_caching', array($this->container['formController'], 'supportPageCaching'));
56: add_action('wp_ajax_nopriv_quform_support_page_caching', array($this->container['formController'], 'supportPageCaching'));
57:
58:
59: add_shortcode('quform', array($this->container['shortcode'], 'form'));
60: add_shortcode('quform_popup', array($this->container['shortcode'], 'popup'));
61: add_shortcode('quform_entry_limit', array($this->container['shortcode'], 'entryLimit'));
62: add_shortcode('quform_entry_count', array($this->container['shortcode'], 'entryCount'));
63: add_shortcode('quform_entries_remaining', array($this->container['shortcode'], 'entriesRemaining'));
64:
65:
66: add_action('widgets_init', array('Quform_Widget_Form', 'register'));
67: add_action('widgets_init', array('Quform_Widget_Popup', 'register'));
68:
69:
70: add_action('wp_ajax_quform_regenerate_captcha', array($this->container['captcha'], 'regenerate'));
71: add_action('wp_ajax_nopriv_quform_regenerate_captcha', array($this->container['captcha'], 'regenerate'));
72:
73:
74: add_action('admin_bar_menu', array($this->container['toolbar'], 'addNodes'), 90);
75: add_action('admin_head', array($this->container['toolbar'], 'printStyles'));
76: add_action('wp_head', array($this->container['toolbar'], 'printStyles'));
77:
78:
79: add_filter('user_has_cap', array($this->container['permissions'], 'fullAccessCheck'), 10, 3);
80:
81:
82: add_action('init', array($this->container['block'], 'register'));
83:
84: if (is_admin() || defined('QUFORM_TESTING')) {
85:
86: register_deactivation_hook(QUFORM_BASENAME, array($this->container['uploader'], 'deactivate'));
87: register_deactivation_hook(QUFORM_BASENAME, array($this->container['session'], 'deactivate'));
88:
89:
90: add_action('admin_menu', array($this->container['adminPageController'], 'createMenus'));
91: add_action('current_screen', array($this->container['adminPageController'], 'process'));
92: add_filter('admin_title', array($this->container['adminPageController'], 'setAdminTitle'));
93: add_filter('admin_body_class', array($this->container['adminPageController'], 'addBodyClass'));
94: add_action('admin_enqueue_scripts', array($this->container['adminPageController'], 'enqueueAssets'));
95:
96:
97: add_action('wp_ajax_quform_verify_purchase_code', array($this->container['license'], 'verifyPurchaseCode'));
98: add_action('wp_ajax_quform_save_settings', array($this->container['settings'], 'save'));
99: add_action('wp_ajax_quform_rebuild_script_cache', array($this->container['settings'], 'rebuildScriptCache'));
100: add_action('wp_ajax_quform_set_popup_enabled', array($this->container['settings'], 'enablePopup'));
101: add_filter('wp_ajax_quform_settings_search_posts', array($this->container['settings'], 'searchPosts'));
102:
103:
104: add_action('admin_init', array($this->container['formController'], 'process'));
105: add_action('wp_ajax_quform_preview_form', array($this->container['builder'], 'preview'));
106: add_action('wp_ajax_nopriv_quform_preview_form', array($this->container['builder'], 'preview'));
107:
108:
109: add_action('wp_ajax_quform_save_forms_table_settings', array($this->container['formsListSettings'], 'save'));
110: add_action('wp_ajax_quform_add_form', array($this->container['builder'], 'add'));
111: add_action('wp_ajax_quform_save_form', array($this->container['builder'], 'save'));
112: add_filter('wp_ajax_quform_builder_search_posts', array($this->container['builder'], 'searchPosts'));
113: add_filter('wp_ajax_quform_builder_get_post_title', array($this->container['builder'], 'getPostTitle'));
114:
115:
116: add_action('admin_enqueue_scripts', array($this->container['insertForm'], 'registerScripts'));
117: add_action('media_buttons', array($this->container['insertForm'], 'button'), 20);
118: add_action('wp_ajax_quform_insert_form', array($this->container['insertForm'], 'display'));
119:
120:
121: add_action('wp_dashboard_setup', array($this->container['dashboardWidget'], 'setup'));
122:
123:
124: add_action('pre_set_site_transient_update_plugins', array($this->container['updater'], 'setUpdateTransient'));
125: add_action('wp_ajax_quform_manual_update_check', array($this->container['updater'], 'checkForUpdate'));
126: add_filter('plugins_api', array($this->container['updater'], 'pluginInformation'), 10, 3);
127:
128:
129: add_action('wp_ajax_quform_save_entries_table_settings', array($this->container['entriesListSettings'], 'save'));
130: add_action('wp_ajax_quform_set_entry_labels', array($this->container['entriesListSettings'], 'setEntryLabels'));
131: add_action('wp_loaded', array($this->container['entryController'], 'process'));
132: add_action('wp_ajax_quform_resend_notifications', array($this->container['notificationResender'], 'resend'));
133: add_filter('wp_ajax_quform_entries_search_users', array($this->container['entriesUserSearcher'], 'search'));
134:
135:
136: add_action('wp_ajax_quform_export_form', array($this->container['formExporter'], 'export'));
137: add_action('wp_ajax_quform_import_form', array($this->container['formImporter'], 'import'));
138: add_action('wp_ajax_quform_get_export_field_list', array($this->container['entryExporter'], 'getExportFieldList'));
139: add_action('wp_ajax_quform_save_export_field_list_order', array($this->container['entryExporter'], 'saveExportFieldListOrder'));
140: add_action('wp_ajax_quform_migrate_get_all_form_ids', array($this->container['migrator'], 'getAllFormIds'));
141: add_action('wp_ajax_quform_migrate_form', array($this->container['migrator'], 'migrateForm'));
142: add_action('wp_ajax_quform_migrate_settings', array($this->container['migrator'], 'migrateSettings'));
143: add_action('wp_ajax_quform_migrate_import_form', array($this->container['migrator'], 'migrateImportForm'));
144:
145:
146: add_action('wp_refresh_nonces', array($this->container['nonceRefresher'], 'refreshNonces'), 10, 3);
147: add_filter('wpmu_drop_tables', array($this->container['repository'], 'dropTablesOnSiteDeletion'));
148: add_filter('wpmu_drop_tables', array($this->container['session'], 'dropTableOnSiteDeletion'));
149: }
150:
151: do_action('quform_bootstrap', $this->container);
152:
153: return $this;
154: }
155:
156: 157: 158: 159: 160: 161:
162: public function getService($service)
163: {
164: return isset($this->container[$service]) ? $this->container[$service] : null;
165: }
166: }
167: