Skip to content

Commit

Permalink
Merge branch 'trunk' into add/social-add-connection-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjuhasz committed May 7, 2024
2 parents fef8379 + 74cf89e commit 7f8d947
Show file tree
Hide file tree
Showing 52 changed files with 630 additions and 270 deletions.
7 changes: 5 additions & 2 deletions .phan/stubs/wpcom-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* `bin/teamcity-builds/jetpack-stubs/stub-defs.php` and regenerate the stubs
* by triggering the Jetpack Staging → Update WPCOM Stubs job in TeamCity.
*
* Stubs automatically generated from WordPress.com commit e060d49d53909b256abff72b5ffe22152e96eadd.
* Stubs automatically generated from WordPress.com commit 753696f231e5c160460266a6f63e5b87cdcbea50.
*/

namespace {
Expand Down Expand Up @@ -321,8 +321,11 @@ public static function get_product_list($_blog_id, $type = \null, ?bool $is_edit
{
}
}
class Memberships_Store_Sandbox extends \Store_Sandbox
class Memberships_Store_Sandbox
{
public function init($force = \false)
{
}
/**
* @return Memberships_Store_Sandbox
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Jetpack Backup: Add a LoadingPlaceholder while waiting for Jetpack Backup price
37 changes: 22 additions & 15 deletions projects/js-packages/components/components/pricing-card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCurrencyObject } from '@automattic/format-currency';
import { LoadingPlaceholder } from '@automattic/jetpack-components';
import { Button } from '@wordpress/components';
import { sprintf, __ } from '@wordpress/i18n';
import TermsOfService from '../terms-of-service';
Expand Down Expand Up @@ -54,7 +55,7 @@ const PricingCard: React.FC< PricingCardProps > = ( {
) }
<h1 className="jp-components__pricing-card__title">{ props.title }</h1>
<div className="jp-components__pricing-card__pricing">
{ props.priceBefore !== props.priceAfter && (
{ props.priceBefore !== props.priceAfter && props.priceAfter > 0 ? (
<div className="jp-components__pricing-card__price-before">
<span className="jp-components__pricing-card__currency">
{ currencyObjectBefore.symbol }
Expand All @@ -70,21 +71,27 @@ const PricingCard: React.FC< PricingCardProps > = ( {
) }
<div className="jp-components__pricing-card__price-strikethrough"></div>
</div>
) : (
<LoadingPlaceholder width="100%" height={ 48 } />
) }
{ props.priceAfter > 0 && (
<>
<div className="jp-components__pricing-card__price-after">
<span className="jp-components__pricing-card__currency">
{ currencyObjectAfter.symbol }
</span>
<span className="jp-components__pricing-card__price">
{ currencyObjectAfter.integer }
</span>
{ showPriceDecimals( currencyObjectAfter ) && (
<span className="jp-components__pricing-card__price-decimal">
{ currencyObjectAfter.fraction }
</span>
) }
</div>
<span className="jp-components__pricing-card__price-details">{ priceDetails }</span>
</>
) }
<div className="jp-components__pricing-card__price-after">
<span className="jp-components__pricing-card__currency">
{ currencyObjectAfter.symbol }
</span>
<span className="jp-components__pricing-card__price">
{ currencyObjectAfter.integer }
</span>
{ showPriceDecimals( currencyObjectAfter ) && (
<span className="jp-components__pricing-card__price-decimal">
{ currencyObjectAfter.fraction }
</span>
) }
</div>
<span className="jp-components__pricing-card__price-details">{ priceDetails }</span>
</div>

{ props.children && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Contact Form: Prevent an editor error when using the Classic Editor and contact forms are enabled
2 changes: 1 addition & 1 deletion projects/packages/forms/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-forms",
"version": "0.31.0",
"version": "0.31.1-alpha",
"description": "Jetpack Forms",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/forms/#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/forms/src/class-jetpack-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class Jetpack_Forms {

const PACKAGE_VERSION = '0.31.0';
const PACKAGE_VERSION = '0.31.1-alpha';

/**
* Load the contact form module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function grunion_media_button() {
*/
public static function mce_external_plugins( $plugin_array ) {
$plugin_array['grunion_form'] = Assets::get_file_url_for_environment(
'jetpack_vendor/automattic/jetpack-forms/dist/contact-form/js/tinymce-plugin-form-button.min.js',
'jetpack_vendor/automattic/jetpack-forms/dist/contact-form/js/tinymce-plugin-form-button.js',
'jetpack_vendor/automattic/jetpack-forms/dist/contact-form/js/tinymce-plugin-form-button.js'
);
return $plugin_array;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Themes: Fixed an issue that was showing a broken Theme Showcase action in the active theme details
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
const wpcomThemesRemoveWpcomActions = () => {
const themeOverlay = document.querySelector( '.theme-overlay' );
if ( ! themeOverlay ) {
const themeBrowser = document.querySelector( '.theme-browser' );
if ( ! themeOverlay || ! themeBrowser ) {
return;
}

const observer = new MutationObserver( mutations => {
for ( const mutation of mutations ) {
for ( const node of mutation.addedNodes ) {
// If this is not an overlay for the active theme, bail and check the next node.
if (
! node.classList.contains( 'theme-overlay' ) ||
! node.classList.contains( 'active' )
) {
continue;
}

const themeActions = node.querySelector( '.theme-actions .active-theme' );
for ( const action of themeActions?.children ?? [] ) {
if ( action.getAttribute( 'href' )?.includes( 'https://wordpress.com' ) ) {
themeActions.removeChild( action );
}
}
return;
}
}
} );

observer.observe( themeOverlay, { childList: true } );
observer.observe( themeBrowser, { childList: true } );
};

document.addEventListener( 'DOMContentLoaded', wpcomThemesRemoveWpcomActions );
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Scheduled Updates: Verify plugins when creating a schedule
2 changes: 1 addition & 1 deletion projects/packages/scheduled-updates/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"autotagger": true,
"branch-alias": {
"dev-trunk": "0.11.x-dev"
"dev-trunk": "0.12.x-dev"
},
"textdomain": "jetpack-scheduled-updates",
"version-constants": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Scheduled_Updates {
*
* @var string
*/
const PACKAGE_VERSION = '0.11.1-alpha';
const PACKAGE_VERSION = '0.12.0-alpha';

/**
* The cron event hook for the scheduled plugins update.
Expand Down Expand Up @@ -70,6 +70,8 @@ public static function init() {
add_action( 'jetpack_scheduled_update_deleted', array( Scheduled_Updates_Health_Paths::class, 'clear' ) );
add_action( 'jetpack_scheduled_update_deleted', array( Scheduled_Updates_Logs::class, 'delete_logs_schedule_id' ), 10, 3 );

add_filter( 'jetpack_scheduled_update_verify_plugins', array( __CLASS__, 'verify_plugins' ) );

// Update cron sync option after options update.
$callback = array( __CLASS__, 'update_option_cron' );

Expand Down Expand Up @@ -359,10 +361,7 @@ public static function add_is_managed_extension_field() {
* @return bool
*/
'get_callback' => function ( $data ) {
$folder = WP_PLUGIN_DIR . '/' . strtok( $data['plugin'], '/' );
$target = is_link( $folder ) ? realpath( $folder ) : false;

return $target && 0 === strpos( $target, '/wordpress/' );
return self::is_plugin_managed( $data['plugin'] );
},
'schema' => array(
'description' => 'Whether the plugin is managed by the host.',
Expand Down Expand Up @@ -436,4 +435,57 @@ public static function deleted_plugin( $plugin_file, $deleted ) {
public static function generate_schedule_id( $args ) {
return md5( serialize( $args ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
}

/**
* Check if a plugin is installed.
*
* @param string $plugin The plugin to check.
* @return bool
*/
public static function is_plugin_installed( $plugin ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$installed_plugins = get_plugins();
return array_key_exists( $plugin, $installed_plugins );
}

/**
* Check if a plugin is managed by the host.
*
* @param string $plugin The plugin to check.
* @return bool
*/
public static function is_plugin_managed( $plugin ) {
$folder = WP_PLUGIN_DIR . '/' . strtok( $plugin, '/' );
$target = is_link( $folder ) ? realpath( $folder ) : false;
return $target && 0 === strpos( $target, '/wordpress/' );
}

/**
* Verify that the plugins are installed.
*
* @param array $plugins List of plugins to update.
* @return bool|\WP_Error
*/
public static function verify_plugins( $plugins ) {
$request_plugins_not_installed_or_managed = true;

foreach ( $plugins as $plugin ) {
if ( self::is_plugin_installed( $plugin ) && ! self::is_plugin_managed( $plugin ) ) {
$request_plugins_not_installed_or_managed = false;
break;
}
}

if ( $request_plugins_not_installed_or_managed ) {
return new \WP_Error(
'rest_forbidden',
__( 'None of the specified plugins are installed or all of them are managed.', 'jetpack-scheduled-updates' ),
array( 'status' => 403 )
);
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ public function create_item( $request ) {
return $result;
}

$verified_plugins = apply_filters( 'jetpack_scheduled_update_verify_plugins', $request['plugins'] );

if ( is_wp_error( $verified_plugins ) ) {
return $verified_plugins;
}

$schedule = $request['schedule'];
$plugins = $request['plugins'];
usort( $plugins, 'strnatcasecmp' );
Expand Down Expand Up @@ -266,6 +272,12 @@ public function update_item( $request ) {
return $result;
}

$verified_plugins = apply_filters( 'jetpack_scheduled_update_verify_plugins', $request['plugins'] );

if ( is_wp_error( $verified_plugins ) ) {
return $verified_plugins;
}

$deleted = $this->delete_item( $request );
if ( is_wp_error( $deleted ) ) {
return $deleted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function set_up() {
)
);
wp_set_current_user( $this->admin_id );
add_filter( 'jetpack_scheduled_update_verify_plugins', '__return_true', 11 );

Scheduled_Updates::init();
}
Expand All @@ -58,7 +59,7 @@ public function set_up() {
public function tear_down() {
wp_delete_user( $this->admin_id );
delete_option( Scheduled_Updates_Health_Paths::OPTION_NAME );

remove_filter( 'jetpack_scheduled_update_verify_plugins', '__return_true', 11 );
parent::tear_down_wordbless();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected function set_up() {
)
);
wp_set_current_user( $this->admin_id );
add_filter( 'jetpack_scheduled_update_verify_plugins', '__return_true', 11 );
}

/**
Expand All @@ -68,7 +69,7 @@ protected function set_up() {
*/
protected function tear_down() {
delete_option( Scheduled_Updates_Logs::OPTION_NAME );

remove_filter( 'jetpack_scheduled_update_verify_plugins', '__return_true', 11 );
parent::tear_down_wordbless();
}

Expand Down
Loading

0 comments on commit 7f8d947

Please sign in to comment.