| @@ -1,6 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +use Give\Framework\Support\Facades\Scripts\ScriptAsset; | |
| 4 | +use Give\Helpers\EnqueueScript; | |
| 5 | +use Give\Helpers\Language; | |
| 6 | + | |
| 3 | 7 | /** |
| 4 | 8 | * Loads the plugin's scripts and styles. |
| 5 | 9 | * |
| 6 | 10 | * Registers and enqueues plugin styles and scripts. Asset versions are based |
| @@ -28,9 +32,9 @@ | ||
| 28 | 32 | * @since 2.1.0 |
| 29 | 33 | * @var bool |
| 30 | 34 | * @access private |
| 31 | 35 | */ |
| 32 | - private $scripts_footer; | |
| 36 | + private static $scripts_footer; | |
| 33 | 37 | |
| 34 | 38 | /** |
| 35 | 39 | * Instantiates the Assets class. |
| 36 | 40 | * |
| @@ -37,9 +41,9 @@ | ||
| 37 | 41 | * @since 2.1.0 |
| 38 | 42 | */ |
| 39 | 43 | public function __construct() { |
| 40 | 44 | $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; | |
| 45 | + self::$scripts_footer = give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ? true : false; | |
| 42 | 46 | $this->init(); |
| 43 | 47 | } |
| 44 | 48 | |
| 45 | 49 | /** |
| @@ -48,26 +52,41 @@ | ||
| 48 | 52 | * @since 2.1.0 |
| 49 | 53 | */ |
| 50 | 54 | public function init() { |
| 51 | 55 | |
| 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 | + 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' ] ); | |
| 56 | 60 | |
| 57 | 61 | 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 | + 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' ] ); | |
| 62 | 66 | |
| 63 | 67 | } else { |
| 64 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_styles' ) ); | |
| 65 | - add_action( 'wp_enqueue_scripts', array( $this, 'public_enqueue_scripts' ) ); | |
| 68 | + add_action( 'wp_enqueue_scripts', [ $this, 'public_enqueue_styles' ] ); | |
| 69 | + add_action( 'wp_enqueue_scripts', [ $this, 'public_enqueue_scripts' ] ); | |
| 66 | 70 | } |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | 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 | + /** | |
| 70 | 89 | * Registers all plugin styles. |
| 71 | 90 | * |
| 72 | 91 | * @since 2.1.0 |
| 73 | 92 | */ |
| @@ -72,22 +91,25 @@ | ||
| 72 | 91 | * @since 2.1.0 |
| 73 | 92 | */ |
| 74 | 93 | public function register_styles() { |
| 75 | 94 | |
| 76 | - // WP-admin. | |
| 77 | - wp_register_style( 'give-admin-styles', GIVE_PLUGIN_URL . 'assets/dist/css/admin' . $this->direction . '.css', array(), GIVE_VERSION ); | |
| 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 ); | |
| 78 | 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 | + | |
| 79 | 101 | // WP-admin: plugin page. |
| 80 | 102 | wp_register_style( |
| 81 | 103 | 'plugin-deactivation-survey-css', |
| 82 | - GIVE_PLUGIN_URL . 'assets/dist/css/plugin-deactivation-survey.css', | |
| 83 | - array(), | |
| 104 | + GIVE_PLUGIN_URL . 'build/assets/dist/css/plugin-deactivation-survey.css', | |
| 105 | + [], | |
| 84 | 106 | GIVE_VERSION |
| 85 | 107 | ); |
| 86 | 108 | |
| 87 | 109 | // Frontend. |
| 88 | 110 | if ( give_is_setting_enabled( give_get_option( 'css' ) ) ) { |
| 89 | - wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), array(), GIVE_VERSION, 'all' ); | |
| 111 | + wp_register_style( 'give-styles', $this->get_frontend_stylesheet_uri(), [], GIVE_VERSION, 'all' ); | |
| 90 | 112 | } |
| 91 | 113 | } |
| 92 | 114 | |
| 93 | 115 | /** |
| @@ -95,27 +117,51 @@ | ||
| 95 | 117 | * |
| 96 | 118 | * @since 2.1.0 |
| 97 | 119 | */ |
| 98 | 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(); | |
| 99 | 136 | |
| 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 ); | |
| 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 | + ); | |
| 107 | 145 | |
| 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' ), | |
| 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' ], | |
| 112 | 151 | GIVE_VERSION, |
| 113 | 152 | true |
| 114 | 153 | ); |
| 115 | 154 | |
| 116 | - // Frontend. | |
| 117 | - wp_register_script( 'give', GIVE_PLUGIN_URL . 'assets/dist/js/give.js', array( 'jquery' ), GIVE_VERSION, $this->scripts_footer ); | |
| 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(); | |
| 118 | 164 | } |
| 119 | 165 | |
| 120 | 166 | /** |
| 121 | 167 | * Enqueues admin styles. |
| @@ -124,8 +170,12 @@ | ||
| 124 | 170 | * |
| 125 | 171 | * @param string $hook Page hook. |
| 126 | 172 | */ |
| 127 | 173 | public function admin_enqueue_styles( $hook ) { |
| 174 | + | |
| 175 | + // Global admin styles | |
| 176 | + wp_enqueue_style( 'give-admin-global-styles' ); | |
| 177 | + | |
| 128 | 178 | // Give Admin Only. |
| 129 | 179 | if ( ! apply_filters( 'give_load_admin_styles', give_is_admin_page(), $hook ) ) { |
| 130 | 180 | return; |
| 131 | 181 | } |
| @@ -151,9 +201,9 @@ | ||
| 151 | 201 | global $pagenow; |
| 152 | 202 | |
| 153 | 203 | // Plugin page script |
| 154 | 204 | if ( 'plugins.php' === $pagenow ) { |
| 155 | - $this->plugin_equeue_scripts(); | |
| 205 | + $this->plugin_enqueue_scripts(); | |
| 156 | 206 | } |
| 157 | 207 | |
| 158 | 208 | // Give Admin Only. |
| 159 | 209 | if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
| @@ -170,29 +220,43 @@ | ||
| 170 | 220 | wp_enqueue_script( 'give-admin-scripts' ); |
| 171 | 221 | |
| 172 | 222 | // Localize admin scripts |
| 173 | 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 | + } | |
| 174 | 238 | } |
| 175 | 239 | |
| 176 | 240 | /** |
| 177 | - * Load admin plugin page related scripts, styles andd localize param | |
| 241 | + * Load admin plugin page related scripts, styles and localize param. | |
| 178 | 242 | * |
| 179 | 243 | * @since 2.2.0 |
| 180 | 244 | * @access private |
| 181 | 245 | */ |
| 182 | - private function plugin_equeue_scripts() { | |
| 246 | + private function plugin_enqueue_scripts() { | |
| 183 | 247 | wp_enqueue_style( 'plugin-deactivation-survey-css' ); |
| 184 | 248 | wp_enqueue_script( 'plugin-deactivation-survey-js' ); |
| 185 | 249 | |
| 186 | - $localized_data = array( | |
| 250 | + $localized_data = [ | |
| 187 | 251 | 'nonce' => wp_create_nonce( 'deactivation_survey_nonce' ), |
| 188 | 252 | 'cancel' => __( 'Cancel', 'give' ), |
| 189 | 253 | 'deactivation_no_option_selected' => __( 'Error: Please select at least one option.', 'give' ), |
| 190 | 254 | 'submit_and_deactivate' => __( 'Submit and Deactivate', 'give' ), |
| 191 | - 'skip_and_deactivate' => __( 'Skip & Deactivate', 'give' ), | |
| 192 | - 'please_fill_field' => __( 'Error: Please fill the field.', 'give' ), | |
| 255 | + 'skip_and_deactivate' => __( 'Skip and Deactivate', 'give' ), | |
| 256 | + 'please_fill_field' => __( 'Error: Please complete the required field.', 'give' ), | |
| 193 | 257 | |
| 194 | - ); | |
| 258 | + ]; | |
| 195 | 259 | |
| 196 | 260 | wp_localize_script( 'plugin-deactivation-survey-js', 'give_vars', $localized_data ); |
| 197 | 261 | } |
| 198 | 262 | |
| @@ -197,12 +261,16 @@ | ||
| 197 | 261 | } |
| 198 | 262 | |
| 199 | 263 | /** |
| 200 | 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. | |
| 201 | 268 | */ |
| 202 | 269 | public function admin_localize_scripts() { |
| 203 | 270 | |
| 204 | - global $post, $pagenow; | |
| 271 | + global $post; | |
| 272 | + | |
| 205 | 273 | $give_options = give_get_settings(); |
| 206 | 274 | |
| 207 | 275 | // Price Separators. |
| 208 | 276 | $thousand_separator = give_get_price_thousand_separator(); |
| @@ -209,14 +277,19 @@ | ||
| 209 | 277 | $decimal_separator = give_get_price_decimal_separator(); |
| 210 | 278 | $number_decimals = give_get_price_decimals(); |
| 211 | 279 | |
| 212 | 280 | // Localize strings & variables for JS. |
| 213 | - $localized_data = array( | |
| 281 | + $localized_data = [ | |
| 214 | 282 | 'post_id' => isset( $post->ID ) ? $post->ID : null, |
| 215 | 283 | 'give_version' => GIVE_VERSION, |
| 216 | 284 | 'thousands_separator' => $thousand_separator, |
| 217 | 285 | 'decimal_separator' => $decimal_separator, |
| 218 | 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', | |
| 219 | 292 | 'quick_edit_warning' => __( 'Not available for variable priced forms.', 'give' ), |
| 220 | 293 | 'delete_payment' => __( 'Are you sure you want to <strong>permanently</strong> delete this donation?', 'give' ), |
| 221 | 294 | 'delete_payment_note' => __( 'Are you sure you want to delete this note?', 'give' ), |
| 222 | 295 | 'revoke_api_key' => __( 'Are you sure you want to revoke this API key?', 'give' ), |
| @@ -224,12 +297,11 @@ | ||
| 224 | 297 | 'resend_receipt' => __( 'Are you sure you want to resend the donation receipt?', 'give' ), |
| 225 | 298 | 'disconnect_user' => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ), |
| 226 | 299 | 'one_option' => __( 'Choose a form', 'give' ), |
| 227 | 300 | 'one_or_more_option' => __( 'Choose one or more forms', 'give' ), |
| 228 | - 'currency_sign' => give_currency_filter( '' ), | |
| 229 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', | |
| 230 | - 'currency_decimals' => give_get_price_decimals(), | |
| 231 | 301 | 'ok' => __( 'Ok', 'give' ), |
| 302 | + 'activate' => __( 'Activate', 'give' ), | |
| 303 | + 'deactivate' => __( 'Deactivate', 'give' ), | |
| 232 | 304 | 'cancel' => __( 'Cancel', 'give' ), |
| 233 | 305 | 'success' => __( 'Success', 'give' ), |
| 234 | 306 | 'error' => __( 'Error', 'give' ), |
| 235 | 307 | 'close' => __( 'Close', 'give' ), |
| @@ -263,75 +335,93 @@ | ||
| 263 | 335 | 'search_placeholder_donor' => __( 'Type to search all donors', 'give' ), |
| 264 | 336 | 'search_placeholder_country' => __( 'Type to search all countries', 'give' ), |
| 265 | 337 | 'search_placeholder_state' => __( 'Type to search all states/provinces', 'give' ), |
| 266 | 338 | 'unlock_donor_fields_title' => __( 'Action forbidden', 'give' ), |
| 267 | - 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to user profile of the donor.', 'give' ), | |
| 339 | + 'unlock_donor_fields_message' => __( 'To edit first name and last name, please go to the user profile of the donor.', 'give' ), | |
| 268 | 340 | 'remove_from_bulk_delete' => __( 'Remove from Bulk Delete', 'give' ), |
| 269 | - 'donors_bulk_action' => array( | |
| 270 | - 'no_donor_selected' => array( | |
| 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' => [ | |
| 271 | 347 | 'title' => __( 'No donors selected', 'give' ), |
| 272 | 348 | 'desc' => __( 'You must choose at least one or more donors to delete.', 'give' ), |
| 273 | - ), | |
| 274 | - 'no_action_selected' => array( | |
| 349 | + ], | |
| 350 | + 'no_action_selected' => [ | |
| 275 | 351 | 'title' => __( 'No action selected', 'give' ), |
| 276 | 352 | 'desc' => __( 'You must select a bulk action to proceed.', 'give' ), |
| 277 | - ), | |
| 278 | - ), | |
| 279 | - 'donations_bulk_action' => array( | |
| 280 | - 'titles' => array( | |
| 353 | + ], | |
| 354 | + ], | |
| 355 | + 'donations_bulk_action' => [ | |
| 356 | + 'titles' => [ | |
| 281 | 357 | 'zero' => __( 'No payments selected', 'give' ), |
| 282 | - ), | |
| 283 | - 'delete' => array( | |
| 358 | + ], | |
| 359 | + 'delete' => [ | |
| 284 | 360 | 'zero' => __( 'You must choose at least one or more donations to delete.', 'give' ), |
| 285 | 361 | 'single' => __( 'Are you sure you want to permanently delete this donation?', 'give' ), |
| 286 | 362 | 'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ), |
| 287 | - ), | |
| 288 | - 'resend-receipt' => array( | |
| 363 | + ], | |
| 364 | + 'resend-receipt' => [ | |
| 289 | 365 | 'zero' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ), |
| 290 | 366 | 'single' => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ), |
| 291 | 367 | 'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ), |
| 292 | - ), | |
| 293 | - 'set-to-status' => array( | |
| 368 | + ], | |
| 369 | + 'set-to-status' => [ | |
| 294 | 370 | 'zero' => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ), |
| 295 | 371 | 'single' => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ), |
| 296 | 372 | 'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ), |
| 297 | - ), | |
| 298 | - ), | |
| 299 | - 'updates' => array( | |
| 373 | + ], | |
| 374 | + ], | |
| 375 | + 'updates' => [ | |
| 300 | 376 | 'ajax_error' => __( 'Please reload this page and try again', 'give' ), |
| 301 | - ), | |
| 302 | - 'metabox_fields' => array( | |
| 303 | - 'media' => array( | |
| 377 | + ], | |
| 378 | + 'metabox_fields' => [ | |
| 379 | + 'media' => [ | |
| 304 | 380 | 'button_title' => __( 'Choose Image', 'give' ), |
| 305 | - ), | |
| 306 | - 'file' => array( | |
| 381 | + ], | |
| 382 | + 'file' => [ | |
| 307 | 383 | 'button_title' => __( 'Choose File', 'give' ), |
| 308 | - ), | |
| 309 | - ), | |
| 310 | - 'chosen' => array( | |
| 384 | + ], | |
| 385 | + ], | |
| 386 | + 'chosen' => [ | |
| 311 | 387 | 'no_results_msg' => __( 'No results match {search_term}', 'give' ), |
| 312 | 388 | 'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ), |
| 313 | - ), | |
| 389 | + ], | |
| 314 | 390 | 'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ), |
| 315 | 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' ), |
| 316 | 392 | 'error_message' => __( 'Something went wrong kindly try again!', 'give' ), |
| 317 | 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'), | |
| 318 | 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'), | |
| 319 | 402 | 'setting_not_save_message' => __( 'Changes you made may not be saved.', 'give' ), |
| 320 | - 'give_donation_amounts' => array( | |
| 403 | + 'give_donation_amounts' => [ | |
| 321 | 404 | 'minimum' => apply_filters( 'give_donation_minimum_limit', 1 ), |
| 322 | 405 | 'maximum' => apply_filters( 'give_donation_maximum_limit', 999999.99 ), |
| 323 | - ), | |
| 406 | + ], | |
| 324 | 407 | 'chosen_add_title_prefix' => __( 'No result found. Press enter to add', 'give' ), |
| 325 | 408 | 'db_update_nonce' => wp_create_nonce( Give_Updates::$background_updater->get_identifier() ), |
| 326 | 409 | 'ajax' => give_test_ajax_works(), |
| 327 | 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' ), |
| 328 | - 'email_notification' => array( | |
| 329 | - 'donor_note' => array( | |
| 330 | - 'status' => Give_Email_Notification_Util::is_email_notification_active( Give_Email_Notification::get_instance('donor-note' ) ) | |
| 331 | - ) | |
| 332 | - ), | |
| 333 | - ); | |
| 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 | + ]; | |
| 334 | 424 | |
| 335 | 425 | wp_localize_script( 'give-admin-scripts', 'give_vars', $localized_data ); |
| 336 | 426 | } |
| 337 | 427 | |
| @@ -342,12 +432,12 @@ | ||
| 342 | 432 | ?> |
| 343 | 433 | <style type="text/css" media="screen"> |
| 344 | 434 | @font-face { |
| 345 | 435 | font-family: 'give-icomoon'; |
| 346 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?ngjl88'; ?>'); | |
| 347 | - src: url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'), | |
| 348 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.woff?ngjl88'; ?>') format('woff'), | |
| 349 | - url('<?php echo GIVE_PLUGIN_URL . 'assets/dist/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg'); | |
| 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'); | |
| 350 | 440 | font-weight: normal; |
| 351 | 441 | font-style: normal; |
| 352 | 442 | } |
| 353 | 443 | |
| @@ -356,8 +446,9 @@ | ||
| 356 | 446 | font-size: 18px; |
| 357 | 447 | width: 18px; |
| 358 | 448 | height: 18px; |
| 359 | 449 | content: "\e800"; |
| 450 | + padding-top: 8px; | |
| 360 | 451 | } |
| 361 | 452 | </style> |
| 362 | 453 | <?php |
| 363 | 454 | |
| @@ -378,20 +469,8 @@ | ||
| 378 | 469 | * |
| 379 | 470 | * @since 2.1.0 |
| 380 | 471 | */ |
| 381 | 472 | public function public_enqueue_scripts() { |
| 382 | - | |
| 383 | - // Call Babel Polyfill with common handle so that it is compatible with plugins and themes. | |
| 384 | - if ( ! wp_script_is( 'babel-polyfill', 'enqueued' ) ) { | |
| 385 | - wp_enqueue_script( | |
| 386 | - 'babel-polyfill', | |
| 387 | - GIVE_PLUGIN_URL . 'assets/dist/js/babel-polyfill.js', | |
| 388 | - array( 'jquery' ), | |
| 389 | - GIVE_VERSION, | |
| 390 | - false | |
| 391 | - ); | |
| 392 | - } | |
| 393 | - | |
| 394 | 473 | wp_enqueue_script( 'give' ); |
| 395 | 474 | |
| 396 | 475 | $this->public_localize_scripts(); |
| 397 | 476 | } |
| @@ -411,59 +490,70 @@ | ||
| 411 | 490 | * @return string $message Send notice message for email access. |
| 412 | 491 | */ |
| 413 | 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' ) ); |
| 414 | 493 | |
| 415 | - $localize_give_vars = apply_filters( 'give_global_script_vars', array( | |
| 416 | - 'ajaxurl' => give_get_ajax_url(), | |
| 417 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), | |
| 418 | - // Do not use this nonce. Its deprecated. | |
| 419 | - 'currency' => give_get_currency(), | |
| 420 | - 'currency_sign' => give_currency_filter( '' ), | |
| 421 | - 'currency_pos' => give_get_currency_position(), | |
| 422 | - 'thousands_separator' => give_get_price_thousand_separator(), | |
| 423 | - 'decimal_separator' => give_get_price_decimal_separator(), | |
| 424 | - 'no_gateway' => __( 'Please select a payment method.', 'give' ), | |
| 425 | - 'bad_minimum' => __( 'The minimum custom donation amount for this form is', 'give' ), | |
| 426 | - 'bad_maximum' => __( 'The maximum custom donation amount for this form is', 'give' ), | |
| 427 | - 'general_loading' => __( 'Loading...', 'give' ), | |
| 428 | - 'purchase_loading' => __( 'Please Wait...', 'give' ), | |
| 429 | - 'number_decimals' => give_get_price_decimals(), | |
| 430 | - 'give_version' => GIVE_VERSION, | |
| 431 | - 'magnific_options' => apply_filters( | |
| 432 | - 'give_magnific_options', | |
| 433 | - array( | |
| 434 | - 'main_class' => 'give-modal', | |
| 435 | - 'close_on_bg_click' => false, | |
| 436 | - ) | |
| 437 | - ), | |
| 438 | - 'form_translation' => apply_filters( | |
| 439 | - 'give_form_translation_js', | |
| 440 | - array( | |
| 441 | - // Field name Validation message. | |
| 442 | - 'payment-mode' => __( 'Please select payment mode.', 'give' ), | |
| 443 | - 'give_first' => __( 'Please enter your first name.', 'give' ), | |
| 444 | - 'give_email' => __( 'Please enter a valid email address.', 'give' ), | |
| 445 | - 'give_user_login' => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ), | |
| 446 | - 'give_user_pass' => __( 'Enter a password.', 'give' ), | |
| 447 | - 'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ), | |
| 448 | - 'give_agree_to_terms' => __( 'You must agree to the terms and conditions.', 'give' ), | |
| 449 | - ) | |
| 450 | - ), | |
| 451 | - 'confirm_email_sent_message' => $message, | |
| 452 | - 'ajax_vars' => apply_filters( 'give_global_ajax_vars', array( | |
| 453 | - 'ajaxurl' => give_get_ajax_url(), | |
| 454 | - 'ajaxNonce' => wp_create_nonce( 'give_ajax_nonce' ), | |
| 455 | - 'loading' => __( 'Loading', 'give' ), | |
| 456 | - // General loading message. | |
| 457 | - 'select_option' => __( 'Please select an option', 'give' ), | |
| 458 | - // Variable pricing error with multi-donation option enabled. | |
| 459 | - 'default_gateway' => give_get_default_gateway( null ), | |
| 460 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', | |
| 461 | - 'number_decimals' => give_get_price_decimals(), | |
| 462 | - ) ), | |
| 463 | - 'cookie_hash' => COOKIEHASH, | |
| 464 | - 'delete_session_nonce_cookie' => absint( Give()->session->is_delete_nonce_cookie() ) | |
| 465 | - ) ); | |
| 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 | + ); | |
| 466 | 556 | |
| 467 | 557 | wp_localize_script( 'give', 'give_global_vars', $localize_give_vars ); |
| 468 | 558 | } |
| 469 | 559 | |
| @@ -484,9 +574,9 @@ | ||
| 484 | 574 | $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
| 485 | 575 | $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
| 486 | 576 | $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
| 487 | 577 | $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $this->direction . '.css'; |
| 488 | - $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'assets/dist/css/' . $file; | |
| 578 | + $give_plugin_style_sheet = trailingslashit( GIVE_PLUGIN_DIR ) . 'build/assets/dist/css/' . $file; | |
| 489 | 579 | $uri = false; |
| 490 | 580 | |
| 491 | 581 | /** |
| 492 | 582 | * Locate the Give stylesheet: |
| @@ -508,9 +598,9 @@ | ||
| 508 | 598 | } else { |
| 509 | 599 | $uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
| 510 | 600 | } |
| 511 | 601 | } elseif ( file_exists( $give_plugin_style_sheet ) ) { |
| 512 | - $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'assets/dist/css/' . $file; | |
| 602 | + $uri = trailingslashit( GIVE_PLUGIN_URL ) . 'build/assets/dist/css/' . $file; | |
| 513 | 603 | } |
| 514 | 604 | |
| 515 | 605 | return apply_filters( 'give_get_stylesheet_uri', $uri ); |
| 516 | 606 | |
| @@ -515,31 +605,35 @@ | ||
| 515 | 605 | return apply_filters( 'give_get_stylesheet_uri', $uri ); |
| 516 | 606 | |
| 517 | 607 | } |
| 518 | 608 | |
| 519 | - /** | |
| 520 | - * Gutenberg admin scripts. | |
| 521 | - */ | |
| 522 | - public function gutenberg_admin_scripts() { | |
| 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 | + ); | |
| 523 | 625 | |
| 524 | - // Enqueue the bundled block JS file | |
| 525 | - wp_enqueue_script( | |
| 526 | - 'give-blocks-js', | |
| 527 | - GIVE_PLUGIN_URL . 'assets/dist/js/gutenberg.js', | |
| 528 | - array( 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api' ), | |
| 529 | - GIVE_VERSION | |
| 530 | - ); | |
| 626 | + $scriptAsset = ScriptAsset::get(GIVE_PLUGIN_DIR . 'build/adminBlocks.asset.php'); | |
| 531 | 627 | |
| 532 | - // Enqueue public styles | |
| 533 | - wp_enqueue_style( 'give-styles' ); | |
| 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 | + ); | |
| 534 | 636 | |
| 535 | - // Enqueue the bundled block css file | |
| 536 | - wp_enqueue_style( | |
| 537 | - 'give-blocks-css', | |
| 538 | - GIVE_PLUGIN_URL . 'assets/dist/css/gutenberg.css', | |
| 539 | - array( ), | |
| 540 | - GIVE_VERSION | |
| 541 | - ); | |
| 542 | - | |
| 543 | - } | |
| 544 | - | |
| 637 | + Language::setScriptTranslations($handle); | |
| 638 | + } | |
| 545 | 639 | } |