Skip to content

Commit

Permalink
Merge pull request #204 from awesomemotive/release/4.7.9
Browse files Browse the repository at this point in the history
`release/4.7.9`
  • Loading branch information
spencerfinnell authored Aug 23, 2023
2 parents ec70460 + 9285a80 commit 81dc243
Show file tree
Hide file tree
Showing 34 changed files with 839 additions and 371 deletions.
33 changes: 33 additions & 0 deletions includes/core/abstracts/abstract-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,4 +1053,37 @@ public function adjust_inventory(
}
}

/**
* Returns the form's success message.
*
* @since 4.7.9
*
* @return string
*/
public function get_confirmation_message() {
return get_post_meta( $this->id, '_success_message', true );
}

/**
* Returns the form's email confirmation message.
*
* @since 4.7.9
*
* @return string
*/
public function get_email_confirmation_message() {
return get_post_meta( $this->id, '_email_confirmation_message', true );
}

/**
* Returns the form's email notification message.
*
* @since 4.7.9
*
* @return string
*/
public function get_email_notification_message() {
return get_post_meta( $this->id, '_email_notification_message', true );
}

}
6 changes: 1 addition & 5 deletions includes/core/assets/css/admin/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,6 @@
position: relative;
flex: 0 0 25%;

@media screen and (min-width: 1400px) {
flex-basis: 22%;
}

