Issues (1282)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/class-give-scripts.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
		// WP-admin.
92
		wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin' . $this->direction . '.css', array(), GIVE_VERSION );
93
94
		// WP-admin: plugin page.
95
		wp_register_style(
96
			'plugin-deactivation-survey-css',
97
			GIVE_PLUGIN_URL . 'assets/dist/css/plugin-deactivation-survey.css',
98
			array(),
99
			GIVE_VERSION
100
		);
101
102
		// Frontend.
103
		if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) {
104
			wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
105
		}
106
	}
107
108
	/**
109
	 * Registers all plugin scripts.
110
	 *
111
	 * @since 2.1.0
112
	 */
113
	public function register_scripts() {
114
115
		// WP-Admin.
116
		wp_register_script( 'give-admin-scripts', GIVE_PLUGIN_URL . 'assets/dist/js/admin.js', array(
117
			'jquery',
118
			'jquery-ui-datepicker',
119
			'wp-color-picker',
120
			'jquery-query',
121
		), GIVE_VERSION );
122
123
		// WP-admin: plugin page.
124
		wp_register_script( 'plugin-deactivation-survey-js',
125
			GIVE_PLUGIN_URL . 'assets/dist/js/plugin-deactivation-survey.js',
126
			array( 'jquery' ),
127
			GIVE_VERSION,
128
			true
129
		);
130
131
		// WP-admin: add-ons page.
132
		wp_register_script( 'admin-add-ons-js',
133
			GIVE_PLUGIN_URL . 'assets/dist/js/admin-add-ons.js',
134
			array( 'jquery' ),
135
			GIVE_VERSION,
136
			true
137
		);
138
139
		// Frontend.
140
		wp_register_script( 'give', GIVE_PLUGIN_URL . 'assets/dist/js/give.js', array( 'jquery' ), GIVE_VERSION, self::$scripts_footer );
141
	}
142
143
	/**
144
	 * Enqueues admin styles.
145
	 *
146
	 * @since 2.1.0
147
	 *
148
	 * @param string $hook Page hook.
149
	 */
150
	public function admin_enqueue_styles( $hook ) {
151
		// Give Admin Only.
152
		if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) {
153
			return;
154
		}
155
156
		// Give enqueues.
157
		wp_enqueue_style( 'give-admin-styles' );
158
		wp_enqueue_style( 'give-admin-bar-notification' );
159
160
		// WP Core enqueues.
161
		wp_enqueue_style( 'wp-color-picker' );
162
		wp_enqueue_style( 'thickbox' ); // @TODO remove once we have modal API.
163
164
	}
165
166
	/**
167
	 * Enqueues admin scripts.
168
	 *
169
	 * @since 2.1.0
170
	 *
171
	 * @param string $hook Page hook.
172
	 */
173
	public function admin_enqueue_scripts( $hook ) {
174
		global $pagenow;
175
176
		// Plugin page script
177
		if ( 'plugins.php' === $pagenow ) {
178
			$this->plugin_enqueue_scripts();
179
		}
180
181
		// Give Admin Only.
182
		if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
183
			return;
184
		}
185
186
		// WP Scripts.
187
		wp_enqueue_script( 'wp-color-picker' );
188
		wp_enqueue_script( 'jquery-ui-datepicker' );
189
		wp_enqueue_script( 'thickbox' );
190
		wp_enqueue_media();
191
192
		// Give admin scripts.
193
		wp_enqueue_script( 'give-admin-scripts' );
194
195
		// Localize admin scripts
196
		$this->admin_localize_scripts();
197
198
		if ( Give_Admin_Settings::is_setting_page( 'licenses'  ) ) {
199
			wp_enqueue_script( 'admin-add-ons-js' );
200
			$localized_data = array(
201
				'notices' => array(
202
					'invalid_license' => __( 'Sorry, you entered an invalid key.', 'give' ),
203
					'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' ),
204
					'addon_activated'   => __( '{pluginName} add-on activated successfully.', 'give' ),
205
					'addon_activation_error'   => __( 'The add-on did not activate successfully.', 'give' ),
206
				),
207
			);
208
209
			wp_localize_script( 'admin-add-ons-js', 'give_addon_var', $localized_data );
210
		}
211
	}
212
213
	/**
214
	 * Load admin plugin page related scripts, styles and localize param.
215
	 *
216
	 * @since  2.2.0
217
	 * @access private
218
	 */
