diff --git a/.distignore b/.distignore index 64695d3653..93e4a2634a 100644 --- a/.distignore +++ b/.distignore @@ -9,6 +9,7 @@ /tests /node_modules /assets/src +/assets/dist/**/*.map /vendor/bin /vendor/composer/installers /vendor/**/*.phar @@ -32,7 +33,6 @@ jsconfig.json globals.d.ts tsconfig.json -cypress.json sample-data/wordpress.sql sample-data/sample-data.numbers bower.json diff --git a/.gitignore b/.gitignore index e98ade911f..1b5241348c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,6 @@ /tmp /tests/bin/tmp -# Cypress -/cypress -/tests/e2e/videos -/tests/e2e/screenshots - # Numerous always-ignore extensions .diff .err diff --git a/assets/src/css/admin/settings.scss b/assets/src/css/admin/settings.scss index 2a80d11d64..324c8493ea 100644 --- a/assets/src/css/admin/settings.scss +++ b/assets/src/css/admin/settings.scss @@ -281,6 +281,7 @@ div.give-field-description { font-size: 14px; } + //-------------------------------------------------------------- // Payment Gateways //-------------------------------------------------------------- diff --git a/assets/src/css/frontend/_card.scss b/assets/src/css/frontend/_card.scss index e4cab92984..8d715e33c9 100644 --- a/assets/src/css/frontend/_card.scss +++ b/assets/src/css/frontend/_card.scss @@ -9,9 +9,9 @@ .give-card { background-color: white; - border: 1px solid $give-card-border; - box-shadow: 0 1px 1px rgba( 0, 0, 0, 0.04 ); - color: inherit; + border-radius: 8px; + box-shadow: 0px 0px 8px rgba(112, 111, 111, 0.25); + color: inherit; display: flex; flex-direction: column; width: 100%; diff --git a/assets/src/css/frontend/_components.donor.scss b/assets/src/css/frontend/_components.donor.scss index 1f26bc0828..2da3a309fd 100644 --- a/assets/src/css/frontend/_components.donor.scss +++ b/assets/src/css/frontend/_components.donor.scss @@ -5,17 +5,34 @@ /** * Single donor with user image, details, and review text. * - * 1. Header wraps the user photo and details. It displays above review text. - * 2. Image is the image of the donor. - * 3. Details include the donor's name, amount given, and date of the donation. + * 1. Card Container wraps the Image, Name, Content & Details. It displays above the tribute message. + * 2. Content includes the donor comment + * 4. Details include the forms title & amount given. */ +@use "sass:string"; + +$MIN_REM_SIZE: 16px; + +/** + * Safely use rem values in distributed code for unpredictable environments (e.g. for use inside a WordPress plugin). + * + * This does not support IE 11 and a few other outdated browser. + * A Sass mixin could be used to provide a fallback value for this. + * + * @param {Number} $value + * @return {String} e.g. for $value: 3 and $MIN_REM_SIZE: 16px => max(3rem, 48px) + */ +@function safe-rem($value) { + @return string.unquote("max(#{$value}rem, #{$value * $MIN_REM_SIZE})"); +} + /*-------------------------------------------------------------- # Spacing --------------------------------------------------------------*/ $donor-space: 20px; -$donor-color: #333; +$donor-color: #00160A; $donor-space-eighth: $donor-space * 0.125; $donor-space-quarter: $donor-space * 0.25; $donor-space-fifth: $donor-space * 0.2; @@ -27,117 +44,177 @@ $donor-space-and-three-quarters: $donor-space * 1.75; $donor-space-double: $donor-space * 2; $donor-space-triple: $donor-space * 3; + .give-donor { - border: 1px solid $give-card-border; - background: #fff; - color: $donor-color; - font-size: 1em; - margin-bottom: $donor-space; - padding: $donor-space; - position: relative; - transition: all 0.2s ease-out; - width: 100%; - - &__header { - - /* [1] */ - align-items: center; - display: flex; - } - - &__image { - - /* [2] */ - display: flex; - align-items: center; - justify-content: center; - - background: #fff; - margin-right: $donor-space-half; - overflow: hidden; - border-radius: 50%; - flex-basis: 40%; - - position: relative; - - img { - object-fit: cover; - width: 100%; - } - - .give-donor__name_initial { - position: absolute; - } - - &[data-anonymous-donation='0'] img[src*='anonymous-user.svg'], - &[data-anonymous-donation='1'] .give-donor__name_initial { - visibility: hidden; - } - - &[data-anonymous-donation='0'][data-has-valid-gravatar='0'] { - border: 1px solid $give-card-border; - } - } - - &__details { - - /* [3] */ - flex-grow: 1; - overflow: hidden; - flex-basis: 60%; - } - - &__name { - font-size: 1em !important; - font-weight: bold !important; - color: $donor-color !important; - line-height: 1.3 !important; - margin: 0 !important; - padding: 0 !important; - } - - &__timestamp { - color: $donor-color !important; - display: block; - font-size: 75% !important; - line-height: 1.3 !important; - } - - &__content { - margin-top: $donor-space-half; - width: 100%; - - p { - color: $donor-color; - font-size: 1em !important; - font-size: 1em !important; - line-height: 1.5 !important; - margin: 0 0 $donor-space !important; - padding: 0 !important; - width: 100%; - } - - &:first-child { - margin-top: 0 !important; - } - - & :last-child { - margin-bottom: 0 !important; - } - } - - &__read-more { - cursor: pointer; - white-space: nowrap; - } - - &__excerpt + &__comment { - display: none; - } + position: relative; + display: flex; + flex-direction: column; + justify-content: space-between; + width:100%; + max-height: 100%; + padding: 18px 0; + margin-bottom: $donor-space; + border: 1px solid $give-card-border; + background: #fff; + color: $donor-color; + transition: all 0.2s ease-out; + + &-container { + flex: 1; + display: flex; + flex-direction: column; + padding: 0 5%; + + &__image { + align-self: center; + display: flex; + align-items: center; + justify-content: center; + background: #fff; + overflow: hidden; + border-radius: 50%; + border: 1px solid $give-card-border; + margin-bottom: 12px; + + img { + object-fit: cover; + object-position: center; + width: 100%; + } + + &__name_initial { + position: absolute; + } + + &[data-anonymous-donation='0'] img[src*='anonymous-user.svg'], + &[data-anonymous-donation='1'] .give-donor-header__name_initial { + visibility: hidden; + } + + &[data-anonymous-donation='0'][data-has-valid-gravatar='0'] { + border: 1px solid $give-card-border; + } + } + + &__name { + width: 100%; + margin: 0 0 10px 0 !important; + font-size: safe-rem(1.5); + font-weight: 600; + text-align: center; + line-height: 20px; + } + } + + /* [1] */ + &-wrapper { + flex: 1; + display: flex; + justify-content: center; + align-items: center; + } + + &-content { + flex: 1; + width: 100%; + margin-bottom: 20px; + line-height: 20px; + padding-left: 16px; + border-left: 2px solid #219653; + font-weight: 400; + letter-spacing: 0; + + p { + width: 100%; + color: $donor-color; + font-size: safe-rem(.875); + font-style: italic; + line-height: 20px; + margin: 0 !important; + } + + &__excerpt &__read-more { + cursor: pointer; + white-space: nowrap; + } + + &__excerpt + &__comment { + display: none; + } + } + + + /* [2] */ + + &-details { + display: flex; + align-items: center; + justify-content: space-between; + + &__wrapper { + display: flex; + flex-direction: column; + width: 100%; + + span:first-child { + color: $donor-color; + font-size: safe-rem(1) !important;; + font-weight: 500 !important;; + letter-spacing: 0; + } + + span:last-child { + color: $donor-color; + font-size: safe-rem(0.8); + font-weight: 400; + letter-spacing: 0; + text-align: left; + } + } + + &__total { + color: #219653; + font-size: safe-rem(1.25); + font-weight: 700; + line-height: 24px; + letter-spacing: 0; + text-align: right; + overflow-wrap: normal; + } + } + + /* [3] */ + + &-tribute{ + display: flex; + align-items: center; + width: 100%; + min-height: 32px; + margin-top: 32px; + + span { + svg { + display: block; + height: 22px; + width: 22px; + margin: 0 15px 0 32px; + } + } + + &__message { + font-size: safe-rem(0.75); + color: $donor-color; + text-align: center; + + span:last-child { + font-weight: 600; + } + } + } } .give-donor-wall-modal { - p:last-child { - margin-bottom: 0; - } + p:last-child { + margin-bottom: 0; + } } diff --git a/assets/src/css/frontend/form-grid.scss b/assets/src/css/frontend/form-grid.scss index 53cf3c8b91..0d615ba603 100644 --- a/assets/src/css/frontend/form-grid.scss +++ b/assets/src/css/frontend/form-grid.scss @@ -1,3 +1,125 @@ +@use "sass:string"; + +$MIN_REM_SIZE: 16px; + +/** + * Safely use rem values in distributed code for unpredictable environments (e.g. for use inside a WordPress plugin). + * + * This does not support IE 11 and a few other outdated browser. + * A Sass mixin could be used to provide a fallback value for this. + * + * @param {Number} $value + * @return {String} e.g. for $value: 3 and $MIN_REM_SIZE: 16px => max(3rem, 48px) + */ +@function safe-rem($value) { + @return string.unquote("max(#{$value}rem, #{$value * $MIN_REM_SIZE})"); +} + + +.give-form-grid { + display: flex; + height: 100%; + + &-media { + position: relative; + min-width: 40%; + border-radius: 2px; + + img { + min-width: 100%; + border-radius: 2px; + object-fit: cover; + } + + &__tags { + position: absolute; + bottom: 0; + left: 0; + right: 0; + display: flex; + align-items: center; + padding: 10px 16px; + border-radius: 2px; + gap: 10px; + + > span { + padding: 4px 10px; + border-radius: 5px; + font-size: safe-rem(.975); + font-weight: 600; + } + } + } + + &-container { + flex-grow: 1; + display: flex; + flex-direction: column; + width: 100%; + + } +} + +#row-media { + max-width: 40%; + min-width: 40%; + + img{ + width: 100%; + min-height:100%; + border-radius: 2px; + object-fit: cover; + } +} + +.give-form-grid-content { + flex-grow: 1; + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: flex-start; + padding: 18px; + + .give-form-grid-media__tags_no_image { + display: flex; + background: none; + margin-bottom: 12px; + border-radius: 2px; + gap: 10px; + + > span { + padding: 4px 10px; + border-radius: 5px; + font-size: safe-rem(.975); + font-weight: 600; + } + + } + + & > h3 { + font-size: safe-rem(1.375) !important; + font-weight: 700 !important; + margin: 0 !important; + } + + & > p { + font-size: 1rem; + font-weight: 400; + } + + & > button { + background-color: transparent!important; + padding: 0; + border: none; + font-size: safe-rem(1); + font-weight: 400; + text-decoration: underline; + text-underline-offset: 5px; + cursor: pointer; + + } +} + .give-form-grid-btn { justify-content: center; align-items: center; @@ -8,7 +130,7 @@ color: #fff; text-align: center; font-family: inherit; - font-size: 1.375rem; + font-size: safe-rem(1); font-weight: 600; line-height: 1.2; diff --git a/assets/src/css/frontend/progress-bar.scss b/assets/src/css/frontend/progress-bar.scss index fd42bfcdaf..0d6bc7cea9 100644 --- a/assets/src/css/frontend/progress-bar.scss +++ b/assets/src/css/frontend/progress-bar.scss @@ -7,38 +7,58 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License */ + + .give-goal-progress { - margin-bottom: 20px; - clear:both; - - .income { - font-size: 46px; - line-height: 48px; - letter-spacing: -1px; - color: #333; - } - - .raised { - margin-bottom: 15px; - } + background: #F6F6F6; + padding: 16px 20px; +} + +.raised { + display: flex; + justify-content: space-between; + + &__details { + display: flex; + flex-direction: column; + font-size: 1rem; + + & > span:first-child { + font-weight: 700 !important; + font-size: 1rem; + } + + & > span:last-child { + font-size: 14px; + font-weight: 400; + + } + + &_donations{ + text-align: right; + } + } + } .give-progress-bar { - height: 20px; - position: relative; - background: #EEE; - border-radius: 25px; - overflow: hidden; - - > span { - display: block; - height: 100%; - border-top-right-radius: 8px; - border-bottom-right-radius: 8px; - border-top-left-radius: 20px; - border-bottom-left-radius: 20px; - background-color: rgb(43, 194, 83); - position: relative; - overflow: hidden; - } + position: relative; + height: 12px; + //background: #F1F1F1; + margin-bottom: 10px; + border-radius: 25px; + + > span { + display: block; + height: 100%; + border-top-right-radius: 8px; + border-bottom-right-radius: 8px; + border-top-left-radius: 20px; + border-bottom-left-radius: 20px; + //background-color: rgb(43, 194, 83); + position: relative; + overflow: hidden; + } } + + diff --git a/assets/src/js/frontend/give-donor-wall.js b/assets/src/js/frontend/give-donor-wall.js index 173829ae84..b2009f6eb7 100644 --- a/assets/src/js/frontend/give-donor-wall.js +++ b/assets/src/js/frontend/give-donor-wall.js @@ -14,7 +14,7 @@ class GiveDonorWall { /** * Add events */ - window.addDynamicEventListener( document, 'click', '.give-donor__read-more', GiveDonorWall.readMoreBtnEvent ); + window.addDynamicEventListener( document, 'click', '.give-donor-content__read-more', GiveDonorWall.readMoreBtnEvent ); window.addDynamicEventListener( document, 'click', '.give-donor__load_more', GiveDonorWall.loadMoreBtnEvent ); }, false ); @@ -38,7 +38,7 @@ class GiveDonorWall { jQuery.magnificPopup.open( { items: { - src: evt.target.parentNode.parentNode.parentNode.getElementsByClassName( 'give-donor__comment' )[ 0 ], + src: evt.target.parentNode.parentNode.parentNode.getElementsByClassName( 'give-donor-content__comment' )[ 0 ], type: 'inline', }, mainClass: 'give-modal give-donor-wall-modal', @@ -151,7 +151,7 @@ class GiveDonorWall { gridWraps = Array.from( shortcodeAttrHiddenField.parentNode.querySelectorAll( '.give-grid__item' ) ); gridWraps.forEach( function( gridWrap, index ) { - gravatarContainer = gridWrap.querySelector( '.give-donor__image' ); + gravatarContainer = gridWrap.querySelector( '.give-donor-container__image' ); // Bailout out if already tried to load gravatar. if ( gravatarContainer.classList.contains( 'gravatar-loaded' ) ) { diff --git a/blocks/components/column-selector/index.js b/blocks/components/column-selector/index.js index 7bdb06832b..d1669e5525 100644 --- a/blocks/components/column-selector/index.js +++ b/blocks/components/column-selector/index.js @@ -1,46 +1,19 @@ -import {__} from '@wordpress/i18n'; import cx from 'classnames'; import './style.scss'; -export function Selector({display, selected, onClick}) { +export function Selector({display, selected}) { const displayValue = String(display); - const handleOnClick = () => { - if (onClick instanceof Function) { - onClick(displayValue); - } - }; - return (
- {display === 'best-fit' ? ( -
-
- {__('Best Fit (Responsive)', 'give')} -
-
-
-
-
-
-
-
-
-
-
-
-
- ) : ( <> {Array(display).fill(null).map((val, i) =>
)} - )}
) } @@ -53,7 +26,7 @@ export function Row({children}) { ) } -export default function ({label, onClick, selected, help}) { +export default function ({label, selected, help}) { return (
{label && ( @@ -64,39 +37,35 @@ export default function ({label, onClick, selected, help}) {

{help}

)} - - - - - - - - - - - - - + {selected === '1' ? ( + + + + ) : selected === '2' ? ( + + + + ) : selected === '3' ? ( + + + + ): + + + + }
) } diff --git a/blocks/components/column-selector/style.scss b/blocks/components/column-selector/style.scss index 71d6582684..92117a7a20 100644 --- a/blocks/components/column-selector/style.scss +++ b/blocks/components/column-selector/style.scss @@ -11,19 +11,19 @@ } .give_column_selector { - padding-bottom: 20px; + padding-bottom: 10px; } .give_column_selector_container { - padding: 10px; - display: flex; flex: 1; + display: flex; flex-direction: row; - align-items: stretch; - background-color: #EEEEEE; - border-radius: 2px; + align-items: center; + min-height: 80px; + padding: 10px; gap: 10px; - cursor: pointer; + background-color: #D9D9D9; + border-radius: 2px; .give_column_selector_box { @include column_selector_box; diff --git a/blocks/components/toggle/index.js b/blocks/components/toggle/index.js new file mode 100644 index 0000000000..cc5a62b34f --- /dev/null +++ b/blocks/components/toggle/index.js @@ -0,0 +1,17 @@ +import {__} from '@wordpress/i18n'; +import './style.scss'; + +export default function ({options, onClick, selected}) { + return ( +
+ {options.map((value, i) => { + return (
onClick(value)} + className="give-toggle__option" style={ selected === value ? {background: '#007cba', color: 'white'} : {}}> + {value} +
) + })} +
+ ); +} diff --git a/blocks/components/toggle/style.scss b/blocks/components/toggle/style.scss new file mode 100644 index 0000000000..e5cf56962b --- /dev/null +++ b/blocks/components/toggle/style.scss @@ -0,0 +1,16 @@ +.give-toggle { + display: flex; + min-height: 42px; + margin-bottom: 20px; + border: 1px solid #757575; + border-radius: 2px; + + &__option { + flex:1; + display: flex; + align-items: center; + justify-content: center; + margin: 3px; + cursor: pointer; + } +} diff --git a/blocks/donation-form-grid/class-give-donation-form-grid-block.php b/blocks/donation-form-grid/class-give-donation-form-grid-block.php index b698366c0a..84f66d038e 100644 --- a/blocks/donation-form-grid/class-give-donation-form-grid-block.php +++ b/blocks/donation-form-grid/class-give-donation-form-grid-block.php @@ -121,7 +121,7 @@ public function register_block() { ), 'columns' => array( 'type' => 'string', - 'default' => 'best-fit', + 'default' => '1', ), 'imageSize' => array( 'type' => 'string', @@ -149,7 +149,7 @@ public function register_block() { ), 'showProgressBar' => array( 'type' => 'boolean', - 'default' => false, + 'default' => true, ), 'showFeaturedImage' => array( 'type' => 'boolean', @@ -157,15 +157,19 @@ public function register_block() { ), 'showDonateButton' => array( 'type' => 'boolean', - 'default' => false, + 'default' => true, ), - 'donateButtonBackgroundColor' => array( + 'tagBackgroundColor' => array( 'type' => 'string', - 'default' => '#66bb6a', + 'default' => '#69b86b', ), + 'tagTextColor' => array( + 'type' => 'string', + 'default' => '#ffffff', + ), 'donateButtonTextColor' => array( 'type' => 'string', - 'default' => '#fff', + 'default' => '#69b86b', ), 'displayType' => array( 'type' => 'string', @@ -175,6 +179,18 @@ public function register_block() { 'type' => 'boolean', 'default' => true, ), + 'filter' => array( + 'type' => 'string', + 'default' => 'tags', + ), + 'imageHeightOptions' => array( + 'type' => 'string', + 'default' => 'auto', + ), + 'progressBarColor' => array( + 'type' => 'string', + 'default' => '#69b86b' + ) ), ) ); @@ -205,13 +221,17 @@ public function render_block( $attributes ) { 'excerpt_length' => $attributes['excerptLength'], 'show_featured_image' => $attributes['showFeaturedImage'], 'show_donate_button' => $attributes['showDonateButton'], - 'donate_button_background_color' => $attributes['donateButtonBackgroundColor'], - 'donate_button_text_color' => $attributes['donateButtonTextColor'], + 'tag_background_color' => $attributes['tagBackgroundColor'], + 'tag_text_color' => $attributes['tagTextColor'], + 'donate_button_text_color' => $attributes['donateButtonTextColor'], 'display_style' => $attributes['displayType'], 'paged' => $attributes['paged'], 'image_size' => $attributes['imageSize'], 'image_height' => $attributes['imageHeight'], - ); + 'filter' => $attributes['filter'], + 'image_height_options' => $attributes['imageHeightOptions'], + 'progress_bar_color' => $attributes['progressBarColor'] + ); $html = give_form_grid_shortcode( $parameters ); $html = ! empty( $html ) ? $html : $this->blank_slate(); diff --git a/blocks/donation-form-grid/data/attributes.js b/blocks/donation-form-grid/data/attributes.js index 2bdd1dc463..8afda399cb 100644 --- a/blocks/donation-form-grid/data/attributes.js +++ b/blocks/donation-form-grid/data/attributes.js @@ -41,7 +41,7 @@ const blockAttributes = { }, columns: { type: 'string', - default: 'best-fit', + default: '1', }, imageSize: { type: 'string', @@ -50,6 +50,10 @@ const blockAttributes = { imageHeight: { type: 'string', default: 'auto', + }, + imageHeightOptions: { + type: 'string', + default: 'auto', }, showTitle: { type: 'boolean', @@ -65,7 +69,7 @@ const blockAttributes = { }, showProgressBar: { type: 'boolean', - default: false, + default: true, }, showFeaturedImage: { type: 'boolean', @@ -73,15 +77,19 @@ const blockAttributes = { }, showDonateButton: { type: 'boolean', - default: false, + default: true, }, - donateButtonBackgroundColor: { + tagBackgroundColor: { type: 'string', - default: '#66bb6a', + default: '#69b86b', }, + tagTextColor: { + type: 'string', + default: '#ffffff', + }, donateButtonTextColor: { type: 'string', - default: '#fff', + default: '#69b86b', }, displayType: { type: 'string', @@ -91,6 +99,14 @@ const blockAttributes = { type: 'integer', default: 16 }, + filter: { + type: 'string', + default: 'tags', + }, + progressBarColor: { + type: 'string', + default: '#69b86b' + } }; export default blockAttributes; diff --git a/blocks/donation-form-grid/data/options.js b/blocks/donation-form-grid/data/options.js index e386cd4780..7b920d3493 100644 --- a/blocks/donation-form-grid/data/options.js +++ b/blocks/donation-form-grid/data/options.js @@ -2,6 +2,7 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n' +import giveDonorWallOptions from "../../donor-wall/data/options"; /** * Options data for various form selects @@ -28,11 +29,10 @@ giveFormOptions.order = [ // Form Display Styles giveFormOptions.columns = [ - { value: 'best-fit', label: __( 'Best Fit', 'give' ) }, - { value: '1', label: '1' }, - { value: '2', label: '2' }, - { value: '3', label: '3' }, - { value: '4', label: '4' }, + { value: '1', label: 'Full Width' }, + { value: '2', label: 'Double' }, + { value: '3', label: 'Triple' }, + { value: '4', label: 'Max (4)' }, ]; // Form Display Styles @@ -41,4 +41,17 @@ giveFormOptions.displayType = [ { value: 'modal_reveal', label: __( 'Modal', 'give' ) }, ]; +//Filter +giveFormOptions.filter = [ + { value: 'formIDs', label: __( 'Form ID', 'give' ) }, + { value: 'categories', label: __( 'Categories', 'give' ) }, + { value: 'tags', label: __( 'Tags', 'give' ) }, +]; + +//Image Height +giveFormOptions.imageHeight = [ + { value: 'auto', label: __( 'Auto', 'give' ) }, + { value: 'custom', label: __( 'Custom', 'give' ) }, +] + export default giveFormOptions; diff --git a/blocks/donation-form-grid/edit/inspector.js b/blocks/donation-form-grid/edit/inspector.js index 9baec603b5..012e177c5a 100644 --- a/blocks/donation-form-grid/edit/inspector.js +++ b/blocks/donation-form-grid/edit/inspector.js @@ -3,23 +3,26 @@ */ import {__} from '@wordpress/i18n' import { select } from '@wordpress/data'; -import {InspectorControls, store } from '@wordpress/block-editor'; +import {InspectorControls, PanelColorSettings, store } from '@wordpress/block-editor'; import { ColorPalette, - FormTokenField, + FormTokenField, Panel, PanelBody, SelectControl, TextControl, - ToggleControl + ToggleControl, } from '@wordpress/components'; -import ColumnSelector from '../../components/column-selector'; /** * Internal dependencies */ import giveFormOptions from '../data/options'; +import ColumnSelector from '../../components/column-selector'; + +import './style.scss' + /** * Render Inspector Controls */ @@ -45,9 +48,13 @@ const Inspector = ({attributes, setAttributes}) => { showProgressBar, showFeaturedImage, showDonateButton, - donateButtonBackgroundColor, + tagBackgroundColor, donateButtonTextColor, - displayType + displayType, + filter, + tagTextColor, + imageHeightOptions, + progressBarColor } = attributes; const saveSetting = (name, value) => { @@ -76,208 +83,260 @@ const Inspector = ({attributes, setAttributes}) => { }; }); + const handleImageOptions = (value) => { + saveSetting('imageHeightOptions', value) + saveSetting('imageHeight', value) + } + + const filterValue = () => { + if (filter === 'categories') { + return <> + saveSetting('categories', value)} + /> + +

+ {__('Type the name of your category to add it to the list. Only forms within the categories you choose will be displayed in this grid.', 'give')} +

+ + } else if (filter === 'tags') { + return <> + saveSetting('tags', value)} + /> + +

