Skip to content

Commit

Permalink
Merge branch 'master' into update/lazy-images-assets-package-dependency
Browse files Browse the repository at this point in the history
* master:
  External Media: Handle space errors on upload (#17014)
  Autoloader: Support unoptimized PSR-4 (#16819)
  Donations / Payments: Use getSiteFragment for building Calypso links (#17042)
  Site Scan & AMP: Include toolbar scripts for Site Scan have data-ampdevmode on AMP requests (#17034)
  Update optin comment to correct default value of true. (#17048)
  Plugins: avoid including network-activated plugins in responses (#17044)
  Instant Search: Fix photon integration (#17037)
  • Loading branch information
davidlonjon committed Sep 4, 2020
2 parents 5582cf4 + c714c84 commit b4f8819
Show file tree
Hide file tree
Showing 62 changed files with 2,563 additions and 827 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ _inc/jetpack-strings.php
/vendor/class-autoloader-handler.php
/vendor/class-classes-handler.php
/vendor/class-files-handler.php
/vendor/class-manifest-handler.php
/vendor/class-plugins-handler.php
/vendor/class-version-selector.php
/vendor/jetpack-autoloader
4 changes: 2 additions & 2 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -6261,8 +6261,8 @@ public static function sync_idc_optin() {
}

/**
* Allows sites to opt in to IDC mitigation which blocks the site from syncing to WordPress.com when the home
* URL or site URL do not match what WordPress.com expects. The default value is either false, or the value of
* Allows sites to opt in for IDC mitigation which blocks the site from syncing to WordPress.com when the home
* URL or site URL do not match what WordPress.com expects. The default value is either true, or the value of
* JETPACK_SYNC_IDC_OPTIN constant if set.
*
* @since 4.3.2
Expand Down
3 changes: 3 additions & 0 deletions composer.lock

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

5 changes: 3 additions & 2 deletions extensions/blocks/donations/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import { DOWN } from '@wordpress/keycodes';
* Internal dependencies
*/
import { SUPPORTED_CURRENCIES } from '../../shared/currencies';
import getSiteFragment from '../../shared/get-site-fragment';

const Controls = props => {
const { attributes, setAttributes, siteSlug } = props;
const { attributes, setAttributes } = props;
const { currency, monthlyDonation, annualDonation, showCustomAmount } = attributes;

const toggleDonation = ( interval, show ) => {
Expand Down Expand Up @@ -112,7 +113,7 @@ const Controls = props => {
onChange={ value => setAttributes( { showCustomAmount: value } ) }
label={ __( 'Show custom amount option', 'jetpack' ) }
/>
<ExternalLink href={ `https://wordpress.com/earn/payments/${ siteSlug }` }>
<ExternalLink href={ `https://wordpress.com/earn/payments/${ getSiteFragment() }` }>
{ __( 'View donation earnings', 'jetpack' ) }
</ExternalLink>
</PanelBody>
Expand Down
3 changes: 0 additions & 3 deletions extensions/blocks/donations/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const Edit = props => {
const [ shouldUpgrade, setShouldUpgrade ] = useState( false );
const [ stripeConnectUrl, setStripeConnectUrl ] = useState( false );
const [ products, setProducts ] = useState( [] );
const [ siteSlug, setSiteSlug ] = useState( '' );

const apiError = message => {
setLoadingError( message );
Expand Down Expand Up @@ -51,7 +50,6 @@ const Edit = props => {
}
setShouldUpgrade( result.should_upgrade_to_access_memberships );
setStripeConnectUrl( result.connect_url );
setSiteSlug( result.site_slug );

const filteredProducts = filterProducts( result.products );

Expand Down Expand Up @@ -91,7 +89,6 @@ const Edit = props => {
{ ...props }
products={ products }
shouldUpgrade={ shouldUpgrade }
siteSlug={ siteSlug }
stripeConnectUrl={ stripeConnectUrl }
/>
);
Expand Down
7 changes: 2 additions & 5 deletions extensions/blocks/recurring-payments/edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import classnames from 'classnames';
import apiFetch from '@wordpress/api-fetch';
import { __, sprintf } from '@wordpress/i18n';
import formatCurrency from '@automattic/format-currency';
import { addQueryArgs, getQueryArg, isURL } from '@wordpress/url';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import {
Expand All @@ -28,6 +27,7 @@ import { applyFilters } from '@wordpress/hooks';
import getJetpackExtensionAvailability from '../../shared/get-jetpack-extension-availability';
import StripeNudge from '../../shared/components/stripe-nudge';
import { minimumTransactionAmountForCurrency } from '../../shared/currencies';
import getSiteFragment from '../../shared/get-site-fragment';
import { icon, isPriceValid, removeInvalidProducts, CURRENCY_OPTIONS } from '.';

const API_STATE_LOADING = 0;
Expand Down Expand Up @@ -63,7 +63,6 @@ class MembershipsButtonEdit extends Component {
shouldUpgrade: false,
upgradeURL: '',
products: [],
siteSlug: '',
editedProductCurrency: 'USD',
editedProductPrice: formatPriceForNumberInputValue(
minimumTransactionAmountForCurrency( 'USD' ),
Expand Down Expand Up @@ -112,7 +111,6 @@ class MembershipsButtonEdit extends Component {
products,
should_upgrade_to_access_memberships: shouldUpgrade,
upgrade_url: upgradeURL,
site_slug: siteSlug,
} = result;
const connected = result.connected_account_id
? API_STATE_CONNECTED
Expand All @@ -122,7 +120,6 @@ class MembershipsButtonEdit extends Component {
connectURL,
shouldUpgrade,
upgradeURL,
siteSlug,
products: removeInvalidProducts( products ),
} );
},
Expand Down Expand Up @@ -415,7 +412,7 @@ class MembershipsButtonEdit extends Component {
/>
</PanelBody>
<PanelBody title={ __( 'Management', 'jetpack' ) }>
<ExternalLink href={ `https://wordpress.com/earn/payments/${ this.state.siteSlug }` }>
<ExternalLink href={ `https://wordpress.com/earn/payments/${ getSiteFragment() }` }>
{ __( 'See your earnings, subscriber list, and payment plans.', 'jetpack' ) }
</ExternalLink>
</PanelBody>
Expand Down
8 changes: 8 additions & 0 deletions extensions/shared/external-media/sources/with-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ export default function withMedia() {
return;
}

// Normalize upload errors.
if ( error.errors?.length ) {
error = {
code: error.errors[ 0 ].error,
message: error.errors[ 0 ].message,
};
}

const { noticeOperations } = this.props;

noticeOperations.createErrorNotice(
Expand Down
31 changes: 28 additions & 3 deletions json-endpoints/jetpack/class.jetpack-json-api-plugins-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ protected function format_plugin( $plugin_file, $plugin_data ) {
$plugin['uninstallable'] = is_uninstallable_plugin( $plugin_file );
if ( is_multisite() ) {
$plugin['network_active'] = is_plugin_active_for_network( $plugin_file );
}
if ( ! empty ( $this->log[ $plugin_file ] ) ) {
$plugin['log'] = $this->log[ $plugin_file ];
}
Expand Down Expand Up @@ -183,6 +187,10 @@ protected function format_plugin_v1_2( $plugin_file, $plugin_data ) {
$plugin['autoupdate_translation'] = $autoupdate || $autoupdate_translation || Jetpack_Options::get_option( 'autoupdate_translations', false );
$plugin['uninstallable'] = is_uninstallable_plugin( $plugin_file );
if ( is_multisite() ) {
$plugin['network_active'] = is_plugin_active_for_network( $plugin_file );
}
if ( ! empty ( $this->log[ $plugin_file ] ) ) {
$plugin['log'] = $this->log[ $plugin_file ];
}
Expand Down Expand Up @@ -248,10 +256,27 @@ protected function get_plugins() {
$plugins = array();
/** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
$installed_plugins = apply_filters( 'all_plugins', get_plugins() );
foreach( $this->plugins as $plugin ) {
if ( ! isset( $installed_plugins[ $plugin ] ) )
foreach ( $this->plugins as $plugin ) {
if ( ! isset( $installed_plugins[ $plugin ] ) ) {
continue;
$plugins[] = $this->format_plugin( $plugin, $installed_plugins[ $plugin ] );
}
$formatted_plugin = $this->format_plugin( $plugin, $installed_plugins[ $plugin ] );
/*
* Do not show network-active plugins
* to folks who do not have the permission to see them.
*/
if (
/** This filter is documented in src/wp-admin/includes/class-wp-plugins-list-table.php */
! apply_filters( 'show_network_active_plugins', current_user_can( 'manage_network_plugins' ) )
&& ! empty( $formatted_plugin['network_active'] )
&& true === $formatted_plugin['network_active']
) {
continue;
}
$plugins[] = $formatted_plugin;
}
$args = $this->query_args();
Expand Down
11 changes: 10 additions & 1 deletion modules/scan/class-admin-bar-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ private function init_hooks() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_toolbar_script' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_toolbar_script' ) );
add_action( 'admin_bar_menu', array( $this, 'add_threats_to_toolbar' ), 999 );

// Inject the data-ampdevmode attribute into the inline <script> output via wp_localize_script(). To revisit after https://github.com/ampproject/amp-wp/issues/4598.
add_filter(
'amp_dev_mode_element_xpaths',
static function ( $expressions ) {
$expressions[] = '//script[ contains( text(), "Jetpack_Scan" ) ]';
return $expressions;
}
);
}

/**
Expand Down Expand Up @@ -90,7 +99,7 @@ public function enqueue_toolbar_script() {
}

// We don't know about threats in the cache lets load the JS that fetches the info and updates the admin bar.
Assets::enqueue_async_script( self::SCRIPT_NAME, '_inc/build/scan/admin-bar-notice.min.js', 'modules/scan/admin-bar-notice.js', array(), self::SCRIPT_VERSION, true );
Assets::enqueue_async_script( self::SCRIPT_NAME, '_inc/build/scan/admin-bar-notice.min.js', 'modules/scan/admin-bar-notice.js', array( 'admin-bar' ), self::SCRIPT_VERSION, true );

$script_data = array(
'nonce' => wp_create_nonce( 'wp_rest' ),
Expand Down
22 changes: 19 additions & 3 deletions modules/search/instant-search/components/photon-image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,29 @@
import { h } from 'preact';
import photon from 'photon';

/**
* Strips query string values from URLs; photon can't handle them.
*
* @param {string} url - Image URL
*
* @returns {string} - Image URL without any query strings.
*/
function stripQueryString( url ) {
return url.split( '?', 1 )[ 0 ];
}

const PhotonImage = ( { useDiv, src, maxWidth = 300, maxHeight = 300, alt, ...otherProps } ) => {
const photonSrc = photon( src, { resize: `${ maxWidth },${ maxHeight }` } );
const photonSrc = photon( stripQueryString( src ), { resize: `${ maxWidth },${ maxHeight }` } );
const srcToDisplay = photonSrc !== null ? photonSrc : src;

return useDiv ? (
<div style={ { backgroundImage: `url("${ src }")` } } title={ alt } { ...otherProps } />
<div
style={ { backgroundImage: `url("${ srcToDisplay }")` } }
title={ alt }
{ ...otherProps }
/>
) : (
<img src={ photonSrc !== null ? photonSrc : src } alt={ alt } { ...otherProps } />
<img src={ srcToDisplay } alt={ alt } { ...otherProps } />
);
};

Expand Down
3 changes: 3 additions & 0 deletions packages/autoloader/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5"
},
"autoload": {
"classmap": [
"src/AutoloadGenerator.php"
],
"psr-4": {
"Automattic\\Jetpack\\Autoloader\\": "src"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/autoloader/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<phpunit bootstrap="tests/php/bootstrap.php" backupGlobals="true" colors="true">
<testsuites>
<testsuite name="main">
<directory prefix="test" suffix=".php">tests/php</directory>
<directory prefix="test" suffix=".php">tests/php/tests</directory>
</testsuite>
</testsuites>
<filter>
Expand Down
Loading

0 comments on commit b4f8819

Please sign in to comment.