219
	private function plugin_enqueue_scripts() {
220
		wp_enqueue_style( 'plugin-deactivation-survey-css' );
221
		wp_enqueue_script( 'plugin-deactivation-survey-js' );
222
223
		$localized_data = array(
224
			'nonce'                           => wp_create_nonce( 'deactivation_survey_nonce' ),
225
			'cancel'                          => __( 'Cancel', 'give' ),
226
			'deactivation_no_option_selected' => __( 'Error: Please select at least one option.', 'give' ),
227
			'submit_and_deactivate'           => __( 'Submit and Deactivate', 'give' ),
228
			'skip_and_deactivate'             => __( 'Skip and Deactivate', 'give' ),
229
			'please_fill_field'               => __( 'Error: Please complete the required field.', 'give' ),
230
231
		);
232
233
		wp_localize_script( 'plugin-deactivation-survey-js', 'give_vars', $localized_data );
234
	}
235
236
	/**
237
	 * Localize admin scripts.
238
	 */
239
	public function admin_localize_scripts() {
240
241
		global $post, $pagenow;
242
		$give_options = give_get_settings();
243
244
		// Price Separators.
245
		$thousand_separator = give_get_price_thousand_separator();
246
		$decimal_separator  = give_get_price_decimal_separator();
247
		$number_decimals    = give_get_price_decimals();
248
249
		$stripe_user_id            = give_get_option( 'give_stripe_user_id', false );
250
		$disconnect_stripe_message = sprintf(
251
			/* translators: %s Stripe User ID */
252
			__( 'Are you sure you want to disconnect Give from Stripe? If disconnected, this website and any others sharing the same Stripe account (%s) that are connected to Give will need to reconnect in order to process payments.', 'give' ),
253
			$stripe_user_id
254
		);
255
256
		// Localize strings & variables for JS.
257
		$localized_data = array(
258
			'post_id'                           => isset( $post->ID ) ? $post->ID : null,
259
			'give_version'                      => GIVE_VERSION,
260
			'thousands_separator'               => $thousand_separator,
261
			'decimal_separator'                 => $decimal_separator,
262
			'number_decimals'                   => $number_decimals,
263
			// Use this for number of decimals instead of `currency_decimals`.
264
			'currency_decimals'                 => $number_decimals,
265
			// If you find usage of this variable then replace it with `number_decimals`.
266
			'currency_sign'                     => give_currency_filter( '' ),
267
			'currency_pos'                      => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
268
			'quick_edit_warning'                => __( 'Not available for variable priced forms.', 'give' ),
269
			'delete_payment'                    => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ),
270
			'delete_payment_note'               => __( 'Are you sure you want to delete this note?', 'give' ),
271
			'revoke_api_key'                    => __( 'Are you sure you want to revoke this API key?', 'give' ),
272
			'regenerate_api_key'                => __( 'Are you sure you want to regenerate this API key?', 'give' ),
273
			'resend_receipt'                    => __( 'Are you sure you want to resend the donation receipt?', 'give' ),
274
			'disconnect_user'                   => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ),
275
			'one_option'                        => __( 'Choose a form', 'give' ),
276
			'one_or_more_option'                => __( 'Choose one or more forms', 'give' ),
277
			'ok'                                => __( 'Ok', 'give' ),
278
			'cancel'                            => __( 'Cancel', 'give' ),
279
			'success'                           => __( 'Success', 'give' ),
280
			'error'                             => __( 'Error', 'give' ),
281
			'close'                             => __( 'Close', 'give' ),
282
			'confirm'                           => __( 'Confirm', 'give' ),
283
			'copied'                            => __( 'Copied!', 'give' ),
284
			'shortcode_not_copy'                => __( 'Shortcode could not be copied.', 'give' ),
285
			'confirm_action'                    => __( 'Confirm Action', 'give' ),
286
			'confirm_deletion'                  => __( 'Confirm Deletion', 'give' ),
287
			'confirm_delete_donation'           => __( 'Confirm Delete Donation', 'give' ),
288
			'confirm_resend'                    => __( 'Confirm re-send', 'give' ),
289
			'confirm_bulk_action'               => __( 'Confirm bulk action', 'give' ),
290
			'restart_upgrade'                   => __( 'Do you want to restart the update process?', 'give' ),
291
			'restart_update'                    => __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ),
292
			'stop_upgrade'                      => __( 'Do you want to stop the update process now?', 'give' ),