+ {__('Type the name of your tag to add it to the list. Only forms with these tags you choose will be displayed in this grid.', 'give')} +

+ } else if (filter === 'formIDs'){ + return <> + saveSetting('formIDs', value)} + /> + +

+ {__('Type the ID of your form to add it to the list. Only forms with these IDs you choose will be displayed in this grid.', 'give')} +

+ } + } + return ( - - saveSetting('columns', value)} - help={__('Controls how many columns of the Form Grid appear. "Best Fit" will adjust responsively to the space available.', 'give')} - /> - - saveSetting('showTitle', value)}/> - - saveSetting('showExcerpt', value)} - /> - - saveSetting('excerptLength', Number.parseInt(value) || 0)} - /> - - saveSetting('showGoal', value)} - /> - - {showGoal && ( + + + saveSetting('columns', value)} + help={__('Controls how many columns of the Form Grid appear. "Best Fit" will adjust responsively to the space available.', 'give')} + /> + saveSetting( 'columns', value ) } /> + + + + saveSetting('showTitle', value)}/> + saveSetting('showGoal', value)} + /> + saveSetting('showExcerpt', value)} + /> + saveSetting('showProgressBar', value)} /> - )} - - saveSetting('showFeaturedImage', value)} - /> - - {showFeaturedImage && ( - <> - saveSetting('imageSize', value)} - help={__('Featured image size. Default "medium." Accepts WordPress image sizes, which by default are "thumbnail," "medium," "large," or "full." ', 'give')} - /> - - saveSetting('imageHeight', value)} - help={__('Featured image height. Default "auto". Accepts valid heights in px, em, or rem.', 'give')} - /> - - )} - - saveSetting('showDonateButton', value)} - /> - {showDonateButton && ( - <> -

- {__('Donate Button Background Color', 'give')} -

- saveSetting('donateButtonBackgroundColor', value)} - value={donateButtonBackgroundColor} - /> -

- {__('Donate Button Text Color', 'give')} -

- saveSetting('donateButtonTextColor', value)} - value={donateButtonTextColor} - /> - - )} -
- - - - saveSetting('orderBy', value)} - help={__('The order forms are displayed in.', 'give')} - /> - - saveSetting('order', value)} - help={__('Whether the order ascends or descends.', 'give')} - /> - - saveSetting('categories', value)} - /> - -