@media screen and (max-width: 782px) {
flex-basis: 100%;
flex-grow: 1;
Expand Down Expand Up @@ -504,7 +500,7 @@
display: flex;

@media screen and (min-width: 1400px) {
flex-basis: 78%;
flex-basis: 75%;
}

@media screen and (max-width: 782px) {
Expand Down
2 changes: 1 addition & 1 deletion includes/core/assets/css/simpay-admin.min.css

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion includes/core/assets/js/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ let spAdmin = {};
// Can make specific panel active on initial page load via url hash.

handleMetaboxTabClick() {
const tabLinks = $( 'ul.simpay-tabs a' );
const tabLinks = $(
'ul.simpay-tabs li:not([data-available="no"]) a'
);
const panels = $( 'div.simpay-panel' );
const allTabLinkParents = tabLinks.parents( 'li' );

Expand Down
40 changes: 0 additions & 40 deletions includes/core/assets/js/admin/notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,13 @@ function upgradeToProLink() {
upgradeLinkEl.setAttribute( 'target', '_blank' );
}

/**
* Binds navigation buttons/links in the "Five Star Rating" admin notice.
*/
function fiveStarRatingNotice() {
const steps = document.querySelectorAll(
'.simpay-admin-notice-five-star-rating'
);

steps.forEach( ( stepEl ) => {
const navigationEls = stepEl.querySelectorAll( '[data-navigate]' );

if ( ! navigationEls ) {
return;
}

navigationEls.forEach( ( navigationEl ) => {
navigationEl.addEventListener( 'click', ( { target } ) => {
const step = target.dataset.navigate;
const stepToShow = document.querySelector(
`.simpay-admin-notice-five-star-rating[data-step="${ step }"]`
);
const stepsToHide = document.querySelectorAll(
`.simpay-admin-notice-five-star-rating:not([data-step="${ step }"])`
);

if ( stepToShow ) {
stepToShow.style.display = 'block';
}

if ( stepsToHide.length > 0 ) {
stepsToHide.forEach( ( stepToHide ) => {
stepToHide.style.display = 'none';
} );
}
} );
} );
} );
}

/**
* Handle AJAX dismissal of notices.
*
* Uses jQuery because the `.notice-dismiss` button is added to the DOM
* via jQuery when the notice loads.
*/
domReady( () => {
fiveStarRatingNotice();
upgradeToProLink();

jQuery( '.simpay-notice' ).each( function () {
Expand Down
1 change: 1 addition & 0 deletions includes/core/assets/js/admin/payment-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ import './stripe-checkout.js';
import './payment-page.js';
import './purchase-restrictions.js';
import './automations.js';
import './notifications.js';
25 changes: 25 additions & 0 deletions includes/core/assets/js/admin/payment-form/notifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* WordPress dependencies
*/
import domReady from '@wordpress/dom-ready';
import { maybeBlockButtonWithUpgradeModal } from '@wpsimplepay/utils';

/**
* Promopts for upgrade if accessing Email Notifications.
*
* @since 4.6.4
*/
function bindUpgradeModal() {
const notificationsTab = document.querySelector(
'div[data-lite] li.simpay-notifications-tab'
);

if ( notificationsTab ) {
notificationsTab.addEventListener(
'click',
maybeBlockButtonWithUpgradeModal
);
}
}

domReady( bindUpgradeModal );
32 changes: 16 additions & 16 deletions includes/core/assets/js/admin/payment-form/prices.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,22 @@ function onChangeLabel( priceEl ) {

let recurringIntervalDisplayReplaced = recurringIntervalDisplay;

recurringIntervalDisplayReplaced =
recurringIntervalDisplayReplaced.replace( '%1$s', label );

recurringIntervalDisplayReplaced =
recurringIntervalDisplayReplaced.replace(
'%2$s',
recurringIntervalCount.value
);

recurringIntervalDisplayReplaced =
recurringIntervalDisplayReplaced.replace(
'%3$s',
recurringIntervalCount.value === '1'
? recurringIntervalDisplayNouns[ 0 ]
: recurringIntervalDisplayNouns[ 1 ]
);
recurringIntervalDisplayReplaced = recurringIntervalDisplayReplaced.replace(
'%1$s',
label
);

recurringIntervalDisplayReplaced = recurringIntervalDisplayReplaced.replace(
'%2$s',
recurringIntervalCount.value
);

recurringIntervalDisplayReplaced = recurringIntervalDisplayReplaced.replace(
'%3$s',
recurringIntervalCount.value === '1'
? recurringIntervalDisplayNouns[ 0 ]
: recurringIntervalDisplayNouns[ 1 ]
);

label = recurringIntervalDisplayReplaced;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/core/assets/js/simpay-admin-notices.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/core/assets/js/simpay-admin.min.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions includes/core/class-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,28 @@ public function print_payment_receipt( $atts = array(), $content = '' ) {
$content = Payment_Confirmation\get_content();
}

// If we have a form, and there is custom content, use it.
// Use a late priority to override content pulled from Pro.
$form_id = isset( $_GET['form_id'] )
? absint( $_GET['form_id'] )
: 0;

$form = simpay_get_form( $form_id );

if ( false !== $form ) {
$form_message = $form->get_confirmation_message();

if ( ! empty( $form_message ) ) {
add_filter(
'simpay_payment_confirmation_content',
function() use ( $form_message ) {
return $form_message;
},
99
);
}
}

/**
* Filters the content of the confirmation shortcode.
*
Expand Down
1 change: 1 addition & 0 deletions includes/core/class-simplepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public function load_admin() {
require_once( SIMPLE_PAY_INC . 'core/post-types/simple-pay/edit-form-payment-page.php' );
require_once( SIMPLE_PAY_INC . 'core/post-types/simple-pay/edit-form-purchase-restrictions.php' );
require_once( SIMPLE_PAY_INC . 'core/post-types/simple-pay/edit-form-automations.php' );
require_once( SIMPLE_PAY_INC . 'core/post-types/simple-pay/edit-form-confirmation.php' );
require_once( SIMPLE_PAY_INC . 'core/post-types/simple-pay/actions.php' );

// Load core back-end only functions.
Expand Down
8 changes: 8 additions & 0 deletions includes/core/post-types/simple-pay/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ function save( $post_id, $post, $update ) {

update_post_meta( $post_id, '_success_redirect_type', $success_redirect_type );

// Success message.
if ( isset( $_POST['_success_message' ] ) && ! empty( $_POST['_success_message'] ) ) {
$success_message = wp_kses_post( $_POST['_success_message'] );
update_post_meta( $post_id, '_success_message', $success_message );
} else {
delete_post_meta( $post_id, '_success_message' );
}

// Success redirect page.
$success_redirect_page = isset( $_POST['_success_redirect_page'] )
? esc_attr( $_POST['_success_redirect_page'] )
Expand Down
Loading

0 comments on commit 81dc243

Please sign in to comment.