293
			'import_failed'                     => __( 'Import failed', 'give' ),
294
			'flush_success'                     => __( 'Flush success', 'give' ),
295
			'flush_error'                       => __( 'Flush error', 'give' ),
296
			'no_form_selected'                  => __( 'No form selected', 'give' ),
297
			'batch_export_no_class'             => __( 'You must choose a method.', 'give' ),
298
			'batch_export_no_reqs'              => __( 'Required fields not completed.', 'give' ),
299
			'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' ),
300
			'delete_test_donor'                 => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ),
301
			'delete_import_donor'               => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ),
302
			'delete_donations_only'             => __( 'Are you sure you want to delete all the donations in the specfied date range?', 'give' ),
303
			'price_format_guide'                => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
304
			/* translators : %s: Donation form options metabox */
305
			'confirm_before_remove_row_text'    => __( 'Do you want to delete this item?', 'give' ),
306
			'matched_success_failure_page'      => __( 'You cannot set the success and failed pages to the same page', 'give' ),
307
			'dismiss_notice_text'               => __( 'Dismiss this notice.', 'give' ),
308
			'search_placeholder'                => __( 'Type to search all forms', 'give' ),
309
			'search_placeholder_donor'          => __( 'Type to search all donors', 'give' ),
310
			'search_placeholder_country'        => __( 'Type to search all countries', 'give' ),
311
			'search_placeholder_state'          => __( 'Type to search all states/provinces', 'give' ),
312
			'unlock_donor_fields_title'         => __( 'Action forbidden', 'give' ),
313
			'unlock_donor_fields_message'       => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ),
314
			'remove_from_bulk_delete'           => __( 'Remove from Bulk Delete', 'give' ),
315
			'donors_bulk_action'                => array(
316
				'no_donor_selected'  => array(
317
					'title' => __( 'No donors selected', 'give' ),
318
					'desc'  => __( 'You must choose at least one or more donors to delete.', 'give' ),
319
				),
320
				'no_action_selected' => array(
321
					'title' => __( 'No action selected', 'give' ),
322
					'desc'  => __( 'You must select a bulk action to proceed.', 'give' ),
323
				),
324
			),
325
			'donations_bulk_action'             => array(
326
				'titles'         => array(
327
					'zero' => __( 'No payments selected', 'give' ),
328
				),
329
				'delete'         => array(
330
					'zero'     => __( 'You must choose at least one or more donations to delete.', 'give' ),
331
					'single'   => __( 'Are you sure you want to permanently delete this donation?', 'give' ),
332
					'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ),
333
				),
334
				'resend-receipt' => array(
335
					'zero'     => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ),
336
					'single'   => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ),
337
					'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ),
338
				),
339
				'set-to-status'  => array(
340
					'zero'     => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ),
341
					'single'   => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ),
342
					'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ),
343
				),
344
			),
345
			'updates'                           => array(
346
				'ajax_error' => __( 'Please reload this page and try again', 'give' ),
347
			),
348
			'metabox_fields'                    => array(
349
				'media' => array(
350
					'button_title' => __( 'Choose Image', 'give' ),
351
				),
352
				'file'  => array(
353
					'button_title' => __( 'Choose File', 'give' ),
354
				),
355
			),
356
			'chosen'                            => array(
357
				'no_results_msg'  => __( 'No results match {search_term}', 'give' ),
358
				'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ),
359
			),
360
			'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ),
361
			'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' ),
362
			'error_message'                     => __( 'Something went wrong kindly try again!', 'give' ),
363
			'give_donation_import'              => 'give_donation_import',
364
			'core_settings_import'              => 'give_core_settings_import',
365
			'setting_not_save_message'          => __( 'Changes you made may not be saved.', 'give' ),
366
			'give_donation_amounts'             => array(
367
				'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ),
368
				'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ),
369
			),
370
			'chosen_add_title_prefix'           => __( 'No result found. Press enter to add', 'give' ),
371
			'db_update_nonce'                   => wp_create_nonce( Give_Updates::$background_updater->get_identifier() ),
372
			'ajax'                              => give_test_ajax_works(),
373
			'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' ),
374
			'email_notification'                => array(
375
				'donor_note' => array(
376
					'status' => Give_Email_Notification_Util::is_email_notification_active( Give_Email_Notification::get_instance( 'donor-note' ) ),
377
				),
378
			),
