Skip to content

Commit

Permalink
Merge branch 'trunk' into add/boost/e2e-tests-concatenate-js-css
Browse files Browse the repository at this point in the history
  • Loading branch information
dilirity committed Apr 3, 2024
2 parents 8798188 + 5bfd7a9 commit 3288ed5
Show file tree
Hide file tree
Showing 119 changed files with 1,462 additions and 345 deletions.
8 changes: 8 additions & 0 deletions .github/files/e2e-tests/e2e-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ const projects = [
suite: '',
buildGroup: 'jetpack-boost',
},
{
project: 'Jetpack Boost - Image Guide',
path: 'projects/plugins/boost/tests/e2e',
testArgs: [ 'specs/image-guide', '--retries=1' ],
targets: [ 'plugins/boost' ],
suite: '',
buildGroup: 'jetpack-boost',
},
{
project: 'Search',
path: 'projects/plugins/search/tests/e2e',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Added options and UI for link formatting
2 changes: 1 addition & 1 deletion projects/js-packages/publicize-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-publicize-components",
"version": "0.48.5",
"version": "0.48.6-alpha",
"description": "A library of JS components required by the Publicize editor plugin",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/publicize-components/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ export function* updateSocialNotesSettings( settings ) {
}
}

/**
* Yield actions to update settings
*
* @param {object} config - config to update
* @yields {object} - an action object.
* @returns {object} - an action object.
*/
export function* updateSocialNotesConfig( config ) {
const prevConfig = select( SOCIAL_STORE_ID ).getSocialNotesConfig();
const newConfig = { ...prevConfig, ...config };
try {
yield setJetpackSettings( { social_notes_config: newConfig } );
yield updateJetpackSettingsControl( { social_notes_config: config } );
const updatedSettings = yield fetchJetpackSettings();
yield setJetpackSettings( updatedSettings );
return true;
} catch ( e ) {
yield setJetpackSettings( { social_notes_config: prevConfig } );
return false;
}
}

/**
* Yield actions to refresh settings
*
Expand Down Expand Up @@ -67,7 +89,17 @@ export function setUpdatingSocialNotesSettingsDone() {
return setJetpackSettings( { social_notes_is_updating: false } );
}

/**
* Set state updating action
*
* @returns {object} - an action object.
*/
export function setUpdatingSocialNotesConfig() {
return setJetpackSettings( { social_notes_config_is_updating: true } );
}

