This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,462 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.8.24] - 2026-06-29
### Changed
- Internal updates.
## [0.8.23] - 2026-06-25
### Changed
- Update package dependencies. [#49831]
## [0.8.22] - 2026-06-22
### Changed
- Update package dependencies. [#49631] [#49691] [#49757]
## [0.8.21] - 2026-06-15
### Changed
- Update package dependencies. [#49273]
## [0.8.20] - 2026-06-08
### Changed
- Update dependencies. [#49354]
## [0.8.19] - 2026-06-01
### Changed
- Update package dependencies. [#48404]
## [0.8.18] - 2026-05-25
### Changed
- Update package dependencies. [#48405]
## [0.8.17] - 2026-05-19
### Changed
- Exclude development files from production builds. [#47365]
- Update dependencies. [#48778]
## [0.8.16] - 2026-05-11
### Changed
- Update dependencies. [#47038]
## [0.8.15] - 2026-05-04
### Changed
- Internal: No longer require automattic/jetpack-changelogger as a per-project dev dependency. [#48225]
## [0.8.14] - 2026-04-27
### Changed
- Update dependencies. [#47038]
## [0.8.13] - 2026-04-20
### Changed
- Update package dependencies. [#48106] [#48141]
## [0.8.12] - 2026-04-15
### Changed
- Update package dependencies. [#47907]
### Fixed
- Media Library: Fix Import Media button styling for WordPress 7.0. [#48083]
## [0.8.11] - 2026-04-13
### Changed
- Update package dependencies. [#47890]
## [0.8.10] - 2026-04-06
### Changed
- Update package dependencies. [#47899]
### Fixed
- External Media: Ensure that the new WordPress "Embed video from URL" option appears in the Cover block options alongside Jetpack's External Media options. [#47819]
## [0.8.9] - 2026-03-30
### Changed
- Update dependencies. [#47038]
## [0.8.8] - 2026-03-23
### Changed
- Update package dependencies. [#47684]
## [0.8.7] - 2026-03-16
### Changed
- Update dependencies. [#47472]
## [0.8.6] - 2026-03-09
### Changed
- Switch to Native TypeScript compiler based on Go. [#47375]
- Update package dependencies. [#47496]
## [0.8.5] - 2026-03-02
### Changed
- Update dependencies. [#47038]
## [0.8.4] - 2026-02-26
### Changed
- Update package dependencies. [#47300]
## [0.8.3] - 2026-02-23
### Changed
- Update package dependencies. [#47173]
## [0.8.2] - 2026-02-16
### Changed
- Update package dependencies. [#47099]
### Fixed
- Compatibility: Clean up deprecated CSS. [#47067]
## [0.8.1] - 2026-02-10
### Changed
- Update dependencies. [#46931] [#47002]
### Fixed
- External Media: Pass media props to MediaSources during replace flow. [#46881]
## [0.8.0] - 2026-02-02
### Changed
- Update package dependencies. [#46854]
### Removed
- Remove support for WordPress <6.8. [#46843]
## [0.7.5] - 2026-01-26
### Changed
- Update package dependencies. [#46716]
## [0.7.4] - 2026-01-19
### Changed
- Update package dependencies. [#46552] [#46647]
## [0.7.3] - 2026-01-12
### Changed
- Update package dependencies. [#46456]
## [0.7.2] - 2026-01-06
### Changed
- Update dependencies. [#46383]
## [0.7.1] - 2025-12-22
### Changed
- Update dependencies. [#46381]
## [0.7.0] - 2025-12-15
### Added
- Support external media in replace flow. [#45841]
## [0.6.0] - 2025-12-08
### Added
- Add filter for adding custom sources to the media sources dropdown. [#46131]
### Fixed
- Ensure proper flags are used with `json_encode()`. [#46092]
## [0.5.14] - 2025-12-01
### Changed
- Update package dependencies. [#46143]
## [0.5.13] - 2025-11-24
### Changed
- Update dependencies. [#46031]
## [0.5.12] - 2025-11-18
### Changed
- Update dependencies. [#45553]
## [0.5.11] - 2025-11-17
### Changed
- Update package dependencies. [#45915]
## [0.5.10] - 2025-11-10
### Changed
- Update dependencies. [#45553]
## [0.5.9] - 2025-11-03
### Changed
- Update package dependencies. [#45652]
## [0.5.8] - 2025-10-27
### Removed
- GutenbergKit: Disable problematic media providers. [#45461]
## [0.5.7] - 2025-10-20
### Changed
- External media: Prevent site editor performance issues by bringing back previous script enqueue approach. [#45546]
- Update dependencies. [#45488]
## [0.5.6] - 2025-10-06
### Changed
- Update package dependencies. [#45334]
## [0.5.5] - 2025-09-29
### Changed
- Update dependencies. [#44940]
## [0.5.4] - 2025-09-22
### Fixed
- Fix lints. [#45242]
## [0.5.3] - 2025-09-19
### Changed
- Update package dependencies. [#45173] [#45229]
## [0.5.2] - 2025-09-15
### Changed
- Update dependencies. [#44940]
## [0.5.1] - 2025-09-08
### Changed
- Update package dependencies. [#45027] [#45097]
## [0.5.0] - 2025-09-01
### Added
- Media Settings: Add Google Photos connection. [#44825]
## [0.4.11] - 2025-08-25
### Changed
- Update dependencies. [#44934]
## [0.4.10] - 2025-08-18
### Added
- Add `typecheck` script to ensure that TypeScript files are type-checked. [#44795]
## [0.4.9] - 2025-08-14
### Changed
- Update package dependencies. [#44701]
## [0.4.8] - 2025-08-11
### Changed
- Update package dependencies. [#44677]
## [0.4.7] - 2025-08-04
### Changed
- Update dependencies. [#44551]
## [0.4.6] - 2025-07-28
### Changed
- Internal updates.
## [0.4.5] - 2025-07-21
### Changed
- Update package dependencies. [#44356]
## [0.4.4] - 2025-07-14
### Changed
- Update dependencies. [#44229]
## [0.4.3] - 2025-07-07
### Changed
- Update package dependencies. [#44148] [#44151]
## [0.4.2] - 2025-06-30
### Changed
- Update dependencies. [#43971]
## [0.4.1] - 2025-06-24
### Changed
- Update dependencies. [#43971]
## [0.4.0] - 2025-06-23
### Changed
- Scripts: Change imports for hosting checks. [#43972]
- Update package dependencies. [#44020]
## [0.3.14] - 2025-06-16
### Changed
- Update dependencies. [#43878]
## [0.3.13] - 2025-06-05
### Changed
- Update package dependencies. [#43734]
## [0.3.12] - 2025-06-02
### Changed
- Internal updates.
## [0.3.11] - 2025-05-26
### Changed
- Update package dependencies. [#43514] [#43578]
## [0.3.10] - 2025-05-19
### Changed
- Update package dependencies. [#43398]
## [0.3.9] - 2025-05-15
### Changed
- Update dependencies. [#42943]
## [0.3.8] - 2025-05-12
### Changed
- Stable release management: Do not ship source files. [#43310]
- Update package dependencies. [#43400]
## [0.3.7] - 2025-05-05
### Changed
- Update package dependencies. [#43326]
### Fixed
- Linting: Address final rules in WordPress Stylelint config. [#43296]
## [0.3.6] - 2025-04-28
### Fixed
- Linting: Fix more Stylelint violations. [#43213]
## [0.3.5] - 2025-04-21
### Fixed
- Scripts: Prevent console warnings by ensuring styles are correctly added to iframe. [#42985]
## [0.3.4] - 2025-04-14
### Fixed
- Linting: Update stylesheets to use WordPress rules for fonts and colors. [#42920] [#42928]
## [0.3.3] - 2025-04-07
### Changed
- Linting: First pass of style coding standards. [#42734]
- Update dependencies. [#42820]
- Update package dependencies. [#42809]
## [0.3.2] - 2025-03-31
### Changed
- Update dependencies. [#42678]
### Fixed
- Components: Prevent deprecation notices by adding `__next40pxDefaultSize` to controls. [#42677]
## [0.3.1] - 2025-03-24
### Changed
- Update dependencies. [#42565]
## [0.3.0] - 2025-03-18
### Changed
- Update package dependencies. [#42511]
### Fixed
- Jetpack App: Fix uploader spacing. [#42472]
## [0.2.6] - 2025-03-17
### Changed
- Update dependencies. [#42498]
## [0.2.5] - 2025-03-12
### Changed
- Internal updates.
## [0.2.4] - 2025-03-10
### Changed
- Internal updates.
## [0.2.3] - 2025-03-03
### Changed
- Update package dependencies. [#42163]
## [0.2.2] - 2025-02-24
### Changed
- Update dependencies.
## [0.2.1] - 2025-02-17
### Changed
- Update dependencies.
## [0.2.0] - 2025-02-11
### Added
- Untangle Calypso Media Page: Enable the feature. [#41628]
## 0.1.0 - 2025-02-10
### Added
- Add external media modal on the Media Import page. [#41282]
- Add Import button in Media Library. [#41544]
- Add track events to the Import page and modal. [#41592]
- Initial version. [#41078]
- Media Library: Add track events for upload from URL feature. [#41620]
- Media Library: Add track event to the Import Media button. [#41626]
### Changed
- Update styles of the external media modal. [#41303]
### Fixed
- Fix the button size in the editor for Gutenberg 18 or below. [#41619]
- Media Library: Fix the Import Media button color in some color schemes. [#41664]
[0.8.24]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.23...v0.8.24
[0.8.23]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.22...v0.8.23
[0.8.22]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.21...v0.8.22
[0.8.21]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.20...v0.8.21
[0.8.20]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.19...v0.8.20
[0.8.19]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.18...v0.8.19
[0.8.18]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.17...v0.8.18
[0.8.17]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.16...v0.8.17
[0.8.16]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.15...v0.8.16
[0.8.15]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.14...v0.8.15
[0.8.14]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.13...v0.8.14
[0.8.13]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.12...v0.8.13
[0.8.12]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.11...v0.8.12
[0.8.11]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.10...v0.8.11
[0.8.10]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.9...v0.8.10
[0.8.9]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.8...v0.8.9
[0.8.8]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.7...v0.8.8
[0.8.7]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.6...v0.8.7
[0.8.6]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.5...v0.8.6
[0.8.5]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.4...v0.8.5
[0.8.4]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.3...v0.8.4
[0.8.3]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.2...v0.8.3
[0.8.2]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.1...v0.8.2
[0.8.1]: https://github.com/Automattic/jetpack-external-media/compare/v0.8.0...v0.8.1
[0.8.0]: https://github.com/Automattic/jetpack-external-media/compare/v0.7.5...v0.8.0
[0.7.5]: https://github.com/Automattic/jetpack-external-media/compare/v0.7.4...v0.7.5
[0.7.4]: https://github.com/Automattic/jetpack-external-media/compare/v0.7.3...v0.7.4
[0.7.3]: https://github.com/Automattic/jetpack-external-media/compare/v0.7.2...v0.7.3
[0.7.2]: https://github.com/Automattic/jetpack-external-media/compare/v0.7.1...v0.7.2
[0.7.1]: https://github.com/Automattic/jetpack-external-media/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/Automattic/jetpack-external-media/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.14...v0.6.0
[0.5.14]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.13...v0.5.14
[0.5.13]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.12...v0.5.13
[0.5.12]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.11...v0.5.12
[0.5.11]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.10...v0.5.11
[0.5.10]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.9...v0.5.10
[0.5.9]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.8...v0.5.9
[0.5.8]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.7...v0.5.8
[0.5.7]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.6...v0.5.7
[0.5.6]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.5...v0.5.6
[0.5.5]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.4...v0.5.5
[0.5.4]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.3...v0.5.4
[0.5.3]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.2...v0.5.3
[0.5.2]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.1...v0.5.2
[0.5.1]: https://github.com/Automattic/jetpack-external-media/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.11...v0.5.0
[0.4.11]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.10...v0.4.11
[0.4.10]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.9...v0.4.10
[0.4.9]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.8...v0.4.9
[0.4.8]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.7...v0.4.8
[0.4.7]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.6...v0.4.7
[0.4.6]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.5...v0.4.6
[0.4.5]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.4...v0.4.5
[0.4.4]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.3...v0.4.4
[0.4.3]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.2...v0.4.3
[0.4.2]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.1...v0.4.2
[0.4.1]: https://github.com/Automattic/jetpack-external-media/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.14...v0.4.0
[0.3.14]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.13...v0.3.14
[0.3.13]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.12...v0.3.13
[0.3.12]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.11...v0.3.12
[0.3.11]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.10...v0.3.11
[0.3.10]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.9...v0.3.10
[0.3.9]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.8...v0.3.9
[0.3.8]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.7...v0.3.8
[0.3.7]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.6...v0.3.7
[0.3.6]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.5...v0.3.6
[0.3.5]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.4...v0.3.5
[0.3.4]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/Automattic/jetpack-external-media/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/Automattic/jetpack-external-media/compare/v0.2.6...v0.3.0
[0.2.6]: https://github.com/Automattic/jetpack-external-media/compare/v0.2.5...v0.2.6
[0.2.5]: https://github.com/Automattic/jetpack-external-media/compare/v0.2.4...v0.2.5
[0.2.4]: https://github.com/Automattic/jetpack-external-media/compare/v0.2.3...v0.2.4
[0.2.3]: https://github.com/Automattic/jetpack-external-media/compare/v0.2.2...v0.2.3
[0.2.2]: https://github.com/Automattic/jetpack-external-media/compare/v0.2.1...v0.2.2
[0.2.1]: https://github.com/Automattic/jetpack-external-media/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/Automattic/jetpack-external-media/compare/v0.1.0...v0.2.0
@@ -0,0 +1,17 @@
<svg width="380" height="183" viewBox="0 0 380 183" fill="none" xmlns="http://www.w3.org/2000/svg">
<g opacity="0.75" filter="url(#filter0_f_5953_11924)">
<path d="M360 -60C360 7.93102 304.931 63 237 63C169.069 63 114 7.93102 114 -60C114 -127.931 169.069 -183 237 -183C304.931 -183 360 -127.931 360 -60Z" fill="url(#paint0_linear_5953_11924)"/>
</g>
<defs>
<filter id="filter0_f_5953_11924" x="-6" y="-303" width="486" height="486" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
<feGaussianBlur stdDeviation="60" result="effect1_foregroundBlur_5953_11924"/>
</filter>
<linearGradient id="paint0_linear_5953_11924" x1="360" y1="-60" x2="114" y2="-60" gradientUnits="userSpaceOnUse">
<stop stop-color="#48FF50"/>
<stop offset="0.471846" stop-color="#108642"/>
<stop offset="1" stop-color="#2E38FA"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 990 B

@@ -0,0 +1,4 @@
<svg width="32" height="33" viewBox="0 0 32 33" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16 32.5C24.8366 32.5 32 25.3366 32 16.5C32 7.66344 24.8366 0.5 16 0.5C7.16344 0.5 0 7.66344 0 16.5C0 25.3366 7.16344 32.5 16 32.5Z" fill="#069E08"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.3295 3.67557V19.1565H7.36005L15.3295 3.67557ZM16.9478 29.3244V13.813H24.9478L16.9478 29.3244Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 427 B

@@ -0,0 +1 @@
<?php return array('dependencies' => array('jetpack-script-data', 'jetpack-shared-stores', 'lodash', 'moment', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '4d906d1b4b531a8e5b01');
@@ -0,0 +1,5 @@
/**
* @license qrcode.react
* Copyright (c) Paul O'Shannessy
* SPDX-License-Identifier: ISC
*/
@@ -0,0 +1 @@
<?php return array('dependencies' => array('wp-i18n'), 'version' => '4bad1e5fd6ef4c5e8d4d');
@@ -0,0 +1 @@
.wpcom-media-library-action-buttons{display:inline-flex;flex-wrap:wrap;gap:4px}.wpcom-media-library-action-buttons>a{position:relative;top:-3px;vertical-align:baseline}.wpcom-media-library-action-buttons>a.page-title-action{margin-left:0}
@@ -0,0 +1 @@
.wpcom-media-library-action-buttons{display:inline-flex;flex-wrap:wrap;gap:4px}.wpcom-media-library-action-buttons>a{position:relative;top:-3px;vertical-align:baseline}.wpcom-media-library-action-buttons>a.page-title-action{margin-right:0}
@@ -0,0 +1 @@
<?php return array('dependencies' => array('jetpack-script-data', 'jetpack-shared-stores', 'lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-plugins', 'wp-polyfill', 'wp-primitives', 'wp-url'), 'version' => '72bc5708683cb81c4fbf');
@@ -0,0 +1,5 @@
/**
* @license qrcode.react
* Copyright (c) Paul O'Shannessy
* SPDX-License-Identifier: ISC
*/
@@ -0,0 +1,118 @@
<?php
/**
* Register the external media to both WP Admin and Editor.
*
* @package automattic/jetpack-external-media
*/
namespace Automattic\Jetpack\External_Media;
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Connection\Initial_State as Connection_Initial_State;
use Automattic\Jetpack\Constants;
use Automattic\Jetpack\External_Connections;
use Automattic\Jetpack\Status\Host;
use Jetpack_Options;
/**
* Class External_Media
*/
class External_Media {
const PACKAGE_VERSION = '0.8.24';
const BASE_DIR = __DIR__ . '/';
const BASE_FILE = __FILE__;
/**
* Add hooks and filters.
*/
public static function init() {
// Load external media import page on WordPress.com sites first.
// We will continue to enable the feature on all sites.
$host = new Host();
if ( $host->is_wpcom_platform() ) {
require_once __DIR__ . '/features/admin/external-media-import.php';
}
// @todo this current approach results in a console warning in the editor related to adding the css to the iframe incorrectly.
// It has been temporarily added back to prevent performance issues in the site editor. See pdWQjU-1rA-p2 for more details.
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'enqueue_block_editor_assets' ) );
External_Connections::add_settings_for_service(
'media',
array(
'service' => 'google_photos',
'title' => __( 'Google Photos', 'jetpack-external-media' ),
'description' => __( 'Access photos stored in your Google Photos library.', 'jetpack-external-media' ),
'support_link' => array(
'wpcom' => 'https://wordpress.com/support/google-photos/',
'jetpack' => 'using-your-google-photos-with-jetpack/',
),
)
);
}
/**
* Enqueue block editor assets.
*/
public static function enqueue_block_editor_assets() {
$assets_base_path = 'build/';
$asset_name = 'jetpack-external-media-editor';
Assets::register_script(
$asset_name,
$assets_base_path . "$asset_name/$asset_name.js",
self::BASE_FILE,
array(
'enqueue' => true,
'textdomain' => 'jetpack-external-media',
)
);
wp_add_inline_script(
$asset_name,
sprintf( 'var JetpackExternalMediaData = %s;', wp_json_encode( self::get_data(), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ) ),
'before'
);
Connection_Initial_State::render_script( $asset_name );
}
/**
* Get the initial state data.
*
* @return array
*/
private static function get_data() {
$host = new Host();
if ( $host->is_wpcom_simple() ) {
$blog_id = get_current_blog_id();
} else {
$blog_id = Jetpack_Options::get_option( 'id', 0 );
}
$jetpack_ai_enabled = false;
if ( $host->is_wpcom_platform() ) {
$jetpack_ai_enabled = true;
}
return array(
'wpcomBlogId' => $blog_id,
'pluginBasePath' => plugins_url( '', Constants::get_constant( 'JETPACK__PLUGIN_FILE' ) ),
'ai-assistant' => array(
'is-enabled' => apply_filters( 'jetpack_ai_enabled', $jetpack_ai_enabled ),
),
);
}
/**
* Check whether the environment supports the newer default size of elements, gradually introduced starting with WP 6.4.
*
* @since jetpack-14.0
* @deprecated since 0.8.0
* @return bool
*/
public static function site_supports_next_default_size() {
_deprecated_function( __METHOD__, 'jetpack-external-media-0.8.0' );
return true;
}
}
@@ -0,0 +1,165 @@
<?php
/**
* The Jetpack external media import page.
*
* Adds Jetpack external media page to Media > Import.
*
* @package automattic/jetpack-external-media
*/
namespace Automattic\Jetpack\External_Media;
use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
}
/**
* Whether the current user is connected to WordPress.com.
*/
function is_current_user_connected() {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
return true;
}
return ( new Connection_Manager( 'jetpack' ) )->is_user_connected();
}
/**
* Register the Jetpack external media page to Media > Import.
*/
function add_jetpack_external_media_import_page() {
/**
* The feature is enabled only when the current user is connected to WordPress.com.
*/
if ( ! is_current_user_connected() ) {
return;
}
$external_media_import_page_hook = add_submenu_page(
'upload.php',
__( 'Import Media', 'jetpack-external-media' ),
__( 'Import Media', 'jetpack-external-media' ),
'upload_files',
'jetpack_external_media_import_page',
__NAMESPACE__ . '\render_jetpack_external_media_import_page'
);
add_action( 'load-upload.php', __NAMESPACE__ . '\enqueue_jetpack_external_media_import_button' );
add_action( "load-$external_media_import_page_hook", __NAMESPACE__ . '\enqueue_jetpack_external_media_import_page' );
}
add_action( 'admin_menu', __NAMESPACE__ . '\add_jetpack_external_media_import_page' );
/**
* Enqueue the assets of the Jetpack external media import button.
*/
function enqueue_jetpack_external_media_import_button() {
$assets_base_path = 'build/';
$asset_name = 'jetpack-external-media-import-button';
Assets::register_script(
$asset_name,
$assets_base_path . "$asset_name/$asset_name.js",
External_Media::BASE_FILE,
array(
'in_footer' => true,
'textdomain' => 'jetpack-external-media',
'css_path' => $assets_base_path . "$asset_name/$asset_name.css",
)
);
Assets::enqueue_script( $asset_name );
wp_localize_script(
$asset_name,
'JETPACK_EXTERNAL_MEDIA_IMPORT_BUTTON',
array(
'href' => admin_url( 'upload.php?page=jetpack_external_media_import_page' ),
)
);
}
/**
* Enqueue the assets of the Jetpack external media page.
*/
function enqueue_jetpack_external_media_import_page() {
$assets_base_path = 'build/';
$asset_name = 'jetpack-external-media-import-page';
Assets::register_script(
$asset_name,
$assets_base_path . "$asset_name/$asset_name.js",
External_Media::BASE_FILE,
array(
'in_footer' => true,
'textdomain' => 'jetpack-external-media',
)
);
Assets::enqueue_script( $asset_name );
}
/**
* Render the container of the Jetpack external media page.
*/
function render_jetpack_external_media_import_page() {
$title = __( 'Import Media', 'jetpack-external-media' );
$description = __( 'WordPress allows you to import media from various platforms directly into the Media Library. To begin, select a platform from the options below:', 'jetpack-external-media' );
$external_media_sources = array(
array(
'slug' => 'google_photos',
'name' => __( 'Google Photos', 'jetpack-external-media' ),
'description' => __( 'Import media from your Google Photos account.', 'jetpack-external-media' ),
),
array(
'slug' => 'pexels',
'name' => __( 'Pexels free photos', 'jetpack-external-media' ),
'description' => __( 'Free stock photos, royalty free images shared by creators.', 'jetpack-external-media' ),
),
array(
'slug' => 'openverse',
'name' => __( 'Openverse', 'jetpack-external-media' ),
'description' => __( 'Explore more than 800 million creative works.', 'jetpack-external-media' ),
),
);
?>
<div id="jetpack-external-media-import" class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
<div id="jetpack-external-media-import-notice"></div>
<p><?php echo esc_html( $description ); ?></p>
<table class="widefat importers striped">
<?php
foreach ( $external_media_sources as $external_media_source ) {
$slug = $external_media_source['slug'];
$name = $external_media_source['name'];
$description = $external_media_source['description'];
$action = sprintf(
'<a aria-label="%1$s" style="cursor:pointer;" data-slug="%2$s">%3$s</a>',
/* translators: %s: The name of the external media source. */
esc_attr( sprintf( __( 'Import %s', 'jetpack-external-media' ), $name ) ),
esc_attr( $slug ),
__( 'Import now', 'jetpack-external-media' )
);
?>
<tr class='importer-item'>
<td class='import-system'>
<span class='importer-title'><?php echo esc_html( $name ); ?></span>
<span class='importer-action'>
<?php echo $action; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we escape things above. ?>
</span>
</td>
<td class='desc'>
<span class='importer-desc'><?php echo esc_html( $description ); ?></span>
</td>
</tr>
<?php
}
?>
</table>
<div id="jetpack-external-media-import-modal"></div>
</div>
<?php
}