379
			'disconnect_stripe_title'           => __( 'Confirm Disconnect?', 'give' ),
380
			'disconnect_stripe_message'         => $disconnect_stripe_message,
381
			'loader_translation'                => array(
382
				'updating'   => __( 'Updating...', 'give' ),
383
				'loading'    => __( 'Loading...', 'give' ),
384
				'uploading'  => __( 'Uploading...', 'give' ),
385
				'processing' => __( 'Processing...', 'give' ),
386
				'activating' => __( 'Activating...', 'give' ),
387
			),
388
		);
389
390
		wp_localize_script( 'give-admin-scripts', 'give_vars', $localized_data );
391
	}
392
393
	/**
394
	 * Global admin head.
395
	 */
396
	public function global_admin_head() {
397
		?>
398
		<style type="text/css" media="screen">
399
			@font-face {
400
				font-family: 'give-icomoon';
401
				src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?ngjl88'; ?>');
402
				src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'),
403
				url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
404
				url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
405
				font-weight: normal;
406
				font-style: normal;
407
			}
408
409
			.dashicons-give:before, #adminmenu div.wp-menu-image.dashicons-give:before {
410
				font-family: 'give-icomoon';
411
				font-size: 18px;
412
				width: 18px;
413
				height: 18px;
414
				content: "\e800";
415
			}
416
		</style>
417
		<?php
418
419
	}
420
421
	/**
422
	 * Enqueues public styles.
423
	 *
424
	 * @since 2.1.0
425
	 */
426
	public function public_enqueue_styles() {
427
		wp_enqueue_style( 'give-styles' );
428
	}
429
430
431
	/**
432
	 * Enqueues public scripts.
433
	 *
434
	 * @since 2.1.0
435
	 */
436
	public function public_enqueue_scripts() {
437
438
		// Call Babel Polyfill with common handle so that it is compatible with plugins and themes.
439
		if ( ! wp_script_is( 'babel-polyfill', 'enqueued' )
440
		     && give_is_setting_enabled( give_get_option( 'babel_polyfill_script', 'enabled' ) )
441
		) {
442
			wp_enqueue_script(
443
				'babel-polyfill',
444
				GIVE_PLUGIN_URL . 'assets/dist/js/babel-polyfill.js',
445
				array( 'jquery' ),
446
				GIVE_VERSION,
447
				false
448
			);
449
		}
450
451
		wp_enqueue_script( 'give' );
452
453
		$this->public_localize_scripts();
454
	}
455
456
	/**
457
	 * Localize / PHP to AJAX vars.
458
	 */
459
	public function public_localize_scripts() {
460
461
		/**
462
		 * Filter to modify access mail send notice
463
		 *
464
		 * @param string Send notice message for email access.
465
		 *
466
		 * @return  string $message Send notice message for email access.
467
		 * @since 2.1.3
468
		 *
469
		 */
470
		$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' ) );
471
472
		$localize_give_vars = apply_filters( 'give_global_script_vars', array(
473
			'ajaxurl'                     => give_get_ajax_url(),
474
			'checkout_nonce'              => wp_create_nonce( 'give_checkout_nonce' ),
475
			// Do not use this nonce. Its deprecated.
476
			'currency'                    => give_get_currency(),
477
			'currency_sign'               => give_currency_filter( '' ),
478
			'currency_pos'                => give_get_currency_position(),
479
			'thousands_separator'         => give_get_price_thousand_separator(),
480
			'decimal_separator'           => give_get_price_decimal_separator(),
481
			'no_gateway'                  => __( 'Please select a payment method.', 'give' ),
482
			'bad_minimum'                 => __( 'The minimum custom donation amount for this form is', 'give' ),
483
			'bad_maximum'                 => __( 'The maximum custom donation amount for this form is', 'give' ),
484
			'general_loading'             => __( 'Loading...', 'give' ),
485
			'purchase_loading'            => __( 'Please Wait...', 'give' ),
486
			'number_decimals'             => give_get_price_decimals(),
487
			'give_version'                => GIVE_VERSION,
488
			'magnific_options'            => apply_filters(
489
				'give_magnific_options',
490
				array(
491
					'main_class'        => 'give-modal',
492
					'close_on_bg_click' => false,
493
				)
494
			),
495
			'form_translation'            => apply_filters(
496
				'give_form_translation_js',
497
				array(
498
					// Field name               Validation message.
499
					'payment-mode'           => __( 'Please select payment mode.', 'give' ),
500
					'give_first'             => __( 'Please enter your first name.', 'give' ),
501
					'give_email'             => __( 'Please enter a valid email address.', 'give' ),
502
					'give_user_login'        => __( 'Invalid email address or username.', 'give' ),
503
					'give_user_pass'         => __( 'Enter a password.', 'give' ),
504
					'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ),
505
					'give_agree_to_terms'    => __( 'You must agree to the terms and conditions.', 'give' ),
506
				)
507
			),
508
			'confirm_email_sent_message'  => $message,
509
			'ajax_vars'                   => apply_filters( 'give_global_ajax_vars', array(
510
				'ajaxurl'         => give_get_ajax_url(),
511
				'ajaxNonce'       => wp_create_nonce( 'give_ajax_nonce' ),
512
				'loading'         => __( 'Loading', 'give' ),
513
				// General loading message.
514
				'select_option'   => __( 'Please select an option', 'give' ),
515
				// Variable pricing error with multi-donation option enabled.
516
				'default_gateway' => give_get_default_gateway( null ),
517
				'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
518
				'number_decimals' => give_get_price_decimals(),
519
			) ),
520
			'cookie_hash'                 => COOKIEHASH,
521
			'session_nonce_cookie_name'   => Give()->session->get_cookie_name( 'nonce' ),
522
			'session_cookie_name'         => Give()->session->get_cookie_name( 'session' ),
523
			'delete_session_nonce_cookie' => absint( Give()->session->is_delete_nonce_cookie() ),
524
		) );
525
526
		wp_localize_script( 'give', 'give_global_vars', $localize_give_vars );
527
	}