export default {
updateSocialNotesSettings,
updateSocialNotesConfig,
refreshSocialNotesSettings,
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const jetpackSettingSelectors = {
getDismissedNotices: state => state.jetpackSettings?.dismissedNotices,
isSocialNotesEnabled: state => state.jetpackSettings?.social_notes_enabled,
isSocialNotesSettingsUpdating: state => state.jetpackSettings?.social_notes_is_updating,
getSocialNotesConfig: state => state.jetpackSettings?.social_notes_config ?? {},
};

export default jetpackSettingSelectors;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Added functionality for extracting the browser and desktop platform from a user agent
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static function get_info( $ua = '' ) {
'is_smartphone' => self::is_mobile( 'smart', false, $ua_info ),
'is_tablet' => $ua_info->is_tablet(),
'platform' => $ua_info->get_platform(),
'desktop_platform' => $ua_info->get_desktop_platform(),
'browser' => $ua_info->get_browser(),
);

$info['is_handheld'] = $info['is_phone'] || $info['is_tablet'];
Expand Down
188 changes: 175 additions & 13 deletions projects/packages/device-detection/src/class-user-agent-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,30 @@ class User_Agent_Info {
*
* @var null|string
*/
private $platform = null;
const PLATFORM_WINDOWS = 'windows';
const PLATFORM_IPHONE = 'iphone';
const PLATFORM_IPOD = 'ipod';
const PLATFORM_IPAD = 'ipad';
const PLATFORM_BLACKBERRY = 'blackberry';
const PLATFORM_BLACKBERRY_10 = 'blackberry_10';
const PLATFORM_SYMBIAN = 'symbian_series60';
const PLATFORM_SYMBIAN_S40 = 'symbian_series40';
const PLATFORM_J2ME_MIDP = 'j2me_midp';
const PLATFORM_ANDROID = 'android';
const PLATFORM_ANDROID_TABLET = 'android_tablet';
const PLATFORM_FIREFOX_OS = 'firefoxOS';
private $platform = null;
const PLATFORM_WINDOWS = 'windows';
const PLATFORM_IPHONE = 'iphone';
const PLATFORM_IPOD = 'ipod';
const PLATFORM_IPAD = 'ipad';
const PLATFORM_BLACKBERRY = 'blackberry';
const PLATFORM_BLACKBERRY_10 = 'blackberry_10';
const PLATFORM_SYMBIAN = 'symbian_series60';
const PLATFORM_SYMBIAN_S40 = 'symbian_series40';
const PLATFORM_J2ME_MIDP = 'j2me_midp';
const PLATFORM_ANDROID = 'android';
const PLATFORM_ANDROID_TABLET = 'android_tablet';
const PLATFORM_FIREFOX_OS = 'firefoxOS';
const PLATFORM_DESKTOP_LINUX = 'linux';
const PLATFORM_DESKTOP_MAC = 'mac';
const PLATFORM_DESKTOP_WINDOWS = 'windows';
const PLATFORM_DESKTOP_CHROME = 'chrome';
const BROWSER_CHROME = 'chrome';
const BROWSER_FIREFOX = 'firefox';
const BROWSER_SAFARI = 'safari';
const BROWSER_EDGE = 'edge';
const BROWSER_OPERA = 'opera';
const BROWSER_IE = 'ie';
const OTHER = 'other';

/**
* A list of dumb-phone user agent parts.
Expand Down Expand Up @@ -277,6 +288,57 @@ public function get_platform() {
return $this->platform;
}

/**
* Returns the platform for desktops
*
* @return string
*/
public function get_desktop_platform() {
$ua = $this->useragent;
if ( empty( $ua ) ) {
return false;
}
$platform = self::OTHER;

if ( static::is_linux_desktop() ) {
$platform = self::PLATFORM_DESKTOP_LINUX;
} elseif ( static::is_mac_desktop() ) {
$platform = self::PLATFORM_DESKTOP_MAC;
} elseif ( static::is_windows_desktop() ) {
$platform = self::PLATFORM_DESKTOP_WINDOWS;
} elseif ( static::is_chrome_desktop() ) {
$platform = self::PLATFORM_DESKTOP_CHROME;
}
return $platform;
}

/**
* A simple pattern matching method for extracting the browser from the user agent.
*
* @return string
*/
public function get_browser() {
$ua = $this->useragent;
if ( empty( $ua ) ) {
return self::OTHER;
}

if ( static::is_opera_mini() || static::is_opera_mobile() || static::is_opera_desktop() || static::is_opera_mini_dumb() ) {
return self::BROWSER_OPERA;
} elseif ( static::is_edge_browser() ) {
return self::BROWSER_EDGE;
} elseif ( static::is_chrome_desktop() || self::is_chrome_for_iOS() ) {
return self::BROWSER_CHROME;
} elseif ( static::is_safari_browser() ) {
return self::BROWSER_SAFARI;
} elseif ( static::is_firefox_mobile() || static::is_firefox_desktop() ) {
return self::BROWSER_FIREFOX;
} elseif ( static::is_ie_browser() ) {
return self::BROWSER_IE;
}
return self::OTHER;
}

/**
* This method detects for UA which can display iPhone-optimized web content.
* Includes iPhone, iPod Touch, Android, WebOS, Fennec (Firefox mobile), etc.
Expand Down Expand Up @@ -714,6 +776,46 @@ public static function is_firefox_os() {
}
}

/**
* Detect Safari browser
*/
public static function is_safari_browser() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Safari' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}

/**
* Detect Edge browser
*/
public static function is_edge_browser() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Edge' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}

/**
* Detect Edge browser
*/
public static function is_ie_browser() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$ua = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
if ( false === ( strpos( $ua, 'MSIE' ) || strpos( $ua, 'Trident/7' ) ) ) {
return false;
}
return true;
}

/**
* Detect modern Opera desktop
*
Expand Down Expand Up @@ -1271,6 +1373,66 @@ public static function is_blackberry_10() {
return ( strpos( $agent, 'bb10' ) !== false ) && ( strpos( $agent, 'mobile' ) !== false );
}

/**
* Determines whether a desktop platform is Linux OS
*
* @return bool
*/
public static function is_linux_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/linux/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}

/**
* Determines whether a desktop platform is Mac OS
*
* @return bool
*/
public static function is_mac_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/macintosh|mac os x/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}

/**
* Determines whether a desktop platform is Windows OS
*
* @return bool
*/
public static function is_windows_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/windows|win32/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}

/**
* Determines whether a desktop platform is Chrome OS
*
* @return bool
*/
public static function is_chrome_desktop() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
if ( ! preg_match( '/chrome/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating.
return false;
}
return true;
}

/**
* Retrieve the blackberry OS version.
*
Expand Down
Loading

0 comments on commit 3288ed5

Please sign in to comment.