Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/settings-newsletter-1023-disabled-conne…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
grzegorz-cp committed Oct 4, 2024
2 parents 80c2a76 + c6f08cf commit 6d75d26
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 62 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Bug Report
description: Report issues with one of our products.
labels: [ 'Needs triage', '[Type] Bug' ]
type: 'Bug'
body:
- type: markdown
attributes:
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/enhancement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Enhancement Request
description: Suggest a change to a feature you like!
title: "Enhancement:"
labels: ["[Type] Enhancement"]
type: 'Enhancement'
body:
- type: dropdown
id: plugin-type
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Feature Request
description: Suggest an idea for this project!
title: "Feature Request:"
labels: ["[Type] Feature Request"]
type: 'Enhancement'
body:
- type: dropdown
id: plugin-type
Expand Down
2 changes: 1 addition & 1 deletion .phan/stubs/amp-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from AMP 2.5.4 and AMP for WP 1.0.98
* Stubs automatically generated from AMP 2.5.4 and AMP for WP 1.0.99.1
* using the definition file `tools/stubs/amp-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down
2 changes: 1 addition & 1 deletion .phan/stubs/woocommerce-internal-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from WooCommerce 9.3.2
* Stubs automatically generated from WooCommerce 9.5.0-dev
* using the definition file `tools/stubs/woocommerce-internal-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down
2 changes: 1 addition & 1 deletion .phan/stubs/woocommerce-payments-stubs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Stubs automatically generated from WooPayments 8.2.1
* Stubs automatically generated from WooPayments 8.2.2
* using the definition file `tools/stubs/woocommerce-payments-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
Expand Down
28 changes: 17 additions & 11 deletions pnpm-lock.yaml

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

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

Admin bar: replace 'Edit Profile' and 'My Account' with 'My Profile'
Original file line number Diff line number Diff line change
Expand Up @@ -236,52 +236,25 @@ function wpcom_add_reader_menu( $wp_admin_bar ) {
add_action( 'admin_bar_menu', 'wpcom_add_reader_menu', 11 );

/**
* Points the "Edit Profile" and "Howdy,..." to /me when appropriate.
* Points the "Edit Profile" and "Howdy,..." to /me.
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar core object.
*/
function wpcom_maybe_replace_edit_profile_menu_to_me( $wp_admin_bar ) {
function wpcom_replace_edit_profile_menu_to_me( $wp_admin_bar ) {
$edit_profile_node = $wp_admin_bar->get_node( 'user-info' );
if ( $edit_profile_node ) {
/**
* The Edit Profile menu should point to /me, instead of the site's profile.php
* if the user is not a member of the current site
*/
if ( ! is_user_member_of_blog() ) {
$edit_profile_node->href = maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' );
$wp_admin_bar->add_node( (array) $edit_profile_node );
}
}
}
// Run this function later than Core: https://github.com/WordPress/wordpress-develop/blob/5a30482419f1b0bcc713a7fdee3a14afd67a1bca/src/wp-includes/class-wp-admin-bar.php#L651
add_action( 'admin_bar_menu', 'wpcom_maybe_replace_edit_profile_menu_to_me', 9999 );

/**
* Adds (Profile) -> My Account menu pointing to /me.
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar core object.
*/
function wpcom_add_my_account_item_to_profile_menu( $wp_admin_bar ) {
$logout_node = $wp_admin_bar->get_node( 'logout' );
if ( $logout_node ) {
// Adds the 'My Account' menu item before 'Log Out'.
$wp_admin_bar->remove_node( 'logout' );
$edit_profile_node->href = maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' );
$edit_profile_node->title = preg_replace( "/(<span class='display-name edit-profile'>)(.*?)(<\/span>)/", '$1' . __( 'My Profile', 'jetpack-mu-wpcom' ) . '$3', $edit_profile_node->title );
$wp_admin_bar->add_node( (array) $edit_profile_node );
}

$wp_admin_bar->add_node(
array(
'id' => 'wpcom-profile',
'parent' => 'user-actions',
'title' => __( 'My Account', 'jetpack-mu-wpcom' ),
'href' => maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' ),
)
);

if ( $logout_node ) {
$wp_admin_bar->add_node( (array) $logout_node );
$my_account_node = $wp_admin_bar->get_node( 'my-account' );
if ( $my_account_node ) {
$my_account_node->href = maybe_add_origin_site_id_to_url( 'https://wordpress.com/me' );
$wp_admin_bar->add_node( (array) $my_account_node );
}
}
add_action( 'admin_bar_menu', 'wpcom_add_my_account_item_to_profile_menu' );
// Run this function later than Core: https://github.com/WordPress/wordpress-develop/blob/5a30482419f1b0bcc713a7fdee3a14afd67a1bca/src/wp-includes/class-wp-admin-bar.php#L651
add_action( 'admin_bar_menu', 'wpcom_replace_edit_profile_menu_to_me', 9999 );

/**
* Replaces the default admin bar class with our own.
Expand Down
4 changes: 4 additions & 0 deletions projects/packages/search/changelog/renovate-photon-4.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
2 changes: 1 addition & 1 deletion projects/packages/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"clsx": "2.1.1",
"fast-json-stable-stringify": "2.1.0",
"lodash": "4.17.21",
"photon": "4.0.0",
"photon": "4.1.1",
"preact": "10.22.1",
"prop-types": "15.7.2",
"q-flat": "1.0.7",
Expand Down
4 changes: 4 additions & 0 deletions projects/packages/wordads/changelog/renovate-photon-4.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
2 changes: 1 addition & 1 deletion projects/packages/wordads/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"clsx": "2.1.1",
"fast-json-stable-stringify": "2.1.0",
"lodash": "4.17.21",
"photon": "4.0.0",
"photon": "4.1.1",
"preact": "10.22.1",
"prop-types": "15.7.2",
"q-flat": "1.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public function setup() {
$this->ignore_attribute = apply_filters( 'jetpack_boost_render_blocking_js_ignore_attribute', 'data-jetpack-boost' );

add_action( 'template_redirect', array( $this, 'start_output_filtering' ), -999999 );

/**
* Shortcodes can sometimes output script to embed widget. It's safer to ignore them.
*/
add_filter( 'do_shortcode_tag', array( $this, 'add_ignore_attribute' ) );
}

/**
Expand Down Expand Up @@ -256,7 +261,7 @@ protected function ignore_exclusion_scripts( $buffer ) {
return preg_replace_callback(
$exclusions,
function ( $script_match ) {
return str_replace( '<script', sprintf( '<script %s="%s"', esc_html( $this->ignore_attribute ), esc_attr( $this->ignore_value ) ), $script_match[0] );
return $this->add_ignore_attribute( $script_match[0] );
},
$buffer
);
Expand Down Expand Up @@ -324,7 +329,18 @@ public function handle_exclusions( $tag, $handle ) {
return $tag;
}

return str_replace( '<script', sprintf( '<script %s="%s"', esc_html( $this->ignore_attribute ), esc_attr( $this->ignore_value ) ), $tag );
return $this->add_ignore_attribute( $tag );
}

/**
* Add the ignore attribute to the script tags
*
* @param string $html HTML code possibly containing a <script> opening tag.
*
* @return string
*/
public function add_ignore_attribute( $html ) {
return str_replace( '<script', sprintf( '<script %s="%s"', esc_html( $this->ignore_attribute ), esc_attr( $this->ignore_value ) ), $html );
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Deferred JS: Exclude all scripts produced by a shortcode.
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
'json-endpoints/class.wpcom-json-api-list-posts-endpoint.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'],
'json-endpoints/class.wpcom-json-api-list-posts-v1-1-endpoint.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternalReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'],
'json-endpoints/class.wpcom-json-api-list-posts-v1-2-endpoint.php' => ['PhanNoopNew', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternalReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'],
'json-endpoints/class.wpcom-json-api-list-roles-endpoint.php' => ['PhanDeprecatedPartiallySupportedCallable', 'PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypeSuspiciousNonTraversableForeach'],
'json-endpoints/class.wpcom-json-api-list-roles-endpoint.php' => ['PhanDeprecatedPartiallySupportedCallable', 'PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn'],
'json-endpoints/class.wpcom-json-api-list-shortcodes-endpoint.php' => ['PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn'],
'json-endpoints/class.wpcom-json-api-list-terms-endpoint.php' => ['PhanNoopNew', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypeSuspiciousNonTraversableForeach'],
'json-endpoints/class.wpcom-json-api-list-users-endpoint.php' => ['PhanNoopNew', 'PhanRedundantCondition', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanUndeclaredProperty'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Blogging Prompt: preserve language on answers link
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/renovate-photon-4.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Updated package dependencies.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Minor check to avoid Warnings


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Change done to avoid fatal in wpcom when using v1 endpoint with force wpcom param
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { __, _x, sprintf } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import clsx from 'clsx';
import './editor.scss';
import { languageToLocale } from '../../shared/locale';
import { usePromptTags } from './use-prompt-tags';

function BloggingPromptEdit( { attributes, noticeOperations, noticeUI, setAttributes } ) {
Expand Down Expand Up @@ -101,9 +102,10 @@ function BloggingPromptEdit( { attributes, noticeOperations, noticeUI, setAttrib
apiFetch( { path } )
.then( prompts => {
const promptData = promptId ? prompts : prompts[ 0 ];
const locale = languageToLocale( siteLanguage );

setAttributes( {
answersLink: promptData.answered_link,
answersLink: promptData.answered_link + `?locale=${ locale }`,
answersLinkText: promptData.answered_link_text,
gravatars: promptData.answered_users_sample.map( ( { avatar } ) => ( { url: avatar } ) ),
promptFetched: true,
Expand Down
22 changes: 22 additions & 0 deletions projects/plugins/jetpack/extensions/shared/locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* languageToLocale converts a language tag to an ISO 639 conforming locale string.
*
* @param {string} language - a language tag to be converted, e.g. "en_US".
* @return {string} ISO 639 locale string, e.g. "en".
*/
export function languageToLocale( language ) {
const withCountryCode = [ 'pt_br', 'pt-br', 'zh_tw', 'zh-tw', 'zh_cn', 'zh-cn' ];

language = language.toLowerCase();
if ( withCountryCode.includes( language ) ) {
language = language.replace( '_', '-' );
} else {
language = language.replace( /([-_].*)$/i, '' );
}

if ( language === '' ) {
return 'en';
}

return language;
}
25 changes: 25 additions & 0 deletions projects/plugins/jetpack/extensions/shared/test/locale.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { languageToLocale } from '../locale';

describe( 'languageToLocale', () => {
test( 'empty string should return en', () => {
expect( languageToLocale( '' ) ).toBe( 'en' );
} );

test( 'underscores should be replaced', () => {
expect( languageToLocale( 'pt_BR' ) ).toBe( 'pt-br' );
expect( languageToLocale( 'zh_CN' ) ).toBe( 'zh-cn' );
expect( languageToLocale( 'zh_TW' ) ).toBe( 'zh-tw' );
} );

test( 'country codes should be dropped', () => {
expect( languageToLocale( 'en-GB' ) ).toBe( 'en' );
expect( languageToLocale( 'en_US' ) ).toBe( 'en' );
expect( languageToLocale( 'es-ES' ) ).toBe( 'es' );
} );

test( 'locales should be lowercase', () => {
expect( languageToLocale( 'EN' ) ).toBe( 'en' );
expect( languageToLocale( 'FR' ) ).toBe( 'fr' );
expect( languageToLocale( 'PL' ) ).toBe( 'pl' );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function callback( $path = '', $blog_id = 0 ) {
return new WP_Error( 'unauthorized', 'User cannot view roles for specified site', 403 );
}

if ( method_exists( $wp_roles, 'get_names' ) ) {
if ( $wp_roles instanceof WP_Roles ) {
$role_names = $wp_roles->get_names();

$role_keys = array_keys( $role_names );
Expand All @@ -134,7 +134,7 @@ public function callback( $path = '', $blog_id = 0 ) {
$role_details->display_name = translate_user_role( $role_names[ $role_key ] );
$roles[] = $role_details;
}
} else {
} elseif ( is_array( $wp_roles ) ) {
// Jetpack Shadow Site side of things.
foreach ( $wp_roles as $role_key => $role ) {
$roles[] = (object) array(
Expand Down
Loading

0 comments on commit 6d75d26

Please sign in to comment.