528
529
	/**
530
	 * Get the stylesheet URI.
531
	 *
532
	 * @since   1.6
533
	 * @updated 2.0.1 Moved to class and renamed as method.
534
	 *
535
	 * @return string
536
	 */
537
	public function get_frontend_stylesheet_uri() {
538
539
		$file          = 'give' . $this->direction . '.css';
540
		$templates_dir = give_get_theme_template_dir_name();
541
542
		// Directory paths to CSS files to support checking via file_exists().
543
		$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
544
		$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css';
545
		$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
546
		$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css';
547
		$give_plugin_style_sheet    = trailingslashit( GIVE_PLUGIN_DIR ) . 'assets/dist/css/' . $file;
548
		$uri                        = false;
549
550
		/**
551
		 * Locate the Give stylesheet:
552
		 *
553
		 * a. Look in the child theme directory first, followed by the parent theme
554
		 * b. followed by the Give core templates directory also look for the min version first,
555
		 * c. followed by non minified version, even if SCRIPT_DEBUG is not enabled. This allows users to copy just give.css to their theme.
556
		 * d. Finally, fallback to the standard Give version. This is the default styles included within the plugin.
557
		 */
558
		if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
559 View Code Duplication
			if ( ! empty( $nonmin ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
560
				$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css';
561
			} else {
562
				$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
563
			}
564
		} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
565 View Code Duplication
			if ( ! empty( $nonmin ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
566
				$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $this->direction . '.css';
567
			} else {
568
				$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
569
			}
570
		} elseif ( file_exists( $give_plugin_style_sheet ) ) {
571
			$uri = trailingslashit( GIVE_PLUGIN_URL ) . 'assets/dist/css/' . $file;
572
		}
573
574
		return apply_filters( 'give_get_stylesheet_uri', $uri );
575
576
	}
577
578
	/**
579
	 * Gutenberg admin scripts.
580
	 */
581
	public function gutenberg_admin_scripts() {
582
583
		// Enqueue the bundled block JS file
584
		//@todo: Update dependencies on 5.0 Stable release
585
		wp_enqueue_script(
586
			'give-blocks-js',
587
			GIVE_PLUGIN_URL . 'assets/dist/js/gutenberg.js',
588
			array(
589
				'wp-i18n',
590
				'wp-element',
591
				'wp-blocks',
592
				'wp-components',
593
				'wp-api',
594
				'wp-editor',
595
			),
596
			GIVE_VERSION
597
		);
598
599
		// Enqueue the bundled block css file
600
		wp_enqueue_style(
601
			'give-blocks-css',
602
			GIVE_PLUGIN_URL . 'assets/dist/css/gutenberg.css',
603
			array( 'give-styles' ),
604
			GIVE_VERSION
605
		);
606
607
	}
608
609
}
610