PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.16.5
GiveWP – Donation Plugin and Fundraising Platform v4.16.5
4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / class-give-scripts.php
give / includes Last commit date
admin 1 week ago api 3 years ago database 5 months ago deprecated 2 months ago donors 5 months ago emails 10 months ago forms 3 weeks ago frontend 6 years ago gateways 2 weeks ago libraries 10 months ago payments 3 days ago actions.php 10 months ago ajax-functions.php 3 weeks ago class-give-async-process.php 1 year ago class-give-background-updater.php 10 months ago class-give-cache-setting.php 1 year ago class-give-cache.php 10 months ago class-give-cli-commands.php 1 year ago class-give-comment.php 10 months ago class-give-cron.php 10 months ago class-give-donate-form.php 2 years ago class-give-donor.php 2 years ago class-give-email-access.php 5 years ago class-give-license-handler.php 2 months ago class-give-logging.php 10 months ago class-give-readme-parser.php 4 years ago class-give-roles.php 5 months ago class-give-scripts.php 1 week ago class-give-session.php 10 months ago class-give-stats.php 6 years ago class-give-template-loader.php 6 years ago class-give-tooltips.php 6 years ago class-give-translation.php 4 years ago class-notices.php 10 months ago country-functions.php 8 months ago currencies-list.php 8 months ago currency-functions.php 4 years ago error-tracking.php 6 years ago filters.php 10 months ago formatting.php 9 months ago install.php 10 months ago login-register.php 2 years ago misc-functions.php 2 months ago plugin-compatibility.php 6 years ago post-types.php 1 year ago price-functions.php 6 years ago process-donation.php 1 year ago setting-functions.php 7 years ago shortcodes.php 1 year ago template-functions.php 1 year ago user-functions.php 3 years ago
class-give-scripts.php
640 lines
1 <?php
2
3 use Give\Framework\Support\Facades\Scripts\ScriptAsset;
4 use Give\Helpers\EnqueueScript;
5 use Give\Helpers\Language;
6
7 /**
8 * Loads the plugin's scripts and styles.
9 *
10 * Registers and enqueues plugin styles and scripts. Asset versions are based
11 * on the current plugin version.
12 *
13 * All script and style handles should be registered in this class even if they
14 * are enqueued dynamically by other classes.
15 *
16 * @since 2.1.0
17 */
18 class Give_Scripts {
19
20 /**
21 * Whether RTL or not.
22 *
23 * @since 2.1.0
24 * @var string
25 * @access private
26 */
27 private $direction;
28
29 /**
30 * Whether scripts should be loaded in the footer or not.
31 *
32 * @since 2.1.0
33 * @var bool
34 * @access private
35 */
36 private static $scripts_footer;
37
38 /**
39 * Instantiates the Assets class.
40 *
41 * @since 2.1.0
42 */
43 public function __construct() {
44 $this->direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : '';
45 self::$scripts_footer = give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ? true : false;
46 $this->init();
47 }
48
49 /**
50 * Fires off hooks to register assets in WordPress.
51 *
52 * @since 2.1.0
53 */
54 public function init() {
55
56 add_action( 'admin_enqueue_scripts', [ $this, 'register_styles' ] );
57 add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ] );
58 add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ] );
59 add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] );
60
61 if ( is_admin() ) {
62 add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
63 add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_styles' ] );
64 add_action( 'enqueue_block_editor_assets', [ $this, 'gutenberg_admin_scripts' ] );
65 add_action( 'admin_head', [ $this, 'global_admin_head' ] );
66
67 } else {
68 add_action( 'wp_enqueue_scripts', [ $this, 'public_enqueue_styles' ] );
69 add_action( 'wp_enqueue_scripts', [ $this, 'public_enqueue_scripts' ] );
70 }
71 }
72
73 /**
74 * Register plugin script.
75 *
76 * @since 2.5.0
77 * @access public
78 *
79 * @param string $handle Script Handle.
80 * @param string $src Script Source URL.
81 * @param array $dep Dependency on a script.
82 * @param mixed $ver Script Version
83 */
84 public static function register_script( $handle, $src, $dep = [], $ver = false ) {
85 wp_register_script( $handle, $src, $dep, $ver, self::$scripts_footer );
86 }
87
88 /**
89 * Registers all plugin styles.
90 *
91 * @since 2.1.0
92 */
93 public function register_styles() {
94
95 // Global WP-admin.
96 wp_register_style( 'give-admin-global-styles', GIVE_PLUGIN_URL . 'build/assets/dist/css/admin-global' . $this->direction . '.css', [], GIVE_VERSION );
97
98 // GiveWP-only WP-admin.
99 wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'build/assets/dist/css/admin' . $this->direction . '.css', [], GIVE_VERSION );
100
101 // WP-admin: plugin page.
102 wp_register_style(
103 'plugin-deactivation-survey-css',
104 GIVE_PLUGIN_URL . 'build/assets/dist/css/plugin-deactivation-survey.css',
105 [],
106 GIVE_VERSION
107 );
108
109 // Frontend.
110 if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) {
111 wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), [], GIVE_VERSION, 'all' );
112 }
113 }
114
115 /**
116 * Registers all plugin scripts.
117 *
118 * @since 2.1.0
119 */
120 public function register_scripts() {
121 // WP-Admin.
122 EnqueueScript::make(
123 'give-admin-scripts',
124 'build/assets/dist/js/admin.js'
125 )
126 ->dependencies(
127 [
128 'jquery',
129 'jquery-ui-datepicker',
130 'wp-color-picker',
131 'jquery-query',
132 ]
133 )
134 ->registerTranslations()
135 ->register();
136
137 // WP-admin: plugin page.
138 wp_register_script(
139 'plugin-deactivation-survey-js',
140 GIVE_PLUGIN_URL . 'build/assets/dist/js/plugin-deactivation-survey.js',
141 [ 'jquery' ],
142 GIVE_VERSION,
143 true
144 );
145
146 // WP-admin: add-ons page.
147 wp_register_script(
148 'admin-add-ons-js',
149 GIVE_PLUGIN_URL . 'build/assets/dist/js/admin-add-ons.js',
150 [ 'jquery' ],
151 GIVE_VERSION,
152 true
153 );
154
155 // Frontend.
156 $giveScript = EnqueueScript::make('give', 'build/assets/dist/js/give.js')
157 ->registerTranslations();
158
159 if (self::$scripts_footer) {
160 $giveScript->loadInFooter();
161 }
162
163 $giveScript->register();
164 }
165
166 /**
167 * Enqueues admin styles.
168 *
169 * @since 2.1.0
170 *
171 * @param string $hook Page hook.
172 */
173 public function admin_enqueue_styles( $hook ) {
174
175 // Global admin styles
176 wp_enqueue_style( 'give-admin-global-styles' );
177
178 // Give Admin Only.
179 if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) {
180 return;
181 }
182
183 // Give enqueues.
184 wp_enqueue_style( 'give-admin-styles' );
185 wp_enqueue_style( 'give-admin-bar-notification' );
186
187 // WP Core enqueues.
188 wp_enqueue_style( 'wp-color-picker' );
189 wp_enqueue_style( 'thickbox' ); // @TODO remove once we have modal API.
190
191 }
192
193 /**
194 * Enqueues admin scripts.
195 *
196 * @since 2.1.0
197 *
198 * @param string $hook Page hook.
199 */
200 public function admin_enqueue_scripts( $hook ) {
201 global $pagenow;
202
203 // Plugin page script
204 if ( 'plugins.php' === $pagenow ) {
205 $this->plugin_enqueue_scripts();
206 }
207
208 // Give Admin Only.
209 if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
210 return;
211 }
212
213 // WP Scripts.
214 wp_enqueue_script( 'wp-color-picker' );
215 wp_enqueue_script( 'jquery-ui-datepicker' );
216 wp_enqueue_script( 'thickbox' );
217 wp_enqueue_media();
218
219 // Give admin scripts.
220 wp_enqueue_script( 'give-admin-scripts' );
221
222 // Localize admin scripts
223 $this->admin_localize_scripts();
224
225 if ( Give_Admin_Settings::is_setting_page( 'licenses' ) ) {
226 wp_enqueue_script( 'admin-add-ons-js' );
227 $localized_data = [
228 'notices' => [
229 'invalid_license' => __( 'Sorry, you entered an invalid key.', 'give' ),
230 'download_file' => __( 'Success! You have activated your license key and are receiving updates and priority support. <a href="{link}">Click here</a> to download your add-on.', 'give' ),
231 'addon_activated' => __( '{pluginName} add-on activated successfully.', 'give' ),
232 'addon_activation_error' => __( 'The add-on did not activate successfully.', 'give' ),
233 ],
234 ];
235
236 wp_localize_script( 'admin-add-ons-js', 'give_addon_var', $localized_data );
237 }
238 }
239
240 /**
241 * Load admin plugin page related scripts, styles and localize param.
242 *
243 * @since 2.2.0
244 * @access private
245 */
246 private function plugin_enqueue_scripts() {
247 wp_enqueue_style( 'plugin-deactivation-survey-css' );
248 wp_enqueue_script( 'plugin-deactivation-survey-js' );
249
250 $localized_data = [
251 'nonce' => wp_create_nonce( 'deactivation_survey_nonce' ),
252 'cancel' => __( 'Cancel', 'give' ),
253 'deactivation_no_option_selected' => __( 'Error: Please select at least one option.', 'give' ),
254 'submit_and_deactivate' => __( 'Submit and Deactivate', 'give' ),
255 'skip_and_deactivate' => __( 'Skip and Deactivate', 'give' ),
256 'please_fill_field' => __( 'Error: Please complete the required field.', 'give' ),
257
258 ];
259
260 wp_localize_script( 'plugin-deactivation-survey-js', 'give_vars', $localized_data );
261 }
262
263 /**
264 * Localize admin scripts.
265 *
266 * @since 2.25.3 Add nonce for payment note AJAX requests.
267 * @since 4.15.4 Add nonce for give_set_notification_status AJAX request.
268 */
269 public function admin_localize_scripts() {
270
271 global $post;
272
273 $give_options = give_get_settings();
274
275 // Price Separators.
276 $thousand_separator = give_get_price_thousand_separator();
277 $decimal_separator = give_get_price_decimal_separator();
278 $number_decimals = give_get_price_decimals();
279
280 // Localize strings & variables for JS.
281 $localized_data = [
282 'post_id' => isset( $post->ID ) ? $post->ID : null,
283 'give_version' => GIVE_VERSION,
284 'thousands_separator' => $thousand_separator,
285 'decimal_separator' => $decimal_separator,
286 'number_decimals' => $number_decimals,
287 // Use this for number of decimals instead of `currency_decimals`.
288 'currency_decimals' => $number_decimals,
289 // If you find usage of this variable then replace it with `number_decimals`.
290 'currency_sign' => give_currency_filter( '' ),
291 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
292 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ),
293 'delete_payment' => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ),
294 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ),
295 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ),
296 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ),
297 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ),
298 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ),
299 'one_option' => __( 'Choose a form', 'give' ),
300 'one_or_more_option' => __( 'Choose one or more forms', 'give' ),
301 'ok' => __( 'Ok', 'give' ),
302 'activate' => __( 'Activate', 'give' ),
303 'deactivate' => __( 'Deactivate', 'give' ),
304 'cancel' => __( 'Cancel', 'give' ),
305 'success' => __( 'Success', 'give' ),
306 'error' => __( 'Error', 'give' ),
307 'close' => __( 'Close', 'give' ),
308 'confirm' => __( 'Confirm', 'give' ),
309 'copied' => __( 'Copied!', 'give' ),
310 'shortcode_not_copy' => __( 'Shortcode could not be copied.', 'give' ),
311 'confirm_action' => __( 'Confirm Action', 'give' ),
312 'confirm_deletion' => __( 'Confirm Deletion', 'give' ),
313 'confirm_delete_donation' => __( 'Confirm Delete Donation', 'give' ),
314 'confirm_resend' => __( 'Confirm re-send', 'give' ),
315 'confirm_bulk_action' => __( 'Confirm bulk action', 'give' ),
316 'restart_upgrade' => __( 'Do you want to restart the update process?', 'give' ),
317 'restart_update' => __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ),
318 'stop_upgrade' => __( 'Do you want to stop the update process now?', 'give' ),
319 'import_failed' => __( 'Import failed', 'give' ),
320 'flush_success' => __( 'Flush success', 'give' ),
321 'flush_error' => __( 'Flush error', 'give' ),
322 'no_form_selected' => __( 'No form selected', 'give' ),
323 'batch_export_no_class' => __( 'You must choose a method.', 'give' ),
324 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ),
325 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
326 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ),
327 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ),
328 'delete_donations_only' => __( 'Are you sure you want to delete all the donations in the specfied date range?', 'give' ),
329 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
330 /* translators : %s: Donation form options metabox */
331 'confirm_before_remove_row_text' => __( 'Do you want to delete this item?', 'give' ),
332 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ),
333 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ),
334 'search_placeholder' => __( 'Type to search all forms', 'give' ),
335 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ),
336 'search_placeholder_country' => __( 'Type to search all countries', 'give' ),
337 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ),
338 'unlock_donor_fields_title' => __( 'Action forbidden', 'give' ),
339 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to the user profile of the donor.', 'give' ),
340 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ),
341 'form_template_required' => [
342 'title' => __( 'Select Form Template', 'give' ),
343 'desc' => __( 'Please activate a "Form Template" to save the donation form. Select a template by clicking on the "Form Template" tab and "Activate".', 'give' ),
344 ],
345 'donors_bulk_action' => [
346 'no_donor_selected' => [
347 'title' => __( 'No donors selected', 'give' ),
348 'desc' => __( 'You must choose at least one or more donors to delete.', 'give' ),
349 ],
350 'no_action_selected' => [
351 'title' => __( 'No action selected', 'give' ),
352 'desc' => __( 'You must select a bulk action to proceed.', 'give' ),
353 ],
354 ],
355 'donations_bulk_action' => [
356 'titles' => [
357 'zero' => __( 'No payments selected', 'give' ),
358 ],
359 'delete' => [
360 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ),
361 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ),
362 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ),
363 ],
364 'resend-receipt' => [
365 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ),
366 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ),
367 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ),
368 ],
369 'set-to-status' => [
370 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ),
371 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ),
372 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ),
373 ],
374 ],
375 'updates' => [
376 'ajax_error' => __( 'Please reload this page and try again', 'give' ),
377 ],
378 'metabox_fields' => [
379 'media' => [
380 'button_title' => __( 'Choose Image', 'give' ),
381 ],
382 'file' => [
383 'button_title' => __( 'Choose File', 'give' ),
384 ],
385 ],
386 'chosen' => [
387 'no_results_msg' => __( 'No results match {search_term}', 'give' ),
388 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ),
389 ],
390 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ),
391 'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ),
392 'error_message' => __( 'Something went wrong kindly try again!', 'give' ),
393 'give_donation_import' => 'give_donation_import',
394 'give_donation_import_nonce' => wp_create_nonce('give_donation_import'),
395 'give_subscription_import' => 'give_subscription_import',
396 'give_subscription_import_nonce' => wp_create_nonce('give_subscription_import'),
397 'core_settings_import' => 'give_core_settings_import',
398 'core_settings_import_nonce' => wp_create_nonce('give_core_settings_import'),
399 'give_insert_payment_note_nonce' => wp_create_nonce('give_insert_payment_note'),
400 'give_delete_payment_note_nonce' => wp_create_nonce('give_delete_payment_note'),
401 'give_set_notification_status_nonce' => wp_create_nonce('give_set_notification_status'),
402 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ),
403 'give_donation_amounts' => [
404 'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ),
405 'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ),
406 ],
407 'chosen_add_title_prefix' => __( 'No result found. Press enter to add', 'give' ),
408 'db_update_nonce' => wp_create_nonce( Give_Updates::$background_updater->get_identifier() ),
409 'ajax' => give_test_ajax_works(),
410 'donor_note_confirm_msg' => __( 'Please confirm you would like to add a donor note. An email notification will be sent to the donor with the note. If you do not want to notify the donor you may add a private note or disable the donor note email.', 'give' ),
411 'email_notification' => [
412 'donor_note' => [
413 'status' => Give_Email_Notification_Util::is_email_notification_active( Give_Email_Notification::get_instance( 'donor-note' ) ),
414 ],
415 ],
416 'loader_translation' => [
417 'updating' => __( 'Updating...', 'give' ),
418 'loading' => __( 'Loading...', 'give' ),
419 'uploading' => __( 'Uploading...', 'give' ),
420 'processing' => __( 'Processing...', 'give' ),
421 'activating' => __( 'Activating...', 'give' ),
422 ],
423 ];
424
425 wp_localize_script( 'give-admin-scripts', 'give_vars', $localized_data );
426 }
427
428 /**
429 * Global admin head.
430 */
431 public function global_admin_head() {
432 ?>
433 <style type="text/css" media="screen">
434 @font-face {
435 font-family: 'give-icomoon';
436 src: url('<?php echo GIVE_PLUGIN_URL . 'build/assets/dist/fonts/icomoon.eot?ngjl88'; ?>');
437 src: url('<?php echo GIVE_PLUGIN_URL . 'build/assets/dist/fonts/icomoon.eot?#iefixngjl88'; ?>') format('embedded-opentype'),
438 url('<?php echo GIVE_PLUGIN_URL . 'build/assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
439 url('<?php echo GIVE_PLUGIN_URL . 'build/assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
440 font-weight: normal;
441 font-style: normal;
442 }
443
444 .dashicons-give:before, #adminmenu div.wp-menu-image.dashicons-give:before {
445 font-family: 'give-icomoon';
446 font-size: 18px;
447 width: 18px;
448 height: 18px;
449 content: "\e800";
450 padding-top: 8px;
451 }
452 </style>
453 <?php
454
455 }
456
457 /**
458 * Enqueues public styles.
459 *
460 * @since 2.1.0
461 */
462 public function public_enqueue_styles() {
463 wp_enqueue_style( 'give-styles' );
464 }
465
466
467 /**
468 * Enqueues public scripts.
469 *
470 * @since 2.1.0
471 */
472 public function public_enqueue_scripts() {
473 wp_enqueue_script( 'give' );
474
475 $this->public_localize_scripts();
476 }
477
478 /**
479 * Localize / PHP to AJAX vars.
480 */
481 public function public_localize_scripts() {
482
483 /**
484 * Filter to modify access mail send notice
485 *
486 * @since 2.1.3
487 *
488 * @param string Send notice message for email access.
489 *
490 * @return string $message Send notice message for email access.
491 */
492 $message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) );
493
494 $localize_give_vars = apply_filters(
495 'give_global_script_vars',
496 [
497 'ajaxurl' => give_get_ajax_url(),
498 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ),
499 // Do not use this nonce. Its deprecated.
500 'currency' => give_get_currency(),
501 'currency_sign' => give_currency_filter( '' ),
502 'currency_pos' => give_get_currency_position(),
503 'thousands_separator' => give_get_price_thousand_separator(),
504 'decimal_separator' => give_get_price_decimal_separator(),
505 'no_gateway' => __( 'Please select a payment method.', 'give' ),
506 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ),
507 'bad_maximum' => __( 'The maximum custom donation amount for this form is', 'give' ),
508 'general_loading' => __( 'Loading...', 'give' ),
509 'purchase_loading' => __( 'Please Wait...', 'give' ),
510 'textForOverlayScreen' => sprintf( '<h3>%1$s</h3><p>%2$s</p>', esc_html__( 'Processing...', 'give' ), esc_html__( 'This will only take a second!', 'give' ) ),
511 'number_decimals' => give_get_price_decimals(),
512 'is_test_mode' => give_is_test_mode(),
513 'give_version' => GIVE_VERSION,
514 'magnific_options' => apply_filters(
515 'give_magnific_options',
516 [
517 'main_class' => 'give-modal',
518 'close_on_bg_click' => false,
519 ]
520 ),
521 'form_translation' => apply_filters(
522 'give_form_translation_js',
523 [
524 // Field name Validation message.
525 'payment-mode' => __( 'Please select payment mode.', 'give' ),
526 'give_first' => __( 'Please enter your first name.', 'give' ),
527 'give_last' => __( 'Please enter your last name.', 'give' ),
528 'give_email' => __( 'Please enter a valid email address.', 'give' ),
529 'give_user_login' => __( 'Invalid email address or username.', 'give' ),
530 'give_user_pass' => __( 'Enter a password.', 'give' ),
531 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ),
532 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ),
533 ]
534 ),
535 'confirm_email_sent_message' => $message,
536 'ajax_vars' => apply_filters(
537 'give_global_ajax_vars',
538 [
539 'ajaxurl' => give_get_ajax_url(),
540 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ),
541 'loading' => __( 'Loading', 'give' ),
542 // General loading message.
543 'select_option' => __( 'Please select an option', 'give' ),
544 // Variable pricing error with multi-donation option enabled.
545 'default_gateway' => give_get_default_gateway( null ),
546 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0',
547 'number_decimals' => give_get_price_decimals(),
548 ]
549 ),
550 'cookie_hash' => COOKIEHASH,
551 'session_nonce_cookie_name' => Give()->session->get_cookie_name( 'nonce' ),
552 'session_cookie_name' => Give()->session->get_cookie_name( 'session' ),
553 'delete_session_nonce_cookie' => absint( Give()->session->is_delete_nonce_cookie() ),
554 ]
555 );
556
557 wp_localize_script( 'give', 'give_global_vars', $localize_give_vars );
558 }
559
560 /**
561 * Get the stylesheet URI.
562 *
563 * @since 1.6
564 * @updated 2.0.1 Moved to class and renamed as method.
565 *
566 * @return string
567 */
568 public function get_frontend_stylesheet_uri() {
569
570 $file = 'give' . $this->direction . '.css';
571 $templates_dir = give_get_theme_template_dir_name();
572
573 // Directory paths to CSS files to support checking via file_exists().
574 $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
575 $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css';
576 $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file;
577 $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css';
578 $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'build/assets/dist/css/' . $file;
579 $uri = false;
580
581 /**
582 * Locate the Give stylesheet:
583 *
584 * a. Look in the child theme directory first, followed by the parent theme
585 * b. followed by the Give core templates directory also look for the min version first,
586 * c. followed by non minified version, even if SCRIPT_DEBUG is not enabled. This allows users to copy just give.css to their theme.
587 * d. Finally, fallback to the standard Give version. This is the default styles included within the plugin.
588 */
589 if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
590 if ( ! empty( $nonmin ) ) {
591 $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css';
592 } else {
593 $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
594 }
595 } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
596 if ( ! empty( $nonmin ) ) {
597 $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css';
598 } else {
599 $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
600 }
601 } elseif ( file_exists( $give_plugin_style_sheet ) ) {
602 $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'build/assets/dist/css/' . $file;
603 }
604
605 return apply_filters( 'give_get_stylesheet_uri', $uri );
606
607 }
608
609 /**
610 * Gutenberg admin scripts.
611 *
612 * @since 3.1.0 Use wp scripts to compile blocks
613 * @since 2.19.0 Remove undefined gutenberg.css
614 * @since 2.19.6 Load script with EnqueueScript.
615 * @since 2.19.6 Load missing block styles
616 */
617 public function gutenberg_admin_scripts()
618 {
619 wp_enqueue_style(
620 'give-blocks-css',
621 GIVE_PLUGIN_URL . 'build/assets/dist/css/admin-block-editor.css',
622 [],
623 GIVE_VERSION
624 );
625
626 $scriptAsset = ScriptAsset::get(GIVE_PLUGIN_DIR . 'build/adminBlocks.asset.php');
627
628 $handle = 'give-blocks-js';
629 wp_enqueue_script(
630 $handle,
631 GIVE_PLUGIN_URL . 'build/adminBlocks.js',
632 array_merge(['give-admin-scripts'], $scriptAsset['dependencies']),
633 $scriptAsset['version'],
634 true
635 );
636
637 Language::setScriptTranslations($handle);
638 }
639 }
640