Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
42.86% |
9 / 21 |
|
75.00% |
9 / 12 |
CRAP | |
0.00% |
0 / 1 |
| Jetpack_Forms | |
42.86% |
9 / 21 |
|
75.00% |
9 / 12 |
56.98 | |
0.00% |
0 / 1 |
| load_contact_form | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 | |||
| plugin_url | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| assets_url | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_feedback_dashboard_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_legacy_menu_item_retired | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_mailpoet_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_hostinger_reach_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_integrations_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_webhooks_enabled | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| show_dashboard_integrations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| show_block_integrations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| show_integration_icons | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Package description here |
| 4 | * |
| 5 | * @package automattic/jetpack-forms |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\Forms; |
| 9 | |
| 10 | use Automattic\Jetpack\Forms\ContactForm\Util; |
| 11 | use Automattic\Jetpack\Forms\Dashboard\Dashboard; |
| 12 | /** |
| 13 | * Understands the Jetpack Forms package. |
| 14 | */ |
| 15 | class Jetpack_Forms { |
| 16 | |
| 17 | const PACKAGE_VERSION = '7.9.0'; |
| 18 | |
| 19 | /** |
| 20 | * Load the contact form module. |
| 21 | */ |
| 22 | public static function load_contact_form() { |
| 23 | Util::init(); |
| 24 | |
| 25 | if ( self::is_feedback_dashboard_enabled() ) { |
| 26 | $dashboard = new Dashboard(); |
| 27 | $dashboard->init(); |
| 28 | } |
| 29 | |
| 30 | if ( is_admin() && apply_filters_deprecated( 'tmp_grunion_allow_editor_view', array( true ), '0.30.5', '', 'This functionality will be removed in an upcoming version.' ) ) { |
| 31 | add_action( 'current_screen', '\Automattic\Jetpack\Forms\ContactForm\Editor_View::add_hooks' ); |
| 32 | } |
| 33 | |
| 34 | add_action( 'init', '\Automattic\Jetpack\Forms\ContactForm\Util::register_pattern' ); |
| 35 | |
| 36 | // Add hook to delete file attachments when a feedback post is deleted |
| 37 | add_action( 'before_delete_post', array( '\Automattic\Jetpack\Forms\ContactForm\Contact_Form', 'delete_feedback_files' ) ); |
| 38 | |
| 39 | // Enforces the availability of block support controls in the UI for classic themes. |
| 40 | add_filter( 'wp_theme_json_data_default', array( '\Automattic\Jetpack\Forms\ContactForm\Contact_Form', 'add_theme_json_data_for_classic_themes' ) ); |
| 41 | |
| 42 | // Initialize abilities registration for WordPress Abilities API (WP 6.9+) |
| 43 | \Automattic\Jetpack\Forms\Abilities\Forms_Abilities::init(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Get the plugin URL. |
| 48 | */ |
| 49 | public static function plugin_url() { |
| 50 | return plugin_dir_url( __FILE__ ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Get the assets URL. |
| 55 | */ |
| 56 | public static function assets_url() { |
| 57 | return plugin_dir_url( __DIR__ ) . 'assets'; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns true if the feedback dashboard is enabled. |
| 62 | * |
| 63 | * @return boolean |
| 64 | */ |
| 65 | public static function is_feedback_dashboard_enabled() { |
| 66 | /** |
| 67 | * Enable the new Jetpack Forms dashboard. |
| 68 | * |
| 69 | * @module contact-form |
| 70 | * @since 0.3.0 |
| 71 | * |
| 72 | * @param bool false Should the new Jetpack Forms dashboard be enabled? Default to false. |
| 73 | */ |
| 74 | return apply_filters( 'jetpack_forms_dashboard_enable', true ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Returns true if the legacy menu item is retired. |
| 79 | * |
| 80 | * @return boolean |
| 81 | */ |
| 82 | public static function is_legacy_menu_item_retired() { |
| 83 | return apply_filters( 'jetpack_forms_retire_legacy_menu_item', true ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns true if MailPoet integration is enabled. |
| 88 | * |
| 89 | * @return boolean |
| 90 | */ |
| 91 | public static function is_mailpoet_enabled() { |
| 92 | /** |
| 93 | * Enable MailPoet integration. |
| 94 | * |
| 95 | * @param bool false Whether MailPoet integration be enabled. Default is false. |
| 96 | */ |
| 97 | return apply_filters( 'jetpack_forms_mailpoet_enable', true ); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Returns true if Hostinger Reach integration is enabled. |
| 102 | * |
| 103 | * @return boolean |
| 104 | */ |
| 105 | public static function is_hostinger_reach_enabled() { |
| 106 | /** |
| 107 | * Enable Hostinger Reach integration. |
| 108 | * |
| 109 | * @param bool false Whether Hostinger Reach integration be enabled. Default is false. |
| 110 | */ |
| 111 | return apply_filters( 'jetpack_forms_hostinger_reach_enable', false ); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Returns true if the Integrations UI should be enabled. |
| 116 | * |
| 117 | * @return boolean |
| 118 | */ |
| 119 | public static function is_integrations_enabled() { |
| 120 | /** |
| 121 | * Whether to enable the Integrations UI. |
| 122 | * |
| 123 | * @param bool true Whether to enable the Integrations UI. Default true. |
| 124 | */ |
| 125 | return apply_filters( 'jetpack_forms_is_integrations_enabled', true ); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Returns true if webhooks are enabled. |
| 130 | * |
| 131 | * @return boolean |
| 132 | */ |
| 133 | public static function is_webhooks_enabled() { |
| 134 | /** |
| 135 | * Whether to enable webhooks for Jetpack Forms. |
| 136 | * |
| 137 | * @param bool true Whether webhooks should be enabled. Default true. |
| 138 | */ |
| 139 | return apply_filters( 'jetpack_forms_webhooks_enabled', true ); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Returns true if the Integrations UI should be shown in the Forms dashboard. |
| 144 | * |
| 145 | * @since 6.22.0 |
| 146 | * |
| 147 | * @return boolean |
| 148 | */ |
| 149 | public static function show_dashboard_integrations() { |
| 150 | /** |
| 151 | * Whether to show Integrations UI in the Forms dashboard. |
| 152 | * |
| 153 | * @since 6.22.0 |
| 154 | * |
| 155 | * @param bool true Whether to show the Integrations UI in the dashboard. Default true. |
| 156 | */ |
| 157 | return apply_filters( 'jetpack_forms_show_dashboard_integrations', true ); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Returns true if the Integrations UI should be shown in the Form block editor. |
| 162 | * |
| 163 | * @since 6.22.0 |
| 164 | * |
| 165 | * @return boolean |
| 166 | */ |
| 167 | public static function show_block_integrations() { |
| 168 | /** |
| 169 | * Whether to show Integrations UI in the Form block editor. |
| 170 | * |
| 171 | * @since 6.22.0 |
| 172 | * |
| 173 | * @param bool true Whether to show the Integrations UI in the editor. Default true. |
| 174 | */ |
| 175 | return apply_filters( 'jetpack_forms_show_block_integrations', true ); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Returns true if integration icons should be shown (editor sidebar and integrations modal). |
| 180 | * |
| 181 | * @since 6.22.0 |
| 182 | * |
| 183 | * @return boolean |
| 184 | */ |
| 185 | public static function show_integration_icons() { |
| 186 | /** |
| 187 | * Whether to show integration icons in the UI. |
| 188 | * |
| 189 | * If set to false, the ActiveIntegrations component (editor sidebar) will be hidden |
| 190 | * and integration icons in the integrations modal will not be rendered. |
| 191 | * |
| 192 | * @since 6.22.0 |
| 193 | * |
| 194 | * @param bool true Whether to show integration icons. Default true. |
| 195 | */ |
| 196 | return apply_filters( 'jetpack_forms_show_integration_icons', true ); |
| 197 | } |
| 198 | } |