Skip to content

Commit

Permalink
Merge branch 'develop' into feature/event-block-telemetry-GIVE-386
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnson authored Apr 25, 2024
2 parents 9670629 + 2e2dd31 commit 16ae6df
Show file tree
Hide file tree
Showing 89 changed files with 10,019 additions and 4,594 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,24 @@ To get started developing on the GiveWP platform you will need to perform the fo
3. Fork this repository from GitHub and then clone that into your plugins directory in a new `give` directory
4. Run `composer install` to set up dependencies
5. Run `npm install` to get the necessary npm packages
6. Activate the plugin in WordPress
7. Run `npm run watch` to start the watch process which will build the sass and script files and live reload using [Browsersync](https://www.browsersync.io/)
6. Run `npm run dev` to build the initial scripts & styles
7. Activate the plugin in WordPress


That's it. You're now ready to start development.

**Available commands**

| Command | Description |
| :------------- | :------------ |
| `npm run watch` | Live reloads JS and SASS files. Typically you'll run this command before you start development. It's necessary to build the JS/CSS however if you're working strictly within PHP it may not be necessary to run. |
| `npm run dev` | Runs a one time build for development. No production files are created. |
| `npm run production` | Builds the minified production files for release. |
| `npm run test` | Run jest tests. Make sure that your docker container is running before running this command. [Read more](https://github.com/impress-org/give/tree/master/tests/e2e) |
Note: as of GiveWP 3.0 we have two separate build processes. One for the legacy codebase that uses [Laravel Mix](https://laravel.com/docs/6.x/mix) and one for scripts introduced 3.0+ that use [@wordpress/scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/). There are commands for running both and individual processes. The commands are as follows:

| Command | Description |
|:-------------------|:----------------------------------------------------------------------------------|
| `npm run dev` | (v2 & v3) Runs a one time build for development. No production files are created. |
| `npm run dev:v3` | (v3) Runs a one time build for development. No production files are created. |
| `npm run watch` | (v2) Automatically re-builds as changes are made. |
| `npm run watch:v3` | (v3) Automatically re-builds as changes are made. |
| `npm run build` | (v2 & v3) Builds the minified production files for release. |
| `npm run build:v3` | (v3) Builds the minified production files for release. |

**Development Notes**

Expand Down
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
== Changelog ==
= 3.7.0: April 10th, 2024 =
* New: Added pre-requisite form builder compatibility for upcoming constant contact add-on release
* New: Added phone number field to the donor details page, more updates for this field will come in future releases!
* Enhancement: Updated the form block option to select more available forms than the original limit of 10
* Enhancement: Updated the form builder left-side menu to open automatically when entering the build screen
* Security: Added sanitizing and escaping to shortcodes
* Fix: Resolved a conflict with GiveWP and WordPress bulk actions functionality

= 3.6.2: April 5th, 2024 =
* Fix: Resolved an issue with WordPress 6.5 and the visual form builder that was making it difficult to interact with blocks

= 3.6.1: March 21st, 2024 =
* Fix: Resolved an issue with PayPal donations and currency switcher on donation forms using the visual form builder

Expand Down
6 changes: 3 additions & 3 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Description: The most robust, flexible, and intuitive way to accept donations on WordPress.
* Author: GiveWP
* Author URI: https://givewp.com/
* Version: 3.6.1
* Requires at least: 6.0
* Version: 3.9.0
* Requires at least: 6.3
* Requires PHP: 7.2
* Text Domain: give
* Domain Path: /languages
Expand Down Expand Up @@ -404,7 +404,7 @@ private function setup_constants()
{
// Plugin version.
if (!defined('GIVE_VERSION')) {
define('GIVE_VERSION', '3.6.1');
define('GIVE_VERSION', '3.9.0');
}

// Plugin Root File.
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/donors/donor-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Processes a donor edit.
*
* @unreleased Add support to the "phone" field
* @since 3.7.0 Add support to the "phone" field
* @since 1.0
*
* @param array $args The $_POST array being passed.
Expand Down Expand Up @@ -132,7 +132,7 @@ function give_edit_donor( $args ) {
* @param array $args The sanitized data submitted.
* @param int $donor_id The donor ID.
*
* @unreleased
* @since 3.7.0
*/
do_action('give_admin_donor_details_updating', $args, $donor->id);

Expand Down
5 changes: 3 additions & 2 deletions includes/admin/donors/donors.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

use Give\Donors\Models\Donor;
use Give\Helpers\IntlTelInput;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -300,7 +301,7 @@ function give_render_donor_view( $view, $callbacks ) {
/**
* View a donor
*
* @unreleased Add "phone" field
* @since 3.7.0 Add "phone" field
* @since 1.0
*
* @param Give_Donor $donor The Donor object being displayed.
Expand Down Expand Up @@ -493,7 +494,7 @@ function give_donor_view( $donor ) {
<td>
<span class="donor-user-id info-item edit-item">
<?php
echo give_get_intl_tel_input($donor_phone_number, "give_donor_phone_number"); ?>
echo IntlTelInput::getHtmlInput($donor_phone_number, "give_donor_phone_number"); ?>
</span>

<span class="donor-user-id info-item editable">
Expand Down
27 changes: 26 additions & 1 deletion includes/admin/payments/view-payment-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
* @since 1.0
*/

// Exit if accessed directly.
use Give\Donations\Models\Donation;
use Give\Donations\ValueObjects\DonationMetaKeys;
use Give\Donors\Models\Donor;

// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
Expand All @@ -29,6 +31,7 @@
/**
* View donation details page
*
* @since 3.9.0 Add donor phone number to the view
* @since 1.0
* @return void
*/
Expand Down Expand Up @@ -61,6 +64,8 @@
$currency_code = $payment->currency;
$payment_mode = $payment->mode;
$base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
$donation_phone_number = Donation::find($payment_id)->phone;
$donor_phone_number = Donor::find($donor_id)->phone;

?>
<div class="wrap give-wrap">
Expand Down Expand Up @@ -640,6 +645,26 @@
);
?>
</p>
<p>
<?php
if ( ! empty($donation_phone_number)) {
?>
<strong><?php
esc_html_e('Donor Phone:', 'give'); ?></strong><br>
<?php
// Show Donor donation phone first and Primary phone on parenthesis if not match both phone.
echo (empty($donor_phone_number) ||
hash_equals($donor_phone_number, $donation_phone_number))
? $donation_phone_number :
sprintf(
'%1$s (<a href="%2$s" target="_blank">%3$s</a>)',
$donation_phone_number,
esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}")),
$donor_phone_number
);
}
?>
</p>
</div>
<div class="column">
<p>
Expand Down
11 changes: 6 additions & 5 deletions includes/class-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ public static function print_frontend_errors( $errors ) {
* Print frontend notice.
* Notice: notice type can be success/error/warning
*
* @since 3.7.0 Escape attributes
* @since 1.8.9
* @access public
*
Expand Down Expand Up @@ -691,11 +692,11 @@ public static function print_frontend_notice( $message, $echo = true, $notice_ty
</p>
%6$s
</div>',
$notice_type,
give_clean( $notice_args['dismissible'] ),
absint( $notice_args['dismiss_interval'] ),
give_clean( $notice_args['dismiss_type'] ),
$message,
esc_attr($notice_type),
esc_attr( $notice_args['dismissible'] ),
esc_attr( $notice_args['dismiss_interval'] ),
esc_attr( $notice_args['dismiss_type'] ),
esc_html($message),
$close_icon
);

Expand Down
2 changes: 2 additions & 0 deletions includes/donors/class-give-donor-wall.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function setup_actions() {
/**
* Displays donors in a grid layout.
*
* @since 3.7.0 Sanitize attributes
* @since 2.27.0 Moved AJAX nonce verification to ajax_handler method.
* @since 2.2.0
*
Expand Down Expand Up @@ -114,6 +115,7 @@ public function setup_actions() {
* @return string|bool The markup of the form grid or false.
*/
public function render_shortcode( $atts ) {
$atts = give_clean($atts);

$give_settings = give_get_settings();

Expand Down
4 changes: 2 additions & 2 deletions includes/login-register.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
give_get_template(
'shortcode-login',
array(
'give_login_redirect' => esc_url($login_redirect),
'give_logout_redirect' => esc_url($logout_redirect),
'give_login_redirect' => $login_redirect,
'give_logout_redirect' => $logout_redirect,
)
);

Expand Down
114 changes: 0 additions & 114 deletions includes/misc-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2624,117 +2624,3 @@ function give_get_page_by_title(string $page_title, string $output = OBJECT, str

return get_post($pages[0], $output);
}

/**
* @see https://github.com/jackocnr/intl-tel-input
*
* @unreleased
*/
function give_get_intl_tel_input(string $value, string $id, string $class = '', string $name = ''):string {

if (empty($name)) {
$name = $id;
}

$styleUrl = 'https://cdn.jsdelivr.net/npm/[email protected]/build/css/intlTelInput.css';
$scriptUrl = 'https://cdn.jsdelivr.net/npm/[email protected]/build/js/intlTelInput.min.js';
$utilsScriptUrl = 'https://cdn.jsdelivr.net/npm/[email protected]/build/js/utils.js';

ob_start();

?>
<script src="<?php echo $scriptUrl; ?>"></script>
<link rel="stylesheet" href="<?php echo $styleUrl; ?>">

<input id="<?php echo $id; ?>" class="<?php echo $class; ?>" name="<?php echo $name; ?>" value="<?php echo $value; ?>" type='text'>
<span id="<?php echo $id . '--error-msg'; ?>" class="give-intl-tel-input-hide" style="color:red;"></span>

<style>
.give-intl-tel-input-hide {
display: none !important;
}
.give-intl-tel-input-error {
border: 1px solid red !important;
}
</style>
<script>
if (document.readyState !== 'loading') {
readyHandler();
} else {
document.addEventListener('DOMContentLoaded', readyHandler);
}
function readyHandler() {
const input = document.querySelector("#<?php echo $id; ?>");
const iti = window.intlTelInput(input, {
utilsScript: "<?php echo $utilsScriptUrl; ?>",
hiddenInput: function(telInputName) {
return {
phone: "<?php echo $id . '--international-format'; ?>",
country: "<?php echo $id . '--country-code'; ?>"
};
},
initialCountry: "<?php echo strtolower(give_get_country()); ?>",
showSelectedDialCode: true,
strictMode: false,
i18n: <?php echo give_get_intl_tel_input_i18n_json_object(); ?>
});

const errorMsg = document.querySelector("#<?php echo $id . '--error-msg'; ?>");
const errorMap = [
"<?php echo __('Invalid number', 'give'); ?>",
"<?php echo __('Invalid country code', 'give'); ?>",
"<?php echo __('Too short', 'give'); ?>",
"<?php echo __('Too long', 'give'); ?>",
"<?php echo __('Invalid number', 'give'); ?>",
];

const reset = () => {
input.classList.remove("give-intl-tel-input-error");
errorMsg.innerHTML = "";
errorMsg.classList.add("give-intl-tel-input-hide");
};

const showError = (msg) => {
input.classList.add("give-intl-tel-input-error");
errorMsg.innerHTML = msg;
errorMsg.classList.remove("give-intl-tel-input-hide");
};

input.addEventListener('change', reset);
input.addEventListener('keyup', reset);
input.form.addEventListener("submit", function(e) {
if (input.value.trim() && !iti.isValidNumber()) {
e.preventDefault();
const errorCode = iti.getValidationError();
const msg = errorMap[errorCode] || errorMap[0];
showError(msg);
return false;
}
});
}
</script>
<?php

return ob_get_clean();
}

/**
* @unreleased
*/
function give_get_intl_tel_input_i18n_json_object() {

$countryList = array_change_key_case(give_get_country_list());
array_shift($countryList); // Remove first empty item from the country list

$i18n = array_merge($countryList, [
'selectedCountryAriaLabel' => __('Selected country', 'give'), // Aria label for the selected country element
'noCountrySelected' => __('No country selected', 'give'), // Screen reader text for when no country is selected
'countryListAriaLabel' => __('List of countries', 'give'), // Aria label for the country list element
'searchPlaceholder' => __('Search', 'give'), // Placeholder for the search input in the dropdown (when countrySearch enabled)
'zeroSearchResults' => __('No results found', 'give'), // Screen reader text for when the search produces no results
'oneSearchResult' => __('1 result found', 'give'), // Screen reader text for when the search produces 1 result
'multipleSearchResults' => __('${count} results found', 'give'), // Screen reader text for when the search produces multiple results, where ${count} will be replaced by the count
]);

return json_encode($i18n);
}
Loading

0 comments on commit 16ae6df

Please sign in to comment.