- {__('Type the name of your category to add it to the list. Only forms within the categories you choose will be displayed in this grid.', 'give')} -

- - saveSetting('tags', value)} - /> - -

- {__('Type the name of your tag to add it to the list. Only forms with these tags you choose will be displayed in this grid.', 'give')} -

+ saveSetting('showDonateButton', value)} + /> + saveSetting('showFeaturedImage', value)} + /> + {showFeaturedImage && ( + <> + saveSetting('imageSize', value)} + /> + handleImageOptions(value)} + /> + + {imageHeightOptions === 'custom' && saveSetting('imageHeight', value)} + help={__('Featured image height. Default "auto". Accepts valid heights in px, em, or rem.', 'give')}/> + } + + )} +
+
+ + + saveSetting('orderBy', value)} + help={__('The order forms are displayed in.', 'give')} + /> - saveSetting('formIDs', value)} - /> + saveSetting('order', value)} + help={__('Whether the order ascends or descends.', 'give')} + /> + saveSetting( 'filter', value ) } /> -

- {__('Type the ID of your form to add it to the list. Only forms with these IDs you choose will be displayed in this grid.', 'give')} -

+ {filterValue(filter)} - saveSetting('excludeForms', value)} - /> + saveSetting('excludeForms', value)} + /> - {excludeForms && ( - <> - saveSetting('excludedFormIDs', value)} - /> -

- {__('Type the ID of your form to exclude it from the list. Forms with these IDs you choose will not be displayed in this grid.', 'give')} + {excludeForms && ( + <> + saveSetting('excludedFormIDs', value)} + /> +

+ {__('Type the ID of your form to exclude it from the list. Forms with these IDs you choose will not be displayed in this grid.', 'give')} +

+ + )} +
+
+ + + saveSetting('displayType', value)} + /> + {displayType === 'redirect' ? +

+ {__('Users will be redirected to the donation form page.', 'give')} +

: +

+ {__('Modal with the donation form will be displayed on the same page.', 'give')}

- - )} -
+ } + saveSetting('formsPerPage', value)} + help={__('Sets the number of forms to be displayed on the first page load.', 'give')} + /> + saveSetting('paged', value)} + help={__('Enable form display to multiple pages.', 'give')} + /> +
+ + saveSetting('tagBackgroundColor', value), + label: __('Tag Background Color', 'give') + + }, + { + value: tagTextColor, + onChange: (value) => saveSetting('tagTextColor', value), + label: __('Tag Text Color', 'give') + }, + { + value: donateButtonTextColor, + onChange: (value) => saveSetting('donateButtonTextColor', value), + label: __('Donate Button Text Color', 'give') + }, + { + value: progressBarColor, + onChange: (value) => saveSetting('progressBarColor', value), + label: __('Progress Bar Color', 'give') + }, + + ] } + /> - - saveSetting('displayType', value)} - help={__('What should happen when a visitor clicks on a form within the grid? "Redirect" sends them to the individual form. "Modal" opens the form in a lightbox/popup on the same page.', 'give')} - /> - saveSetting('formsPerPage', value)} - help={__('How many forms should display on the first page load? To restrict display to only one page, disable pagination below.', 'give')} - /> - saveSetting('paged', value)} - /> -
); }; diff --git a/blocks/donation-form-grid/edit/style.scss b/blocks/donation-form-grid/edit/style.scss new file mode 100644 index 0000000000..f95f3439a3 --- /dev/null +++ b/blocks/donation-form-grid/edit/style.scss @@ -0,0 +1,62 @@ +.give-form-grid-inspector{ + flex-direction: row !important; + align-items: center !important; + justify-content: space-between !important; + + &__filter { + margin-top: -18px !important; + } + + &__help { + font-size: 0.75rem; + color: rgb(117, 117, 117); + font-style: normal; + margin: -15px 0 15px 0 !important; + } + + + + .components-base-control__label { + margin: 0 !important; + } + + .components-base-control__field { + display: flex !important; + flex-direction: row!important; + align-items: center !important; + justify-content: space-between !important; + + .components-text-control__input { + flex: .7 !important; + } + } + + .components-flex-item { + display: flex !important; + align-items: center !important; + justify-content: center !important; + + .components-input-control__label{ + flex: 1 !important; + margin: 0 !important; + } + } + + .components-input-control__container { + max-width: 135px !important; + + > select { + line-height: 1.2 !important; + } + } + } + + .components-form-token-field{ + label { display: none !important;} + } + + .exclude__form { + margin-top: 20px !important; + border: 1px solid transparent; + } + diff --git a/blocks/donor-wall/class-give-donor-wall.php b/blocks/donor-wall/class-give-donor-wall.php index bdf2489732..cf4cb40563 100644 --- a/blocks/donor-wall/class-give-donor-wall.php +++ b/blocks/donor-wall/class-give-donor-wall.php @@ -92,20 +92,20 @@ public function register_block() { 'default' => '12', ], 'formID' => [ - 'type' => 'string', - 'default' => '0', + 'type' => 'array', + 'default' => [], ], 'ids' => [ - 'type' => 'string', - 'default' => '', + 'type' => 'array', + 'default' => [], ], 'categories' => [ - 'type' => 'string', - 'default' => '', + 'type' => 'array', + 'default' => [], ], 'tags' => [ - 'type' => 'string', - 'default' => '', + 'type' => 'array', + 'default' => [], ], 'orderBy' => [ 'type' => 'string', @@ -121,7 +121,7 @@ public function register_block() { ], 'columns' => [ 'type' => 'string', - 'default' => 'best-fit', + 'default' => '3', ], 'showAvatar' => [ 'type' => 'boolean', @@ -136,14 +136,10 @@ public function register_block() { 'default' => false, ], 'showForm' => [ - 'type' => 'boolean', - 'default' => false, - ], - 'showTotal' => [ 'type' => 'boolean', 'default' => true, ], - 'showDate' => [ + 'showTotal' => [ 'type' => 'boolean', 'default' => true, ], @@ -161,7 +157,7 @@ public function register_block() { ], 'commentLength' => [ 'type' => 'string', - 'default' => '140', + 'default' => '80', ], 'readMoreText' => [ 'type' => 'string', @@ -173,8 +169,24 @@ public function register_block() { ], 'avatarSize' => [ 'type' => 'string', - 'default' => '60', + 'default' => '75', ], + 'toggleOptions' => [ + 'type' => 'string', + 'default' => 'Donor info', + ], + 'filter' => [ + 'type' => 'string', + 'default' => 'Donor ID', + ], + 'color' => [ + 'type' => 'string', + 'default' => '#219653', + ], + 'showTributes' => [ + 'type' => 'boolean', + 'default' => false, + ], ], ] ); @@ -193,10 +205,10 @@ public function render_block( $attributes ) { $parameters = [ 'donors_per_page' => absint( $attributes['donorsPerPage'] ), - 'form_id' => $attributes['formID'], - 'ids' => $attributes['ids'], - 'cats' => $attributes['categories'], - 'tags' => $attributes['tags'], + 'form_id' => implode(',', $this->getAsArray($attributes['formID'] ) ), + 'ids' => implode(',', $this->getAsArray($attributes['ids'] ) ), + 'cats' => implode(',', $this->getAsArray($attributes['categories'] ) ), + 'tags' => implode(',', $this->getAsArray($attributes['tags'] ) ), 'orderby' => $attributes['orderBy'], 'order' => $attributes['order'], 'pages' => absint( $attributes['paged'] ), @@ -206,14 +218,17 @@ public function render_block( $attributes ) { 'show_company_name' => $attributes['showCompanyName'], 'show_form' => $attributes['showForm'], 'show_total' => $attributes['showTotal'], - 'show_time' => $attributes['showDate'], 'show_comments' => $attributes['showComments'], - 'anonymous' => $attributes['showAnonymous'], + 'show_tributes' => $attributes['showTributes'], + 'anonymous' => $attributes['showAnonymous'], 'comment_length' => absint( $attributes['commentLength'] ), 'only_comments' => $attributes['onlyComments'], 'readmore_text' => $attributes['readMoreText'], 'loadmore_text' => $attributes['loadMoreText'], - 'avatar_size' => $avatarSize ?: 60, + 'toggle_options' => $attributes['toggleOptions'], + 'filter' => $attributes['filter'], + 'avatar_size' => $avatarSize ?: 75, + 'color' => $attributes['color'] ]; $html = Give_Donor_Wall::get_instance()->render_shortcode( $parameters ); @@ -222,6 +237,26 @@ public function render_block( $attributes ) { return $html; } + + /** + * @unreleased + * + * @param string|array $value + * @return array + */ + private function getAsArray($value) { + if ( is_array($value) ) { + return $value; + } + + // Backward compatibility + if (strpos($value, ',')) { + return explode(',', $value); + } + + return [$value]; + } + /** * Return formatted notice when shortcode returns an empty string * diff --git a/blocks/donor-wall/data/attributes.js b/blocks/donor-wall/data/attributes.js index c0c46ceab4..ef7af361ce 100644 --- a/blocks/donor-wall/data/attributes.js +++ b/blocks/donor-wall/data/attributes.js @@ -13,20 +13,20 @@ const blockAttributes = { default: '12', }, formID: { - type: 'string', - default: '0', + type: 'array', + default: [], }, ids: { - type: 'string', - default: '', + type: 'array', + default: [], }, categories: { - type: 'string', - default: '', + type: 'array', + default: [], }, tags: { type: 'string', - default: '', + default: [], }, orderBy: { type: 'string', @@ -42,7 +42,7 @@ const blockAttributes = { }, columns: { type: 'string', - default: 'best-fit', + default: '3', }, showAvatar: { type: 'boolean', @@ -57,14 +57,10 @@ const blockAttributes = { default: false, }, showForm: { - type: 'boolean', - default: false, - }, - showTotal: { type: 'boolean', default: true, }, - showDate: { + showTotal: { type: 'boolean', default: true, }, @@ -72,6 +68,10 @@ const blockAttributes = { type: 'boolean', default: true, }, + showTributes: { + type: 'boolean', + default: true, + }, showAnonymous: { type: 'boolean', default: true, @@ -82,7 +82,7 @@ const blockAttributes = { }, commentLength: { type: 'string', - default: '140', + default: '80', }, readMoreText: { type: 'string', @@ -94,8 +94,20 @@ const blockAttributes = { }, avatarSize: { type: 'string', - default: '60', + default: '75', }, + toggleOptions: { + type: 'string', + default: 'Donor info', + }, + filter: { + type: 'string', + default: 'Donor ID', + }, + color: { + type: 'string', + default: '#219653', + }, }; export default blockAttributes; diff --git a/blocks/donor-wall/data/options.js b/blocks/donor-wall/data/options.js index afb2a43f4f..9407d6e89c 100644 --- a/blocks/donor-wall/data/options.js +++ b/blocks/donor-wall/data/options.js @@ -10,11 +10,10 @@ const giveDonorWallOptions = {}; // Form Display Styles giveDonorWallOptions.columns = [ - { value: 'best-fit', label: __( 'Best Fit', 'give' ) }, - { value: '1', label: '1' }, - { value: '2', label: '2' }, - { value: '3', label: '3' }, - { value: '4', label: '4' }, + { value: '1', label: 'Full width' }, + { value: '2', label: 'Double' }, + { value: '3', label: 'Triple' }, + { value: '4', label: 'Max (4)' }, ]; // Order @@ -29,4 +28,20 @@ giveDonorWallOptions.orderBy = [ { value: 'post_date', label: __( 'Date Created', 'give' ) }, ]; +//Toggle Switch +giveDonorWallOptions.toggleOptions = [ + { value: 'Donor info', label: __( 'Donor Info', 'give' ) }, + { value: 'Wall attributes', label: __( 'Wall Attributes', 'give' ) }, +]; + +//Filter +giveDonorWallOptions.filter = [ + { value: 'ids', label: __( 'Donor ID', 'give' ) }, + { value: 'formID', label: __( 'Form ID', 'give' ) }, + { value: 'categories', label: __( 'Categories', 'give' ) }, + { value: 'tags', label: __( 'Tags', 'give' ) }, +]; + + + export default giveDonorWallOptions; diff --git a/blocks/donor-wall/edit/inspector.js b/blocks/donor-wall/edit/inspector.js index 9fdfc546e0..afdebb7fdd 100644 --- a/blocks/donor-wall/edit/inspector.js +++ b/blocks/donor-wall/edit/inspector.js @@ -2,145 +2,252 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n' -import { InspectorControls } from '@wordpress/block-editor'; -import { PanelBody, SelectControl, ToggleControl, TextControl } from '@wordpress/components'; + +import {InspectorControls, ColorPalette,} from '@wordpress/block-editor'; +import {PanelBody, Panel, SelectControl, ToggleControl, TextControl, FormTokenField } from '@wordpress/components'; /** * Internal dependencies */ import giveDonorWallOptions from '../data/options'; +import ColumnSelector from '../../components/column-selector'; +import ToggleOptions from '../../components/toggle'; + +import './style.scss' +import Toggle from "../../components/toggle"; + /** * Render Inspector Controls */ const Inspector = ( { attributes, setAttributes } ) => { - const { donorsPerPage, ids, formID, categories, tags, orderBy, order, columns, avatarSize, showAvatar, showName, showCompanyName, showForm, showTotal, showDate, showComments, showAnonymous, onlyComments, commentLength, readMoreText, loadMoreText } = attributes; + const { donorsPerPage, ids, formID, categories, tags, orderBy, order, columns, avatarSize, showAvatar, showName, showCompanyName, onlyComments, showForm, showTotal, showComments, showAnonymous, commentLength, readMoreText, loadMoreText, toggleOptions, filter, color, showTributes } = attributes; + const saveSetting = ( name, value ) => { setAttributes( { [ name ]: value, } ); }; - return ( + const getAsArray = value => { + if (Array.isArray(value)) { + return value; + } + + // Backward compatibility + if (formIDs.indexOf(',')) { + return value.split(','); + } + + return [value]; + }; + + const filterValue = () => { + if(filter === 'categories'){ + return <> saveSetting('categories', value)} + value={getAsArray(categories)}/> +

+ {__('Type the name of your category to add it to the list. Only forms within the categories you choose will be displayed in this grid.', 'give')} +

+ + + } else if (filter === 'tags'){ + return <> saveSetting('tags', value)}/> +

+ {__('Type the name of your tag to add it to the list. Only forms with these tags you choose will be displayed in this grid.', 'give')} +

+ + + } else if (filter === 'ids'){ + return <> saveSetting('ids', value)}/> +

+ {__('By default, all donors will display. Use this setting to restrict the donor wall to only display certain donors. Use a comma-separated list of donor IDs.', 'give')} +

+ + + } else if (filter === 'formID' ){ + return <> saveSetting('formID', value)}/> +

+ {__('Type the ID of your form to add it to the list. Only forms with these IDs you choose will be displayed in this grid.', 'give')} +

+ + } + }; + return ( - - saveSetting( 'donorsPerPage', value ) } - help={ __('How many donors should show up on the initial page load?', 'give' ) } - /> - saveSetting( 'ids', value ) } - help={ __('By default, all donors will display. Use this setting to restrict the donor wall to only display certain donors. Use a comma-separated list of donor IDs.', 'give') } - /> - saveSetting( 'formID', value ) } - help={ __('By Default, donations to all forms will display. Use this setting to restrict the donor to display only donations to certains forms. Use a comma-separated list of form IDs.', 'give') } - /> - saveSetting( 'categories', value ) }/> - saveSetting( 'tags', value ) }/> - saveSetting( 'orderBy', value ) } /> - saveSetting( 'order', value ) } /> - saveSetting( 'columns', value ) } /> - saveSetting( 'avatarSize', value ) } /> - saveSetting( 'showAvatar', value ) } /> - saveSetting( 'showName', value ) } /> - saveSetting( 'showCompanyName', value ) } /> - saveSetting( 'showForm', value ) } /> - saveSetting( 'showTotal', value ) } /> - saveSetting( 'showDate', value ) } /> - saveSetting( 'showComments', value ) } /> - saveSetting( 'showAnonymous', value ) } /> - saveSetting( 'onlyComments', value ) } /> - saveSetting( 'commentLength', value ) } /> - saveSetting( 'readMoreText', value ) } /> - saveSetting( 'loadMoreText', value ) } /> - - + + + saveSetting('columns', value)} + help={__('Controls how many columns of the Form Grid appear. All sizes will adjust responsively to the space available. The maximum number allowed per row is 4', 'give')} + /> + saveSetting( 'columns', value ) } /> + + + + + saveSetting( 'toggleOptions', value ) } + selected={toggleOptions}/> + {toggleOptions === 'Donor info' ? + <> + saveSetting( 'showName', value ) } /> + saveSetting( 'showCompanyName', value ) } /> + saveSetting( 'showAnonymous', value ) } /> + saveSetting( 'showAvatar', value ) } /> + saveSetting( 'avatarSize', value ) } /> + : + <> + saveSetting( 'showForm', value ) } /> + saveSetting( 'showTotal', value ) } /> + { !!window.Give_Tribute && saveSetting( 'showTributes', value ) } />} + saveSetting( 'showComments', value ) } /> + saveSetting( 'onlyComments', value ) } /> + saveSetting( 'commentLength', value ) } /> + saveSetting( 'readMoreText', value ) } /> + + } + + + + + saveSetting( 'orderBy', value ) } /> + saveSetting( 'order', value ) } /> + saveSetting( 'filter', value ) } /> + + {filterValue(filter)} + + + + + saveSetting( 'donorsPerPage', value ) } + help={ __('How many donors should show up on the initial page load?', 'give' ) } + /> + saveSetting( 'loadMoreText', value ) } /> + + + + + setAttributes( { color: value } )} + /> + + + ); }; diff --git a/blocks/donor-wall/edit/style.scss b/blocks/donor-wall/edit/style.scss new file mode 100644 index 0000000000..304e89463e --- /dev/null +++ b/blocks/donor-wall/edit/style.scss @@ -0,0 +1,44 @@ +.give-donor-wall-inspector{ + flex-direction: row !important; + align-items: center !important; + justify-content: space-between !important; + + .components-base-control__label { + margin: 0 !important; + } + + .components-base-control__field { + display: flex !important; + flex-direction: row!important; + align-items: center !important; + justify-content: space-between !important; + + .components-text-control__input { + flex: .7 !important; + } + } + + .components-flex-item { + display: flex !important; + align-items: center !important; + justify-content: center !important; + + .components-input-control__label{ + flex: 1 !important; + margin: 0 !important; + } + } + + .components-input-control__container { + max-width: 165px !important; + + > select { + line-height: 1.2 !important; + } + } + } + +.components-form-token-field { + margin-top: -18px !important; + label { display: none !important;} +} diff --git a/blocks/donor-wall/index.js b/blocks/donor-wall/index.js index 1571317f8a..4560a1ae4c 100644 --- a/blocks/donor-wall/index.js +++ b/blocks/donor-wall/index.js @@ -17,7 +17,7 @@ import GiveDonorWallGrid from './edit/block'; export default registerBlockType( 'give/donor-wall', { title: __( 'Donor Wall', 'give' ), - description: __( 'The GiveWP Donor Wall block inserts an existing donation form into the page. Each form\'s presentation can be customized below.', 'give' ), + description: __( 'The GiveWP Donor Wall block displays donations on the front end of the site. The settings below allow you to customize the information displayed', 'give' ), category: 'give', icon: , keywords: [ diff --git a/blocks/load.php b/blocks/load.php index d37b343523..45d7329a28 100644 --- a/blocks/load.php +++ b/blocks/load.php @@ -34,3 +34,4 @@ function give_blocks_category( $categories, $post ) { require_once GIVE_PLUGIN_DIR . 'blocks/donation-form/class-give-donation-form-block.php'; require_once GIVE_PLUGIN_DIR . 'blocks/donation-form-grid/class-give-donation-form-grid-block.php'; require_once GIVE_PLUGIN_DIR . 'blocks/donor-wall/class-give-donor-wall.php'; + diff --git a/composer.json b/composer.json index 454b8219d3..30aca8bf06 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ }, "config": { "platform": { - "php": "5.6.40" + "php": "7.0" }, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, diff --git a/cypress.json b/cypress.json deleted file mode 100644 index c285f70db7..0000000000 --- a/cypress.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "env": { - "wp_user": "admin", - "wp_pass": "password", - "site": { - "url": "http://localhost:8888" - } - }, - "fixturesFolder": "tests/e2e/fixtues", - "integrationFolder": "tests/e2e/integration", - "pluginsFolder": "tests/e2e/plugins", - "screenshotsFolder": "tests/e2e/screenshots", - "videosFolder": "tests/e2e/videos", - "supportFile": "tests/e2e/support/index.js" -} diff --git a/give.php b/give.php index 7835c1e2be..941ac3021b 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.20.2 + * Version: 2.21.0 * Requires at least: 5.0 * Requires PHP: 7.0 * Text Domain: give @@ -85,6 +85,7 @@ /** * Main Give Class * + * @since 2.21.0 Remove php dependency validation logic and constant * @since 2.19.6 add $donations, $subscriptions, and replace $donors class with DonorRepositoryProxy * @since 2.8.0 build in a service container * @since 1.0 @@ -218,18 +219,6 @@ public function __construct() */ public function boot() { - // PHP version - if (!defined('GIVE_REQUIRED_PHP_VERSION')) { - define('GIVE_REQUIRED_PHP_VERSION', '5.6.0'); - } - - // Bailout: Need minimum php version to load plugin. - if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) { - add_action('admin_notices', [$this, 'minimum_phpversion_notice']); - - return; - } - $this->setup_constants(); // Add compatibility notice for recurring and stripe support with Give 2.5.0. @@ -305,7 +294,7 @@ private function setup_constants() { // Plugin version. if (!defined('GIVE_VERSION')) { - define('GIVE_VERSION', '2.20.2'); + define('GIVE_VERSION', '2.21.0'); } // Plugin Root File. @@ -357,55 +346,6 @@ public function load_textdomain() load_plugin_textdomain('give', false, $give_lang_dir); } - /** - * Show minimum PHP version notice. - * - * @since 1.8.12 - * @access public - */ - public function minimum_phpversion_notice() - { - // Bailout. - if (!is_admin()) { - return; - } - - $notice_desc = '

' . __( - 'Your site could be faster and more secure with a newer PHP version.', - 'give' - ) . '

'; - $notice_desc .= '

' . __( - 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and GiveWP are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', - 'give' - ) . '

'; - $notice_desc .= '

' . __( - 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', - 'give' - ) . '

'; - $notice_desc .= '

' . __('To which version should I update?', 'give') . '

'; - $notice_desc .= '

' . __( - 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', - 'give' - ) . '

'; - $notice_desc .= '

' . __('Can\'t update? Ask your host!', 'give') . '

