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