From ebf62c27cc93669255ccbd3939018a65d267a3f0 Mon Sep 17 00:00:00 2001 From: Paulo Iankoski Date: Tue, 11 Jul 2023 16:29:09 -0300 Subject: [PATCH 01/27] Refactor: change Donation Form block (v2) to support v3 forms (#6849) * feature: add short-circuit to give_form shortcode * feature: disable display options for v3 forms * fix: prevent iframes to be clicked * fix: prevent PHP Warning * doc: add unreleased tags --- blocks/donation-form/edit/block.scss | 5 ++ blocks/utils/index.js | 53 ++++++++++---------- includes/shortcodes.php | 12 ++++- src/Views/Form/Templates/Classic/Classic.php | 10 ++-- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/blocks/donation-form/edit/block.scss b/blocks/donation-form/edit/block.scss index 2c3721d54a..98e857e293 100644 --- a/blocks/donation-form/edit/block.scss +++ b/blocks/donation-form/edit/block.scss @@ -4,6 +4,11 @@ form[id*='give-form'] #give-gateway-radio-list > li input[type='radio'] { display: inline-block; } + + iframe { + pointer-events: none; + width: 100% !important; + } } .give-change-donation-form-btn { diff --git a/blocks/utils/index.js b/blocks/utils/index.js index 1e59407f4a..2f4c2a8a0b 100644 --- a/blocks/utils/index.js +++ b/blocks/utils/index.js @@ -1,14 +1,14 @@ /** * WordPress dependencies */ -import { __ } from '@wordpress/i18n' +import {__} from '@wordpress/i18n'; /** * getSiteUrl from API root * @returns {string} siteurl */ export function getSiteUrl() { - return wpApiSettings.root.replace( '/wp-json/', '' ); + return wpApiSettings.root.replace('/wp-json/', ''); } /** @@ -20,24 +20,22 @@ export function getSiteUrl() { * * @return {[]} */ -export function getFormOptions( forms ) { - let formOptions = []; - - if ( forms ) { - formOptions = forms.map( - ( { id, title: { rendered: title } } ) => { - return { - value: id, - label: title === '' ? `${ id } : ${ __( 'No form title', 'give' ) }` : title, - }; - } - ); - } - - // Add Default option - formOptions.unshift( { value: '0', label: __( '-- Select Form --', 'give' ) } ); - - return formOptions; +export function getFormOptions(forms) { + let formOptions = []; + + if (forms) { + formOptions = forms.map(({id, title: {rendered: title}}) => { + return { + value: id, + label: title === '' ? `${id} : ${__('No form title', 'give')}` : title, + }; + }); + } + + // Add Default option + formOptions.unshift({value: '0', label: __('-- Select Form --', 'give')}); + + return formOptions; } /** @@ -45,6 +43,7 @@ export function getFormOptions( forms ) { * * Note: if selected form has legacy form template or empty (old forms) then it will return true otherwise false. * + * @unreleased Filter v3 forms out of the form list. * @since 2.7.0 * * @param {object} forms @@ -52,12 +51,14 @@ export function getFormOptions( forms ) { * * @return {boolean} */ -export function isLegacyForm( forms, SelectedFormId ) { - if ( forms ) { - const data = forms.find( form => parseInt( form.id ) === parseInt( SelectedFormId ) ); +export function isLegacyForm(forms, SelectedFormId) { + if (forms) { + const data = forms.find((form) => parseInt(form.id) === parseInt(SelectedFormId)); - return data && ( ! data.formTemplate || data.formTemplate === 'legacy' ); - } + return ( + data && data.excerpt.rendered !== '

[]

\n' && (!data.formTemplate || data.formTemplate === 'legacy') + ); + } - return false; + return false; } diff --git a/includes/shortcodes.php b/includes/shortcodes.php index b19f491471..5adfbfa2d3 100644 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -131,9 +131,10 @@ function give_donation_history( $atts, $content = false ) { * * Show the Give donation form. * + * @unreleased Add short-circuit filter to allow for custom output. * @since 1.0 - * - * @param array $atts Shortcode attributes + + * @param array $atts Shortcode attributes * * @return string */ @@ -148,6 +149,13 @@ function give_form_shortcode( $atts ) { $atts['id'] = $atts['id'] ?: FrontendFormTemplateUtils::getFormId(); $formId = absint( $atts['id'] ); + // Short-circuit the shortcode output if the filter returns a non-empty string. + $output = apply_filters('givewp_form_shortcode_output', '', $atts); + + if ($output) { + return $output; + } + // Fetch the Give Form. ob_start(); diff --git a/src/Views/Form/Templates/Classic/Classic.php b/src/Views/Form/Templates/Classic/Classic.php index 5ac89ccb11..c9466016dd 100644 --- a/src/Views/Form/Templates/Classic/Classic.php +++ b/src/Views/Form/Templates/Classic/Classic.php @@ -2,13 +2,13 @@ namespace Give\Views\Form\Templates\Classic; -use Give\Helpers\Form\Template\Utils\Frontend; -use Give_Donate_Form; use Give\Form\Template; use Give\Form\Template\Hookable; use Give\Form\Template\Scriptable; use Give\Helpers\Form\Template as FormTemplateUtils; +use Give\Helpers\Form\Template\Utils\Frontend; use Give\Receipt\DonationReceipt; +use Give_Donate_Form; use InvalidArgumentException; /** @@ -196,11 +196,15 @@ public function loadScripts() /** * @inheritDoc + * + * @unreleased Check if visual_appearance is set before accessing it. */ public function getLoadingView() { return $this->loadFile('views/loading.php', [ - 'options' => $this->options[ 'visual_appearance' ] + 'options' => array_key_exists('visual_appearance', $this->options) + ? $this->options['visual_appearance'] + : [], ]); } From 45183bb8aba519c4d83eb17e87f507ac43a2917b Mon Sep 17 00:00:00 2001 From: Joshua Dinh <75056371+JoshuaHungDinh@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:24:05 -0700 Subject: [PATCH 02/27] fix: check for arrays represented as strings (#6831) --- templates/shortcode-form-grid.php | 240 ++++++++++++++++-------------- 1 file changed, 129 insertions(+), 111 deletions(-) diff --git a/templates/shortcode-form-grid.php b/templates/shortcode-form-grid.php index 2227db2346..82dc349416 100644 --- a/templates/shortcode-form-grid.php +++ b/templates/shortcode-form-grid.php @@ -7,7 +7,7 @@ use Give\Helpers\Form\Template; use Give\Helpers\Form\Utils as FormUtils; -if ( ! defined( 'ABSPATH' ) ) { +if ( ! defined('ABSPATH')) { exit; } @@ -17,32 +17,32 @@ * @since 2.27.1 Use get_the_excerpt function to get short description of donation form to display in form grid. */ -$form_id = get_the_ID(); // Form ID. -$give_settings = $args[0]; // Give settings. -$atts = $args[1]; // Shortcode attributes. -$raw_content = ''; // Raw form content. +$form_id = get_the_ID(); // Form ID. +$give_settings = $args[0]; // Give settings. +$atts = $args[1]; // Shortcode attributes. +$raw_content = ''; // Raw form content. $stripped_content = ''; // Form content stripped of HTML tags and shortcodes. -$excerpt = ''; // Trimmed form excerpt ready for display. +$excerpt = ''; // Trimmed form excerpt ready for display. $flex_direction = $atts['columns'] === '1' ? "row" : "column"; -$activeTemplate = FormUtils::isLegacyForm( $form_id ) ? 'legacy' : Template::getActiveID( $form_id ); +$activeTemplate = FormUtils::isLegacyForm($form_id) ? 'legacy' : Template::getActiveID($form_id); /* @var \Give\Form\Template $formTemplate */ -$formTemplate = Give()->templates->getTemplate( $activeTemplate ); +$formTemplate = Give()->templates->getTemplate($activeTemplate); -$renderTags = static function($wrapper_class, $apply_styles = true) use($form_id , $atts ) { - if( !taxonomy_exists( 'give_forms_tag' ) ) { +$renderTags = static function ($wrapper_class, $apply_styles = true) use ($form_id, $atts) { + if ( ! taxonomy_exists('give_forms_tag')) { return ''; } - $tags = wp_get_post_terms($form_id,'give_forms_tag'); + $tags = wp_get_post_terms($form_id, 'give_forms_tag'); - $tag_bg_color = ! empty( $atts['tag_background_color'] ) + $tag_bg_color = ! empty($atts['tag_background_color']) ? $atts['tag_background_color'] : '#69b86b'; - $tag_text_color = ! empty( $atts['tag_text_color'] ) + $tag_text_color = ! empty($atts['tag_text_color']) ? $atts['tag_text_color'] : '#ffffff'; @@ -51,21 +51,23 @@ : 'none'; $tag_elements = array_map( - static function($term)use($tag_text_color,$tag_bg_color){ + static function ($term) use ($tag_text_color, $tag_bg_color) { $style = sprintf( 'color: %s; background-color: %s;', esc_attr($tag_text_color), esc_attr($tag_bg_color) ); + return "$term->name"; - }, $tags + }, + $tags ); $tag_elements = implode('', $tag_elements); $styles = sprintf( - "background-color: %s;", - $apply_styles ? esc_attr($tag_container_color) : '' - ); + "background-color: %s;", + $apply_styles ? esc_attr($tag_container_color) : '' + ); return "
@@ -79,24 +81,23 @@ static function($term)use($tag_text_color,$tag_bg_color){ "; - } elseif( + } elseif ( give_is_setting_enabled($give_settings['form_featured_img']) && ($imageSrc = $formTemplate->getFormFeaturedImage($form_id)) && $atts['show_featured_image'] - && $atts['columns'] === '1') - { + && $atts['columns'] === '1') { echo "
- + {$renderTags('give-form-grid-media__tags')}
@@ -153,7 +153,7 @@ static function($term)use($tag_text_color,$tag_bg_color){
{$renderTags('give-form-grid-media__tags_no_image', false)} @@ -165,38 +165,40 @@ static function($term)use($tag_text_color,$tag_bg_color){ %1$s', - $formTemplate->getFormHeading( $form_id ) + $formTemplate->getFormHeading($form_id) ); } // Maybe display the form excerpt. - if ( true === $atts['show_excerpt'] ) { - if ( $raw_content = get_the_excerpt( $form_id ) ) { + if (true === $atts['show_excerpt']) { + if ($raw_content = get_the_excerpt($form_id)) { $stripped_content = wp_strip_all_tags( - strip_shortcodes( $raw_content ) + strip_shortcodes($raw_content) ); } else { // Get content from the form post's content field. - $raw_content = give_get_meta( $form_id, '_give_form_content', true ); + $raw_content = give_get_meta($form_id, '_give_form_content', true); - if ( ! empty( $raw_content ) ) { + if ( ! empty($raw_content)) { $stripped_content = wp_strip_all_tags( - strip_shortcodes( $raw_content ) + strip_shortcodes($raw_content) ); } } // Maybe truncate excerpt. - if ( 0 < $atts['excerpt_length'] ) { - $excerpt = wp_trim_words( $stripped_content, $atts['excerpt_length'] ); + if (0 < $atts['excerpt_length']) { + $excerpt = wp_trim_words($stripped_content, $atts['excerpt_length']); } else { $excerpt = $stripped_content; } - printf( '

%s

', $excerpt ); + $excerpt = ($excerpt === '[]') ? '' : $excerpt; + + printf('

%s

', $excerpt); } if ($atts['show_donate_button']): @@ -223,58 +225,56 @@ static function($term)use($tag_text_color,$tag_bg_color){
ID, '_give_goal_option', true ); + $form = new Give_Donate_Form($form_id); + $goal_option = give_get_meta($form->ID, '_give_goal_option', true); // Sanity check - ensure form has pass all condition to show goal. - $hide_goal = ( isset( $atts['show_goal'] ) && ! filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ) ) - || empty( $form->ID ) - || ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) ) - || ! give_is_setting_enabled( $goal_option ) || 0 === $form->goal; + $hide_goal = (isset($atts['show_goal']) && ! filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN)) + || empty($form->ID) + || (is_singular('give_forms') && ! give_is_setting_enabled($goal_option)) + || ! give_is_setting_enabled($goal_option) || 0 === $form->goal; // Maybe display the goal progress bar. - if (!$hide_goal) : - $goal_progress_stats = give_goal_progress_stats( $form ); - $goal_format = $goal_progress_stats['format']; - $color = $atts['progress_bar_color']; - $show_goal = isset( $atts['show_goal'] ) ? filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ) : true; + if ( ! $hide_goal) : + $goal_progress_stats = give_goal_progress_stats($form); + $goal_format = $goal_progress_stats['format']; + $color = $atts['progress_bar_color']; + $show_goal = isset($atts['show_goal']) ? filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN) : true; $shortcode_stats = apply_filters( 'give_goal_shortcode_stats', - array( + [ 'income' => $form->get_earnings(), - 'goal' => $goal_progress_stats['raw_goal'], - ), + 'goal' => $goal_progress_stats['raw_goal'], + ], $form_id, $goal_progress_stats, $args ); $income = $shortcode_stats['income']; - $goal = $shortcode_stats['goal']; - - switch ( $goal_format ) { + $goal = $shortcode_stats['goal']; + switch ($goal_format) { case 'donation': - $progress = $goal ? round( ( $form->get_sales() / $goal ) * 100, 2 ) : 0; + $progress = $goal ? round(($form->get_sales() / $goal) * 100, 2) : 0; $progress_bar_value = $form->get_sales() >= $goal ? 100 : $progress; break; case 'donors': - $progress = $goal ? round( ( give_get_form_donor_count( $form->ID ) / $goal ) * 100, 2 ) : 0; - $progress_bar_value = give_get_form_donor_count( $form->ID ) >= $goal ? 100 : $progress; + $progress = $goal ? round((give_get_form_donor_count($form->ID) / $goal) * 100, 2) : 0; + $progress_bar_value = give_get_form_donor_count($form->ID) >= $goal ? 100 : $progress; break; case 'percentage': - $progress = $goal ? round( ( $income / $goal ) * 100, 2 ) : 0; + $progress = $goal ? round(($income / $goal) * 100, 2) : 0; $progress_bar_value = $income >= $goal ? 100 : $progress; break; default: - $progress = $goal ? round( ( $income / $goal ) * 100, 2 ) : 0; + $progress = $goal ? round(($income / $goal) * 100, 2) : 0; $progress_bar_value = $income >= $goal ? 100 : $progress; break; - } ?> @@ -294,14 +294,18 @@ static function($term)use($tag_text_color,$tag_bg_color){
false, 'currency' => $form_currency, - 'decimal' => false, - ), + 'decimal' => false, + ], $form_id ); @@ -325,11 +329,11 @@ static function($term)use($tag_text_color,$tag_bg_color){ */ $goal_format_args = apply_filters( 'give_goal_amount_format_args', - array( + [ 'sanitize' => false, 'currency' => $form_currency, - 'decimal' => false, - ), + 'decimal' => false, + ], $form_id ); @@ -343,9 +347,9 @@ static function($term)use($tag_text_color,$tag_bg_color){ */ $goal_amounts = apply_filters( 'give_goal_amounts', - array( + [ $form_currency => $goal, - ), + ], $form_id ); @@ -359,103 +363,117 @@ static function($term)use($tag_text_color,$tag_bg_color){ */ $income_amounts = apply_filters( 'give_goal_raised_amounts', - array( + [ $form_currency => $income, - ), + ], $form_id ); // Get human readable donation amount. - $income = give_human_format_large_amount( give_format_amount( $income, $income_format_args ), array( 'currency' => $form_currency ) ); - $goal = give_human_format_large_amount( give_format_amount( $goal, $goal_format_args ), array( 'currency' => $form_currency ) ); + $income = give_human_format_large_amount( + give_format_amount($income, $income_format_args), ['currency' => $form_currency] + ); + $goal = give_human_format_large_amount( + give_format_amount($goal, $goal_format_args), + ['currency' => $form_currency] + ); // Format the human readable donation amount. $formatted_income = give_currency_filter( $income, - array( + [ 'form_id' => $form_id, - ) + ] ); $formatted_goal = give_currency_filter( $goal, - array( + [ 'form_id' => $form_id, - ) + ] ); echo sprintf( /* translators: 1: amount of income raised 2: goal target amount. */ - __( '%2$s - of %4$s', 'give' ), - esc_attr( wp_json_encode( $income_amounts, JSON_PRETTY_PRINT ) ), - esc_attr( $formatted_income ), - esc_attr( wp_json_encode( $goal_amounts, JSON_PRETTY_PRINT ) ), - esc_attr( $formatted_goal ) + __( + '%2$s + of %4$s', + 'give' + ), + esc_attr(wp_json_encode($income_amounts, JSON_PRETTY_PRINT)), + esc_attr($formatted_income), + esc_attr(wp_json_encode($goal_amounts, JSON_PRETTY_PRINT)), + esc_attr($formatted_goal) ); - elseif ( 'percentage' === $goal_format ) : + elseif ('percentage' === $goal_format) : echo sprintf( /* translators: %s: percentage of the amount raised compared to the goal target */ - __( ' + __( + ' %s%% - of 100%', 'give' ), - round( $progress ) + of 100%', + 'give' + ), + round($progress) ); - elseif ( 'donation' === $goal_format ) :?> + elseif ('donation' === $goal_format) :?> - get_sales(), array( 'decimal' => false ))?> + get_sales(), ['decimal' => false]) ?> - false ))); ?> + false]) + ); ?> - + - ID ) ?> + ID) ?> - false ))); ?> + false]) + ); ?>
- get_sales(), array( 'decimal' => false )) ?> + get_sales(), ['decimal' => false]) ?> - +
- +
$form_id, + 'id' => $form_id, 'display_style' => 'button', ] ); - } else { printf( '
', $form_id ); - give_get_donation_form( $form_id ); + give_get_donation_form($form_id); echo '
'; } } From 093391ba70aa0e44ac1aeb3deb51cd95adce5c7a Mon Sep 17 00:00:00 2001 From: Angela Blake <35241639+angelablake@users.noreply.github.com> Date: Wed, 12 Jul 2023 15:44:54 -0500 Subject: [PATCH 03/27] chore: prepare for 2.30.0 release --- blocks/utils/index.js | 2 +- give.php | 4 ++-- includes/ajax-functions.php | 2 +- includes/donors/class-give-donor-wall.php | 2 +- includes/gateways/functions.php | 2 +- includes/shortcodes.php | 2 +- readme.txt | 10 +++++++++- .../Adapters/LegacyPaymentGatewayRegisterAdapter.php | 10 +++++----- .../Contracts/PaymentGatewayInterface.php | 4 ++-- src/Framework/PaymentGateways/PaymentGateway.php | 8 ++++---- .../PaymentGateways/PaymentGatewayRegister.php | 2 +- .../Adapters/LegacyPaymentGatewayAdapter.php | 10 +++++----- .../Gateways/TestGateway/TestGateway.php | 2 +- .../Gateways/TestGateway/TestGatewayOffsite.php | 4 ++-- .../PayPalCommerce/AjaxRequestHandler.php | 4 ++-- ...egisterPayPalDonationsRefreshTokenCronJobByMode.php | 10 +++++----- .../PayPalCheckoutSdk/Requests/GenerateClientToken.php | 4 ++-- .../Requests/VerifyWebhookSignature.php | 4 ++-- src/PaymentGateways/PayPalCommerce/RefreshToken.php | 4 ++-- .../PayPalCommerce/Repositories/MerchantDetails.php | 2 +- .../PayPalCommerce/Repositories/Traits/HasMode.php | 2 +- src/PaymentGateways/PayPalCommerce/ScriptLoader.php | 2 +- .../PayPalCommerce/onBoardingRedirectHandler.php | 2 +- src/Views/Form/Templates/Classic/Classic.php | 2 +- .../PaymentGateways/PaymentGatewaysRegisterTest.php | 2 +- 25 files changed, 55 insertions(+), 47 deletions(-) diff --git a/blocks/utils/index.js b/blocks/utils/index.js index 2f4c2a8a0b..78921baa6a 100644 --- a/blocks/utils/index.js +++ b/blocks/utils/index.js @@ -43,7 +43,7 @@ export function getFormOptions(forms) { * * Note: if selected form has legacy form template or empty (old forms) then it will return true otherwise false. * - * @unreleased Filter v3 forms out of the form list. + * @since 2.30.0 Filter v3 forms out of the form list. * @since 2.7.0 * * @param {object} forms diff --git a/give.php b/give.php index 226359e103..1d2bb73c31 100644 --- a/give.php +++ b/give.php @@ -6,7 +6,7 @@ * Description: The most robust, flexible, and intuitive way to accept donations on WordPress. * Author: GiveWP * Author URI: https://givewp.com/ - * Version: 2.29.2 + * Version: 2.30.0 * Requires at least: 5.0 * Requires PHP: 7.0 * Text Domain: give @@ -316,7 +316,7 @@ private function setup_constants() { // Plugin version. if (!defined('GIVE_VERSION')) { - define('GIVE_VERSION', '2.29.2'); + define('GIVE_VERSION', '2.30.0'); } // Plugin Root File. diff --git a/includes/ajax-functions.php b/includes/ajax-functions.php index bd76a4e902..2570f1698a 100644 --- a/includes/ajax-functions.php +++ b/includes/ajax-functions.php @@ -190,7 +190,7 @@ function give_load_checkout_fields() { /** * Retrieve a states drop down * - * @unreleased add 'state_label' & 'states' to response + * @since 2.30.0 add 'state_label' & 'states' to response * @since 1.0 * * @return void diff --git a/includes/donors/class-give-donor-wall.php b/includes/donors/class-give-donor-wall.php index c91febb9cd..c4d8fe9097 100644 --- a/includes/donors/class-give-donor-wall.php +++ b/includes/donors/class-give-donor-wall.php @@ -182,7 +182,7 @@ public function render_shortcode( $atts ) { /** * Parse shortcode attributes * - * @unreleased + * @since 2.30.0 * @since 2.2.0 * @access public * diff --git a/includes/gateways/functions.php b/includes/gateways/functions.php index f3bd2297c1..51c872bb5d 100644 --- a/includes/gateways/functions.php +++ b/includes/gateways/functions.php @@ -17,7 +17,7 @@ /** * Returns a list of all available gateways. * - * @unreleased add filter give_payment_gateways_admin_label + * @since 2.30.0 add filter give_payment_gateways_admin_label * @since 1.0 * @return array $gateways All the available gateways */ diff --git a/includes/shortcodes.php b/includes/shortcodes.php index 5adfbfa2d3..18e68d65b2 100644 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -131,7 +131,7 @@ function give_donation_history( $atts, $content = false ) { * * Show the Give donation form. * - * @unreleased Add short-circuit filter to allow for custom output. + * @since 2.30.0 Add short-circuit filter to allow for custom output. * @since 1.0 * @param array $atts Shortcode attributes diff --git a/readme.txt b/readme.txt index 1c1a981817..73df61b0dc 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: donation, donate, recurring donations, fundraising, crowdfunding Requires at least: 5.0 Tested up to: 6.2 Requires PHP: 7.0 -Stable tag: 2.29.2 +Stable tag: 2.30.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -258,6 +258,14 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri 8. GiveWP has a dedicated support team to help answer any questions you may have and help you through stumbling blocks. == Changelog == += 2.30.0: July 12th, 2023 = +* Feature: Attributes of the [give_donor_wall] shortcode can now be filtered. +* Feature: Added state label and list of states for the v3 form billing address block. Existing functionality is not modified. +* Fix: Empty excerpt fields for v3 forms no longer display as [] on the Form Grid. +* Refactor: Updated the gateway adapter for v3 forms. +* Refactor: Updated legacy donation form block title with a (v2) suffix. +* Refactor: The v2 Donation Form block now supports v3 forms. + = 2.29.2: June 29th, 2023 = * Enhancement: PayPal Donations now has separate buttons to connect to PayPal Live and PayPal Sandbox. * Fix: Form Field Manager conditional radio and checkbox fields that are not visible no longer prevent donation submission. diff --git a/src/Framework/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayRegisterAdapter.php b/src/Framework/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayRegisterAdapter.php index ffd0dddcc2..5278a167ac 100644 --- a/src/Framework/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayRegisterAdapter.php +++ b/src/Framework/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayRegisterAdapter.php @@ -12,7 +12,7 @@ class LegacyPaymentGatewayRegisterAdapter * Run the necessary legacy hooks on our LegacyPaymentGatewayAdapter * that prepares data to be sent to each gateway * - * @unreleased check for getLegacyFormFieldMarkup before attempting to use + * @since 2.30.0 check for getLegacyFormFieldMarkup before attempting to use * * @since 2.19.0 * @throws Exception @@ -70,7 +70,7 @@ static function (int $donationId, string $newStatus, string $oldStatus) use ( /** * Adds new payment gateways to legacy list for settings * - * @unreleased update admin_label to include version compatibility + * @since 2.30.0 update admin_label to include version compatibility * @since 2.25.0 add is_visible key to $gatewayData * @since 2.19.0 */ @@ -91,7 +91,7 @@ public function addNewPaymentGatewaysToLegacyListSettings(array $gatewaysData, a } /** - * @unreleased check if v2 compatible + * @since 2.30.0 check if v2 compatible * @since 2.25.0 */ public function supportsV2Forms(PaymentGateway $gateway): bool @@ -100,7 +100,7 @@ public function supportsV2Forms(PaymentGateway $gateway): bool } /** - * @unreleased + * @since 2.30.0 */ public function getRegisteredGatewayAdminLabelWithSupportedFormVersion(PaymentGateway $gateway): string { @@ -117,7 +117,7 @@ public function getRegisteredGatewayAdminLabelWithSupportedFormVersion(PaymentGa /** * Update the admin label for gateways to display version compatibility * - * @unreleased + * @since 2.30.0 */ public function updatePaymentGatewayAdminLabelsWithSupportedFormVersions(string $label, string $gatewayId): string { diff --git a/src/Framework/PaymentGateways/Contracts/PaymentGatewayInterface.php b/src/Framework/PaymentGateways/Contracts/PaymentGatewayInterface.php index 568ee6bb16..8acd455969 100644 --- a/src/Framework/PaymentGateways/Contracts/PaymentGatewayInterface.php +++ b/src/Framework/PaymentGateways/Contracts/PaymentGatewayInterface.php @@ -21,14 +21,14 @@ interface PaymentGatewayInterface extends SubscriptionModuleInterface * * This will likely be removed in the future when GiveWP 2.x is no longer supported * - * @unreleased + * @since 2.30.0 */ public function supportsFormVersions(): array; /** * Enqueue script for the gateway to display fields and interact with the form * - * @unreleased + * @since 2.30.0 */ public function enqueueScript(int $formId); diff --git a/src/Framework/PaymentGateways/PaymentGateway.php b/src/Framework/PaymentGateways/PaymentGateway.php index 739cf1abf4..4e5052438b 100644 --- a/src/Framework/PaymentGateways/PaymentGateway.php +++ b/src/Framework/PaymentGateways/PaymentGateway.php @@ -20,7 +20,7 @@ use ReflectionMethod; /** - * @unreleased added enqueueScript() and formSettings() methods. + * @since 2.30.0 added enqueueScript() and formSettings() methods. * @since 2.18.0 */ abstract class PaymentGateway implements PaymentGatewayInterface, @@ -57,7 +57,7 @@ public function __construct(SubscriptionModule $subscriptionModule = null) } /** - * @unreleased + * @since 2.30.0 */ public function supportsFormVersions(): array { @@ -79,7 +79,7 @@ public function supportsFormVersions(): array /** * Enqueue gateway scripts using WordPress wp_enqueue_script(). * - * @unreleased + * @since 2.30.0 * * @return void */ @@ -91,7 +91,7 @@ public function enqueueScript(int $formId) /** * Convenient way of localizing data to the JS gateway object accessible from `this.settings`. * - * @unreleased + * @since 2.30.0 */ public function formSettings(int $formId): array { diff --git a/src/Framework/PaymentGateways/PaymentGatewayRegister.php b/src/Framework/PaymentGateways/PaymentGatewayRegister.php index 03b80f5a3b..a0d0cd72ce 100644 --- a/src/Framework/PaymentGateways/PaymentGatewayRegister.php +++ b/src/Framework/PaymentGateways/PaymentGatewayRegister.php @@ -21,7 +21,7 @@ class PaymentGatewayRegister extends PaymentGatewaysIterator /** * Get Gateways * - * @unreleased added $supportedFormVersion param to filter gateways by supported form version + * @since 2.30.0 added $supportedFormVersion param to filter gateways by supported form version * @since 2.18.0 */ public function getPaymentGateways(int $supportedFormVersion = null): array diff --git a/src/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayAdapter.php b/src/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayAdapter.php index 99eb8acc89..1283c5d0fb 100644 --- a/src/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayAdapter.php +++ b/src/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayAdapter.php @@ -44,7 +44,7 @@ public function getLegacyFormFieldMarkup( /** * First we create a payment, then move on to the gateway processing * - * @unreleased Add success, cancel and failed URLs to gateway data. This will be used in both v2 and v3 forms so gateways can just refer to the gateway data. + * @since 2.30.0 Add success, cancel and failed URLs to gateway data. This will be used in both v2 and v3 forms so gateways can just refer to the gateway data. * @since 2.24.0 add support for payment mode * @since 2.21.0 Replace give_insert_payment with donation model. Store legacy subscription data in donation meta. * Attach subscription id to donation. @@ -136,7 +136,7 @@ public function handleBeforeGateway(array $legacyDonationData, PaymentGateway $r } /** - * @unreleased + * @since 2.30.0 */ protected function getGatewayDataSuccessUrl(int $donationId): string { @@ -150,7 +150,7 @@ protected function getGatewayDataSuccessUrl(int $donationId): string } /** - * @unreleased + * @since 2.30.0 */ protected function getGatewayDataFailedUrl(int $donationId): string { @@ -164,7 +164,7 @@ protected function getGatewayDataFailedUrl(int $donationId): string } /** - * @unreleased + * @since 2.30.0 */ protected function getGatewayDataCancelUrl(int $donationId): string { @@ -327,7 +327,7 @@ public function maybeRefundOnGateway( } /** - * @unreleased + * @since 2.30.0 */ protected function addUrlsToGatewayData(Donation $donation, $gatewayData, PaymentGateway $registeredGateway) { diff --git a/src/PaymentGateways/Gateways/TestGateway/TestGateway.php b/src/PaymentGateways/Gateways/TestGateway/TestGateway.php index 2fd179ed4c..2920088167 100644 --- a/src/PaymentGateways/Gateways/TestGateway/TestGateway.php +++ b/src/PaymentGateways/Gateways/TestGateway/TestGateway.php @@ -45,7 +45,7 @@ public function getName(): string } /** - * @unreleased + * @since 2.30.0 */ public function enqueueScript(int $formId) { diff --git a/src/PaymentGateways/Gateways/TestGateway/TestGatewayOffsite.php b/src/PaymentGateways/Gateways/TestGateway/TestGatewayOffsite.php index c871353c5c..52206292f5 100644 --- a/src/PaymentGateways/Gateways/TestGateway/TestGatewayOffsite.php +++ b/src/PaymentGateways/Gateways/TestGateway/TestGatewayOffsite.php @@ -30,7 +30,7 @@ class TestGatewayOffsite extends PaymentGateway ]; /** - * @unreleased + * @since 2.30.0 */ public function enqueueScript(int $formId) { @@ -128,7 +128,7 @@ public function createSubscription( /** * An example of using a secureRouteMethod for extending the Gateway API to handle a redirect. * - * @unreleased update with new gatewayData params + * @since 2.30.0 update with new gatewayData params * @since 2.21.0 update to use Donation model * @since 2.19.0 * diff --git a/src/PaymentGateways/PayPalCommerce/AjaxRequestHandler.php b/src/PaymentGateways/PayPalCommerce/AjaxRequestHandler.php index 54ecc57138..db7ab2a1ff 100644 --- a/src/PaymentGateways/PayPalCommerce/AjaxRequestHandler.php +++ b/src/PaymentGateways/PayPalCommerce/AjaxRequestHandler.php @@ -131,7 +131,7 @@ public function onBoardedUserAjaxRequestHandler() /** * This function handle ajax request with give_paypal_commerce_get_partner_url action. * - * @unreleased Add support for mode param. + * @since 2.30.0 Add support for mode param. * @since 2.9.0 */ public function onGetPartnerUrlAjaxRequestHandler() @@ -176,7 +176,7 @@ public function onGetPartnerUrlAjaxRequestHandler() /** * give_paypal_commerce_disconnect_account ajax request handler. * - * @unreleased Add support for mode param. + * @since 2.30.0 Add support for mode param. * @since 2.25.0 Remove merchant seller token. * @since 2.9.0 */ diff --git a/src/PaymentGateways/PayPalCommerce/Migrations/RegisterPayPalDonationsRefreshTokenCronJobByMode.php b/src/PaymentGateways/PayPalCommerce/Migrations/RegisterPayPalDonationsRefreshTokenCronJobByMode.php index 90cc81ed51..df91853dd1 100644 --- a/src/PaymentGateways/PayPalCommerce/Migrations/RegisterPayPalDonationsRefreshTokenCronJobByMode.php +++ b/src/PaymentGateways/PayPalCommerce/Migrations/RegisterPayPalDonationsRefreshTokenCronJobByMode.php @@ -15,14 +15,14 @@ /** * Class RegisterPayPalDonationsRefreshTokenCronJobByMode * - * @unreleased + * @since 2.30.0 */ class RegisterPayPalDonationsRefreshTokenCronJobByMode extends Migration { /** * @inerhitDoc - * @unreleased + * @since 2.30.0 */ public function run() { @@ -58,7 +58,7 @@ public function run() /** * @inerhitDoc - * @unreleased + * @since 2.30.0 */ public static function id() { @@ -67,7 +67,7 @@ public static function id() /** * @inerhitDoc - * @unreleased + * @since 2.30.0 */ public static function timestamp() { @@ -76,7 +76,7 @@ public static function timestamp() /** * @inerhitDoc - * @unreleased + * @since 2.30.0 */ public static function title() { diff --git a/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/GenerateClientToken.php b/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/GenerateClientToken.php index 670ec7fde7..870d89032f 100644 --- a/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/GenerateClientToken.php +++ b/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/GenerateClientToken.php @@ -9,12 +9,12 @@ * * This class use to generate a client token for PayPal JS SDK. * - * @unreleased + * @since 2.30.0 */ class GenerateClientToken extends HttpRequest { /** - * @unreleased + * @since 2.30.0 */ public function __construct() { diff --git a/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/VerifyWebhookSignature.php b/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/VerifyWebhookSignature.php index ff6379c240..a5d1222366 100644 --- a/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/VerifyWebhookSignature.php +++ b/src/PaymentGateways/PayPalCommerce/PayPalCheckoutSdk/Requests/VerifyWebhookSignature.php @@ -6,12 +6,12 @@ /** * Class VerifyWebhookSignature * - * @unreleased + * @since 2.30.0 */ class VerifyWebhookSignature extends HttpRequest { /** - * @unreleased + * @since 2.30.0 * @param array $requestBody Request body. */ public function __construct(array $requestBody) diff --git a/src/PaymentGateways/PayPalCommerce/RefreshToken.php b/src/PaymentGateways/PayPalCommerce/RefreshToken.php index 3e8e22de37..bf09176c79 100644 --- a/src/PaymentGateways/PayPalCommerce/RefreshToken.php +++ b/src/PaymentGateways/PayPalCommerce/RefreshToken.php @@ -12,7 +12,7 @@ /** * Class RefreshToken * - * @unreleased Add support for mode. + * @since 2.30.0 Add support for mode. * @since 2.9.0 */ class RefreshToken @@ -158,7 +158,7 @@ public function refreshToken() * - give_paypal_commerce_refresh_sandbox_token * - give_paypal_commerce_refresh_live_token * - * @unreleased + * @since 2.30.0 * @return void */ public function cronJobRefreshToken() diff --git a/src/PaymentGateways/PayPalCommerce/Repositories/MerchantDetails.php b/src/PaymentGateways/PayPalCommerce/Repositories/MerchantDetails.php index 49b7da9d95..8316be3dca 100644 --- a/src/PaymentGateways/PayPalCommerce/Repositories/MerchantDetails.php +++ b/src/PaymentGateways/PayPalCommerce/Repositories/MerchantDetails.php @@ -123,7 +123,7 @@ public function deleteClientToken() /** * Get client token for hosted credit card fields. * - * @unreleased Use PayPal client to generate client token. + * @since 2.30.0 Use PayPal client to generate client token. * @since 2.9.0 * * @return string diff --git a/src/PaymentGateways/PayPalCommerce/Repositories/Traits/HasMode.php b/src/PaymentGateways/PayPalCommerce/Repositories/Traits/HasMode.php index 20fe3ae683..9b91b9d348 100644 --- a/src/PaymentGateways/PayPalCommerce/Repositories/Traits/HasMode.php +++ b/src/PaymentGateways/PayPalCommerce/Repositories/Traits/HasMode.php @@ -38,7 +38,7 @@ public function setMode($mode) /** * This function returns the current mode * - * @unreleased + * @since 2.30.0 */ public function getMode(): string { diff --git a/src/PaymentGateways/PayPalCommerce/ScriptLoader.php b/src/PaymentGateways/PayPalCommerce/ScriptLoader.php index 1807405297..72f05332ee 100644 --- a/src/PaymentGateways/PayPalCommerce/ScriptLoader.php +++ b/src/PaymentGateways/PayPalCommerce/ScriptLoader.php @@ -213,7 +213,7 @@ public function loadPublicAssets() /** * Get PayPal partner js url. * - * @unreleased sandbox PayPal partner js loads slow. So we are using live url for now. + * @since 2.30.0 sandbox PayPal partner js loads slow. So we are using live url for now. * @since 2.9.0 * * @return string diff --git a/src/PaymentGateways/PayPalCommerce/onBoardingRedirectHandler.php b/src/PaymentGateways/PayPalCommerce/onBoardingRedirectHandler.php index d92b7e70b8..6c40f373db 100644 --- a/src/PaymentGateways/PayPalCommerce/onBoardingRedirectHandler.php +++ b/src/PaymentGateways/PayPalCommerce/onBoardingRedirectHandler.php @@ -75,7 +75,7 @@ public function __construct( /** * This function set mode from request. * - * @unreleased + * @since 2.30.0 * @return void */ private function setModeFromRequest() diff --git a/src/Views/Form/Templates/Classic/Classic.php b/src/Views/Form/Templates/Classic/Classic.php index c9466016dd..95554d0d28 100644 --- a/src/Views/Form/Templates/Classic/Classic.php +++ b/src/Views/Form/Templates/Classic/Classic.php @@ -197,7 +197,7 @@ public function loadScripts() /** * @inheritDoc * - * @unreleased Check if visual_appearance is set before accessing it. + * @since 2.30.0 Check if visual_appearance is set before accessing it. */ public function getLoadingView() { diff --git a/tests/Unit/PaymentGateways/PaymentGatewaysRegisterTest.php b/tests/Unit/PaymentGateways/PaymentGatewaysRegisterTest.php index b3481d2fb7..f5f9c58628 100644 --- a/tests/Unit/PaymentGateways/PaymentGatewaysRegisterTest.php +++ b/tests/Unit/PaymentGateways/PaymentGatewaysRegisterTest.php @@ -85,7 +85,7 @@ public function testShouldGetRegisteredPaymentGateways() } /** - * @unreleased + * @since 2.30.0 * @throws Exception * @throws OverflowException */ From 0484f54cff94c318de255c81cb879f5640778cee Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Mon, 17 Jul 2023 16:09:28 -0700 Subject: [PATCH 04/27] feature: add summer sales banner class --- .../InPluginUpsells/SummerSalesBanner.php | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/Promotions/InPluginUpsells/SummerSalesBanner.php diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php new file mode 100644 index 0000000000..22353831b1 --- /dev/null +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -0,0 +1,106 @@ + 'bfgt2023', + 'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'), + 'leadHeader' => __('Make it stellar.', 'give'), + 'leadText' => __('Save 30% on all StellarWP products.', 'give'), + 'contentText' => __( + 'Purchase any StellarWP product during the sale and get 100% off WP Business Reviews and take 40% off all other brands.', + 'give' + ), + 'actionText' => __('Shop Now', 'give'), + 'alternateActionText' => __('View all StellarWP Deals', 'give'), + 'actionURL' => 'https://go.givewp.com/ss23give', + 'alternateActionURL' => 'https://go.givewp.com/ss23stellar', + 'startDate' => '2023-07-16 00:00', + 'endDate' => '2023-07-19 23:59', + ], + [ + 'id' => 'bfgt2023', + 'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'), + 'leadHeader' => __('Make it yours.', 'give'), + 'leadText' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), + 'contentText' => __( + 'Purchase any StellarWP product during the sale and get 100% off WP Business Reviews and take 40% off all other brands.', + 'give' + ), + 'actionText' => __('Shop Now', 'give'), + 'alternateActionText' => __('View all StellarWP Deals', 'give'), + 'actionURL' => 'https://go.givewp.com/ss23give', + 'alternateActionURL' => 'https://go.givewp.com/ss23stellar', + 'startDate' => '2023-07-16 00:00', + 'endDate' => '2023-07-19 23:59', + ], + ]; + } + + /** + * @unrleased + */ + public function loadScripts(): void + { + wp_enqueue_script( + 'give-in-plugin-upsells-sale-banners', + GIVE_PLUGIN_URL . 'assets/dist/js/admin-upsell-sale-banner.js', + [], + GIVE_VERSION, + true + ); + + wp_localize_script( + 'give-in-plugin-upsells-sale-banners', + 'GiveSaleBanners', + [ + 'apiRoot' => esc_url_raw(rest_url('give-api/v2/sale-banner')), + 'apiNonce' => wp_create_nonce('wp_rest'), + ] + ); + + wp_enqueue_style( + 'give-in-plugin-upsells-summer-sales-banner', + GIVE_PLUGIN_URL . 'assets/dist/css/admin-summer-sales-banner.css', + '1.0.0', + ); + + wp_enqueue_style('givewp-admin-fonts'); + } + + /** + * @unreleased + */ + public function render(): void + { + $banners = $this->getVisibleBanners(); + + if ( ! empty($banners)) { + include __DIR__ . '/resources/views/summer-sales-banner.php'; + } + } + + + /** + * @unreleased + */ + public static function isShowing(): bool + { + global $pagenow; + + return $pagenow === 'plugins.php'; + } +} From c96533ae9ac4567135cb911b16001759fdacc3d0 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Mon, 17 Jul 2023 16:09:57 -0700 Subject: [PATCH 05/27] feature: register hooks --- src/Promotions/ServiceProvider.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Promotions/ServiceProvider.php b/src/Promotions/ServiceProvider.php index f0a4022e5a..e0e84051df 100644 --- a/src/Promotions/ServiceProvider.php +++ b/src/Promotions/ServiceProvider.php @@ -14,6 +14,7 @@ use Give\Promotions\InPluginUpsells\PaymentGateways; use Give\Promotions\InPluginUpsells\RecurringDonationsTab; use Give\Promotions\InPluginUpsells\SaleBanners; +use Give\Promotions\InPluginUpsells\SummerSalesBanner; use Give\ServiceProviders\ServiceProvider as ServiceProviderContract; class ServiceProvider implements ServiceProviderContract @@ -39,7 +40,7 @@ public function boot() } /** - * @since 2.27.1 Removed Recurring donations tab app. + * @since 2.27.1 Removed Recurring donations tab app. * * Boots the Plugin Upsell promotional page * @@ -59,6 +60,10 @@ private function bootPluginUpsells() Hooks::addAction('admin_notices', SaleBanners::class, 'render'); Hooks::addAction('admin_enqueue_scripts', SaleBanners::class, 'loadScripts'); } + if (SummerSalesBanner::isShowing()) { + Hooks::addAction('admin_notices', SummerSalesBanner::class, 'render'); + Hooks::addAction('admin_enqueue_scripts', SummerSalesBanner::class, 'loadScripts'); + } if (PaymentGateways::isShowing()) { Hooks::addAction('admin_enqueue_scripts', PaymentGateways::class, 'loadScripts'); From c372f3c1a41e288eca7a5ca540ef38894fb24361 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Mon, 17 Jul 2023 16:10:19 -0700 Subject: [PATCH 06/27] feature: add sales banner view --- .../resources/views/summer-sales-banner.php | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php diff --git a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php new file mode 100644 index 0000000000..6aca22f2b6 --- /dev/null +++ b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php @@ -0,0 +1,80 @@ + + From ae907d47aafe23b3d9313c598463100b1ce99762 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Mon, 17 Jul 2023 16:10:40 -0700 Subject: [PATCH 07/27] feature: add sales banner styles --- assets/src/css/admin/summer-sales-banner.scss | 207 ++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 assets/src/css/admin/summer-sales-banner.scss diff --git a/assets/src/css/admin/summer-sales-banner.scss b/assets/src/css/admin/summer-sales-banner.scss new file mode 100644 index 0000000000..a8ba6d8d83 --- /dev/null +++ b/assets/src/css/admin/summer-sales-banner.scss @@ -0,0 +1,207 @@ +.give-sale-banners-container { + /* Box-sizing reset */ + &, + & *, + & ::before, + & ::after { + box-sizing: border-box; + } + + display: grid; + row-gap: 1.875rem; + font-family: 'Open Sans', system-ui, sans-serif; + + #give-in-plugin-upsells & { + margin-top: 2rem; + margin-bottom: 0.5rem; + } + + .give_forms_page_give-payment-history &, + .give_forms_page_give-donors &, + .post-type-give_forms.post-new-php &, + .post-type-give_forms.edit-php & { + background-color: #fff; + margin: -10px -20px 30px -20px; + border-bottom: 1px solid #dbdbdb; + padding: 30px 20px; + } +} + +.give-sale-banner { + position: relative; + display: flex; + justify-content: space-between; + background: #1D202F; + min-height: 180px; + --banner-y-pad: 0.6875em; + padding-top: var(--banner-y-pad); + padding-bottom: var(--banner-y-pad); + padding-left: 3.25em; + padding-right: 1.3125em; + box-shadow: 0 0.0625em 0.25em rgba(0, 0, 0, 0.25); + font-size: clamp(max(0.875rem, 14px), 2vw, max(1rem, 16px)); + color: #F9FAF9; +} + +.give-sale-banner-content { + display: flex; + align-items: center; + justify-content: space-between; + width: 75%; + + & * { + font-size: inherit; + font-family: Neurial Grotesk; + } + + & a { + display: inline-block; + color: inherit; + font-weight: 700; + text-decoration-thickness: 0.05em; + transform-style: preserve-3d; + font-size: 0.875rem; + font-family: Inconsolata; + + + &::after { + content: ""; + position: absolute; + transform: translateZ(-1px); + display: block; + background-color: #fff; + height: calc(100% + 0.2em); + width: calc(100% + 0.6em); + top: -0.1em; + left: -0.3em; + opacity: 0; + box-shadow: 0 0.0625em 0.125em rgba(0, 0, 0, 0.05); + transition: opacity 0.2s ease-in-out; + } + + &:focus { + outline: none; + box-shadow: none; + } + } + + &__primary-cta { + flex: 1; + + > h1 { + font-size: 1.5rem; + font-style: normal; + font-weight: 700; + line-height: normal; + color: #F9FAF9; + } + + > p { + font-size: 1.375rem; + font-style: normal; + font-weight: 400; + line-height: normal; + } + + > a { + margin-top: 1.125rem; + display: inline-flex; + padding: 0.73125rem 1.6714375rem; + justify-content: center; + align-items: center; + background: #62B265; + border-radius: 9999px; + text-decoration: none; + } + } + + &__secondary-cta { + flex: 1; + display: flex; + flex-direction: column; + gap: 1.125rem; + } + + & p { + display: flex; + flex-wrap: wrap; + row-gap: 0.25rem; + column-gap: 0.9375em; + margin: 0; + line-height: 1.37; + } +} + +.give-sale-banner-action { + margin-top: .25rem; + + &__abstract-icon { + position: absolute; + bottom: 0; + right: 0; + } +} + +.give-sale-banner-dismiss { + --size: 1.25rem; + /* Artificially align this with the sale icon, since we shouldn’t use align-items: center on the banner */ + margin-top: calc((var(--sale-icon-size) - var(--size)) / 2); + appearance: none; + background: none; + display: grid; + place-content: center; + padding: 0; + width: var(--size); + height: var(--size); + border: 0; + border-radius: 9999px; + outline-offset: 0.25rem; + color: inherit; + cursor: pointer; + font-size: inherit; + transition: color 0.2s, transform 0.2s; + + & svg { + width: var(--size); + height: var(--size); + transition: fill 200ms ease-in-out; + + fill: none; + + /* This ensures that the event target is the button when clicked. */ + pointer-events: none; + } + + &:hover { + transform: scale(1.15); + } + + &:active { + transform: scale(0.95); + } +} + + +@media screen and (max-width: 1200px) { + .give-sale-banner-content { + gap: 1rem; + width: 60%; + } +} + +@media screen and (max-width: 900px) { + .give-sale-banner-content { + flex-direction: column; + align-items: flex-start; + } +} + +@media screen and (max-width: 650px) { + .give-sale-banner-content__secondary-cta { + display: none; + } + .give-sale-banner-action__abstract-icon { + max-width: 6.25rem; + max-height: 7.8125rem; + } +} From 47c9518f36b7e3be543e774a796046b445c2d1a4 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Mon, 17 Jul 2023 16:11:10 -0700 Subject: [PATCH 08/27] feature: update webpack --- webpack.mix.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack.mix.js b/webpack.mix.js index cbc7ecb8ce..a15bc0ac7e 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -18,6 +18,7 @@ mix.setPublicPath('assets/dist') .sass('src/Views/Form/Templates/Classic/resources/css/form.scss', 'css/give-classic-template.css') .sass('src/MultiFormGoals/resources/css/common.scss', 'css/multi-form-goal-block.css') .sass('src/DonationSummary/resources/css/summary.scss', 'css/give-donation-summary.css') + .sass('assets/src/css/admin/summer-sales-banner.scss', 'css/admin-summer-sales-banner.css') .js('assets/src/js/frontend/give.js', 'js/') .js('assets/src/js/frontend/give-stripe.js', 'js/') From d2ac4d25a7aa1736e73907c90894c54b58a222dd Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Tue, 18 Jul 2023 14:40:08 -0700 Subject: [PATCH 09/27] feature: check for valid licenses prior to rendering banner info. --- .../InPluginUpsells/SummerSalesBanner.php | 99 +++++++++++++------ 1 file changed, 68 insertions(+), 31 deletions(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index 22353831b1..01c4b4b215 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -14,42 +14,41 @@ class SummerSalesBanner extends SaleBanners */ public function getBanners(): array { + $commonBannerInfo = [ + 'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'), + 'leadHeader' => __('Make it yours.', 'give'), + 'contentText' => __( + 'Purchase any StellarWP product during the sale and get 100% off WP Business Reviews and take 40% off all other brands.', + 'give' + ), + 'actionText' => __('Shop Now', 'give'), + 'alternateActionText' => __('View all StellarWP Deals', 'give'), + 'actionURL' => 'https://go.givewp.com/ss23give', + 'alternateActionURL' => 'https://go.givewp.com/ss23stellar', + 'startDate' => '2023-07-16 00:00', + 'endDate' => '2023-07-19 23:59', + ]; + + $has_valid_license = self::hasValidLicenses(); + + if ($has_valid_license) { + return [ + array_merge($commonBannerInfo, [ + 'id' => 'bfgt2023stellar', + 'leadText' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), + ]), + ]; + } + return [ - [ - 'id' => 'bfgt2023', - 'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'), - 'leadHeader' => __('Make it stellar.', 'give'), + array_merge($commonBannerInfo, [ + 'id' => 'bfgt2023givewp', 'leadText' => __('Save 30% on all StellarWP products.', 'give'), - 'contentText' => __( - 'Purchase any StellarWP product during the sale and get 100% off WP Business Reviews and take 40% off all other brands.', - 'give' - ), - 'actionText' => __('Shop Now', 'give'), - 'alternateActionText' => __('View all StellarWP Deals', 'give'), - 'actionURL' => 'https://go.givewp.com/ss23give', - 'alternateActionURL' => 'https://go.givewp.com/ss23stellar', - 'startDate' => '2023-07-16 00:00', - 'endDate' => '2023-07-19 23:59', - ], - [ - 'id' => 'bfgt2023', - 'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'), - 'leadHeader' => __('Make it yours.', 'give'), - 'leadText' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), - 'contentText' => __( - 'Purchase any StellarWP product during the sale and get 100% off WP Business Reviews and take 40% off all other brands.', - 'give' - ), - 'actionText' => __('Shop Now', 'give'), - 'alternateActionText' => __('View all StellarWP Deals', 'give'), - 'actionURL' => 'https://go.givewp.com/ss23give', - 'alternateActionURL' => 'https://go.givewp.com/ss23stellar', - 'startDate' => '2023-07-16 00:00', - 'endDate' => '2023-07-19 23:59', - ], + ]), ]; } + /** * @unrleased */ @@ -103,4 +102,42 @@ public static function isShowing(): bool return $pagenow === 'plugins.php'; } + + /** + * @unreleased + */ + public static function hasValidLicenses(): bool + { + $requiredPluginSlugs = [ + 'recurring' => 'give-recurring', + 'form_field_manager' => 'give-form-field-manager', + 'fee_recovery' => 'give-fee-recovery', + 'manual_donations' => 'give-manual-donations', + 'peer_to_peer' => 'give-peer-to-peer', + ]; + + + return sort($requiredPluginSlugs) === sort(self::getAllExistingLicenseSlugs()); + } + + /** + * @unreleased + */ + public static function getAllExistingLicenseSlugs(): array + { + $pluginSlugs = []; + $licenses = get_option("give_licenses", []); + + foreach ($licenses as $license) { + if (isset($license['is_all_access_pass']) && $license['is_all_access_pass'] && ! empty($license['download'])) { + $slugs = array_column($license['download'], 'plugin_slug'); + $pluginSlugs = array_merge($pluginSlugs, $slugs); + } else { + $pluginSlugs[] = $license['plugin_slug']; + } + } + + return $pluginSlugs; + } } + From 38630bec5cd9a89d7860c27275914bd9c0ab9494 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Tue, 18 Jul 2023 14:45:31 -0700 Subject: [PATCH 10/27] fix: remove items causing failed build check --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index 01c4b4b215..112beb0ed9 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -52,7 +52,7 @@ public function getBanners(): array /** * @unrleased */ - public function loadScripts(): void + public function loadScripts() { wp_enqueue_script( 'give-in-plugin-upsells-sale-banners', @@ -74,7 +74,6 @@ public function loadScripts(): void wp_enqueue_style( 'give-in-plugin-upsells-summer-sales-banner', GIVE_PLUGIN_URL . 'assets/dist/css/admin-summer-sales-banner.css', - '1.0.0', ); wp_enqueue_style('givewp-admin-fonts'); @@ -83,7 +82,7 @@ public function loadScripts(): void /** * @unreleased */ - public function render(): void + public function render() { $banners = $this->getVisibleBanners(); From 55e3e72ab12e226c2ec294d23e8c2809550150bc Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Tue, 18 Jul 2023 15:24:27 -0700 Subject: [PATCH 11/27] Refactor: update styles --- assets/src/css/admin/summer-sales-banner.scss | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/assets/src/css/admin/summer-sales-banner.scss b/assets/src/css/admin/summer-sales-banner.scss index a8ba6d8d83..c0ccd6c41e 100644 --- a/assets/src/css/admin/summer-sales-banner.scss +++ b/assets/src/css/admin/summer-sales-banner.scss @@ -6,25 +6,6 @@ & ::after { box-sizing: border-box; } - - display: grid; - row-gap: 1.875rem; - font-family: 'Open Sans', system-ui, sans-serif; - - #give-in-plugin-upsells & { - margin-top: 2rem; - margin-bottom: 0.5rem; - } - - .give_forms_page_give-payment-history &, - .give_forms_page_give-donors &, - .post-type-give_forms.post-new-php &, - .post-type-give_forms.edit-php & { - background-color: #fff; - margin: -10px -20px 30px -20px; - border-bottom: 1px solid #dbdbdb; - padding: 30px 20px; - } } .give-sale-banner { From 5b867dbe524a9a8e1544be15dc80eb50f1c35953 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Tue, 18 Jul 2023 15:24:58 -0700 Subject: [PATCH 12/27] refactor: replace banners with banner --- .../InPluginUpsells/SummerSalesBanner.php | 16 ++- .../resources/views/summer-sales-banner.php | 131 ++++++++---------- 2 files changed, 70 insertions(+), 77 deletions(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index 112beb0ed9..da14f65150 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -15,7 +15,7 @@ class SummerSalesBanner extends SaleBanners public function getBanners(): array { $commonBannerInfo = [ - 'accessibleLabel' => __('Black Friday/Giving Tuesday Sale', 'give'), + 'accessibleLabel' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), 'leadHeader' => __('Make it yours.', 'give'), 'contentText' => __( 'Purchase any StellarWP product during the sale and get 100% off WP Business Reviews and take 40% off all other brands.', @@ -29,9 +29,9 @@ public function getBanners(): array 'endDate' => '2023-07-19 23:59', ]; - $has_valid_license = self::hasValidLicenses(); + $hasValidLicenses = self::hasValidLicenses(); - if ($has_valid_license) { + if ($hasValidLicenses) { return [ array_merge($commonBannerInfo, [ 'id' => 'bfgt2023stellar', @@ -84,9 +84,9 @@ public function loadScripts() */ public function render() { - $banners = $this->getVisibleBanners(); + $banner = $this->getVisibleBanners(); - if ( ! empty($banners)) { + if ( ! empty($banner)) { include __DIR__ . '/resources/views/summer-sales-banner.php'; } } @@ -115,14 +115,16 @@ public static function hasValidLicenses(): bool 'peer_to_peer' => 'give-peer-to-peer', ]; + $licensedPluginSlugs = self::getLicensedPluginSlugs(); - return sort($requiredPluginSlugs) === sort(self::getAllExistingLicenseSlugs()); + + return sort($requiredPluginSlugs) === sort($licensedPluginSlugs); } /** * @unreleased */ - public static function getAllExistingLicenseSlugs(): array + public static function getLicensedPluginSlugs(): array { $pluginSlugs = []; $licenses = get_option("give_licenses", []); diff --git a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php index 6aca22f2b6..9fbf01e72b 100644 --- a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php +++ b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php @@ -1,80 +1,71 @@ - From a921166816e5018634efb07f2a81b90ea843aa85 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Wed, 19 Jul 2023 09:37:25 -0700 Subject: [PATCH 13/27] Refactor: split links --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index da14f65150..757392ce00 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -23,7 +23,6 @@ public function getBanners(): array ), 'actionText' => __('Shop Now', 'give'), 'alternateActionText' => __('View all StellarWP Deals', 'give'), - 'actionURL' => 'https://go.givewp.com/ss23give', 'alternateActionURL' => 'https://go.givewp.com/ss23stellar', 'startDate' => '2023-07-16 00:00', 'endDate' => '2023-07-19 23:59', @@ -36,6 +35,7 @@ public function getBanners(): array array_merge($commonBannerInfo, [ 'id' => 'bfgt2023stellar', 'leadText' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), + 'actionURL' => 'https://go.givewp.com/ss23give', ]), ]; } @@ -44,6 +44,7 @@ public function getBanners(): array array_merge($commonBannerInfo, [ 'id' => 'bfgt2023givewp', 'leadText' => __('Save 30% on all StellarWP products.', 'give'), + 'actionURL' => 'https://go.givewp.com/ss23stellar', ]), ]; } From edd43546804d2c15676cc636540a50c0b3a54cee Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Wed, 19 Jul 2023 10:58:42 -0700 Subject: [PATCH 14/27] fix: add acurate display dates --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index 757392ce00..d7cb182ac8 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -24,8 +24,8 @@ public function getBanners(): array 'actionText' => __('Shop Now', 'give'), 'alternateActionText' => __('View all StellarWP Deals', 'give'), 'alternateActionURL' => 'https://go.givewp.com/ss23stellar', - 'startDate' => '2023-07-16 00:00', - 'endDate' => '2023-07-19 23:59', + 'startDate' => '2023-07-24 00:00', + 'endDate' => '2023-07-31 23:59', ]; $hasValidLicenses = self::hasValidLicenses(); From 076fa80dbec0020c567012d6c2871111fa08f634 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Wed, 19 Jul 2023 12:40:05 -0700 Subject: [PATCH 15/27] fix: update default value --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index d7cb182ac8..f6f1ad2a4a 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -75,6 +75,7 @@ public function loadScripts() wp_enqueue_style( 'give-in-plugin-upsells-summer-sales-banner', GIVE_PLUGIN_URL . 'assets/dist/css/admin-summer-sales-banner.css', + [], ); wp_enqueue_style('givewp-admin-fonts'); From 19c02d6f44bf91d970829c252d497840cb58edd2 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Wed, 19 Jul 2023 12:53:27 -0700 Subject: [PATCH 16/27] fix: add version --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index f6f1ad2a4a..b51708f0f5 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -76,6 +76,7 @@ public function loadScripts() 'give-in-plugin-upsells-summer-sales-banner', GIVE_PLUGIN_URL . 'assets/dist/css/admin-summer-sales-banner.css', [], + GIVE_VERSION, ); wp_enqueue_style('givewp-admin-fonts'); From ed4c6485c77208c382c4f94fb0dbaf13cdef610b Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Wed, 19 Jul 2023 13:49:59 -0700 Subject: [PATCH 17/27] fix: remove trailing comma --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index b51708f0f5..2ed087da53 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -76,7 +76,7 @@ public function loadScripts() 'give-in-plugin-upsells-summer-sales-banner', GIVE_PLUGIN_URL . 'assets/dist/css/admin-summer-sales-banner.css', [], - GIVE_VERSION, + GIVE_VERSION ); wp_enqueue_style('givewp-admin-fonts'); From 91a0884c3a5ef6c7aaae70f4ce64586d087f4f0a Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Thu, 20 Jul 2023 10:02:52 -0700 Subject: [PATCH 18/27] doc: add unreleased tags --- .../InPluginUpsells/resources/views/summer-sales-banner.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php index 9fbf01e72b..66eb9cd92f 100644 --- a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php +++ b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php @@ -1,4 +1,7 @@ Date: Thu, 20 Jul 2023 13:05:36 -0700 Subject: [PATCH 19/27] fix: remove paths --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 2 -- src/Promotions/ServiceProvider.php | 4 ---- 2 files changed, 6 deletions(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index 2ed087da53..e8dfd349b0 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -2,8 +2,6 @@ namespace Give\Promotions\InPluginUpsells; -use Give\Framework\Shims\Shim; - /** * @unrleased */ diff --git a/src/Promotions/ServiceProvider.php b/src/Promotions/ServiceProvider.php index e0e84051df..48ff27e498 100644 --- a/src/Promotions/ServiceProvider.php +++ b/src/Promotions/ServiceProvider.php @@ -4,15 +4,11 @@ use Give\Helpers\Hooks; use Give\Promotions\FreeAddonModal\Controllers\CompleteRestApiEndpoint; -use Give\Promotions\FreeAddonModal\Controllers\DisplaySettingsButton; -use Give\Promotions\FreeAddonModal\Controllers\EnqueueModal; -use Give\Promotions\FreeAddonModal\Controllers\PreventFreshInstallPromotion; use Give\Promotions\InPluginUpsells\AddonsAdminPage; use Give\Promotions\InPluginUpsells\Endpoints\HideSaleBannerRoute; use Give\Promotions\InPluginUpsells\Endpoints\ProductRecommendationsRoute; use Give\Promotions\InPluginUpsells\LegacyFormEditor; use Give\Promotions\InPluginUpsells\PaymentGateways; -use Give\Promotions\InPluginUpsells\RecurringDonationsTab; use Give\Promotions\InPluginUpsells\SaleBanners; use Give\Promotions\InPluginUpsells\SummerSalesBanner; use Give\ServiceProviders\ServiceProvider as ServiceProviderContract; From 3db8245b5215e00f5734ad317dc9d37636ba5144 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Thu, 20 Jul 2023 13:09:28 -0700 Subject: [PATCH 20/27] fix: swap ids --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index e8dfd349b0..27f272992d 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -31,7 +31,7 @@ public function getBanners(): array if ($hasValidLicenses) { return [ array_merge($commonBannerInfo, [ - 'id' => 'bfgt2023stellar', + 'id' => 'bfgt2023givewp', 'leadText' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), 'actionURL' => 'https://go.givewp.com/ss23give', ]), @@ -40,7 +40,7 @@ public function getBanners(): array return [ array_merge($commonBannerInfo, [ - 'id' => 'bfgt2023givewp', + 'id' => 'bfgt2023stellar', 'leadText' => __('Save 30% on all StellarWP products.', 'give'), 'actionURL' => 'https://go.givewp.com/ss23stellar', ]), From b251d1581bfafeb7dde08d1ad1fc7fce328c4475 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Thu, 20 Jul 2023 13:53:40 -0700 Subject: [PATCH 21/27] fix: hide svg overflow --- assets/src/css/admin/summer-sales-banner.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/src/css/admin/summer-sales-banner.scss b/assets/src/css/admin/summer-sales-banner.scss index c0ccd6c41e..db19069664 100644 --- a/assets/src/css/admin/summer-sales-banner.scss +++ b/assets/src/css/admin/summer-sales-banner.scss @@ -6,6 +6,8 @@ & ::after { box-sizing: border-box; } + + overflow: hidden; } .give-sale-banner { From d4208ce849a80a2da0d5a07dee06c10aa776d5d8 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Thu, 20 Jul 2023 15:22:50 -0700 Subject: [PATCH 22/27] fix: add link on mobile view - update responsive styles --- assets/src/css/admin/summer-sales-banner.scss | 45 +++++++++++-------- .../resources/views/summer-sales-banner.php | 9 +++- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/assets/src/css/admin/summer-sales-banner.scss b/assets/src/css/admin/summer-sales-banner.scss index db19069664..7d8e6df1b1 100644 --- a/assets/src/css/admin/summer-sales-banner.scss +++ b/assets/src/css/admin/summer-sales-banner.scss @@ -29,16 +29,16 @@ .give-sale-banner-content { display: flex; align-items: center; - justify-content: space-between; - width: 75%; + justify-content: flex-start; + gap: 3rem; + width: 70%; & * { font-size: inherit; font-family: Neurial Grotesk; } - & a { - display: inline-block; + a { color: inherit; font-weight: 700; text-decoration-thickness: 0.05em; @@ -69,7 +69,7 @@ } &__primary-cta { - flex: 1; + width: fit-content; > h1 { font-size: 1.5rem; @@ -86,7 +86,8 @@ line-height: normal; } - > a { + + &-link { margin-top: 1.125rem; display: inline-flex; padding: 0.73125rem 1.6714375rem; @@ -95,6 +96,14 @@ background: #62B265; border-radius: 9999px; text-decoration: none; + margin-right: auto; + } + + &-mobile-link { + display: none; + margin: 1rem 0 0 1rem; + color: #fff; + background: none; } } @@ -164,27 +173,27 @@ } } - -@media screen and (max-width: 1200px) { - .give-sale-banner-content { - gap: 1rem; - width: 60%; - } -} - -@media screen and (max-width: 900px) { +@media screen and (max-width: 1100px) { .give-sale-banner-content { flex-direction: column; align-items: flex-start; } } -@media screen and (max-width: 650px) { +@media screen and (max-width: 770px) { + .give-sale-banner { + padding-left: 1rem; + } .give-sale-banner-content__secondary-cta { display: none; } + + .give-sale-banner-content__primary-cta-mobile-link { + display: inline-block; + } + .give-sale-banner-action__abstract-icon { - max-width: 6.25rem; - max-height: 7.8125rem; + max-width: 8.25rem; + max-height: 9.5rem; } } diff --git a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php index 66eb9cd92f..e333a8955f 100644 --- a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php +++ b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php @@ -29,8 +29,13 @@ class="give-sale-banner">
From a9a9312ed603b92acb3428c35baa4428eee96a7d Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Fri, 21 Jul 2023 09:06:15 -0700 Subject: [PATCH 23/27] fix: update sort --- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index 27f272992d..e863f7b804 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -118,8 +118,10 @@ public static function hasValidLicenses(): bool $licensedPluginSlugs = self::getLicensedPluginSlugs(); + sort($requiredPluginSlugs); + sort($licensedPluginSlugs); - return sort($requiredPluginSlugs) === sort($licensedPluginSlugs); + return $requiredPluginSlugs == $licensedPluginSlugs; } /** From 164b8d95d01d544c859466decdcbd1a811b440be Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Fri, 21 Jul 2023 09:19:10 -0700 Subject: [PATCH 24/27] fix: swap banner info --- .../InPluginUpsells/SummerSalesBanner.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index e863f7b804..c99847c0e6 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -31,18 +31,19 @@ public function getBanners(): array if ($hasValidLicenses) { return [ array_merge($commonBannerInfo, [ - 'id' => 'bfgt2023givewp', - 'leadText' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), - 'actionURL' => 'https://go.givewp.com/ss23give', + 'id' => 'bfgt2023stellar', + 'leadText' => __('Save 30% on all StellarWP products.', 'give'), + 'actionURL' => 'https://go.givewp.com/ss23stellar', ]), ]; } return [ array_merge($commonBannerInfo, [ - 'id' => 'bfgt2023stellar', - 'leadText' => __('Save 30% on all StellarWP products.', 'give'), - 'actionURL' => 'https://go.givewp.com/ss23stellar', + 'id' => 'bfgt2023givewp', + 'leadText' => __('Save 30% on all GiveWP Pricing Plans.', 'give'), + 'actionURL' => 'https://go.givewp.com/ss23give', + ]), ]; } From 27f95df70c66eeb083b8f171b6faf998bd7263fd Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Fri, 21 Jul 2023 13:30:08 -0700 Subject: [PATCH 25/27] fix: load additional font, add defaults, improve button accessability --- assets/src/css/admin/summer-sales-banner.scss | 25 ++++---- .../InPluginUpsells/SummerSalesBanner.php | 8 +++ .../resources/views/summer-sales-banner.php | 57 +++++++++---------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/assets/src/css/admin/summer-sales-banner.scss b/assets/src/css/admin/summer-sales-banner.scss index 7d8e6df1b1..0bd2d92423 100644 --- a/assets/src/css/admin/summer-sales-banner.scss +++ b/assets/src/css/admin/summer-sales-banner.scss @@ -35,7 +35,7 @@ & * { font-size: inherit; - font-family: Neurial Grotesk; + font-family: 'Neurial Grotesk', Montserrat, sans-serif; } a { @@ -44,8 +44,6 @@ text-decoration-thickness: 0.05em; transform-style: preserve-3d; font-size: 0.875rem; - font-family: Inconsolata; - &::after { content: ""; @@ -88,6 +86,7 @@ &-link { + font-family: 'Inconsolata', Montserrat, sans-serif;; margin-top: 1.125rem; display: inline-flex; padding: 0.73125rem 1.6714375rem; @@ -124,20 +123,17 @@ } } -.give-sale-banner-action { - margin-top: .25rem; - - &__abstract-icon { - position: absolute; - bottom: 0; - right: 0; - } +.give-sale-banner__abstract-icon { + position: absolute; + bottom: 0; + right: 0; } + .give-sale-banner-dismiss { --size: 1.25rem; /* Artificially align this with the sale icon, since we shouldn’t use align-items: center on the banner */ - margin-top: calc((var(--sale-icon-size) - var(--size)) / 2); + //margin-top: calc((var(--sale-icon-size) - var(--size)) / 2); appearance: none; background: none; display: grid; @@ -146,18 +142,17 @@ width: var(--size); height: var(--size); border: 0; - border-radius: 9999px; outline-offset: 0.25rem; color: inherit; cursor: pointer; font-size: inherit; transition: color 0.2s, transform 0.2s; + z-index: 999; & svg { width: var(--size); height: var(--size); transition: fill 200ms ease-in-out; - fill: none; /* This ensures that the event target is the button when clicked. */ @@ -192,7 +187,7 @@ display: inline-block; } - .give-sale-banner-action__abstract-icon { + .give-sale-banner__abstract-icon { max-width: 8.25rem; max-height: 9.5rem; } diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index c99847c0e6..804cc38115 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -79,6 +79,14 @@ public function loadScripts() ); wp_enqueue_style('givewp-admin-fonts'); + + wp_enqueue_style( + 'Inconsolpata', + 'https://fonts.googleapis.com/css2?family=Inconsolata&display=swap', + [], + '1.0', + 'all' + ); } /** diff --git a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php index e333a8955f..d71c87146a 100644 --- a/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php +++ b/src/Promotions/InPluginUpsells/resources/views/summer-sales-banner.php @@ -30,8 +30,8 @@ class="give-sale-banner">

- " rel="noopener" - target="_blank"> +
-
-
- - - - - - - - - - - - -
- - +
+ + + + + + + + + + + +
+
From 75328268edb41b0f5300975db933acc8fd078fc8 Mon Sep 17 00:00:00 2001 From: Joshua Dinh Date: Fri, 21 Jul 2023 13:41:52 -0700 Subject: [PATCH 26/27] fix: alignment --- assets/src/css/admin/summer-sales-banner.scss | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/src/css/admin/summer-sales-banner.scss b/assets/src/css/admin/summer-sales-banner.scss index 0bd2d92423..92011dafe7 100644 --- a/assets/src/css/admin/summer-sales-banner.scss +++ b/assets/src/css/admin/summer-sales-banner.scss @@ -29,7 +29,7 @@ .give-sale-banner-content { display: flex; align-items: center; - justify-content: flex-start; + justify-content: center; gap: 3rem; width: 70%; @@ -179,6 +179,7 @@ .give-sale-banner { padding-left: 1rem; } + .give-sale-banner-content__secondary-cta { display: none; } @@ -192,3 +193,9 @@ max-height: 9.5rem; } } + +@media screen and (max-width: 480px) { + .give-sale-banner-content__primary-cta-mobile-link { + margin-left: 0; + } +} From 159bdfdb84758a8ff2f5a78ac545009fd74f11e2 Mon Sep 17 00:00:00 2001 From: Angela Blake <35241639+angelablake@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:53:17 -0500 Subject: [PATCH 27/27] chore: prepare for 2.31.0 release --- give.php | 4 ++-- readme.txt | 5 ++++- src/Promotions/InPluginUpsells/SummerSalesBanner.php | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/give.php b/give.php index 1d2bb73c31..ff66c4a85b 100644 --- a/give.php +++ b/give.php @@ -6,7 +6,7 @@ * Description: The most robust, flexible, and intuitive way to accept donations on WordPress. * Author: GiveWP * Author URI: https://givewp.com/ - * Version: 2.30.0 + * Version: 2.31.0 * Requires at least: 5.0 * Requires PHP: 7.0 * Text Domain: give @@ -316,7 +316,7 @@ private function setup_constants() { // Plugin version. if (!defined('GIVE_VERSION')) { - define('GIVE_VERSION', '2.30.0'); + define('GIVE_VERSION', '2.31.0'); } // Plugin Root File. diff --git a/readme.txt b/readme.txt index 73df61b0dc..0f92cb0cdb 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: donation, donate, recurring donations, fundraising, crowdfunding Requires at least: 5.0 Tested up to: 6.2 Requires PHP: 7.0 -Stable tag: 2.30.0 +Stable tag: 2.31.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -258,6 +258,9 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri 8. GiveWP has a dedicated support team to help answer any questions you may have and help you through stumbling blocks. == Changelog == += 2.31.0: July 21st, 2023 = +* Feature: New banner added to the plugin page for annual summer discounts + = 2.30.0: July 12th, 2023 = * Feature: Attributes of the [give_donor_wall] shortcode can now be filtered. * Feature: Added state label and list of states for the v3 form billing address block. Existing functionality is not modified. diff --git a/src/Promotions/InPluginUpsells/SummerSalesBanner.php b/src/Promotions/InPluginUpsells/SummerSalesBanner.php index 804cc38115..407f12e866 100644 --- a/src/Promotions/InPluginUpsells/SummerSalesBanner.php +++ b/src/Promotions/InPluginUpsells/SummerSalesBanner.php @@ -90,7 +90,7 @@ public function loadScripts() } /** - * @unreleased + * @since 2.31.0 */ public function render() { @@ -103,7 +103,7 @@ public function render() /** - * @unreleased + * @since 2.31.0 */ public static function isShowing(): bool { @@ -113,7 +113,7 @@ public static function isShowing(): bool } /** - * @unreleased + * @since 2.31.0 */ public static function hasValidLicenses(): bool { @@ -134,7 +134,7 @@ public static function hasValidLicenses(): bool } /** - * @unreleased + * @since 2.31.0 */ public static function getLicensedPluginSlugs(): array {