'; - $notice_desc .= '

' . sprintf( - __( - 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', - 'give' - ), - sprintf( - '', - esc_url('https://wordpress.org/hosting/') - ), - '' - ) . '

'; - - echo sprintf( - '
%1$s
', - wp_kses_post($notice_desc) - ); - } - /** * Display compatibility notice for Give 2.5.0 and Recurring 1.8.13 when Stripe premium is not active. * diff --git a/includes/admin/admin-actions.php b/includes/admin/admin-actions.php index 92fc36604c..bed2404881 100644 --- a/includes/admin/admin-actions.php +++ b/includes/admin/admin-actions.php @@ -76,10 +76,12 @@ function give_redirect_to_clean_url_admin_pages() { if ( $redirect ) { // Redirect. wp_redirect( - remove_query_arg( - [ '_wp_http_referer', '_wpnonce' ], - wp_unslash( $_SERVER['REQUEST_URI'] ) - ) + esc_url_raw( + remove_query_arg( + [ '_wp_http_referer', '_wpnonce' ], + wp_unslash( $_SERVER['REQUEST_URI'] ) + ) + ) ); exit; } diff --git a/includes/admin/class-api-keys-table.php b/includes/admin/class-api-keys-table.php index f02900e2c1..7cd6579157 100644 --- a/includes/admin/class-api-keys-table.php +++ b/includes/admin/class-api-keys-table.php @@ -316,7 +316,7 @@ public function query() { foreach ( $users as $user ) { $keys[ $user->ID ]['id'] = $user->ID; $keys[ $user->ID ]['email'] = $user->user_email; - $keys[ $user->ID ]['user'] = '' . $user->user_login . ''; + $keys[ $user->ID ]['user'] = '' . $user->user_login . ''; $keys[ $user->ID ]['key'] = Give()->api->get_user_public_key( $user->ID ); $keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID ); diff --git a/includes/admin/donors/donor-actions.php b/includes/admin/donors/donor-actions.php index 61d41b115b..b8538e36f4 100644 --- a/includes/admin/donors/donor-actions.php +++ b/includes/admin/donors/donor-actions.php @@ -161,7 +161,7 @@ function give_edit_donor( $args ) { if ( $output['success'] ) { wp_safe_redirect( - esc_url( + esc_url_raw( add_query_arg( array( 'post_type' => 'give_forms', @@ -358,7 +358,7 @@ function give_disconnect_donor_user_id( $args ) { give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); } - $output['redirect'] = $redirect_url; + $output['redirect'] = esc_url_raw( $redirect_url ); /** * Fires after disconnecting user ID from a donor. @@ -516,7 +516,7 @@ function give_remove_donor_email() { $url = add_query_arg( 'give-messages[]', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); } - wp_safe_redirect( $url ); + wp_safe_redirect( esc_url_raw( $url ) ); exit; } @@ -569,7 +569,7 @@ function give_set_donor_primary_email() { $url = add_query_arg( 'give-messages[]', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); } - wp_safe_redirect( $url ); + wp_safe_redirect( esc_url_raw( $url ) ); exit; } @@ -673,7 +673,7 @@ function give_process_donor_deletion( $args ) { admin_url( 'edit.php?post_type=give_forms&page=give-donors' ) ); - wp_safe_redirect( $redirect_url ); + wp_safe_redirect( esc_url_raw( $redirect_url ) ); give_die(); } diff --git a/includes/admin/donors/donors.php b/includes/admin/donors/donors.php index f16622a1ff..55f67ffcdd 100644 --- a/includes/admin/donors/donors.php +++ b/includes/admin/donors/donors.php @@ -827,9 +827,9 @@ class="button js-cancel"> 'give-remove-donor-email' ); ?> - +  |  - + diff --git a/includes/admin/emails/abstract-email-notification.php b/includes/admin/emails/abstract-email-notification.php index e2a89f2fd0..d2c1f505a5 100755 --- a/includes/admin/emails/abstract-email-notification.php +++ b/includes/admin/emails/abstract-email-notification.php @@ -909,22 +909,22 @@ public function preview_email_template_tags( $message ) { 'billing_address' => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '', 'email_access_link' => sprintf( '%2$s', - add_query_arg( + esc_url( add_query_arg( array( 'give_nl' => uniqid(), ), give_get_history_page_uri() - ), + ) ), __( 'View your donation history »', 'give' ) ), 'donation_history_link' => sprintf( '%2$s', - add_query_arg( + esc_url( add_query_arg( array( 'give_nl' => uniqid(), ), give_get_history_page_uri() - ), + ) ), __( 'View your donation history »', 'give' ) ), 'reset_password_link' => $user_id ? give_email_tag_reset_password_link( array( 'user_id' => $user_id ), $payment_id ) : '', diff --git a/includes/admin/emails/class-donation-receipt-email.php b/includes/admin/emails/class-donation-receipt-email.php index dbb20630a0..0e78cfe3f7 100755 --- a/includes/admin/emails/class-donation-receipt-email.php +++ b/includes/admin/emails/class-donation-receipt-email.php @@ -329,13 +329,15 @@ public function resend_donation_receipt( $data ) { ); wp_redirect( - add_query_arg( - array( - 'give-messages[]' => 'email-sent', - 'give-action' => false, - 'purchase_id' => false, - ) - ) + esc_url_raw( + add_query_arg( + array( + 'give-messages[]' => 'email-sent', + 'give-action' => false, + 'purchase_id' => false, + ) + ) + ) ); exit; } diff --git a/includes/admin/emails/class-donor-register-email.php b/includes/admin/emails/class-donor-register-email.php index 8fd3e19d93..f5b1bf19da 100755 --- a/includes/admin/emails/class-donor-register-email.php +++ b/includes/admin/emails/class-donor-register-email.php @@ -174,7 +174,7 @@ public function email_preview_header( $email_preview_header, $email ) { // Remove user id query param if set from request url. $query = remove_query_arg( array( 'user_id' ), $query ); - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); + $request_url = esc_url( home_url( '/?' . str_replace( '', '', $query ) ) ); ?> diff --git a/includes/admin/emails/class-email-notifications.php b/includes/admin/emails/class-email-notifications.php index 4f48f96f77..8a7f1546aa 100755 --- a/includes/admin/emails/class-email-notifications.php +++ b/includes/admin/emails/class-email-notifications.php @@ -396,7 +396,7 @@ public function send_preview_email() { } // Remove the test email query arg. - wp_redirect( remove_query_arg( 'give_action' ) ); + wp_redirect( esc_url_raw( remove_query_arg( 'give_action' ) ) ); exit; } diff --git a/includes/admin/emails/class-new-donor-register-email.php b/includes/admin/emails/class-new-donor-register-email.php index 4242464ccd..e85ec5eaaa 100755 --- a/includes/admin/emails/class-new-donor-register-email.php +++ b/includes/admin/emails/class-new-donor-register-email.php @@ -169,7 +169,7 @@ public function email_preview_header( $email_preview_header, $email ) { // Remove user id query param if set from request url. $query = remove_query_arg( array( 'user_id' ), $query ); - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); + $request_url = esc_url( home_url( '/?' . str_replace( '', '', $query ) ) ); ?>