Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release May 15 #3103

Merged
merged 30 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1342cb7
chore(release): merge in release v3.6.8
matticbot Apr 11, 2024
2a7bcef
chore(release): merge in release v3.6.9
matticbot Apr 12, 2024
22b55e4
chore(deps-dev): bump @wordpress/browserslist-config
dependabot[bot] Apr 15, 2024
252e647
chore(deps-dev): bump @rushstack/eslint-patch from 1.10.1 to 1.10.2
dependabot[bot] Apr 15, 2024
0d415b2
chore(deps-dev): bump @types/wordpress__blocks from 12.5.13 to 12.5.14
dependabot[bot] Apr 15, 2024
6896331
chore(release): merge in release v3.6.10
matticbot Apr 15, 2024
a6e8a6e
refactor(data-events): add abstract Connector class for shared method…
dkoo Apr 18, 2024
f1edb9b
chore(release): merge in release v3.6.11
matticbot Apr 19, 2024
23e827b
chore(deps-dev): bump @wordpress/browserslist-config
dependabot[bot] Apr 22, 2024
426b6f9
chore(deps): bump qs and @types/qs
dependabot[bot] Apr 22, 2024
e51c6af
chore(release): merge in release v3.6.12
matticbot Apr 22, 2024
7d4ee61
chore(release): merge in release v3.6.13
matticbot Apr 22, 2024
4606721
fix: ensure only admins can reset starter content and newspack option…
adekbadek Apr 23, 2024
b39b92d
chore(release): merge in release v3.7.0
matticbot Apr 24, 2024
78ddb0f
chore(release): merge in release v3.8.0
matticbot Apr 25, 2024
a4aaf10
chore(release): merge in release v3.8.0
matticbot Apr 25, 2024
4a2859b
feat: add product option to autocomplete orders (#3072)
dkoo Apr 25, 2024
9ef0e6d
feat(ras): skip campaign setup (#3051)
jaredrethman Apr 25, 2024
678c337
Merge pull request #3089 from Automattic/trunk
dkoo Apr 25, 2024
d294dee
chore(release): 4.0.0-alpha.1 [skip ci]
semantic-release-bot Apr 25, 2024
8a01449
Merge branch 'release' into alpha
dkoo Apr 25, 2024
1e10964
chore(release): 4.0.0-alpha.2 [skip ci]
semantic-release-bot Apr 25, 2024
f31aa65
Merge branch 'release' into alpha
dkoo Apr 26, 2024
31898b6
chore(release): 4.0.0-alpha.3 [skip ci]
semantic-release-bot Apr 26, 2024
f9e8387
OAuth: use a custom table for transients (#3106)
dkoo May 13, 2024
6de1bba
Merge branch 'release' into alpha
dkoo May 13, 2024
31b2b99
Merge branch 'release' into alpha
adekbadek May 14, 2024
d92c7b4
Merge branch 'release' into alpha
adekbadek May 15, 2024
bfbe554
fix: autocomplete orders only for virtual products (#3111)
dkoo May 15, 2024
0457e12
chore: fix merge conflicts
dkoo May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
## [3.8.6](https://github.com/Automattic/newspack-plugin/compare/v3.8.5...v3.8.6) (2024-05-15)
# [4.0.0-alpha.3](https://github.com/Automattic/newspack-plugin/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2024-04-26)


### Bug Fixes

* **google-login:** get the email from the /tokeninfo endpoint ([#3117](https://github.com/Automattic/newspack-plugin/issues/3117)) ([3296f1a](https://github.com/Automattic/newspack-plugin/commit/3296f1a0b36c7992749d6209bce3ed3ef2ea5ec5))
* enable Memberships fix cron job only when environment constant is defined ([#3087](https://github.com/Automattic/newspack-plugin/issues/3087)) ([5d40297](https://github.com/Automattic/newspack-plugin/commit/5d40297252a9022bb9b63b72cf805a08c37eb553))

## [3.8.5](https://github.com/Automattic/newspack-plugin/compare/v3.8.4...v3.8.5) (2024-05-14)
# [4.0.0-alpha.2](https://github.com/Automattic/newspack-plugin/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2024-04-25)


### Bug Fixes

* **oauth-transients:** remove redundant cleanup ([#3112](https://github.com/Automattic/newspack-plugin/issues/3112)) ([c123c02](https://github.com/Automattic/newspack-plugin/commit/c123c0248ecf9aab8f16e5ab63e84f9900b3d6f5))
* remove deprecated filter callback ([#3090](https://github.com/Automattic/newspack-plugin/issues/3090)) ([5d7d0bf](https://github.com/Automattic/newspack-plugin/commit/5d7d0bf71d16907d3aa98def372a7d9ede8949c6))

## [3.8.4](https://github.com/Automattic/newspack-plugin/compare/v3.8.3...v3.8.4) (2024-05-14)
## [3.8.1](https://github.com/Automattic/newspack-plugin/compare/v3.8.0...v3.8.1) (2024-04-25)


### Bug Fixes

* **google-oauth:** use a custom table for transients ([#3106](https://github.com/Automattic/newspack-plugin/issues/3106)) ([d4a2f5c](https://github.com/Automattic/newspack-plugin/commit/d4a2f5ce8ff6931b98593dafe759eab8b59d7ab2))
* remove deprecated filter callback ([#3090](https://github.com/Automattic/newspack-plugin/issues/3090)) ([5d7d0bf](https://github.com/Automattic/newspack-plugin/commit/5d7d0bf71d16907d3aa98def372a7d9ede8949c6))


## [3.8.3](https://github.com/Automattic/newspack-plugin/compare/v3.8.2...v3.8.3) (2024-05-13)
# [4.0.0-alpha.1](https://github.com/Automattic/newspack-plugin/compare/v3.8.0...v4.0.0-alpha.1) (2024-04-25)


### Bug Fixes

* **ras:** sync purchase data only for most recent order/subscription ([#3086](https://github.com/Automattic/newspack-plugin/issues/3086)) ([2c7763a](https://github.com/Automattic/newspack-plugin/commit/2c7763a53894e5c350d6ce76e0f4ab3b1e768bc5))
* ensure only admins can reset starter content and newspack options ([#3081](https://github.com/Automattic/newspack-plugin/issues/3081)) ([4606721](https://github.com/Automattic/newspack-plugin/commit/46067217985f904286ddb2c952ba0e1deb954e56))

## [3.8.2](https://github.com/Automattic/newspack-plugin/compare/v3.8.1...v3.8.2) (2024-04-26)

### Features

### Bug Fixes
* add product option to autocomplete orders ([#3072](https://github.com/Automattic/newspack-plugin/issues/3072)) ([4a2859b](https://github.com/Automattic/newspack-plugin/commit/4a2859b894eab499e194102b0636dc20466e0c22))
* **ras:** skip campaign setup ([#3051](https://github.com/Automattic/newspack-plugin/issues/3051)) ([9ef0e6d](https://github.com/Automattic/newspack-plugin/commit/9ef0e6d1de8d4dafda4d2af1304206d0f8190b15))

* enable Memberships fix cron job only when environment constant is defined ([#3087](https://github.com/Automattic/newspack-plugin/issues/3087)) ([5d40297](https://github.com/Automattic/newspack-plugin/commit/5d40297252a9022bb9b63b72cf805a08c37eb553))

## [3.8.1](https://github.com/Automattic/newspack-plugin/compare/v3.8.0...v3.8.1) (2024-04-25)
### BREAKING CHANGES

* Changes order autocompletion behavior for existing products!

### Bug Fixes
* feat: add product option to autocomplete orders

* remove deprecated filter callback ([#3090](https://github.com/Automattic/newspack-plugin/issues/3090)) ([5d7d0bf](https://github.com/Automattic/newspack-plugin/commit/5d7d0bf71d16907d3aa98def372a7d9ede8949c6))
* chore: update outdated docblock description

# [3.8.0](https://github.com/Automattic/newspack-plugin/compare/v3.7.0...v3.8.0) (2024-04-25)

Expand Down
19 changes: 19 additions & 0 deletions assets/other-scripts/custom-product-options/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* globals jQuery */
( function ( $ ) {
if ( ! $ ) {
return;
}
$( '#variable_product_options' ).on( 'change', 'input.variable_is_virtual', function ( e ) {
$( e.currentTarget )
.closest( '.woocommerce_variation' )
.find( '.show_if_variation_virtual' )
.hide();

if ( $( e.currentTarget ).is( ':checked' ) ) {
$( e.currentTarget )
.closest( '.woocommerce_variation' )
.find( '.show_if_variation_virtual' )
.show();
}
} );
} )( jQuery );
19 changes: 10 additions & 9 deletions assets/wizards/engagement/components/prerequisite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export default function Prerequisite( {
saveConfig,
}: PrequisiteProps ) {
const { href } = prerequisite;
const isValid = Boolean( prerequisite.active || prerequisite.is_skipped );

// If the prerequisite is active but has empty fields, show a warning.
const hasEmptyFields = () => {
if ( prerequisite.active && prerequisite.fields && prerequisite.warning ) {
if ( isValid && prerequisite.fields && prerequisite.warning ) {
const emptyValues = Object.keys( prerequisite.fields ).filter(
fieldName => '' === config[ fieldName as keyof Config ]
);
Expand Down Expand Up @@ -93,9 +94,7 @@ export default function Prerequisite( {
: sprintf(
// Translators: Save or Update settings.
__( '%s settings', 'newspack-plugin' ),
prerequisite.active
? __( 'Update', 'newspack-plugin' )
: __( 'Save', 'newspack-plugin' )
isValid ? __( 'Update', 'newspack-plugin' ) : __( 'Save', 'newspack-plugin' )
) }
</Button>
</div>
Expand Down Expand Up @@ -138,7 +137,7 @@ export default function Prerequisite( {
} }
>
{ /* eslint-disable no-nested-ternary */ }
{ ( prerequisite.active
{ ( isValid
? __( 'Update ', 'newspack-plugin' )
: prerequisite.fields
? __( 'Save ', 'newspack-plugin' )
Expand All @@ -158,8 +157,10 @@ export default function Prerequisite( {
);

let status = __( 'Pending', 'newspack-plugin' );
if ( prerequisite.active ) {
status = __( 'Ready', 'newspack-plugin' );
if ( isValid ) {
status = `${ __( 'Ready', 'newspack-plugin' ) } ${
prerequisite.is_skipped ? `(${ __( 'Skipped', 'newspack-plugin' ) })` : ''
}`;
}
if ( prerequisite.is_unavailable ) {
status = __( 'Unavailable', 'newspack-plugin' );
Expand All @@ -170,14 +171,14 @@ export default function Prerequisite( {
className="newspack-ras-wizard__prerequisite"
isMedium
expandable={ ! prerequisite.is_unavailable }
collapse={ prerequisite.active }
collapse={ isValid }
title={ prerequisite.label }
description={ sprintf(
/* translators: %s: Prerequisite status */
__( 'Status: %s', 'newspack-plugin' ),
status
) }
checkbox={ prerequisite.active ? 'checked' : 'unchecked' }
checkbox={ isValid ? 'checked' : 'unchecked' }
notificationLevel="info"
notification={ hasEmptyFields() }
>
Expand Down
1 change: 1 addition & 0 deletions assets/wizards/engagement/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export type PrequisiteProps = {
action_enabled?: boolean;
disabled_text?: string;
is_unavailable?: boolean;
is_skipped?: boolean;
};
};

Expand Down
65 changes: 63 additions & 2 deletions assets/wizards/engagement/views/reader-activation/campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ import {
SectionHeader,
Waiting,
withWizardScreen,
utils,
} from '../../../../components/src';
import Prompt from '../../components/prompt';
import Router from '../../../../components/src/proxied-imports/router';
import './style.scss';

const { useHistory } = Router;

export default withWizardScreen( () => {
const { is_skipped_campaign_setup, reader_activation_url } = newspack_engagement_wizard;

const [ inFlight, setInFlight ] = useState( false );
const [ error, setError ] = useState( false );
const [ prompts, setPrompts ] = useState( null );
const [ allReady, setAllReady ] = useState( false );
const { reader_activation_url } = newspack_engagement_wizard;
const [ skipped, setSkipped ] = useState( {
status: '',
isSkipped: is_skipped_campaign_setup === '1',
} );
const history = useHistory();

const fetchPrompts = () => {
setError( false );
Expand All @@ -40,6 +50,45 @@ export default withWizardScreen( () => {
.finally( () => setInFlight( false ) );
};

/**
* Display prompt requiring editors to confirm skipping, on confirmation send request to
* server to store skipped option in options table and redirect back to RAS
*
* @return {void}
*/
async function onSkipCampaignSetup() {
if (
! utils.confirmAction(
__(
'Are you sure you want to skip setting up a reader activation campaign?',
'newspack-plugin'
)
)
) {
return;
}
setError( false );
setSkipped( { ...skipped, status: 'pending' } );
try {
const request = await apiFetch( {
path: '/newspack/v1/wizard/newspack-engagement-wizard/reader-activation/skip-campaign-setup',
method: 'POST',
data: { skip: ! skipped.isSkipped },
} );
if ( ! request.updated ) {
setError( { message: __( 'Server not updated', 'newspack-plugin' ) } );
setSkipped( { isSkipped: false, status: '' } );
return;
}
setSkipped( { isSkipped: Boolean( request.skipped ), status: '' } );
newspack_engagement_wizard.is_skipped_campaign_setup = request.skipped ? '1' : '';
history.push( '/reader-activation/complete' );
} catch ( err ) {
setError( err );
setSkipped( { isSkipped: false, status: '' } );
}
}

useEffect( () => {
window.scrollTo( 0, 0 );
fetchPrompts();
Expand Down Expand Up @@ -83,9 +132,21 @@ export default withWizardScreen( () => {
/>
) ) }
<div className="newspack-buttons-card">
<Button
isTertiary
disabled={ inFlight || skipped.isSkipped || skipped.status === 'pending' }
onClick={ onSkipCampaignSetup }
>
{ /* eslint-disable-next-line no-nested-ternary */ }
{ skipped.status === 'pending'
? __( 'Skipping…', 'newspack-plugin' )
: skipped.isSkipped
? __( 'Skipped', 'newspack-plugin' )
: __( 'Skip', 'newspack-plugin' ) }
</Button>
<Button
isPrimary
disabled={ inFlight || ! allReady }
disabled={ inFlight || ( ! allReady && ! skipped.isSkipped ) }
href={ `${ reader_activation_url }/complete` }
>
{ __( 'Continue', 'newspack-plugin' ) }
Expand Down
63 changes: 49 additions & 14 deletions assets/wizards/engagement/views/reader-activation/complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,26 @@ import {
} from '../../../../components/src';

const listItems = [
__(
'Your <strong>current segments and prompts</strong> will be deactivated and archived.',
'newspack-plugin'
),
__(
'<strong>Reader registration</strong> will be activated to enable better targeting for driving engagement and conversations.',
'newspack-plugin'
),
__(
'The <strong>Reader Activation campaign</strong> will be activated with default segments and settings.',
'newspack-plugin'
),
{
text: __(
'Your <strong>current segments and prompts</strong> will be deactivated and archived.',
'newspack-plugin'
),
isSkipped: '<span class="is-skipped">[skipped]</span>',
},
{
text: __(
'<strong>Reader registration</strong> will be activated to enable better targeting for driving engagement and conversations.',
'newspack-plugin'
),
},
{
text: __(
'The <strong>Reader Activation campaign</strong> will be activated with default segments and settings.',
'newspack-plugin'
),
isSkipped: '<span class="is-skipped">[skipped]</span>',
},
];

const activationSteps = [
Expand All @@ -42,6 +50,8 @@ const activationSteps = [
__( 'Activating Reader Activation Campaign…', 'newspack-plugin' ),
];

const activationStepsCount = activationSteps.length;

/**
* Get a random number between min and max.
*
Expand All @@ -60,7 +70,29 @@ export default withWizardScreen( () => {
const [ progressLabel, setProgressLabel ] = useState( false );
const [ completed, setCompleted ] = useState( false );
const timer = useRef();
const { reader_activation_url } = newspack_engagement_wizard;
const { reader_activation_url, is_skipped_campaign_setup = '' } = newspack_engagement_wizard;
const isSkippedCampaignSetup = is_skipped_campaign_setup === '1';

/**
* If skipped, remove first item.
*/
if ( isSkippedCampaignSetup && activationSteps.length !== activationStepsCount - 1 ) {
activationSteps.shift();
}

/**
* Generate step list strings
*/
for ( const listItemIndex in listItems ) {
if ( ! listItems[ listItemIndex ].text ) {
continue;
}
const suffix = isSkippedCampaignSetup ? ` ${ listItems[ listItemIndex ].isSkipped ?? '' }` : '';
listItems[ listItemIndex ] = `${ listItems[ listItemIndex ].text }${ suffix }`;
if ( isSkippedCampaignSetup ) {
listItems[ listItemIndex ] += ` ${ listItems[ listItemIndex ].isSkipped ?? '' }`;
}
}

useEffect( () => {
if ( timer.current ) {
Expand All @@ -80,7 +112,7 @@ export default withWizardScreen( () => {
setProgressLabel( __( 'Done!', 'newspack-plugin' ) );
setTimeout( () => {
setInFlight( false );
window.location = reader_activation_url;
// window.location = reader_activation_url;
}, 3000 );
}
}, [ completed, progress ] );
Expand All @@ -95,6 +127,9 @@ export default withWizardScreen( () => {
await apiFetch( {
path: '/newspack/v1/wizard/newspack-engagement-wizard/reader-activation/activate',
method: 'post',
data: {
skip_activation: isSkippedCampaignSetup,
},
} )
);
} catch ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export default withWizardScreen( ( { wizardApiFetch } ) => {
const _allReady =
! missingPlugins.length &&
prerequisites &&
Object.keys( prerequisites ).every( key => prerequisites[ key ]?.active );
Object.keys( prerequisites ).every(
key => prerequisites[ key ]?.active || prerequisites[ key ]?.skipped
);

setAllReady( _allReady );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
margin-top: 0 !important;
}

span.is-skipped {
color: wp-colors.$gray-700;
}

.newspack-ras-campaign {
&__prompt-wizard,
&__completed {
Expand Down
4 changes: 4 additions & 0 deletions includes/class-newspack.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private function includes() {
include_once NEWSPACK_ABSPATH . 'includes/data-events/class-popups.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/class-memberships.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/connectors/ga4/class-ga4.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/connectors/class-connector.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/connectors/class-mailchimp.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/connectors/class-activecampaign.php';
include_once NEWSPACK_ABSPATH . 'includes/data-events/class-woo-user-registration.php';
Expand Down Expand Up @@ -207,6 +208,9 @@ class_exists( 'Newspack_Popups' ) && 'edit.php?post_type=' . \Newspack_Popups::N
* Handle resetting of various options and content.
*/
public function handle_resets() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$redirect_url = admin_url( 'admin.php?page=newspack' );
$newspack_reset = filter_input( INPUT_GET, 'newspack_reset', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( 'starter-content' === $newspack_reset ) {
Expand Down
Loading