Skip to content

Commit

Permalink
Merge branch 'master' into fix/plain-permalinks-authorization-url
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymitr committed Nov 23, 2021
2 parents 23e1c69 + 56854e9 commit 3359a76
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Added style improvements to license flow components.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.jp-license-activation-screen-controls {
background: var( --jp-white );
padding: 64px;
padding: 32px;
display: flex;
flex-direction: column;
justify-content: space-between;
Expand All @@ -20,6 +20,11 @@
font-weight: 600;
font-size: var( --font-body );
}

@media screen and ( min-width: 780px ) {
padding: 64px;
}

}

.jp-license-activation-screen-controls--license-field,
Expand Down Expand Up @@ -80,6 +85,10 @@

margin-top: 24px;

display: flex;
justify-content: center;
width: 100%;

&:hover {
background-color: var( --jp-green-60 );
border-color: var( --jp-green-60 );
Expand All @@ -105,4 +114,9 @@
color: #a7aaad;
border-color: var( --jp-gray );
}

@media screen and ( min-width: 480px ) {
justify-content: flex-start;
width: auto;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ const ActivationScreenIllustration = props => {
const { imageUrl, showSupportLink = false } = props;
return (
<div className="jp-license-activation-screen-illustration">
<img className="jp-license-activation-screen-illustration__img" src={ imageUrl } alt="" />
<div className="jp-license-activation-screen-illustration--wrapper">
<img className="jp-license-activation-screen-illustration--img" src={ imageUrl } alt="" />
</div>
{ showSupportLink && (
<p className="jp-license-activation-screen-illustration__support-link">
<p className="jp-license-activation-screen-illustration--support-link">
{ createInterpolateElement( __( 'Do you need help? <a>Contact us.</a>', 'jetpack' ), {
a: <a href={ getRedirectUrl( 'jetpack-support' ) } />,
} ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@
justify-content: space-between;
padding: 32px;
}

.jp-license-activation-screen-illustration--wrapper {
display: flex;
flex: 1;
img {
max-width: 100%;
height: auto;
align-self: center;
}
}

.jp-license-activation-screen-illustration--support-link {
flex: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ describe( 'ActivationScreenIllustration', () => {
const wrapper = shallow( <ActivationScreenIllustration { ...testProps } /> );

it( 'correct images src is used', () => {
const image = wrapper.find( '.jp-license-activation-screen-illustration__img' );
const image = wrapper.find( '.jp-license-activation-screen-illustration--img' );

expect( image ).to.have.lengthOf( 1 );
expect( image.prop( 'src' ) ).to.equal( testProps.imageUrl );
} );

it( 'support link rendered', () => {
expect(
wrapper.find( '.jp-license-activation-screen-illustration__support-link' )
wrapper.find( '.jp-license-activation-screen-illustration--support-link' )
).to.have.lengthOf( 1 );
} );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.jp-license-activation-screen-success-info {
background: var( --jp-white );
padding: 64px;
padding: 32px;
display: flex;
flex-direction: column;
justify-content: space-between;
Expand All @@ -20,6 +20,10 @@
font-weight: 600;
font-size: var( --font-body );
}

@media screen and ( min-width: 780px ) {
padding: 64px;
}
}

.jp-license-activation-screen-success-info--button {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
.jp-license-activation-screen {
box-shadow: 0px 4px 24px 0px #00000026;
display: flex;
flex-direction: row;
flex-direction: column;
// this clips our children to our border radius
border-radius: 4px;
overflow: hidden;
min-height: 540px;

@media screen and ( min-width: 780px ) {
flex-direction: row;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Adds filters to allow sideloading of the Jetpack Backup plugin through JITMs.
2 changes: 1 addition & 1 deletion projects/packages/jitm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"link-template": "https://github.com/Automattic/jetpack-jitm/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "2.1.x-dev"
}
}
}
2 changes: 1 addition & 1 deletion projects/packages/jitm/src/class-jitm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class JITM {

const PACKAGE_VERSION = '2.0.8';
const PACKAGE_VERSION = '2.1.0-alpha';

/**
* The configuration method that is called from the jetpack-config package.
Expand Down
38 changes: 38 additions & 0 deletions projects/packages/jitm/src/class-post-connection-jitm.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,40 @@ public static function jitm_jetpack_creative_mail_activate() {
);
}

/**
* A special filter used in the CTA of a JITM offering to install the Jetpack Backup plugin.
*
* @return string The new CTA
*/
public static function jitm_jetpack_backup_install() {
return wp_nonce_url(
add_query_arg(
array(
'jetpack-backup-action' => 'install',
),
admin_url( 'admin.php?page=jetpack' )
),
'jetpack-backup-install'
);
}

/**
* A special filter used in the CTA of a JITM offering to activate the Jetpack Backup plugin.
*
* @return string The new CTA
*/
public static function jitm_jetpack_backup_activate() {
return wp_nonce_url(
add_query_arg(
array(
'jetpack-backup-action' => 'activate',
),
admin_url( 'admin.php?page=jetpack' )
),
'jetpack-backup-install'
);
}

/**
* This is an entire admin notice dedicated to messaging and handling of the case where a user is trying to delete
* the connection owner.
Expand Down Expand Up @@ -366,6 +400,10 @@ public function get_messages( $message_path, $query, $full_jp_logo_exists ) {
add_filter( 'jitm_jetpack_creative_mail_install', array( $this, 'jitm_jetpack_creative_mail_install' ) );
add_filter( 'jitm_jetpack_creative_mail_activate', array( $this, 'jitm_jetpack_creative_mail_activate' ) );

// Jetpack Backup.
add_filter( 'jitm_jetpack_backup_install', array( $this, 'jitm_jetpack_backup_install' ) );
add_filter( 'jitm_jetpack_backup_activate', array( $this, 'jitm_jetpack_backup_activate' ) );

$user = wp_get_current_user();

// Unauthenticated or invalid requests just bail.
Expand Down
1 change: 1 addition & 0 deletions projects/plugins/jetpack/3rd-party/3rd-party.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function load_3rd_party() {
'class-jetpack-crm-data.php',
'class-jetpack-modules-overrides.php', // Special case. Tools to be used to override module settings.
'creative-mail.php',
'jetpack-backup.php',
'debug-bar.php',
'class-domain-mapping.php',
'crowdsignal.php',
Expand Down
105 changes: 105 additions & 0 deletions projects/plugins/jetpack/3rd-party/jetpack-backup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* Compatibility functions for the Jetpack Backup plugin.
* https://wordpress.org/plugins/jetpack-backup/
*
* @since 10.4
*
* @package automattic/jetpack
*/

namespace Automattic\Jetpack\Jetpack_Backup;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

const PLUGIN_SLUG = 'jetpack-backup';
const PLUGIN_FILE = 'jetpack-backup/jetpack-backup.php';

add_action( 'admin_notices', __NAMESPACE__ . '\error_notice' );
add_action( 'admin_init', __NAMESPACE__ . '\try_install' );

/**
* Verify the intent to install Jetpack Backup, and kick off installation.
*
* This works in tandem with a JITM set up in the JITM package.
*/
function try_install() {
if ( ! isset( $_GET['jetpack-backup-action'] ) ) {
return;
}

check_admin_referer( 'jetpack-backup-install' );

$result = false;
// If the plugin install fails, redirect to plugin install page pre-populated with jetpack-backup search term.
$redirect_on_error = admin_url( 'plugin-install.php?s=jetpack-backup&tab=search&type=term' );

// Attempt to install and activate the plugin.
if ( current_user_can( 'activate_plugins' ) ) {
switch ( $_GET['jetpack-backup-action'] ) {
case 'install':
$result = install_and_activate();
break;
case 'activate':
$result = activate();
break;
}
}

if ( $result ) {
/** This action is already documented in _inc/lib/class.core-rest-api-endpoints.php */
do_action( 'jetpack_activated_plugin', PLUGIN_FILE, 'jitm' );
$redirect = admin_url( 'admin.php?page=jetpack-backup' );
} else {
$redirect = add_query_arg( 'jetpack-backup-install-error', true, $redirect_on_error );
}

wp_safe_redirect( $redirect );

exit;
}

/**
* Install and activate the Jetpack Backup plugin.
*
* @return bool result of installation
*/
function install_and_activate() {
jetpack_require_lib( 'plugins' );
$result = \Jetpack_Plugins::install_and_activate_plugin( PLUGIN_SLUG );

if ( is_wp_error( $result ) ) {
return false;
} else {
return true;
}
}

/**
* Activate the Jetpack Backup plugin.
*
* @return bool result of activation
*/
function activate() {
$result = activate_plugin( PLUGIN_FILE );

// Activate_plugin() returns null on success.
return is_null( $result );
}

/**
* Notify the user that the installation of Jetpack Backup failed.
*/
function error_notice() {
if ( empty( $_GET['jetpack-backup-install-error'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}

?>
<div class="notice notice-error is-dismissible">
<p><?php esc_html_e( 'There was an error installing Jetpack Backup. Please try again.', 'jetpack' ); ?></p>
</div>
<?php
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: compat

Jetpack Backup: Add considtions that allow sideloading of Jetpack Backup plugin via JITMs.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Updated package dependencies.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/add-license-styling-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Updated package dependencies.
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"automattic/jetpack-error": "1.3.x-dev",
"automattic/jetpack-heartbeat": "1.3.x-dev",
"automattic/jetpack-identity-crisis": "0.4.x-dev",
"automattic/jetpack-jitm": "2.0.x-dev",
"automattic/jetpack-jitm": "2.1.x-dev",
"automattic/jetpack-lazy-images": "2.0.x-dev",
"automattic/jetpack-licensing": "1.5.x-dev",
"automattic/jetpack-logo": "1.5.x-dev",
Expand Down
6 changes: 3 additions & 3 deletions projects/plugins/jetpack/composer.lock

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

0 comments on commit 3359a76

Please sign in to comment.