PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.6.0
GiveWP – Donation Plugin and Fundraising Platform v2.6.0
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 6 years ago api 6 years ago database 6 years ago deprecated 6 years ago donors 6 years ago emails 6 years ago forms 6 years ago frontend 7 years ago gateways 6 years ago libraries 7 years ago payments 6 years ago actions.php 6 years ago ajax-functions.php 6 years ago class-give-async-process.php 7 years ago class-give-background-updater.php 6 years ago class-give-cache-setting.php 6 years ago class-give-cache.php 6 years ago class-give-cli-commands.php 6 years ago class-give-comment.php 7 years ago class-give-cron.php 6 years ago class-give-donate-form.php 6 years ago class-give-donor-wall-widget.php 6 years ago class-give-donor.php 6 years ago class-give-email-access.php 7 years ago class-give-license-handler.php 6 years ago class-give-logging.php 6 years ago class-give-readme-parser.php 7 years ago class-give-roles.php 6 years ago class-give-scripts.php 6 years ago class-give-session.php 6 years ago class-give-stats.php 7 years ago class-give-template-loader.php 8 years ago class-give-tooltips.php 7 years ago class-give-translation.php 8 years ago class-notices.php 6 years ago country-functions.php 6 years ago currencies-list.php 6 years ago currency-functions.php 6 years ago error-tracking.php 7 years ago filters.php 6 years ago formatting.php 6 years ago install.php 6 years ago login-register.php 7 years ago misc-functions.php 6 years ago plugin-compatibility.php 6 years ago post-types.php 6 years ago price-functions.php 7 years ago process-donation.php 6 years ago setting-functions.php 6 years ago shortcodes.php 6 years ago template-functions.php 6 years ago user-functions.php 6 years ago
class-give-scripts.php
629 lines
1 <?php
2
3 /**
4 * Loads the plugin's scripts and styles.
5 *
6 * Registers and enqueues plugin styles and scripts. Asset versions are based
7 * on the current plugin version.
8 *
9 * All script and style handles should be registered in this class even if they
10 * are enqueued dynamically by other classes.
11 *
12 * @since 2.1.0
13 */
14 class Give_Scripts {
15
16 /**
17 * Whether RTL or not.
18 *
19 * @since 2.1.0
20 * @var string
21 * @access private
22 */
23 private $direction;
24
25 /**
26 * Whether scripts should be loaded in the footer or not.
27 *
28 * @since 2.1.0
29 * @var bool
30 * @access private
31 */
32 private static $scripts_footer;
33
34 /**
35 * Instantiates the Assets class.
36 *
37 * @since 2.1.0
38 */
39 public function __construct() {
40 $this->direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : '';
41 self::$scripts_footer = give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ? true : false;
42 $this->init();
43 }
44
45 /**
46 * Fires off hooks to register assets in WordPress.
47 *
48 * @since 2.1.0
49 */
50 public function init() {
51
52 add_action( 'admin_enqueue_scripts', array( $this, 'register_styles' ) );
53 add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
54 add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );
55 add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
56
57 if ( is_admin() ) {
58 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
59 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) );
60 add_action( 'enqueue_block_editor_assets', array( $this, 'gutenberg_admin_scripts' ) );
61 add_action( 'admin_head', array( $this, 'global_admin_head' ) );
62
63 } else {
64 add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_styles' ) );
65 add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_scripts' ) );
66 }
67 }
68
69 /**
70 * Register plugin script.
71 *
72 * @since 2.5.0
73 * @access public
74 *
75 * @param string $handle Script Handle.
76 * @param string $src Script Source URL.
77 * @param array $dep Dependency on a script.
78 * @param mixed $ver Script Version
79 */
80 public static function register_script( $handle, $src, $dep = array(), $ver = false ) {
81 wp_register_script( $handle, $src, $dep, $ver, self::$scripts_footer );
82 }
83
84 /**
85 * Registers all plugin styles.
86 *
87 * @since 2.1.0
88 */
89 public function register_styles() {
90
91 // Global WP-admin.
92 wp_register_style( 'give-admin-global-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin-global' . $this->direction . '.css', array(), GIVE_VERSION );
93
94 // GiveWP-only WP-admin.
95 wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin' . $this->direction . '.css', array(), GIVE_VERSION );
96
97 // WP-admin: plugin page.
98 wp_register_style(
99 'plugin-deactivation-survey-css',
100 GIVE_PLUGIN_URL . 'assets/dist/css/plugin-deactivation-survey.css',
101 array(),
102 GIVE_VERSION
103 );
104
105 // Frontend.
106 if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) {
107 wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
108 }
109 }
110
111 /**
112 * Registers all plugin scripts.
113 *
114 * @since 2.1.0
115 */
116 public function register_scripts() {
117
118 // WP-Admin.
119 wp_register_script(
120 'give-admin-scripts',
121 GIVE_PLUGIN_URL . 'assets/dist/js/admin.js',
122 array(
123 'jquery',
124 'jquery-ui-datepicker',
125 'wp-color-picker',
126 'jquery-query',
127 ),
128 GIVE_VERSION
129 );
130
131 // WP-admin: plugin page.
132 wp_register_script(
133 'plugin-deactivation-survey-js',
134 GIVE_PLUGIN_URL . 'assets/dist/js/plugin-deactivation-survey.js',
135 array( 'jquery' ),
136 GIVE_VERSION,
137 true
138 );
139
140 // WP-admin: add-ons page.
141 wp_register_script(
142 'admin-add-ons-js',
143 GIVE_PLUGIN_URL . 'assets/dist/js/admin-add-ons.js',
144 array( 'jquery' ),
145 GIVE_VERSION,
146 true
147 );
148
149 // Frontend.
150 wp_register_script( 'give', GIVE_PLUGIN_URL . 'assets/dist/js/give.js', array( 'jquery' ), GIVE_VERSION, self::$scripts_footer );
151 }
152
153 /**
154 * Enqueues admin styles.
155 *
156 * @since 2.1.0
157 *
158 * @param string $hook Page hook.
159 */
160 public function admin_enqueue_styles( $hook ) {
161
162 // Global admin styles
163 wp_enqueue_style( 'give-admin-global-styles' );
164
165 // Give Admin Only.
166 if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) {
167 return;
168 }
169
170 // Give enqueues.
171 wp_enqueue_style( 'give-admin-styles' );
172 wp_enqueue_style( 'give-admin-bar-notification' );
173
174 // WP Core enqueues.
175 wp_enqueue_style( 'wp-color-picker' );
176 wp_enqueue_style( 'thickbox' ); // @TODO remove once we have modal API.
177
178 }
179
180 /**
181 * Enqueues admin scripts.
182 *
183 * @since 2.1.0
184 *
185 * @param string $hook Page hook.
186 */
187 public function admin_enqueue_scripts( $hook ) {
188 global $pagenow;
189
190 // Plugin page script
191 if ( 'plugins.php' === $pagenow ) {
192 $this->plugin_enqueue_scripts();
193 }
194
195 // Give Admin Only.
196 if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
197 return;
198 }
199
200 // WP Scripts.
201 wp_enqueue_script( 'wp-color-picker' );
202 wp_enqueue_script( 'jquery-ui-datepicker' );
203 wp_enqueue_script( 'thickbox' );
204 wp_enqueue_media();
205
206 // Give admin scripts.
207 wp_enqueue_script( 'give-admin-scripts' );
208
209 // Localize admin scripts
210 $this->admin_localize_scripts();
211
212 if ( Give_Admin_Settings::is_setting_page( 'licenses' ) ) {
213 wp_enqueue_script( 'admin-add-ons-js' );
214 $localized_data = array(
215 'notices' => array(
216 'invalid_license' => __( 'Sorry, you entered an invalid key.', 'give' ),
217 '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' ),
218 'addon_activated' => __( '{pluginName} add-on activated successfully.', 'give' ),
219 'addon_activation_error' => __( 'The add-on did not activate successfully.', 'give' ),
220 ),
221 );
222
223 wp_localize_script( 'admin-add-ons-js', 'give_addon_var', $localized_data );
224 }
225 }
226
227 /**
228 * Load admin plugin page related scripts, styles and localize param.
229 *
230 * @since 2.2.0
231 * @access private
232 */
233 private function plugin_enqueue_scripts() {
234 wp_enqueue_style( 'plugin-deactivation-survey-css' );
235 wp_enqueue_script( 'plugin-deactivation-survey-js' );
236
237 $localized_data = array(
238 'nonce' => wp_create_nonce( 'deactivation_survey_nonce' ),
239 'cancel' => __( 'Cancel', 'give' ),
240 'deactivation_no_option_selected' => __( 'Error: Please select at least one option.', 'give' ),
241 'submit_and_deactivate' => __( 'Submit and Deactivate', 'give' ),
242 'skip_and_deactivate' => __( 'Skip and Deactivate', 'give' ),
243 'please_fill_field' => __( 'Error: Please complete the required field.', 'give' ),
244
245 );
246
247 wp_localize_script( 'plugin-deactivation-survey-js', 'give_vars', $localized_data );
248 }
249
250 /**
251 * Localize admin scripts.
252 */
253 public function admin_localize_scripts() {
254
255 global $post, $pagenow;
256 $give_options = give_get_settings();
257
258 // Price Separators.
259 $thousand_separator = give_get_price_thousand_separator();
260 $decimal_separator = give_get_price_decimal_separator();
261 $number_decimals = give_get_price_decimals();
262
263 $stripe_user_id = give_get_option( 'give_stripe_user_id', false );
264 $disconnect_stripe_message = sprintf(
265 /* translators: %s Stripe User ID */
266 __( 'Are you sure you want to disconnect GiveWP from Stripe? If disconnected, this website and any others sharing the same Stripe account (%s) that are connected to GiveWP will need to reconnect in order to process payments.', 'give' ),
267 $stripe_user_id
268 );
269
270 // Localize strings & variables for JS.
271 $localized_data = array(
272 'post_id' => isset( $post->ID ) ? $post->ID : null,
273 'give_version' => GIVE_VERSION,
274 'thousands_separator' => $thousand_separator,
275 'decimal_separator' => $decimal_separator,
276 'number_decimals' => $number_decimals,
277 // Use this for number of decimals instead of `currency_decimals`.
278 'currency_decimals' => $number_decimals,
279 // If you find usage of this variable then replace it with `number_decimals`.
280 'currency_sign' => give_currency_filter( '' ),
281 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
282 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ),
283 'delete_payment' => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ),
284 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ),
285 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ),
286 'regenerate_api_key' => __( 'Are you sure you want to regenerate this API key?', 'give' ),
287 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ),
288 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ),
289 'one_option' => __( 'Choose a form', 'give' ),
290 'one_or_more_option' => __( 'Choose one or more forms', 'give' ),
291 'ok' => __( 'Ok', 'give' ),
292 'cancel' => __( 'Cancel', 'give' ),
293 'success' => __( 'Success', 'give' ),
294 'error' => __( 'Error', 'give' ),
295 'close' => __( 'Close', 'give' ),
296 'confirm' => __( 'Confirm', 'give' ),
297 'copied' => __( 'Copied!', 'give' ),
298 'shortcode_not_copy' => __( 'Shortcode could not be copied.', 'give' ),
299 'confirm_action' => __( 'Confirm Action', 'give' ),
300 'confirm_deletion' => __( 'Confirm Deletion', 'give' ),
301 'confirm_delete_donation' => __( 'Confirm Delete Donation', 'give' ),
302 'confirm_resend' => __( 'Confirm re-send', 'give' ),
303 'confirm_bulk_action' => __( 'Confirm bulk action', 'give' ),
304 'restart_upgrade' => __( 'Do you want to restart the update process?', 'give' ),
305 'restart_update' => __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ),
306 'stop_upgrade' => __( 'Do you want to stop the update process now?', 'give' ),
307 'import_failed' => __( 'Import failed', 'give' ),
308 'flush_success' => __( 'Flush success', 'give' ),
309 'flush_error' => __( 'Flush error', 'give' ),
310 'no_form_selected' => __( 'No form selected', 'give' ),
311 'batch_export_no_class' => __( 'You must choose a method.', 'give' ),
312 'batch_export_no_reqs' => __( 'Required fields not completed.', 'give' ),
313 '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' ),
314 'delete_test_donor' => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ),
315 'delete_import_donor' => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ),
316 'delete_donations_only' => __( 'Are you sure you want to delete all the donations in the specfied date range?', 'give' ),
317 'price_format_guide' => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
318 /* translators : %s: Donation form options metabox */
319 'confirm_before_remove_row_text' => __( 'Do you want to delete this item?', 'give' ),
320 'matched_success_failure_page' => __( 'You cannot set the success and failed pages to the same page', 'give' ),
321 'dismiss_notice_text' => __( 'Dismiss this notice.', 'give' ),
322 'search_placeholder' => __( 'Type to search all forms', 'give' ),
323 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ),
324 'search_placeholder_country' => __( 'Type to search all countries', 'give' ),
325 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ),
326 'unlock_donor_fields_title' => __( 'Action forbidden', 'give' ),
327 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ),
328 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ),
329 'donors_bulk_action' => array(
330 'no_donor_selected' => array(
331 'title' => __( 'No donors selected', 'give' ),
332 'desc' => __( 'You must choose at least one or more donors to delete.', 'give' ),
333 ),
334 'no_action_selected' => array(
335 'title' => __( 'No action selected', 'give' ),
336 'desc' => __( 'You must select a bulk action to proceed.', 'give' ),
337 ),
338 ),
339 'donations_bulk_action' => array(
340 'titles' => array(
341 'zero' => __( 'No payments selected', 'give' ),
342 ),
343 'delete' => array(
344 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ),
345 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ),
346 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ),
347 ),
348 'resend-receipt' => array(
349 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ),
350 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ),
351 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ),
352 ),
353 'set-to-status' => array(
354 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ),
355 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ),
356 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ),
357 ),
358 ),
359 'updates' => array(
360 'ajax_error' => __( 'Please reload this page and try again', 'give' ),
361 ),
362 'metabox_fields' => array(
363 'media' => array(
364 'button_title' => __( 'Choose Image', 'give' ),
365 ),
366 'file' => array(
367 'button_title' => __( 'Choose File', 'give' ),
368 ),
369 ),
370 'chosen' => array(
371 'no_results_msg' => __( 'No results match {search_term}', 'give' ),
372 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ),
373 ),
374 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ),
375 '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' ),
376 'error_message' => __( 'Something went wrong kindly try again!', 'give' ),
377 'give_donation_import' => 'give_donation_import',
378 'core_settings_import' => 'give_core_settings_import',
379 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ),
380 'give_donation_amounts' => array(
381 'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ),
382 'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ),
383 ),
384 'chosen_add_title_prefix' => __( 'No result found. Press enter to add', 'give' ),
385 'db_update_nonce' => wp_create_nonce( Give_Updates::$background_updater->get_identifier() ),
386 'ajax' => give_test_ajax_works(),
387 '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' ),
388 'email_notification' => array(
389 'donor_note' => array(
390 'status' => Give_Email_Notification_Util::is_email_notification_active( Give_Email_Notification::get_instance( 'donor-note' ) ),
391 ),
392 ),
393 'disconnect_stripe_title' => __( 'Confirm Disconnect?', 'give' ),
394 'disconnect_stripe_message' => $disconnect_stripe_message,
395 'loader_translation' => array(
396 'updating' => __( 'Updating...', 'give' ),
397 'loading' => __( 'Loading...', 'give' ),
398 'uploading' => __( 'Uploading...', 'give' ),
399 'processing' => __( 'Processing...', 'give' ),
400 'activating' => __( 'Activating...', 'give' ),
401 ),
402 );
403
404 wp_localize_script( 'give-admin-scripts', 'give_vars', $localized_data );
405 }
406
407 /**
408 * Global admin head.
409 */
410 public function global_admin_head() {
411 ?>
412 <style type="text/css" media="screen">
413 @font-face {
414 font-family: 'give-icomoon';
415 src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?ngjl88'; ?>');
416 src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?#iefixngjl88'; ?>') format('embedded-opentype'),
417 url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
418 url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
419 font-weight: normal;
420 font-style: normal;
421 }
422
423 .dashicons-give:before, #adminmenu div.wp-menu-image.dashicons-give:before {
424 font-family: 'give-icomoon';
425 font-size: 18px;
426 width: 18px;
427 height: 18px;
428 content: "\e800";
429 }
430 </style>
431 <?php
432
433 }
434
435 /**
436 * Enqueues public styles.
437 *
438 * @since 2.1.0
439 */
440 public function public_enqueue_styles() {
441 wp_enqueue_style( 'give-styles' );
442 }
443
444
445 /**
446 * Enqueues public scripts.
447 *
448 * @since 2.1.0
449 */
450 public function public_enqueue_scripts() {
451
452 // Call Babel Polyfill with common handle so that it is compatible with plugins and themes.
453 if ( ! wp_script_is( 'babel-polyfill', 'enqueued' )
454 && give_is_setting_enabled( give_get_option( 'babel_polyfill_script', 'enabled' ) )
455 ) {
456 wp_enqueue_script(
457 'babel-polyfill',
458 GIVE_PLUGIN_URL . 'assets/dist/js/babel-polyfill.js',
459 array( 'jquery' ),
460 GIVE_VERSION,
461 false
462 );
463 }
464
465 wp_enqueue_script( 'give' );
466
467 $this->public_localize_scripts();
468 }
469
470 /**
471 * Localize / PHP to AJAX vars.
472 */
473 public function public_localize_scripts() {
474
475 /**
476 * Filter to modify access mail send notice
477 *
478 * @param string Send notice message for email access.
479 *
480 * @return string $message Send notice message for email access.
481 * @since 2.1.3
482 */
483 $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' ) );
484
485 $localize_give_vars = apply_filters(
486 'give_global_script_vars',
487 array(
488 'ajaxurl' => give_get_ajax_url(),
489 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ),
490 // Do not use this nonce. Its deprecated.
491 'currency' => give_get_currency(),
492 'currency_sign' => give_currency_filter( '' ),
493 'currency_pos' => give_get_currency_position(),
494 'thousands_separator' => give_get_price_thousand_separator(),
495 'decimal_separator' => give_get_price_decimal_separator(),
496 'no_gateway' => __( 'Please select a payment method.', 'give' ),
497 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ),
498 'bad_maximum' => __( 'The maximum custom donation amount for this form is', 'give' ),
499 'general_loading' => __( 'Loading...', 'give' ),
500 'purchase_loading' => __( 'Please Wait...', 'give' ),
501 'number_decimals' => give_get_price_decimals(),
502 'give_version' => GIVE_VERSION,
503 'magnific_options' => apply_filters(
504 'give_magnific_options',
505 array(
506 'main_class' => 'give-modal',
507 'close_on_bg_click' => false,
508 )
509 ),
510 'form_translation' => apply_filters(
511 'give_form_translation_js',
512 array(
513 // Field name Validation message.
514 'payment-mode' => __( 'Please select payment mode.', 'give' ),
515 'give_first' => __( 'Please enter your first name.', 'give' ),
516 'give_email' => __( 'Please enter a valid email address.', 'give' ),
517 'give_user_login' => __( 'Invalid email address or username.', 'give' ),
518 'give_user_pass' => __( 'Enter a password.', 'give' ),
519 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ),
520 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ),
521 )
522 ),
523 'confirm_email_sent_message' => $message,
524 'ajax_vars' => apply_filters(
525 'give_global_ajax_vars',
526 array(
527 'ajaxurl' => give_get_ajax_url(),
528 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ),
529 'loading' => __( 'Loading', 'give' ),
530 // General loading message.
531 'select_option' => __( 'Please select an option', 'give' ),
532 // Variable pricing error with multi-donation option enabled.
533 'default_gateway' => give_get_default_gateway( null ),
534 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0',
535 'number_decimals' => give_get_price_decimals(),
536 )
537 ),
538 'cookie_hash' => COOKIEHASH,
539 'session_nonce_cookie_name' => Give()->session->get_cookie_name( 'nonce' ),
540 'session_cookie_name' => Give()->session->get_cookie_name( 'session' ),
541 'delete_session_nonce_cookie' => absint( Give()->session->is_delete_nonce_cookie() ),
542 )
543 );
544
545 wp_localize_script( 'give', 'give_global_vars', $localize_give_vars );
546 }
547
548 /**
549 * Get the stylesheet URI.
550 *
551 * @since 1.6
552 * @updated 2.0.1 Moved to class and renamed as method.
553 *
554 * @return string
555 */
556 public function get_frontend_stylesheet_uri() {
557
558 $file = 'give' . $this->direction . '.css';
559 $templates_dir = give_get_theme_template_dir_name();
560
561 // Directory paths to CSS files to support checking via file_exists().
562 $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
563 $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css';
564 $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file;
565 $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css';
566 $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'assets/dist/css/' . $file;
567 $uri = false;
568
569 /**
570 * Locate the Give stylesheet:
571 *
572 * a. Look in the child theme directory first, followed by the parent theme
573 * b. followed by the Give core templates directory also look for the min version first,
574 * c. followed by non minified version, even if SCRIPT_DEBUG is not enabled. This allows users to copy just give.css to their theme.
575 * d. Finally, fallback to the standard Give version. This is the default styles included within the plugin.
576 */
577 if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
578 if ( ! empty( $nonmin ) ) {
579 $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css';
580 } else {
581 $uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
582 }
583 } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
584 if ( ! empty( $nonmin ) ) {
585 $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css';
586 } else {
587 $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
588 }
589 } elseif ( file_exists( $give_plugin_style_sheet ) ) {
590 $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'assets/dist/css/' . $file;
591 }
592
593 return apply_filters( 'give_get_stylesheet_uri', $uri );
594
595 }
596
597 /**
598 * Gutenberg admin scripts.
599 */
600 public function gutenberg_admin_scripts() {
601
602 // Enqueue the bundled block JS file
603 // @todo: Update dependencies on 5.0 Stable release
604 wp_enqueue_script(
605 'give-blocks-js',
606 GIVE_PLUGIN_URL . 'assets/dist/js/gutenberg.js',
607 array(
608 'wp-i18n',
609 'wp-element',
610 'wp-blocks',
611 'wp-components',
612 'wp-api',
613 'wp-editor',
614 ),
615 GIVE_VERSION
616 );
617
618 // Enqueue the bundled block css file
619 wp_enqueue_style(
620 'give-blocks-css',
621 GIVE_PLUGIN_URL . 'assets/dist/css/gutenberg.css',
622 array( 'give-styles' ),
623 GIVE_VERSION
624 );
625
626 }
627
628 }
629