From d12ab9f30380f0e37e1337239d88b2a52d530e79 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Sun, 21 Dec 2025 15:24:51 +0900 Subject: [PATCH 1/6] Add Media Resource Checker plugin --- .../wporg-media-resource-checker/.gitignore | 2 + .../build/index.asset.php | 1 + .../build/index.js | 1 + .../build/style-index-rtl.css | 1 + .../build/style-index.css | 1 + .../wporg-media-resource-checker/package.json | 20 ++ .../wporg-media-resource-checker/src/hooks.js | 38 ++++ .../wporg-media-resource-checker/src/index.js | 175 ++++++++++++++++++ .../src/style.scss | 32 ++++ .../wporg-media-resource-checker/src/utils.js | 91 +++++++++ .../wporg-media-resource-checker.php | 84 +++++++++ 11 files changed, 446 insertions(+) create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/.gitignore create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/package.json create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/hooks.js create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/style.scss create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/.gitignore b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/.gitignore new file mode 100644 index 0000000000..504afef81f --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +package-lock.json diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php new file mode 100644 index 0000000000..0f6421e1e2 --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php @@ -0,0 +1 @@ + array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'f13102762651a2180e59'); diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js new file mode 100644 index 0000000000..12bdc3a85d --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js @@ -0,0 +1 @@ +(()=>{"use strict";var e,r={566(){function e(r){var o,i,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var n=r.length;for(o=0;o{const o=(0,w.useSelect)(e=>{const r=e(m.store).getEntityRecord("root","__unstableBase");return r?.home||r?.url||null},[]),i=((e,r)=>{const o=h.find(r=>r.name===e);return o?r[o.urlKey]:null})(e,r),t=i&&((e,r)=>{if(!r)return!1;if(!e||(0,u.isBlobURL)(e))return!1;const o=(0,d.getAuthority)(r),i=(0,d.getAuthority)(e);return o!==i&&!p.some(e=>i.match(e.regex))})(i,o);return{hasInvalidResource:t,siteUrl:o,mediaUrl:i}},v=({BlockEdit:e,siteUrl:r,mediaUrl:i,...t})=>{const a=[(0,d.getAuthority)(r),...p.map(e=>e.authority)];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{...t}),t.isSelected&&(0,c.jsx)(n.BlockControls,{children:(0,c.jsx)(s.Dropdown,{contentClassName:"",renderToggle:({isOpen:e,onToggle:r})=>(0,c.jsx)(s.ToolbarGroup,{children:(0,c.jsx)(s.ToolbarButton,{"aria-expanded":e,"aria-haspopup":"true",onClick:r,label:(0,o.__)("Media resource error"),icon:l,className:"wporg-media-resource-checker-toolbar-button"})}),renderContent:()=>(0,c.jsxs)("div",{className:"wporg-media-resource-checker-popover-content",children:[(0,c.jsx)("p",{children:(0,o.__)("This media resource is from a domain other than the recommended ones.","wporg-media-resource-checker")}),(0,c.jsx)("p",{children:i&&(0,c.jsx)(s.ExternalLink,{href:i,children:i})}),(0,c.jsx)("p",{children:(0,o.__)("Please use a media resource from the following recommended domains:","wporg-media-resource-checker")}),(0,c.jsx)("ul",{children:a.map(e=>(0,c.jsx)("li",{children:e},e))})]})})})]})},f=(0,t.createHigherOrderComponent)(e=>r=>{const{name:o,attributes:i}=r,{hasInvalidResource:t,siteUrl:n,mediaUrl:s}=g(o,i);return t?(0,c.jsx)(v,{BlockEdit:e,siteUrl:n,mediaUrl:s,...r}):(0,c.jsx)(e,{...r},"edit")},"withMediaResourceChecker"),x=(0,t.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:t,wrapperProps:n={}}=o,{hasInvalidResource:s}=g(i,t),a=s?{...n,className:r(n.className,"wporg-media-resource-checker-has-invalid-resource")}:n;return(0,c.jsx)(e,{...o,wrapperProps:a})},"withInvalidResourceClassName");(0,i.addFilter)("editor.BlockEdit","wporg-media-resource-checker/with-media-resource-checker",f),(0,i.addFilter)("editor.BlockListBlock","wporg-media-resource-checker/with-invalid-resource-class-name",x)}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.m=r,e=[],i.O=(r,o,t,n)=>{if(!o){var s=1/0;for(d=0;d=n)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(a=!1,n0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[o,t,n]},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={57:0,350:0};i.O.j=r=>0===e[r];var r=(r,o)=>{var t,n,[s,a,c]=o,l=0;if(s.some(r=>0!==e[r])){for(t in a)i.o(a,t)&&(i.m[t]=a[t]);if(c)var d=c(i)}for(r&&r(o);li(566));t=i.O(t)})(); \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css new file mode 100644 index 0000000000..438ff039de --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css @@ -0,0 +1 @@ +.wporg-media-resource-checker-has-invalid-resource:before{background:rgba(204,24,24,.2);border:2px solid #cc1818;box-sizing:border-box;content:"";display:block;height:100%;right:0;position:absolute;top:0;width:100%;z-index:2}.wporg-media-resource-checker-toolbar-button svg{fill:#cc1818}.wporg-media-resource-checker-popover-content{width:240px;word-break:break-word}.wporg-media-resource-checker-popover-content p{margin:0 0 1em}.wporg-media-resource-checker-popover-content ul{list-style:disc outside;margin:0;padding-right:1.5em} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css new file mode 100644 index 0000000000..eb7c5a61b0 --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css @@ -0,0 +1 @@ +.wporg-media-resource-checker-has-invalid-resource:before{background:rgba(204,24,24,.2);border:2px solid #cc1818;box-sizing:border-box;content:"";display:block;height:100%;left:0;position:absolute;top:0;width:100%;z-index:2}.wporg-media-resource-checker-toolbar-button svg{fill:#cc1818}.wporg-media-resource-checker-popover-content{width:240px;word-break:break-word}.wporg-media-resource-checker-popover-content p{margin:0 0 1em}.wporg-media-resource-checker-popover-content ul{list-style:disc outside;margin:0;padding-left:1.5em} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/package.json b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/package.json new file mode 100644 index 0000000000..9263518a9d --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/package.json @@ -0,0 +1,20 @@ +{ + "name": "wporg-media-resource-checker", + "version": "1.0.0", + "description": "Displays warnings in the block editor when media resources are from domains other than the recommended ones.", + "author": "WordPress.org", + "license": "GPL-2.0-or-later", + "scripts": { + "start": "wp-scripts start", + "build": "wp-scripts build", + "format": "wp-scripts format src", + "packages-update": "wp-scripts packages-update" + }, + "devDependencies": { + "@wordpress/icons": "^11.3.0", + "@wordpress/scripts": "^31.1.0" + }, + "dependencies": { + "clsx": "^2.1.1" + } +} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/hooks.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/hooks.js new file mode 100644 index 0000000000..35ce6785e0 --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/hooks.js @@ -0,0 +1,38 @@ +/** + * WordPress dependencies + */ +import { useSelect } from '@wordpress/data'; +import { store as coreStore } from '@wordpress/core-data'; + +/** + * Internal dependencies + */ +import { getBlockMediaResourceToCheck, isInvalidResource } from './utils'; + +/** + * Custom hook to check if a block has an invalid media resource. + * + * @param {string} name The block name. + * @param {Object} attributes The block attributes. + * @return {Object} Object containing hasInvalidResource, siteUrl, and mediaUrl. + */ +export const useHasInvalidSource = ( name, attributes ) => { + const siteUrl = useSelect( ( select ) => { + const siteData = select( coreStore ).getEntityRecord( + 'root', + '__unstableBase' + ); + return siteData?.home || siteData?.url || null; + }, [] ); + + const mediaUrl = getBlockMediaResourceToCheck( name, attributes ); + + const hasInvalidResource = + mediaUrl && isInvalidResource( mediaUrl, siteUrl ); + + return { + hasInvalidResource, + siteUrl, + mediaUrl, + }; +}; diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js new file mode 100644 index 0000000000..f417187c2b --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js @@ -0,0 +1,175 @@ +/** + * External dependencies + */ +import clsx from 'clsx'; + +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { addFilter } from '@wordpress/hooks'; +import { createHigherOrderComponent } from '@wordpress/compose'; +import { BlockControls } from '@wordpress/block-editor'; +import { + Dropdown, + ExternalLink, + ToolbarButton, + ToolbarGroup, +} from '@wordpress/components'; +import { caution } from '@wordpress/icons'; +import { getAuthority } from '@wordpress/url'; + +/** + * Internal dependencies + */ +import { ALLOWED_DOMAINS } from './utils'; +import { useHasInvalidSource } from './hooks'; +import './style.scss'; + +/** + * Block edit component with warning. + * + * @param {Object} props Component props. + * @param {Object} props.BlockEdit The block edit component. + * @return {Function} The block edit with warning component. + */ +const BlockEditWithWarning = ( { BlockEdit, siteUrl, mediaUrl, ...props } ) => { + const siteAuthority = getAuthority( siteUrl ); + const allowedDomainList = [ + siteAuthority, + ...ALLOWED_DOMAINS.map( ( domain ) => domain.authority ), + ]; + + return ( + <> + + { props.isSelected && ( + + { + return ( + + + + ); + } } + renderContent={ () => { + return ( +
+

+ { __( + 'This media resource is from a domain other than the recommended ones.', + 'wporg-media-resource-checker' + ) } +

+

+ { mediaUrl && ( + + { mediaUrl } + + ) } +

+

+ { __( + 'Please use a media resource from the following recommended domains:', + 'wporg-media-resource-checker' + ) } +

+
    + { allowedDomainList.map( ( domain ) => ( +
  • { domain }
  • + ) ) } +
+
+ ); + } } + /> +
+ ) } + + ); +}; + +/** + * Higher order component to check if the media resource is from a domain + * other than the recommended ones. + * + * @param {Function} BlockEdit The block edit component. + * @return {Function} The higher order component. + */ +const withMediaResourceChecker = createHigherOrderComponent( ( BlockEdit ) => { + return ( props ) => { + const { name, attributes } = props; + + const { hasInvalidResource, siteUrl, mediaUrl } = useHasInvalidSource( + name, + attributes + ); + + return hasInvalidResource ? ( + + ) : ( + + ); + }; +}, 'withMediaResourceChecker' ); + +/** + * Higher order component to add className to wrapperProps for blocks + * with invalid resources. + * + * @param {Function} BlockListBlock The block list block component. + * @return {Function} The higher order component. + */ +const withInvalidResourceClassName = createHigherOrderComponent( + ( BlockListBlock ) => { + return ( props ) => { + const { name, attributes, wrapperProps = {} } = props; + + const { hasInvalidResource } = useHasInvalidSource( + name, + attributes + ); + + const newWrapperProps = hasInvalidResource + ? { + ...wrapperProps, + className: clsx( + wrapperProps.className, + 'wporg-media-resource-checker-has-invalid-resource' + ), + } + : wrapperProps; + + return ( + + ); + }; + }, + 'withInvalidResourceClassName' +); + +addFilter( + 'editor.BlockEdit', + 'wporg-media-resource-checker/with-media-resource-checker', + withMediaResourceChecker +); + +addFilter( + 'editor.BlockListBlock', + 'wporg-media-resource-checker/with-invalid-resource-class-name', + withInvalidResourceClassName +); diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/style.scss b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/style.scss new file mode 100644 index 0000000000..e5fcaf3a37 --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/style.scss @@ -0,0 +1,32 @@ +.wporg-media-resource-checker-has-invalid-resource::before { + content: ''; + display: block; + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + z-index: 2; + border: 2px solid #cc1818; + background: rgba(#cc1818, 0.2); + box-sizing: border-box; +} + +.wporg-media-resource-checker-toolbar-button svg { + fill: #cc1818; +} + +.wporg-media-resource-checker-popover-content { + width: 240px; + word-break: break-word; + + p { + margin: 0 0 1em; + } + + ul { + margin: 0; + list-style: disc outside; + padding-left: 1.5em; + } +} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js new file mode 100644 index 0000000000..02c04339a9 --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js @@ -0,0 +1,91 @@ +/** + * WordPress dependencies + */ +import { isBlobURL } from '@wordpress/blob'; +import { getAuthority } from '@wordpress/url'; + +// List of blocks to check. +const BLOCKS_TO_CHECK = [ + { + name: 'core/image', + idKey: 'id', + urlKey: 'url', + }, + { + name: 'core/video', + idKey: 'id', + urlKey: 'src', + }, + { + name: 'core/cover', + idKey: 'id', + urlKey: 'url', + }, +]; + +// List of allowed domain regexes. +export const ALLOWED_DOMAINS = [ + { + authority: 'wordpress.org', + regex: /^(.*\.)?wordpress\.org$/, + }, + { + authority: 'wp.com', + regex: /^(.*\.)?wp\.com$/, + }, +]; + +/** + * Gets the media resource to check for the block. + * + * @param {string} blockName The name of the block. + * @param {Object} attributes The attributes of the block. + * @return {string|null} The media resource to check, or null if the block is not in the list of blocks to check. + */ +export const getBlockMediaResourceToCheck = ( blockName, attributes ) => { + const blockToCheck = BLOCKS_TO_CHECK.find( + ( block ) => block.name === blockName + ); + if ( ! blockToCheck ) { + return null; + } + return attributes[ blockToCheck.urlKey ]; +}; + +/** + * Checks whether the block has an invalid resource. + * + * @param {string} mediaUrl The media URL to check. + * @param {string} siteUrl The site URL. + * @return {boolean} True if the resource is invalid. + */ +export const isInvalidResource = ( mediaUrl, siteUrl ) => { + if ( ! siteUrl ) { + return false; + } + + // If no URL, cannot determine. + if ( ! mediaUrl || isBlobURL( mediaUrl ) ) { + return false; + } + + const siteAuthority = getAuthority( siteUrl ); + const mediaAuthority = getAuthority( mediaUrl ); + + // If the authority is the same, it means the resource is from the site. + if ( siteAuthority === mediaAuthority ) { + return false; + } + + // Check if the authority is from an allowed domain. + if ( + ALLOWED_DOMAINS.some( ( domain ) => + mediaAuthority.match( domain.regex ) + ) + ) { + return false; + } + + // The media is not from an allowed domain. + return true; +}; diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php new file mode 100644 index 0000000000..cbbd2ed1ab --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php @@ -0,0 +1,84 @@ + Date: Mon, 5 Jan 2026 17:51:24 +0900 Subject: [PATCH 2/6] Check if media authority is correct --- .../build/index.asset.php | 2 +- .../build/index.js | 667 +++++++++++++++++- .../build/index.js.map | 1 + .../build/style-index-rtl.css | 36 +- .../build/style-index.css | 38 +- .../build/style-index.css.map | 1 + .../wporg-media-resource-checker/src/utils.js | 5 + 7 files changed, 746 insertions(+), 4 deletions(-) create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map create mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php index 0f6421e1e2..75957dc69e 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'f13102762651a2180e59'); + array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'dd073cf3a99c39afec64'); diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js index 12bdc3a85d..3699470d9e 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js @@ -1 +1,666 @@ -(()=>{"use strict";var e,r={566(){function e(r){var o,i,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var n=r.length;for(o=0;o{const o=(0,w.useSelect)(e=>{const r=e(m.store).getEntityRecord("root","__unstableBase");return r?.home||r?.url||null},[]),i=((e,r)=>{const o=h.find(r=>r.name===e);return o?r[o.urlKey]:null})(e,r),t=i&&((e,r)=>{if(!r)return!1;if(!e||(0,u.isBlobURL)(e))return!1;const o=(0,d.getAuthority)(r),i=(0,d.getAuthority)(e);return o!==i&&!p.some(e=>i.match(e.regex))})(i,o);return{hasInvalidResource:t,siteUrl:o,mediaUrl:i}},v=({BlockEdit:e,siteUrl:r,mediaUrl:i,...t})=>{const a=[(0,d.getAuthority)(r),...p.map(e=>e.authority)];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{...t}),t.isSelected&&(0,c.jsx)(n.BlockControls,{children:(0,c.jsx)(s.Dropdown,{contentClassName:"",renderToggle:({isOpen:e,onToggle:r})=>(0,c.jsx)(s.ToolbarGroup,{children:(0,c.jsx)(s.ToolbarButton,{"aria-expanded":e,"aria-haspopup":"true",onClick:r,label:(0,o.__)("Media resource error"),icon:l,className:"wporg-media-resource-checker-toolbar-button"})}),renderContent:()=>(0,c.jsxs)("div",{className:"wporg-media-resource-checker-popover-content",children:[(0,c.jsx)("p",{children:(0,o.__)("This media resource is from a domain other than the recommended ones.","wporg-media-resource-checker")}),(0,c.jsx)("p",{children:i&&(0,c.jsx)(s.ExternalLink,{href:i,children:i})}),(0,c.jsx)("p",{children:(0,o.__)("Please use a media resource from the following recommended domains:","wporg-media-resource-checker")}),(0,c.jsx)("ul",{children:a.map(e=>(0,c.jsx)("li",{children:e},e))})]})})})]})},f=(0,t.createHigherOrderComponent)(e=>r=>{const{name:o,attributes:i}=r,{hasInvalidResource:t,siteUrl:n,mediaUrl:s}=g(o,i);return t?(0,c.jsx)(v,{BlockEdit:e,siteUrl:n,mediaUrl:s,...r}):(0,c.jsx)(e,{...r},"edit")},"withMediaResourceChecker"),x=(0,t.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:t,wrapperProps:n={}}=o,{hasInvalidResource:s}=g(i,t),a=s?{...n,className:r(n.className,"wporg-media-resource-checker-has-invalid-resource")}:n;return(0,c.jsx)(e,{...o,wrapperProps:a})},"withInvalidResourceClassName");(0,i.addFilter)("editor.BlockEdit","wporg-media-resource-checker/with-media-resource-checker",f),(0,i.addFilter)("editor.BlockListBlock","wporg-media-resource-checker/with-invalid-resource-class-name",x)}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.m=r,e=[],i.O=(r,o,t,n)=>{if(!o){var s=1/0;for(d=0;d=n)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(a=!1,n0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[o,t,n]},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={57:0,350:0};i.O.j=r=>0===e[r];var r=(r,o)=>{var t,n,[s,a,c]=o,l=0;if(s.some(r=>0!==e[r])){for(t in a)i.o(a,t)&&(i.m[t]=a[t]);if(c)var d=c(i)}for(r&&r(o);li(566));t=i.O(t)})(); \ No newline at end of file +/******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "./node_modules/@wordpress/icons/build-module/library/caution.js" +/*!***********************************************************************!*\ + !*** ./node_modules/@wordpress/icons/build-module/library/caution.js ***! + \***********************************************************************/ +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (/* binding */ caution_default) +/* harmony export */ }); +/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/primitives */ "@wordpress/primitives"); +/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__); +// packages/icons/src/library/caution.tsx + + +var caution_default = /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)( + _wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__.Path, + { + fillRule: "evenodd", + clipRule: "evenodd", + d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" + } +) }); + +//# sourceMappingURL=caution.js.map + + +/***/ }, + +/***/ "./node_modules/clsx/dist/clsx.mjs" +/*!*****************************************!*\ + !*** ./node_modules/clsx/dist/clsx.mjs ***! + \*****************************************/ +(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ clsx: () => (/* binding */ clsx), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t (/* binding */ useHasInvalidSource) +/* harmony export */ }); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/core-data */ "@wordpress/core-data"); +/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_core_data__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.js"); +/** + * WordPress dependencies + */ + + + +/** + * Internal dependencies + */ + + +/** + * Custom hook to check if a block has an invalid media resource. + * + * @param {string} name The block name. + * @param {Object} attributes The block attributes. + * @return {Object} Object containing hasInvalidResource, siteUrl, and mediaUrl. + */ +const useHasInvalidSource = (name, attributes) => { + const siteUrl = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.useSelect)(select => { + const siteData = select(_wordpress_core_data__WEBPACK_IMPORTED_MODULE_1__.store).getEntityRecord('root', '__unstableBase'); + return siteData?.home || siteData?.url || null; + }, []); + const mediaUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getBlockMediaResourceToCheck)(name, attributes); + const hasInvalidResource = mediaUrl && (0,_utils__WEBPACK_IMPORTED_MODULE_2__.isInvalidResource)(mediaUrl, siteUrl); + return { + hasInvalidResource, + siteUrl, + mediaUrl + }; +}; + +/***/ }, + +/***/ "./src/index.js" +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ "./node_modules/clsx/dist/clsx.mjs"); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); +/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); +/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); +/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/icons */ "./node_modules/@wordpress/icons/build-module/library/caution.js"); +/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); +/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_7__); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils */ "./src/utils.js"); +/* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./hooks */ "./src/hooks.js"); +/* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./style.scss */ "./src/style.scss"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__); +/** + * External dependencies + */ + + +/** + * WordPress dependencies + */ + + + + + + + + +/** + * Internal dependencies + */ + + + + +/** + * Block edit component with warning. + * + * @param {Object} props Component props. + * @param {Object} props.BlockEdit The block edit component. + * @return {Function} The block edit with warning component. + */ + +const BlockEditWithWarning = ({ + BlockEdit, + siteUrl, + mediaUrl, + ...props +}) => { + const siteAuthority = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_7__.getAuthority)(siteUrl); + const allowedDomainList = [siteAuthority, ..._utils__WEBPACK_IMPORTED_MODULE_8__.ALLOWED_DOMAINS.map(domain => domain.authority)]; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.Fragment, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockEdit, { + ...props + }), props.isSelected && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.BlockControls, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.Dropdown, { + contentClassName: "", + renderToggle: ({ + isOpen, + onToggle + }) => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToolbarGroup, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToolbarButton, { + "aria-expanded": isOpen, + "aria-haspopup": "true", + onClick: onToggle, + label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Media resource error'), + icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__["default"], + className: "wporg-media-resource-checker-toolbar-button" + }) + }); + }, + renderContent: () => { + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)("div", { + className: "wporg-media-resource-checker-popover-content", + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("p", { + children: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('This media resource is from a domain other than the recommended ones.', 'wporg-media-resource-checker') + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("p", { + children: mediaUrl && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ExternalLink, { + href: mediaUrl, + children: mediaUrl + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("p", { + children: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Please use a media resource from the following recommended domains:', 'wporg-media-resource-checker') + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("ul", { + children: allowedDomainList.map(domain => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("li", { + children: domain + }, domain)) + })] + }); + } + }) + })] + }); +}; + +/** + * Higher order component to check if the media resource is from a domain + * other than the recommended ones. + * + * @param {Function} BlockEdit The block edit component. + * @return {Function} The higher order component. + */ +const withMediaResourceChecker = (0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.createHigherOrderComponent)(BlockEdit => { + return props => { + const { + name, + attributes + } = props; + const { + hasInvalidResource, + siteUrl, + mediaUrl + } = (0,_hooks__WEBPACK_IMPORTED_MODULE_9__.useHasInvalidSource)(name, attributes); + return hasInvalidResource ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockEditWithWarning, { + BlockEdit: BlockEdit, + siteUrl: siteUrl, + mediaUrl: mediaUrl, + ...props + }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockEdit, { + ...props + }, "edit"); + }; +}, 'withMediaResourceChecker'); + +/** + * Higher order component to add className to wrapperProps for blocks + * with invalid resources. + * + * @param {Function} BlockListBlock The block list block component. + * @return {Function} The higher order component. + */ +const withInvalidResourceClassName = (0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.createHigherOrderComponent)(BlockListBlock => { + return props => { + const { + name, + attributes, + wrapperProps = {} + } = props; + const { + hasInvalidResource + } = (0,_hooks__WEBPACK_IMPORTED_MODULE_9__.useHasInvalidSource)(name, attributes); + const newWrapperProps = hasInvalidResource ? { + ...wrapperProps, + className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__["default"])(wrapperProps.className, 'wporg-media-resource-checker-has-invalid-resource') + } : wrapperProps; + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockListBlock, { + ...props, + wrapperProps: newWrapperProps + }); + }; +}, 'withInvalidResourceClassName'); +(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__.addFilter)('editor.BlockEdit', 'wporg-media-resource-checker/with-media-resource-checker', withMediaResourceChecker); +(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__.addFilter)('editor.BlockListBlock', 'wporg-media-resource-checker/with-invalid-resource-class-name', withInvalidResourceClassName); + +/***/ }, + +/***/ "./src/style.scss" +/*!************************!*\ + !*** ./src/style.scss ***! + \************************/ +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +// extracted by mini-css-extract-plugin + + +/***/ }, + +/***/ "./src/utils.js" +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ALLOWED_DOMAINS: () => (/* binding */ ALLOWED_DOMAINS), +/* harmony export */ getBlockMediaResourceToCheck: () => (/* binding */ getBlockMediaResourceToCheck), +/* harmony export */ isInvalidResource: () => (/* binding */ isInvalidResource) +/* harmony export */ }); +/* harmony import */ var _wordpress_blob__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/blob */ "@wordpress/blob"); +/* harmony import */ var _wordpress_blob__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blob__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); +/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_1__); +/** + * WordPress dependencies + */ + + + +// List of blocks to check. +const BLOCKS_TO_CHECK = [{ + name: 'core/image', + idKey: 'id', + urlKey: 'url' +}, { + name: 'core/video', + idKey: 'id', + urlKey: 'src' +}, { + name: 'core/cover', + idKey: 'id', + urlKey: 'url' +}]; + +// List of allowed domain regexes. +const ALLOWED_DOMAINS = [{ + authority: 'wordpress.org', + regex: /^(.*\.)?wordpress\.org$/ +}, { + authority: 'wp.com', + regex: /^(.*\.)?wp\.com$/ +}]; + +/** + * Gets the media resource to check for the block. + * + * @param {string} blockName The name of the block. + * @param {Object} attributes The attributes of the block. + * @return {string|null} The media resource to check, or null if the block is not in the list of blocks to check. + */ +const getBlockMediaResourceToCheck = (blockName, attributes) => { + const blockToCheck = BLOCKS_TO_CHECK.find(block => block.name === blockName); + if (!blockToCheck) { + return null; + } + return attributes[blockToCheck.urlKey]; +}; + +/** + * Checks whether the block has an invalid resource. + * + * @param {string} mediaUrl The media URL to check. + * @param {string} siteUrl The site URL. + * @return {boolean} True if the resource is invalid. + */ +const isInvalidResource = (mediaUrl, siteUrl) => { + if (!siteUrl) { + return false; + } + + // If no URL, cannot determine. + if (!mediaUrl || (0,_wordpress_blob__WEBPACK_IMPORTED_MODULE_0__.isBlobURL)(mediaUrl)) { + return false; + } + const siteAuthority = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_1__.getAuthority)(siteUrl); + const mediaAuthority = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_1__.getAuthority)(mediaUrl); + + // If the media authority is not set, it means the resource is not a valid URL. + if (!mediaAuthority) { + return true; + } + + // If the authority is the same, it means the resource is from the site. + if (siteAuthority === mediaAuthority) { + return false; + } + + // Check if the authority is from an allowed domain. + if (ALLOWED_DOMAINS.some(domain => mediaAuthority.match(domain.regex))) { + return false; + } + + // The media is not from an allowed domain. + return true; +}; + +/***/ }, + +/***/ "@wordpress/blob" +/*!******************************!*\ + !*** external ["wp","blob"] ***! + \******************************/ +(module) { + +module.exports = window["wp"]["blob"]; + +/***/ }, + +/***/ "@wordpress/block-editor" +/*!*************************************!*\ + !*** external ["wp","blockEditor"] ***! + \*************************************/ +(module) { + +module.exports = window["wp"]["blockEditor"]; + +/***/ }, + +/***/ "@wordpress/components" +/*!************************************!*\ + !*** external ["wp","components"] ***! + \************************************/ +(module) { + +module.exports = window["wp"]["components"]; + +/***/ }, + +/***/ "@wordpress/compose" +/*!*********************************!*\ + !*** external ["wp","compose"] ***! + \*********************************/ +(module) { + +module.exports = window["wp"]["compose"]; + +/***/ }, + +/***/ "@wordpress/core-data" +/*!**********************************!*\ + !*** external ["wp","coreData"] ***! + \**********************************/ +(module) { + +module.exports = window["wp"]["coreData"]; + +/***/ }, + +/***/ "@wordpress/data" +/*!******************************!*\ + !*** external ["wp","data"] ***! + \******************************/ +(module) { + +module.exports = window["wp"]["data"]; + +/***/ }, + +/***/ "@wordpress/hooks" +/*!*******************************!*\ + !*** external ["wp","hooks"] ***! + \*******************************/ +(module) { + +module.exports = window["wp"]["hooks"]; + +/***/ }, + +/***/ "@wordpress/i18n" +/*!******************************!*\ + !*** external ["wp","i18n"] ***! + \******************************/ +(module) { + +module.exports = window["wp"]["i18n"]; + +/***/ }, + +/***/ "@wordpress/primitives" +/*!************************************!*\ + !*** external ["wp","primitives"] ***! + \************************************/ +(module) { + +module.exports = window["wp"]["primitives"]; + +/***/ }, + +/***/ "@wordpress/url" +/*!*****************************!*\ + !*** external ["wp","url"] ***! + \*****************************/ +(module) { + +module.exports = window["wp"]["url"]; + +/***/ }, + +/***/ "react/jsx-runtime" +/*!**********************************!*\ + !*** external "ReactJSXRuntime" ***! + \**********************************/ +(module) { + +module.exports = window["ReactJSXRuntime"]; + +/***/ } + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Check if module exists (development only) +/******/ if (__webpack_modules__[moduleId] === undefined) { +/******/ var e = new Error("Cannot find module '" + moduleId + "'"); +/******/ e.code = 'MODULE_NOT_FOUND'; +/******/ throw e; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = __webpack_modules__; +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/chunk loaded */ +/******/ (() => { +/******/ var deferred = []; +/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { +/******/ if(chunkIds) { +/******/ priority = priority || 0; +/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; +/******/ deferred[i] = [chunkIds, fn, priority]; +/******/ return; +/******/ } +/******/ var notFulfilled = Infinity; +/******/ for (var i = 0; i < deferred.length; i++) { +/******/ var [chunkIds, fn, priority] = deferred[i]; +/******/ var fulfilled = true; +/******/ for (var j = 0; j < chunkIds.length; j++) { +/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { +/******/ chunkIds.splice(j--, 1); +/******/ } else { +/******/ fulfilled = false; +/******/ if(priority < notFulfilled) notFulfilled = priority; +/******/ } +/******/ } +/******/ if(fulfilled) { +/******/ deferred.splice(i--, 1) +/******/ var r = fn(); +/******/ if (r !== undefined) result = r; +/******/ } +/******/ } +/******/ return result; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/jsonp chunk loading */ +/******/ (() => { +/******/ // no baseURI +/******/ +/******/ // object to store loaded and loading chunks +/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched +/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded +/******/ var installedChunks = { +/******/ "index": 0, +/******/ "./style-index": 0 +/******/ }; +/******/ +/******/ // no chunk on demand loading +/******/ +/******/ // no prefetching +/******/ +/******/ // no preloaded +/******/ +/******/ // no HMR +/******/ +/******/ // no HMR manifest +/******/ +/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); +/******/ +/******/ // install a JSONP callback for chunk loading +/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { +/******/ var [chunkIds, moreModules, runtime] = data; +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0; +/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { +/******/ for(moduleId in moreModules) { +/******/ if(__webpack_require__.o(moreModules, moduleId)) { +/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(runtime) var result = runtime(__webpack_require__); +/******/ } +/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { +/******/ installedChunks[chunkId][0](); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ return __webpack_require__.O(result); +/******/ } +/******/ +/******/ var chunkLoadingGlobal = globalThis["webpackChunkwporg_media_resource_checker"] = globalThis["webpackChunkwporg_media_resource_checker"] || []; +/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); +/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); +/******/ })(); +/******/ +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module depends on other loaded chunks and execution need to be delayed +/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["./style-index"], () => (__webpack_require__("./src/index.js"))) +/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); +/******/ +/******/ })() +; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map new file mode 100644 index 0000000000..ab805ef61e --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;AAAA;AACkD;AACV;AACxC,sCAAsC,sDAAG,CAAC,sDAAG,IAAI,qFAAqF,sDAAG;AACzI,EAAE,uDAAI;AACN;AACA;AACA;AACA;AACA;AACA,GAAG;AAGD;AACF;;;;;;;;;;;;;;;;ACdA,cAAc,aAAa,+CAA+C,gDAAgD,eAAe,QAAQ,IAAI,0CAA0C,yCAAyC,SAAgB,gBAAgB,wCAAwC,IAAI,mDAAmD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A;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA,4G;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://wporg-media-resource-checker/./node_modules/@wordpress/icons/build-module/library/caution.js","webpack://wporg-media-resource-checker/./node_modules/clsx/dist/clsx.mjs","webpack://wporg-media-resource-checker/./src/hooks.js","webpack://wporg-media-resource-checker/./src/index.js","webpack://wporg-media-resource-checker/./src/style.scss","webpack://wporg-media-resource-checker/./src/utils.js","webpack://wporg-media-resource-checker/external window [\"wp\",\"blob\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"blockEditor\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"components\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"compose\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"coreData\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"data\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"hooks\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"i18n\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"primitives\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"url\"]","webpack://wporg-media-resource-checker/external window \"ReactJSXRuntime\"","webpack://wporg-media-resource-checker/webpack/bootstrap","webpack://wporg-media-resource-checker/webpack/runtime/chunk loaded","webpack://wporg-media-resource-checker/webpack/runtime/compat get default export","webpack://wporg-media-resource-checker/webpack/runtime/define property getters","webpack://wporg-media-resource-checker/webpack/runtime/hasOwnProperty shorthand","webpack://wporg-media-resource-checker/webpack/runtime/make namespace object","webpack://wporg-media-resource-checker/webpack/runtime/jsonp chunk loading","webpack://wporg-media-resource-checker/webpack/before-startup","webpack://wporg-media-resource-checker/webpack/startup","webpack://wporg-media-resource-checker/webpack/after-startup"],"sourcesContent":["// packages/icons/src/library/caution.tsx\nimport { Path, SVG } from \"@wordpress/primitives\";\nimport { jsx } from \"react/jsx-runtime\";\nvar caution_default = /* @__PURE__ */ jsx(SVG, { viewBox: \"0 0 24 24\", xmlns: \"http://www.w3.org/2000/svg\", children: /* @__PURE__ */ jsx(\n Path,\n {\n fillRule: \"evenodd\",\n clipRule: \"evenodd\",\n d: \"M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z\"\n }\n) });\nexport {\n caution_default as default\n};\n//# sourceMappingURL=caution.js.map\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t {\n\tconst siteUrl = useSelect( ( select ) => {\n\t\tconst siteData = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'__unstableBase'\n\t\t);\n\t\treturn siteData?.home || siteData?.url || null;\n\t}, [] );\n\n\tconst mediaUrl = getBlockMediaResourceToCheck( name, attributes );\n\n\tconst hasInvalidResource =\n\t\tmediaUrl && isInvalidResource( mediaUrl, siteUrl );\n\n\treturn {\n\t\thasInvalidResource,\n\t\tsiteUrl,\n\t\tmediaUrl,\n\t};\n};\n","/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { BlockControls } from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tExternalLink,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { caution } from '@wordpress/icons';\nimport { getAuthority } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { ALLOWED_DOMAINS } from './utils';\nimport { useHasInvalidSource } from './hooks';\nimport './style.scss';\n\n/**\n * Block edit component with warning.\n *\n * @param {Object} props Component props.\n * @param {Object} props.BlockEdit The block edit component.\n * @return {Function} The block edit with warning component.\n */\nconst BlockEditWithWarning = ( { BlockEdit, siteUrl, mediaUrl, ...props } ) => {\n\tconst siteAuthority = getAuthority( siteUrl );\n\tconst allowedDomainList = [\n\t\tsiteAuthority,\n\t\t...ALLOWED_DOMAINS.map( ( domain ) => domain.authority ),\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t{ props.isSelected && (\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trenderContent={ () => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'This media resource is from a domain other than the recommended ones.',\n\t\t\t\t\t\t\t\t\t\t\t'wporg-media-resource-checker'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t\t{ mediaUrl && (\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t{ mediaUrl }\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Please use a media resource from the following recommended domains:',\n\t\t\t\t\t\t\t\t\t\t\t'wporg-media-resource-checker'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\t\t{ allowedDomainList.map( ( domain ) => (\n\t\t\t\t\t\t\t\t\t\t\t
  • { domain }
  • \n\t\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t
\n\t\t\t) }\n\t\t\n\t);\n};\n\n/**\n * Higher order component to check if the media resource is from a domain\n * other than the recommended ones.\n *\n * @param {Function} BlockEdit The block edit component.\n * @return {Function} The higher order component.\n */\nconst withMediaResourceChecker = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst { name, attributes } = props;\n\n\t\tconst { hasInvalidResource, siteUrl, mediaUrl } = useHasInvalidSource(\n\t\t\tname,\n\t\t\tattributes\n\t\t);\n\n\t\treturn hasInvalidResource ? (\n\t\t\t\n\t\t) : (\n\t\t\t\n\t\t);\n\t};\n}, 'withMediaResourceChecker' );\n\n/**\n * Higher order component to add className to wrapperProps for blocks\n * with invalid resources.\n *\n * @param {Function} BlockListBlock The block list block component.\n * @return {Function} The higher order component.\n */\nconst withInvalidResourceClassName = createHigherOrderComponent(\n\t( BlockListBlock ) => {\n\t\treturn ( props ) => {\n\t\t\tconst { name, attributes, wrapperProps = {} } = props;\n\n\t\t\tconst { hasInvalidResource } = useHasInvalidSource(\n\t\t\t\tname,\n\t\t\t\tattributes\n\t\t\t);\n\n\t\t\tconst newWrapperProps = hasInvalidResource\n\t\t\t\t? {\n\t\t\t\t\t\t...wrapperProps,\n\t\t\t\t\t\tclassName: clsx(\n\t\t\t\t\t\t\twrapperProps.className,\n\t\t\t\t\t\t\t'wporg-media-resource-checker-has-invalid-resource'\n\t\t\t\t\t\t),\n\t\t\t\t }\n\t\t\t\t: wrapperProps;\n\n\t\t\treturn (\n\t\t\t\t\n\t\t\t);\n\t\t};\n\t},\n\t'withInvalidResourceClassName'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'wporg-media-resource-checker/with-media-resource-checker',\n\twithMediaResourceChecker\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'wporg-media-resource-checker/with-invalid-resource-class-name',\n\twithInvalidResourceClassName\n);\n","// extracted by mini-css-extract-plugin\nexport {};","/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getAuthority } from '@wordpress/url';\n\n// List of blocks to check.\nconst BLOCKS_TO_CHECK = [\n\t{\n\t\tname: 'core/image',\n\t\tidKey: 'id',\n\t\turlKey: 'url',\n\t},\n\t{\n\t\tname: 'core/video',\n\t\tidKey: 'id',\n\t\turlKey: 'src',\n\t},\n\t{\n\t\tname: 'core/cover',\n\t\tidKey: 'id',\n\t\turlKey: 'url',\n\t},\n];\n\n// List of allowed domain regexes.\nexport const ALLOWED_DOMAINS = [\n\t{\n\t\tauthority: 'wordpress.org',\n\t\tregex: /^(.*\\.)?wordpress\\.org$/,\n\t},\n\t{\n\t\tauthority: 'wp.com',\n\t\tregex: /^(.*\\.)?wp\\.com$/,\n\t},\n];\n\n/**\n * Gets the media resource to check for the block.\n *\n * @param {string} blockName The name of the block.\n * @param {Object} attributes The attributes of the block.\n * @return {string|null} The media resource to check, or null if the block is not in the list of blocks to check.\n */\nexport const getBlockMediaResourceToCheck = ( blockName, attributes ) => {\n\tconst blockToCheck = BLOCKS_TO_CHECK.find(\n\t\t( block ) => block.name === blockName\n\t);\n\tif ( ! blockToCheck ) {\n\t\treturn null;\n\t}\n\treturn attributes[ blockToCheck.urlKey ];\n};\n\n/**\n * Checks whether the block has an invalid resource.\n *\n * @param {string} mediaUrl The media URL to check.\n * @param {string} siteUrl The site URL.\n * @return {boolean} True if the resource is invalid.\n */\nexport const isInvalidResource = ( mediaUrl, siteUrl ) => {\n\tif ( ! siteUrl ) {\n\t\treturn false;\n\t}\n\n\t// If no URL, cannot determine.\n\tif ( ! mediaUrl || isBlobURL( mediaUrl ) ) {\n\t\treturn false;\n\t}\n\n\tconst siteAuthority = getAuthority( siteUrl );\n\tconst mediaAuthority = getAuthority( mediaUrl );\n\n\t// If the media authority is not set, it means the resource is not a valid URL.\n\tif ( ! mediaAuthority ) {\n\t\treturn true;\n\t}\n\n\t// If the authority is the same, it means the resource is from the site.\n\tif ( siteAuthority === mediaAuthority ) {\n\t\treturn false;\n\t}\n\n\t// Check if the authority is from an allowed domain.\n\tif (\n\t\tALLOWED_DOMAINS.some( ( domain ) =>\n\t\t\tmediaAuthority.match( domain.regex )\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\t// The media is not from an allowed domain.\n\treturn true;\n};\n","module.exports = window[\"wp\"][\"blob\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"compose\"];","module.exports = window[\"wp\"][\"coreData\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"hooks\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","module.exports = window[\"wp\"][\"url\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Check if module exists (development only)\n\tif (__webpack_modules__[moduleId] === undefined) {\n\t\tvar e = new Error(\"Cannot find module '\" + moduleId + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkwporg_media_resource_checker\"] = globalThis[\"webpackChunkwporg_media_resource_checker\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["useSelect","store","coreStore","getBlockMediaResourceToCheck","isInvalidResource","useHasInvalidSource","name","attributes","siteUrl","select","siteData","getEntityRecord","home","url","mediaUrl","hasInvalidResource","clsx","__","addFilter","createHigherOrderComponent","BlockControls","Dropdown","ExternalLink","ToolbarButton","ToolbarGroup","caution","getAuthority","ALLOWED_DOMAINS","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","BlockEditWithWarning","BlockEdit","props","siteAuthority","allowedDomainList","map","domain","authority","children","isSelected","contentClassName","renderToggle","isOpen","onToggle","onClick","label","icon","className","renderContent","href","withMediaResourceChecker","withInvalidResourceClassName","BlockListBlock","wrapperProps","newWrapperProps","isBlobURL","BLOCKS_TO_CHECK","idKey","urlKey","regex","blockName","blockToCheck","find","block","mediaAuthority","some","match"],"ignoreList":[],"sourceRoot":""} \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css index 438ff039de..45c3be753f 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css @@ -1 +1,35 @@ -.wporg-media-resource-checker-has-invalid-resource:before{background:rgba(204,24,24,.2);border:2px solid #cc1818;box-sizing:border-box;content:"";display:block;height:100%;right:0;position:absolute;top:0;width:100%;z-index:2}.wporg-media-resource-checker-toolbar-button svg{fill:#cc1818}.wporg-media-resource-checker-popover-content{width:240px;word-break:break-word}.wporg-media-resource-checker-popover-content p{margin:0 0 1em}.wporg-media-resource-checker-popover-content ul{list-style:disc outside;margin:0;padding-right:1.5em} +/*!***************************************************************************************************************************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/style.scss ***! + \***************************************************************************************************************************************************************************************************************************************/ +.wporg-media-resource-checker-has-invalid-resource::before { + content: ""; + display: block; + width: 100%; + height: 100%; + position: absolute; + top: 0; + right: 0; + z-index: 2; + border: 2px solid #cc1818; + background: rgba(204, 24, 24, 0.2); + box-sizing: border-box; +} + +.wporg-media-resource-checker-toolbar-button svg { + fill: #cc1818; +} + +.wporg-media-resource-checker-popover-content { + width: 240px; + word-break: break-word; +} + +.wporg-media-resource-checker-popover-content p { + margin: 0 0 1em; +} + +.wporg-media-resource-checker-popover-content ul { + margin: 0; + list-style: disc outside; + padding-right: 1.5em; +} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css index eb7c5a61b0..4bd303cd26 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css @@ -1 +1,37 @@ -.wporg-media-resource-checker-has-invalid-resource:before{background:rgba(204,24,24,.2);border:2px solid #cc1818;box-sizing:border-box;content:"";display:block;height:100%;left:0;position:absolute;top:0;width:100%;z-index:2}.wporg-media-resource-checker-toolbar-button svg{fill:#cc1818}.wporg-media-resource-checker-popover-content{width:240px;word-break:break-word}.wporg-media-resource-checker-popover-content p{margin:0 0 1em}.wporg-media-resource-checker-popover-content ul{list-style:disc outside;margin:0;padding-left:1.5em} +/*!***************************************************************************************************************************************************************************************************************************************!*\ + !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/style.scss ***! + \***************************************************************************************************************************************************************************************************************************************/ +.wporg-media-resource-checker-has-invalid-resource::before { + content: ""; + display: block; + width: 100%; + height: 100%; + position: absolute; + top: 0; + left: 0; + z-index: 2; + border: 2px solid #cc1818; + background: rgba(204, 24, 24, 0.2); + box-sizing: border-box; +} + +.wporg-media-resource-checker-toolbar-button svg { + fill: #cc1818; +} + +.wporg-media-resource-checker-popover-content { + width: 240px; + word-break: break-word; +} + +.wporg-media-resource-checker-popover-content p { + margin: 0 0 1em; +} + +.wporg-media-resource-checker-popover-content ul { + margin: 0; + list-style: disc outside; + padding-left: 1.5em; +} + +/*# sourceMappingURL=style-index.css.map*/ \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map new file mode 100644 index 0000000000..9b5beb593d --- /dev/null +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map @@ -0,0 +1 @@ +{"version":3,"file":"./style-index.css","mappings":";;;AAAA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACD;;AAEA;EACC;AACD;;AAEA;EACC;EACA;AACD;;AACC;EACC;AACF;;AAEC;EACC;EACA;EACA;AAAF,C","sources":["webpack://wporg-media-resource-checker/./src/style.scss"],"sourcesContent":[".wporg-media-resource-checker-has-invalid-resource::before {\n\tcontent: '';\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\tz-index: 2;\n\tborder: 2px solid #cc1818;\n\tbackground: rgba(#cc1818, 0.2);\n\tbox-sizing: border-box;\n}\n\n.wporg-media-resource-checker-toolbar-button svg {\n\tfill: #cc1818;\n}\n\n.wporg-media-resource-checker-popover-content {\n\twidth: 240px;\n\tword-break: break-word;\n\n\tp {\n\t\tmargin: 0 0 1em;\n\t}\n\n\tul {\n\t\tmargin: 0;\n\t\tlist-style: disc outside;\n\t\tpadding-left: 1.5em;\n\t}\n}\n"],"names":[],"ignoreList":[],"sourceRoot":""} \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js index 02c04339a9..846abc983f 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js @@ -72,6 +72,11 @@ export const isInvalidResource = ( mediaUrl, siteUrl ) => { const siteAuthority = getAuthority( siteUrl ); const mediaAuthority = getAuthority( mediaUrl ); + // If the media authority is not set, it means the resource is not a valid URL. + if ( ! mediaAuthority ) { + return true; + } + // If the authority is the same, it means the resource is from the site. if ( siteAuthority === mediaAuthority ) { return false; From 87d63973a3791aad6a0f0f403c9acdb192127941 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 5 Jan 2026 18:10:56 +0900 Subject: [PATCH 3/6] Change namaspace --- .../wporg-media-resource-checker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php index cbbd2ed1ab..7629b30653 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php @@ -8,9 +8,9 @@ * License: GPLv2 or later */ -namespace WPOrg_Media_Resource_Checker; +namespace WordPressdotorg\Media_Resource_Checker; -use function WPOrg_Media_Resource_Checker\{ get_build_path, get_build_url }; +use function WordPressdotorg\Media_Resource_Checker\{ get_build_path, get_build_url }; defined( 'WPINC' ) || die(); From 9d72889046a4003c82cde8967de38455847ffb52 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 5 Jan 2026 18:15:08 +0900 Subject: [PATCH 4/6] Don't use get_build_url() and get_build_path() function --- .../build/index.asset.php | 2 +- .../build/index.js | 667 +----------------- .../build/index.js.map | 1 - .../build/style-index-rtl.css | 36 +- .../build/style-index.css | 38 +- .../build/style-index.css.map | 1 - .../wporg-media-resource-checker.php | 30 +- 7 files changed, 8 insertions(+), 767 deletions(-) delete mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map delete mode 100644 wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php index 75957dc69e..764116679e 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'dd073cf3a99c39afec64'); + array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'f73ee5e47d975bb710c1'); diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js index 3699470d9e..06fc37a9a3 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js @@ -1,666 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./node_modules/@wordpress/icons/build-module/library/caution.js" -/*!***********************************************************************!*\ - !*** ./node_modules/@wordpress/icons/build-module/library/caution.js ***! - \***********************************************************************/ -(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (/* binding */ caution_default) -/* harmony export */ }); -/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/primitives */ "@wordpress/primitives"); -/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__); -// packages/icons/src/library/caution.tsx - - -var caution_default = /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)( - _wordpress_primitives__WEBPACK_IMPORTED_MODULE_0__.Path, - { - fillRule: "evenodd", - clipRule: "evenodd", - d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" - } -) }); - -//# sourceMappingURL=caution.js.map - - -/***/ }, - -/***/ "./node_modules/clsx/dist/clsx.mjs" -/*!*****************************************!*\ - !*** ./node_modules/clsx/dist/clsx.mjs ***! - \*****************************************/ -(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ clsx: () => (/* binding */ clsx), -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t (/* binding */ useHasInvalidSource) -/* harmony export */ }); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/core-data */ "@wordpress/core-data"); -/* harmony import */ var _wordpress_core_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_core_data__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./src/utils.js"); -/** - * WordPress dependencies - */ - - - -/** - * Internal dependencies - */ - - -/** - * Custom hook to check if a block has an invalid media resource. - * - * @param {string} name The block name. - * @param {Object} attributes The block attributes. - * @return {Object} Object containing hasInvalidResource, siteUrl, and mediaUrl. - */ -const useHasInvalidSource = (name, attributes) => { - const siteUrl = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.useSelect)(select => { - const siteData = select(_wordpress_core_data__WEBPACK_IMPORTED_MODULE_1__.store).getEntityRecord('root', '__unstableBase'); - return siteData?.home || siteData?.url || null; - }, []); - const mediaUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.getBlockMediaResourceToCheck)(name, attributes); - const hasInvalidResource = mediaUrl && (0,_utils__WEBPACK_IMPORTED_MODULE_2__.isInvalidResource)(mediaUrl, siteUrl); - return { - hasInvalidResource, - siteUrl, - mediaUrl - }; -}; - -/***/ }, - -/***/ "./src/index.js" -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var clsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! clsx */ "./node_modules/clsx/dist/clsx.mjs"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/hooks */ "@wordpress/hooks"); -/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); -/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/icons */ "./node_modules/@wordpress/icons/build-module/library/caution.js"); -/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); -/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_7__); -/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./utils */ "./src/utils.js"); -/* harmony import */ var _hooks__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./hooks */ "./src/hooks.js"); -/* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./style.scss */ "./src/style.scss"); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__); -/** - * External dependencies - */ - - -/** - * WordPress dependencies - */ - - - - - - - - -/** - * Internal dependencies - */ - - - - -/** - * Block edit component with warning. - * - * @param {Object} props Component props. - * @param {Object} props.BlockEdit The block edit component. - * @return {Function} The block edit with warning component. - */ - -const BlockEditWithWarning = ({ - BlockEdit, - siteUrl, - mediaUrl, - ...props -}) => { - const siteAuthority = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_7__.getAuthority)(siteUrl); - const allowedDomainList = [siteAuthority, ..._utils__WEBPACK_IMPORTED_MODULE_8__.ALLOWED_DOMAINS.map(domain => domain.authority)]; - return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.Fragment, { - children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockEdit, { - ...props - }), props.isSelected && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.BlockControls, { - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.Dropdown, { - contentClassName: "", - renderToggle: ({ - isOpen, - onToggle - }) => { - return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToolbarGroup, { - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToolbarButton, { - "aria-expanded": isOpen, - "aria-haspopup": "true", - onClick: onToggle, - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Media resource error'), - icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__["default"], - className: "wporg-media-resource-checker-toolbar-button" - }) - }); - }, - renderContent: () => { - return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsxs)("div", { - className: "wporg-media-resource-checker-popover-content", - children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("p", { - children: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('This media resource is from a domain other than the recommended ones.', 'wporg-media-resource-checker') - }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("p", { - children: mediaUrl && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ExternalLink, { - href: mediaUrl, - children: mediaUrl - }) - }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("p", { - children: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Please use a media resource from the following recommended domains:', 'wporg-media-resource-checker') - }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("ul", { - children: allowedDomainList.map(domain => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)("li", { - children: domain - }, domain)) - })] - }); - } - }) - })] - }); -}; - -/** - * Higher order component to check if the media resource is from a domain - * other than the recommended ones. - * - * @param {Function} BlockEdit The block edit component. - * @return {Function} The higher order component. - */ -const withMediaResourceChecker = (0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.createHigherOrderComponent)(BlockEdit => { - return props => { - const { - name, - attributes - } = props; - const { - hasInvalidResource, - siteUrl, - mediaUrl - } = (0,_hooks__WEBPACK_IMPORTED_MODULE_9__.useHasInvalidSource)(name, attributes); - return hasInvalidResource ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockEditWithWarning, { - BlockEdit: BlockEdit, - siteUrl: siteUrl, - mediaUrl: mediaUrl, - ...props - }) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockEdit, { - ...props - }, "edit"); - }; -}, 'withMediaResourceChecker'); - -/** - * Higher order component to add className to wrapperProps for blocks - * with invalid resources. - * - * @param {Function} BlockListBlock The block list block component. - * @return {Function} The higher order component. - */ -const withInvalidResourceClassName = (0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.createHigherOrderComponent)(BlockListBlock => { - return props => { - const { - name, - attributes, - wrapperProps = {} - } = props; - const { - hasInvalidResource - } = (0,_hooks__WEBPACK_IMPORTED_MODULE_9__.useHasInvalidSource)(name, attributes); - const newWrapperProps = hasInvalidResource ? { - ...wrapperProps, - className: (0,clsx__WEBPACK_IMPORTED_MODULE_0__["default"])(wrapperProps.className, 'wporg-media-resource-checker-has-invalid-resource') - } : wrapperProps; - return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_11__.jsx)(BlockListBlock, { - ...props, - wrapperProps: newWrapperProps - }); - }; -}, 'withInvalidResourceClassName'); -(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__.addFilter)('editor.BlockEdit', 'wporg-media-resource-checker/with-media-resource-checker', withMediaResourceChecker); -(0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__.addFilter)('editor.BlockListBlock', 'wporg-media-resource-checker/with-invalid-resource-class-name', withInvalidResourceClassName); - -/***/ }, - -/***/ "./src/style.scss" -/*!************************!*\ - !*** ./src/style.scss ***! - \************************/ -(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - -__webpack_require__.r(__webpack_exports__); -// extracted by mini-css-extract-plugin - - -/***/ }, - -/***/ "./src/utils.js" -/*!**********************!*\ - !*** ./src/utils.js ***! - \**********************/ -(__unused_webpack_module, __webpack_exports__, __webpack_require__) { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ ALLOWED_DOMAINS: () => (/* binding */ ALLOWED_DOMAINS), -/* harmony export */ getBlockMediaResourceToCheck: () => (/* binding */ getBlockMediaResourceToCheck), -/* harmony export */ isInvalidResource: () => (/* binding */ isInvalidResource) -/* harmony export */ }); -/* harmony import */ var _wordpress_blob__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/blob */ "@wordpress/blob"); -/* harmony import */ var _wordpress_blob__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blob__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); -/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_1__); -/** - * WordPress dependencies - */ - - - -// List of blocks to check. -const BLOCKS_TO_CHECK = [{ - name: 'core/image', - idKey: 'id', - urlKey: 'url' -}, { - name: 'core/video', - idKey: 'id', - urlKey: 'src' -}, { - name: 'core/cover', - idKey: 'id', - urlKey: 'url' -}]; - -// List of allowed domain regexes. -const ALLOWED_DOMAINS = [{ - authority: 'wordpress.org', - regex: /^(.*\.)?wordpress\.org$/ -}, { - authority: 'wp.com', - regex: /^(.*\.)?wp\.com$/ -}]; - -/** - * Gets the media resource to check for the block. - * - * @param {string} blockName The name of the block. - * @param {Object} attributes The attributes of the block. - * @return {string|null} The media resource to check, or null if the block is not in the list of blocks to check. - */ -const getBlockMediaResourceToCheck = (blockName, attributes) => { - const blockToCheck = BLOCKS_TO_CHECK.find(block => block.name === blockName); - if (!blockToCheck) { - return null; - } - return attributes[blockToCheck.urlKey]; -}; - -/** - * Checks whether the block has an invalid resource. - * - * @param {string} mediaUrl The media URL to check. - * @param {string} siteUrl The site URL. - * @return {boolean} True if the resource is invalid. - */ -const isInvalidResource = (mediaUrl, siteUrl) => { - if (!siteUrl) { - return false; - } - - // If no URL, cannot determine. - if (!mediaUrl || (0,_wordpress_blob__WEBPACK_IMPORTED_MODULE_0__.isBlobURL)(mediaUrl)) { - return false; - } - const siteAuthority = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_1__.getAuthority)(siteUrl); - const mediaAuthority = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_1__.getAuthority)(mediaUrl); - - // If the media authority is not set, it means the resource is not a valid URL. - if (!mediaAuthority) { - return true; - } - - // If the authority is the same, it means the resource is from the site. - if (siteAuthority === mediaAuthority) { - return false; - } - - // Check if the authority is from an allowed domain. - if (ALLOWED_DOMAINS.some(domain => mediaAuthority.match(domain.regex))) { - return false; - } - - // The media is not from an allowed domain. - return true; -}; - -/***/ }, - -/***/ "@wordpress/blob" -/*!******************************!*\ - !*** external ["wp","blob"] ***! - \******************************/ -(module) { - -module.exports = window["wp"]["blob"]; - -/***/ }, - -/***/ "@wordpress/block-editor" -/*!*************************************!*\ - !*** external ["wp","blockEditor"] ***! - \*************************************/ -(module) { - -module.exports = window["wp"]["blockEditor"]; - -/***/ }, - -/***/ "@wordpress/components" -/*!************************************!*\ - !*** external ["wp","components"] ***! - \************************************/ -(module) { - -module.exports = window["wp"]["components"]; - -/***/ }, - -/***/ "@wordpress/compose" -/*!*********************************!*\ - !*** external ["wp","compose"] ***! - \*********************************/ -(module) { - -module.exports = window["wp"]["compose"]; - -/***/ }, - -/***/ "@wordpress/core-data" -/*!**********************************!*\ - !*** external ["wp","coreData"] ***! - \**********************************/ -(module) { - -module.exports = window["wp"]["coreData"]; - -/***/ }, - -/***/ "@wordpress/data" -/*!******************************!*\ - !*** external ["wp","data"] ***! - \******************************/ -(module) { - -module.exports = window["wp"]["data"]; - -/***/ }, - -/***/ "@wordpress/hooks" -/*!*******************************!*\ - !*** external ["wp","hooks"] ***! - \*******************************/ -(module) { - -module.exports = window["wp"]["hooks"]; - -/***/ }, - -/***/ "@wordpress/i18n" -/*!******************************!*\ - !*** external ["wp","i18n"] ***! - \******************************/ -(module) { - -module.exports = window["wp"]["i18n"]; - -/***/ }, - -/***/ "@wordpress/primitives" -/*!************************************!*\ - !*** external ["wp","primitives"] ***! - \************************************/ -(module) { - -module.exports = window["wp"]["primitives"]; - -/***/ }, - -/***/ "@wordpress/url" -/*!*****************************!*\ - !*** external ["wp","url"] ***! - \*****************************/ -(module) { - -module.exports = window["wp"]["url"]; - -/***/ }, - -/***/ "react/jsx-runtime" -/*!**********************************!*\ - !*** external "ReactJSXRuntime" ***! - \**********************************/ -(module) { - -module.exports = window["ReactJSXRuntime"]; - -/***/ } - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Check if module exists (development only) -/******/ if (__webpack_modules__[moduleId] === undefined) { -/******/ var e = new Error("Cannot find module '" + moduleId + "'"); -/******/ e.code = 'MODULE_NOT_FOUND'; -/******/ throw e; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = __webpack_modules__; -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/chunk loaded */ -/******/ (() => { -/******/ var deferred = []; -/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { -/******/ if(chunkIds) { -/******/ priority = priority || 0; -/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; -/******/ deferred[i] = [chunkIds, fn, priority]; -/******/ return; -/******/ } -/******/ var notFulfilled = Infinity; -/******/ for (var i = 0; i < deferred.length; i++) { -/******/ var [chunkIds, fn, priority] = deferred[i]; -/******/ var fulfilled = true; -/******/ for (var j = 0; j < chunkIds.length; j++) { -/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { -/******/ chunkIds.splice(j--, 1); -/******/ } else { -/******/ fulfilled = false; -/******/ if(priority < notFulfilled) notFulfilled = priority; -/******/ } -/******/ } -/******/ if(fulfilled) { -/******/ deferred.splice(i--, 1) -/******/ var r = fn(); -/******/ if (r !== undefined) result = r; -/******/ } -/******/ } -/******/ return result; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/jsonp chunk loading */ -/******/ (() => { -/******/ // no baseURI -/******/ -/******/ // object to store loaded and loading chunks -/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched -/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded -/******/ var installedChunks = { -/******/ "index": 0, -/******/ "./style-index": 0 -/******/ }; -/******/ -/******/ // no chunk on demand loading -/******/ -/******/ // no prefetching -/******/ -/******/ // no preloaded -/******/ -/******/ // no HMR -/******/ -/******/ // no HMR manifest -/******/ -/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); -/******/ -/******/ // install a JSONP callback for chunk loading -/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { -/******/ var [chunkIds, moreModules, runtime] = data; -/******/ // add "moreModules" to the modules object, -/******/ // then flag all "chunkIds" as loaded and fire callback -/******/ var moduleId, chunkId, i = 0; -/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { -/******/ for(moduleId in moreModules) { -/******/ if(__webpack_require__.o(moreModules, moduleId)) { -/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; -/******/ } -/******/ } -/******/ if(runtime) var result = runtime(__webpack_require__); -/******/ } -/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); -/******/ for(;i < chunkIds.length; i++) { -/******/ chunkId = chunkIds[i]; -/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { -/******/ installedChunks[chunkId][0](); -/******/ } -/******/ installedChunks[chunkId] = 0; -/******/ } -/******/ return __webpack_require__.O(result); -/******/ } -/******/ -/******/ var chunkLoadingGlobal = globalThis["webpackChunkwporg_media_resource_checker"] = globalThis["webpackChunkwporg_media_resource_checker"] || []; -/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); -/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); -/******/ })(); -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module depends on other loaded chunks and execution need to be delayed -/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["./style-index"], () => (__webpack_require__("./src/index.js"))) -/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); -/******/ -/******/ })() -; -//# sourceMappingURL=index.js.map \ No newline at end of file +(()=>{"use strict";var e,r={566(){function e(r){var o,i,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var n=r.length;for(o=0;o{const o=(0,w.useSelect)(e=>{const r=e(m.store).getEntityRecord("root","__unstableBase");return r?.home||r?.url||null},[]),i=((e,r)=>{const o=h.find(r=>r.name===e);return o?r[o.urlKey]:null})(e,r),t=i&&((e,r)=>{if(!r)return!1;if(!e||(0,u.isBlobURL)(e))return!1;const o=(0,d.getAuthority)(r),i=(0,d.getAuthority)(e);return!i||o!==i&&!p.some(e=>i.match(e.regex))})(i,o);return{hasInvalidResource:t,siteUrl:o,mediaUrl:i}},v=({BlockEdit:e,siteUrl:r,mediaUrl:i,...t})=>{const a=[(0,d.getAuthority)(r),...p.map(e=>e.authority)];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{...t}),t.isSelected&&(0,c.jsx)(n.BlockControls,{children:(0,c.jsx)(s.Dropdown,{contentClassName:"",renderToggle:({isOpen:e,onToggle:r})=>(0,c.jsx)(s.ToolbarGroup,{children:(0,c.jsx)(s.ToolbarButton,{"aria-expanded":e,"aria-haspopup":"true",onClick:r,label:(0,o.__)("Media resource error"),icon:l,className:"wporg-media-resource-checker-toolbar-button"})}),renderContent:()=>(0,c.jsxs)("div",{className:"wporg-media-resource-checker-popover-content",children:[(0,c.jsx)("p",{children:(0,o.__)("This media resource is from a domain other than the recommended ones.","wporg-media-resource-checker")}),(0,c.jsx)("p",{children:i&&(0,c.jsx)(s.ExternalLink,{href:i,children:i})}),(0,c.jsx)("p",{children:(0,o.__)("Please use a media resource from the following recommended domains:","wporg-media-resource-checker")}),(0,c.jsx)("ul",{children:a.map(e=>(0,c.jsx)("li",{children:e},e))})]})})})]})},f=(0,t.createHigherOrderComponent)(e=>r=>{const{name:o,attributes:i}=r,{hasInvalidResource:t,siteUrl:n,mediaUrl:s}=g(o,i);return t?(0,c.jsx)(v,{BlockEdit:e,siteUrl:n,mediaUrl:s,...r}):(0,c.jsx)(e,{...r},"edit")},"withMediaResourceChecker"),x=(0,t.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:t,wrapperProps:n={}}=o,{hasInvalidResource:s}=g(i,t),a=s?{...n,className:r(n.className,"wporg-media-resource-checker-has-invalid-resource")}:n;return(0,c.jsx)(e,{...o,wrapperProps:a})},"withInvalidResourceClassName");(0,i.addFilter)("editor.BlockEdit","wporg-media-resource-checker/with-media-resource-checker",f),(0,i.addFilter)("editor.BlockListBlock","wporg-media-resource-checker/with-invalid-resource-class-name",x)}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.m=r,e=[],i.O=(r,o,t,n)=>{if(!o){var s=1/0;for(d=0;d=n)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(a=!1,n0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[o,t,n]},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={57:0,350:0};i.O.j=r=>0===e[r];var r=(r,o)=>{var t,n,[s,a,c]=o,l=0;if(s.some(r=>0!==e[r])){for(t in a)i.o(a,t)&&(i.m[t]=a[t]);if(c)var d=c(i)}for(r&&r(o);li(566));t=i.O(t)})(); \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map deleted file mode 100644 index ab805ef61e..0000000000 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;AAAA;AACkD;AACV;AACxC,sCAAsC,sDAAG,CAAC,sDAAG,IAAI,qFAAqF,sDAAG;AACzI,EAAE,uDAAI;AACN;AACA;AACA;AACA;AACA;AACA,GAAG;AAGD;AACF;;;;;;;;;;;;;;;;ACdA,cAAc,aAAa,+CAA+C,gDAAgD,eAAe,QAAQ,IAAI,0CAA0C,yCAAyC,SAAgB,gBAAgB,wCAAwC,IAAI,mDAAmD,SAAS,iEAAe,IAAI,E;;;;;;;;;;;;;;;;;;;ACAnY;AACA;AACA;AAC4C;AACc;;AAE1D;AACA;AACA;AAC0E;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,mBAAmB,GAAGA,CAAEC,IAAI,EAAEC,UAAU,KAAM;EAC1D,MAAMC,OAAO,GAAGR,0DAAS,CAAIS,MAAM,IAAM;IACxC,MAAMC,QAAQ,GAAGD,MAAM,CAAEP,uDAAU,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ACAA,6C;;;;;;;;;;ACAA,4C;;;;;;;;;;ACAA,yC;;;;;;;;;;ACAA,0C;;;;;;;;;;ACAA,sC;;;;;;;;;;ACAA,uC;;;;;;;;;;ACAA,sC;;;;;;;;;;ACAA,4C;;;;;;;;;;ACAA,qC;;;;;;;;;;ACAA,2C;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WC/BA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,E;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA,E;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA,4G;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://wporg-media-resource-checker/./node_modules/@wordpress/icons/build-module/library/caution.js","webpack://wporg-media-resource-checker/./node_modules/clsx/dist/clsx.mjs","webpack://wporg-media-resource-checker/./src/hooks.js","webpack://wporg-media-resource-checker/./src/index.js","webpack://wporg-media-resource-checker/./src/style.scss","webpack://wporg-media-resource-checker/./src/utils.js","webpack://wporg-media-resource-checker/external window [\"wp\",\"blob\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"blockEditor\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"components\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"compose\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"coreData\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"data\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"hooks\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"i18n\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"primitives\"]","webpack://wporg-media-resource-checker/external window [\"wp\",\"url\"]","webpack://wporg-media-resource-checker/external window \"ReactJSXRuntime\"","webpack://wporg-media-resource-checker/webpack/bootstrap","webpack://wporg-media-resource-checker/webpack/runtime/chunk loaded","webpack://wporg-media-resource-checker/webpack/runtime/compat get default export","webpack://wporg-media-resource-checker/webpack/runtime/define property getters","webpack://wporg-media-resource-checker/webpack/runtime/hasOwnProperty shorthand","webpack://wporg-media-resource-checker/webpack/runtime/make namespace object","webpack://wporg-media-resource-checker/webpack/runtime/jsonp chunk loading","webpack://wporg-media-resource-checker/webpack/before-startup","webpack://wporg-media-resource-checker/webpack/startup","webpack://wporg-media-resource-checker/webpack/after-startup"],"sourcesContent":["// packages/icons/src/library/caution.tsx\nimport { Path, SVG } from \"@wordpress/primitives\";\nimport { jsx } from \"react/jsx-runtime\";\nvar caution_default = /* @__PURE__ */ jsx(SVG, { viewBox: \"0 0 24 24\", xmlns: \"http://www.w3.org/2000/svg\", children: /* @__PURE__ */ jsx(\n Path,\n {\n fillRule: \"evenodd\",\n clipRule: \"evenodd\",\n d: \"M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z\"\n }\n) });\nexport {\n caution_default as default\n};\n//# sourceMappingURL=caution.js.map\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t {\n\tconst siteUrl = useSelect( ( select ) => {\n\t\tconst siteData = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'__unstableBase'\n\t\t);\n\t\treturn siteData?.home || siteData?.url || null;\n\t}, [] );\n\n\tconst mediaUrl = getBlockMediaResourceToCheck( name, attributes );\n\n\tconst hasInvalidResource =\n\t\tmediaUrl && isInvalidResource( mediaUrl, siteUrl );\n\n\treturn {\n\t\thasInvalidResource,\n\t\tsiteUrl,\n\t\tmediaUrl,\n\t};\n};\n","/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { BlockControls } from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tExternalLink,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { caution } from '@wordpress/icons';\nimport { getAuthority } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { ALLOWED_DOMAINS } from './utils';\nimport { useHasInvalidSource } from './hooks';\nimport './style.scss';\n\n/**\n * Block edit component with warning.\n *\n * @param {Object} props Component props.\n * @param {Object} props.BlockEdit The block edit component.\n * @return {Function} The block edit with warning component.\n */\nconst BlockEditWithWarning = ( { BlockEdit, siteUrl, mediaUrl, ...props } ) => {\n\tconst siteAuthority = getAuthority( siteUrl );\n\tconst allowedDomainList = [\n\t\tsiteAuthority,\n\t\t...ALLOWED_DOMAINS.map( ( domain ) => domain.authority ),\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t{ props.isSelected && (\n\t\t\t\t\n\t\t\t\t\t {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trenderContent={ () => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'This media resource is from a domain other than the recommended ones.',\n\t\t\t\t\t\t\t\t\t\t\t'wporg-media-resource-checker'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t\t{ mediaUrl && (\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t{ mediaUrl }\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Please use a media resource from the following recommended domains:',\n\t\t\t\t\t\t\t\t\t\t\t'wporg-media-resource-checker'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t

\n\t\t\t\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\t\t\t{ allowedDomainList.map( ( domain ) => (\n\t\t\t\t\t\t\t\t\t\t\t
  • { domain }
  • \n\t\t\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t
\n\t\t\t) }\n\t\t\n\t);\n};\n\n/**\n * Higher order component to check if the media resource is from a domain\n * other than the recommended ones.\n *\n * @param {Function} BlockEdit The block edit component.\n * @return {Function} The higher order component.\n */\nconst withMediaResourceChecker = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst { name, attributes } = props;\n\n\t\tconst { hasInvalidResource, siteUrl, mediaUrl } = useHasInvalidSource(\n\t\t\tname,\n\t\t\tattributes\n\t\t);\n\n\t\treturn hasInvalidResource ? (\n\t\t\t\n\t\t) : (\n\t\t\t\n\t\t);\n\t};\n}, 'withMediaResourceChecker' );\n\n/**\n * Higher order component to add className to wrapperProps for blocks\n * with invalid resources.\n *\n * @param {Function} BlockListBlock The block list block component.\n * @return {Function} The higher order component.\n */\nconst withInvalidResourceClassName = createHigherOrderComponent(\n\t( BlockListBlock ) => {\n\t\treturn ( props ) => {\n\t\t\tconst { name, attributes, wrapperProps = {} } = props;\n\n\t\t\tconst { hasInvalidResource } = useHasInvalidSource(\n\t\t\t\tname,\n\t\t\t\tattributes\n\t\t\t);\n\n\t\t\tconst newWrapperProps = hasInvalidResource\n\t\t\t\t? {\n\t\t\t\t\t\t...wrapperProps,\n\t\t\t\t\t\tclassName: clsx(\n\t\t\t\t\t\t\twrapperProps.className,\n\t\t\t\t\t\t\t'wporg-media-resource-checker-has-invalid-resource'\n\t\t\t\t\t\t),\n\t\t\t\t }\n\t\t\t\t: wrapperProps;\n\n\t\t\treturn (\n\t\t\t\t\n\t\t\t);\n\t\t};\n\t},\n\t'withInvalidResourceClassName'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'wporg-media-resource-checker/with-media-resource-checker',\n\twithMediaResourceChecker\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'wporg-media-resource-checker/with-invalid-resource-class-name',\n\twithInvalidResourceClassName\n);\n","// extracted by mini-css-extract-plugin\nexport {};","/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getAuthority } from '@wordpress/url';\n\n// List of blocks to check.\nconst BLOCKS_TO_CHECK = [\n\t{\n\t\tname: 'core/image',\n\t\tidKey: 'id',\n\t\turlKey: 'url',\n\t},\n\t{\n\t\tname: 'core/video',\n\t\tidKey: 'id',\n\t\turlKey: 'src',\n\t},\n\t{\n\t\tname: 'core/cover',\n\t\tidKey: 'id',\n\t\turlKey: 'url',\n\t},\n];\n\n// List of allowed domain regexes.\nexport const ALLOWED_DOMAINS = [\n\t{\n\t\tauthority: 'wordpress.org',\n\t\tregex: /^(.*\\.)?wordpress\\.org$/,\n\t},\n\t{\n\t\tauthority: 'wp.com',\n\t\tregex: /^(.*\\.)?wp\\.com$/,\n\t},\n];\n\n/**\n * Gets the media resource to check for the block.\n *\n * @param {string} blockName The name of the block.\n * @param {Object} attributes The attributes of the block.\n * @return {string|null} The media resource to check, or null if the block is not in the list of blocks to check.\n */\nexport const getBlockMediaResourceToCheck = ( blockName, attributes ) => {\n\tconst blockToCheck = BLOCKS_TO_CHECK.find(\n\t\t( block ) => block.name === blockName\n\t);\n\tif ( ! blockToCheck ) {\n\t\treturn null;\n\t}\n\treturn attributes[ blockToCheck.urlKey ];\n};\n\n/**\n * Checks whether the block has an invalid resource.\n *\n * @param {string} mediaUrl The media URL to check.\n * @param {string} siteUrl The site URL.\n * @return {boolean} True if the resource is invalid.\n */\nexport const isInvalidResource = ( mediaUrl, siteUrl ) => {\n\tif ( ! siteUrl ) {\n\t\treturn false;\n\t}\n\n\t// If no URL, cannot determine.\n\tif ( ! mediaUrl || isBlobURL( mediaUrl ) ) {\n\t\treturn false;\n\t}\n\n\tconst siteAuthority = getAuthority( siteUrl );\n\tconst mediaAuthority = getAuthority( mediaUrl );\n\n\t// If the media authority is not set, it means the resource is not a valid URL.\n\tif ( ! mediaAuthority ) {\n\t\treturn true;\n\t}\n\n\t// If the authority is the same, it means the resource is from the site.\n\tif ( siteAuthority === mediaAuthority ) {\n\t\treturn false;\n\t}\n\n\t// Check if the authority is from an allowed domain.\n\tif (\n\t\tALLOWED_DOMAINS.some( ( domain ) =>\n\t\t\tmediaAuthority.match( domain.regex )\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\t// The media is not from an allowed domain.\n\treturn true;\n};\n","module.exports = window[\"wp\"][\"blob\"];","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"compose\"];","module.exports = window[\"wp\"][\"coreData\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"hooks\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"wp\"][\"primitives\"];","module.exports = window[\"wp\"][\"url\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Check if module exists (development only)\n\tif (__webpack_modules__[moduleId] === undefined) {\n\t\tvar e = new Error(\"Cannot find module '\" + moduleId + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkwporg_media_resource_checker\"] = globalThis[\"webpackChunkwporg_media_resource_checker\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["useSelect","store","coreStore","getBlockMediaResourceToCheck","isInvalidResource","useHasInvalidSource","name","attributes","siteUrl","select","siteData","getEntityRecord","home","url","mediaUrl","hasInvalidResource","clsx","__","addFilter","createHigherOrderComponent","BlockControls","Dropdown","ExternalLink","ToolbarButton","ToolbarGroup","caution","getAuthority","ALLOWED_DOMAINS","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","BlockEditWithWarning","BlockEdit","props","siteAuthority","allowedDomainList","map","domain","authority","children","isSelected","contentClassName","renderToggle","isOpen","onToggle","onClick","label","icon","className","renderContent","href","withMediaResourceChecker","withInvalidResourceClassName","BlockListBlock","wrapperProps","newWrapperProps","isBlobURL","BLOCKS_TO_CHECK","idKey","urlKey","regex","blockName","blockToCheck","find","block","mediaAuthority","some","match"],"ignoreList":[],"sourceRoot":""} \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css index 45c3be753f..438ff039de 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index-rtl.css @@ -1,35 +1 @@ -/*!***************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/style.scss ***! - \***************************************************************************************************************************************************************************************************************************************/ -.wporg-media-resource-checker-has-invalid-resource::before { - content: ""; - display: block; - width: 100%; - height: 100%; - position: absolute; - top: 0; - right: 0; - z-index: 2; - border: 2px solid #cc1818; - background: rgba(204, 24, 24, 0.2); - box-sizing: border-box; -} - -.wporg-media-resource-checker-toolbar-button svg { - fill: #cc1818; -} - -.wporg-media-resource-checker-popover-content { - width: 240px; - word-break: break-word; -} - -.wporg-media-resource-checker-popover-content p { - margin: 0 0 1em; -} - -.wporg-media-resource-checker-popover-content ul { - margin: 0; - list-style: disc outside; - padding-right: 1.5em; -} +.wporg-media-resource-checker-has-invalid-resource:before{background:rgba(204,24,24,.2);border:2px solid #cc1818;box-sizing:border-box;content:"";display:block;height:100%;right:0;position:absolute;top:0;width:100%;z-index:2}.wporg-media-resource-checker-toolbar-button svg{fill:#cc1818}.wporg-media-resource-checker-popover-content{width:240px;word-break:break-word}.wporg-media-resource-checker-popover-content p{margin:0 0 1em}.wporg-media-resource-checker-popover-content ul{list-style:disc outside;margin:0;padding-right:1.5em} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css index 4bd303cd26..eb7c5a61b0 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css @@ -1,37 +1 @@ -/*!***************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/style.scss ***! - \***************************************************************************************************************************************************************************************************************************************/ -.wporg-media-resource-checker-has-invalid-resource::before { - content: ""; - display: block; - width: 100%; - height: 100%; - position: absolute; - top: 0; - left: 0; - z-index: 2; - border: 2px solid #cc1818; - background: rgba(204, 24, 24, 0.2); - box-sizing: border-box; -} - -.wporg-media-resource-checker-toolbar-button svg { - fill: #cc1818; -} - -.wporg-media-resource-checker-popover-content { - width: 240px; - word-break: break-word; -} - -.wporg-media-resource-checker-popover-content p { - margin: 0 0 1em; -} - -.wporg-media-resource-checker-popover-content ul { - margin: 0; - list-style: disc outside; - padding-left: 1.5em; -} - -/*# sourceMappingURL=style-index.css.map*/ \ No newline at end of file +.wporg-media-resource-checker-has-invalid-resource:before{background:rgba(204,24,24,.2);border:2px solid #cc1818;box-sizing:border-box;content:"";display:block;height:100%;left:0;position:absolute;top:0;width:100%;z-index:2}.wporg-media-resource-checker-toolbar-button svg{fill:#cc1818}.wporg-media-resource-checker-popover-content{width:240px;word-break:break-word}.wporg-media-resource-checker-popover-content p{margin:0 0 1em}.wporg-media-resource-checker-popover-content ul{list-style:disc outside;margin:0;padding-left:1.5em} diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map deleted file mode 100644 index 9b5beb593d..0000000000 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/style-index.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"./style-index.css","mappings":";;;AAAA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACD;;AAEA;EACC;AACD;;AAEA;EACC;EACA;AACD;;AACC;EACC;AACF;;AAEC;EACC;EACA;EACA;AAAF,C","sources":["webpack://wporg-media-resource-checker/./src/style.scss"],"sourcesContent":[".wporg-media-resource-checker-has-invalid-resource::before {\n\tcontent: '';\n\tdisplay: block;\n\twidth: 100%;\n\theight: 100%;\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\tz-index: 2;\n\tborder: 2px solid #cc1818;\n\tbackground: rgba(#cc1818, 0.2);\n\tbox-sizing: border-box;\n}\n\n.wporg-media-resource-checker-toolbar-button svg {\n\tfill: #cc1818;\n}\n\n.wporg-media-resource-checker-popover-content {\n\twidth: 240px;\n\tword-break: break-word;\n\n\tp {\n\t\tmargin: 0 0 1em;\n\t}\n\n\tul {\n\t\tmargin: 0;\n\t\tlist-style: disc outside;\n\t\tpadding-left: 1.5em;\n\t}\n}\n"],"names":[],"ignoreList":[],"sourceRoot":""} \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php index 7629b30653..2a87b88065 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/wporg-media-resource-checker.php @@ -10,8 +10,6 @@ namespace WordPressdotorg\Media_Resource_Checker; -use function WordPressdotorg\Media_Resource_Checker\{ get_build_path, get_build_url }; - defined( 'WPINC' ) || die(); define( __NAMESPACE__ . '\PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); @@ -23,38 +21,18 @@ add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\enqueue_block_editor_assets' ); add_action( 'enqueue_block_assets', __NAMESPACE__ . '\enqueue_block_assets' ); - -/** - * Shortcut to the build directory. - * - * @return string - */ -function get_build_path() { - return PLUGIN_DIR . 'build/'; -} - -/** - * Shortcut to the build URL. - * - * @return string - */ -function get_build_url() { - return PLUGIN_URL . 'build/'; -} - - /** * Enqueue scripts for the block editor. */ function enqueue_block_editor_assets() { - $script_asset_path = get_build_path() . 'index.asset.php'; + $script_asset_path = __DIR__ . '/build/index.asset.php'; if ( ! file_exists( $script_asset_path ) ) { wp_die( 'You need to run `yarn start` or `yarn build` to build the required assets.' ); } $script_asset = require( $script_asset_path ); wp_enqueue_script( 'wporg-media-resource-checker', - get_build_url() . 'index.js', + plugins_url( 'build/index.js', __FILE__ ), $script_asset['dependencies'], $script_asset['version'], true @@ -70,14 +48,14 @@ function enqueue_block_assets() { if ( ! is_admin() ) { return; } - $script_asset_path = get_build_path() . 'index.asset.php'; + $script_asset_path = __DIR__ . '/build/index.asset.php'; if ( ! file_exists( $script_asset_path ) ) { wp_die( 'You need to run `yarn start` or `yarn build` to build the required assets.' ); } $script_asset = require( $script_asset_path ); wp_enqueue_style( 'wporg-media-resource-checker', - get_build_url() . 'style-index.css', + plugins_url( 'build/style-index.css', __FILE__ ), [], $script_asset['version'] ); From 302493e59c5620e88ae7089630ab76448503ce38 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 5 Jan 2026 18:19:15 +0900 Subject: [PATCH 5/6] Add w.org as an allowed domain --- .../wporg-media-resource-checker/build/index.asset.php | 2 +- .../plugins/wporg-media-resource-checker/build/index.js | 2 +- .../plugins/wporg-media-resource-checker/src/utils.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php index 764116679e..79c2101b64 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => 'f73ee5e47d975bb710c1'); + array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '48363bc5ab178fe2158e'); diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js index 06fc37a9a3..e213f40c25 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,r={566(){function e(r){var o,i,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var n=r.length;for(o=0;o{const o=(0,w.useSelect)(e=>{const r=e(m.store).getEntityRecord("root","__unstableBase");return r?.home||r?.url||null},[]),i=((e,r)=>{const o=h.find(r=>r.name===e);return o?r[o.urlKey]:null})(e,r),t=i&&((e,r)=>{if(!r)return!1;if(!e||(0,u.isBlobURL)(e))return!1;const o=(0,d.getAuthority)(r),i=(0,d.getAuthority)(e);return!i||o!==i&&!p.some(e=>i.match(e.regex))})(i,o);return{hasInvalidResource:t,siteUrl:o,mediaUrl:i}},v=({BlockEdit:e,siteUrl:r,mediaUrl:i,...t})=>{const a=[(0,d.getAuthority)(r),...p.map(e=>e.authority)];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{...t}),t.isSelected&&(0,c.jsx)(n.BlockControls,{children:(0,c.jsx)(s.Dropdown,{contentClassName:"",renderToggle:({isOpen:e,onToggle:r})=>(0,c.jsx)(s.ToolbarGroup,{children:(0,c.jsx)(s.ToolbarButton,{"aria-expanded":e,"aria-haspopup":"true",onClick:r,label:(0,o.__)("Media resource error"),icon:l,className:"wporg-media-resource-checker-toolbar-button"})}),renderContent:()=>(0,c.jsxs)("div",{className:"wporg-media-resource-checker-popover-content",children:[(0,c.jsx)("p",{children:(0,o.__)("This media resource is from a domain other than the recommended ones.","wporg-media-resource-checker")}),(0,c.jsx)("p",{children:i&&(0,c.jsx)(s.ExternalLink,{href:i,children:i})}),(0,c.jsx)("p",{children:(0,o.__)("Please use a media resource from the following recommended domains:","wporg-media-resource-checker")}),(0,c.jsx)("ul",{children:a.map(e=>(0,c.jsx)("li",{children:e},e))})]})})})]})},f=(0,t.createHigherOrderComponent)(e=>r=>{const{name:o,attributes:i}=r,{hasInvalidResource:t,siteUrl:n,mediaUrl:s}=g(o,i);return t?(0,c.jsx)(v,{BlockEdit:e,siteUrl:n,mediaUrl:s,...r}):(0,c.jsx)(e,{...r},"edit")},"withMediaResourceChecker"),x=(0,t.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:t,wrapperProps:n={}}=o,{hasInvalidResource:s}=g(i,t),a=s?{...n,className:r(n.className,"wporg-media-resource-checker-has-invalid-resource")}:n;return(0,c.jsx)(e,{...o,wrapperProps:a})},"withInvalidResourceClassName");(0,i.addFilter)("editor.BlockEdit","wporg-media-resource-checker/with-media-resource-checker",f),(0,i.addFilter)("editor.BlockListBlock","wporg-media-resource-checker/with-invalid-resource-class-name",x)}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.m=r,e=[],i.O=(r,o,t,n)=>{if(!o){var s=1/0;for(d=0;d=n)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(a=!1,n0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[o,t,n]},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={57:0,350:0};i.O.j=r=>0===e[r];var r=(r,o)=>{var t,n,[s,a,c]=o,l=0;if(s.some(r=>0!==e[r])){for(t in a)i.o(a,t)&&(i.m[t]=a[t]);if(c)var d=c(i)}for(r&&r(o);li(566));t=i.O(t)})(); \ No newline at end of file +(()=>{"use strict";var e,r={566(){function e(r){var o,i,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var n=r.length;for(o=0;o{const o=(0,w.useSelect)(e=>{const r=e(m.store).getEntityRecord("root","__unstableBase");return r?.home||r?.url||null},[]),i=((e,r)=>{const o=h.find(r=>r.name===e);return o?r[o.urlKey]:null})(e,r),t=i&&((e,r)=>{if(!r)return!1;if(!e||(0,u.isBlobURL)(e))return!1;const o=(0,d.getAuthority)(r),i=(0,d.getAuthority)(e);return!i||o!==i&&!p.some(e=>i.match(e.regex))})(i,o);return{hasInvalidResource:t,siteUrl:o,mediaUrl:i}},v=({BlockEdit:e,siteUrl:r,mediaUrl:i,...t})=>{const a=[(0,d.getAuthority)(r),...p.map(e=>e.authority)];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{...t}),t.isSelected&&(0,c.jsx)(n.BlockControls,{children:(0,c.jsx)(s.Dropdown,{contentClassName:"",renderToggle:({isOpen:e,onToggle:r})=>(0,c.jsx)(s.ToolbarGroup,{children:(0,c.jsx)(s.ToolbarButton,{"aria-expanded":e,"aria-haspopup":"true",onClick:r,label:(0,o.__)("Media resource error"),icon:l,className:"wporg-media-resource-checker-toolbar-button"})}),renderContent:()=>(0,c.jsxs)("div",{className:"wporg-media-resource-checker-popover-content",children:[(0,c.jsx)("p",{children:(0,o.__)("This media resource is from a domain other than the recommended ones.","wporg-media-resource-checker")}),(0,c.jsx)("p",{children:i&&(0,c.jsx)(s.ExternalLink,{href:i,children:i})}),(0,c.jsx)("p",{children:(0,o.__)("Please use a media resource from the following recommended domains:","wporg-media-resource-checker")}),(0,c.jsx)("ul",{children:a.map(e=>(0,c.jsx)("li",{children:e},e))})]})})})]})},f=(0,t.createHigherOrderComponent)(e=>r=>{const{name:o,attributes:i}=r,{hasInvalidResource:t,siteUrl:n,mediaUrl:s}=g(o,i);return t?(0,c.jsx)(v,{BlockEdit:e,siteUrl:n,mediaUrl:s,...r}):(0,c.jsx)(e,{...r},"edit")},"withMediaResourceChecker"),x=(0,t.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:t,wrapperProps:n={}}=o,{hasInvalidResource:s}=g(i,t),a=s?{...n,className:r(n.className,"wporg-media-resource-checker-has-invalid-resource")}:n;return(0,c.jsx)(e,{...o,wrapperProps:a})},"withInvalidResourceClassName");(0,i.addFilter)("editor.BlockEdit","wporg-media-resource-checker/with-media-resource-checker",f),(0,i.addFilter)("editor.BlockListBlock","wporg-media-resource-checker/with-invalid-resource-class-name",x)}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.m=r,e=[],i.O=(r,o,t,n)=>{if(!o){var s=1/0;for(d=0;d=n)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(a=!1,n0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[o,t,n]},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={57:0,350:0};i.O.j=r=>0===e[r];var r=(r,o)=>{var t,n,[s,a,c]=o,l=0;if(s.some(r=>0!==e[r])){for(t in a)i.o(a,t)&&(i.m[t]=a[t]);if(c)var d=c(i)}for(r&&r(o);li(566));t=i.O(t)})(); \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js index 846abc983f..a93b26df94 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js @@ -29,6 +29,10 @@ export const ALLOWED_DOMAINS = [ authority: 'wordpress.org', regex: /^(.*\.)?wordpress\.org$/, }, + { + authority: 'w.org', + regex: /^(.*\.)?w\.org$/, + }, { authority: 'wp.com', regex: /^(.*\.)?wp\.com$/, From e1db3537837f0fbeb7d6bd9826a89e477e530346 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 5 Jan 2026 18:57:35 +0900 Subject: [PATCH 6/6] Adjust allowed media resources --- .../build/index.asset.php | 2 +- .../build/index.js | 2 +- .../wporg-media-resource-checker/src/index.js | 4 +- .../wporg-media-resource-checker/src/utils.js | 51 ++++++++++++++----- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php index 79c2101b64..1ed00c1871 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '48363bc5ab178fe2158e'); + array('react-jsx-runtime', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '5969b60b5680025d093d'); diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js index e213f40c25..777c9caadc 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/build/index.js @@ -1 +1 @@ -(()=>{"use strict";var e,r={566(){function e(r){var o,i,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var n=r.length;for(o=0;o{const o=(0,w.useSelect)(e=>{const r=e(m.store).getEntityRecord("root","__unstableBase");return r?.home||r?.url||null},[]),i=((e,r)=>{const o=h.find(r=>r.name===e);return o?r[o.urlKey]:null})(e,r),t=i&&((e,r)=>{if(!r)return!1;if(!e||(0,u.isBlobURL)(e))return!1;const o=(0,d.getAuthority)(r),i=(0,d.getAuthority)(e);return!i||o!==i&&!p.some(e=>i.match(e.regex))})(i,o);return{hasInvalidResource:t,siteUrl:o,mediaUrl:i}},v=({BlockEdit:e,siteUrl:r,mediaUrl:i,...t})=>{const a=[(0,d.getAuthority)(r),...p.map(e=>e.authority)];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{...t}),t.isSelected&&(0,c.jsx)(n.BlockControls,{children:(0,c.jsx)(s.Dropdown,{contentClassName:"",renderToggle:({isOpen:e,onToggle:r})=>(0,c.jsx)(s.ToolbarGroup,{children:(0,c.jsx)(s.ToolbarButton,{"aria-expanded":e,"aria-haspopup":"true",onClick:r,label:(0,o.__)("Media resource error"),icon:l,className:"wporg-media-resource-checker-toolbar-button"})}),renderContent:()=>(0,c.jsxs)("div",{className:"wporg-media-resource-checker-popover-content",children:[(0,c.jsx)("p",{children:(0,o.__)("This media resource is from a domain other than the recommended ones.","wporg-media-resource-checker")}),(0,c.jsx)("p",{children:i&&(0,c.jsx)(s.ExternalLink,{href:i,children:i})}),(0,c.jsx)("p",{children:(0,o.__)("Please use a media resource from the following recommended domains:","wporg-media-resource-checker")}),(0,c.jsx)("ul",{children:a.map(e=>(0,c.jsx)("li",{children:e},e))})]})})})]})},f=(0,t.createHigherOrderComponent)(e=>r=>{const{name:o,attributes:i}=r,{hasInvalidResource:t,siteUrl:n,mediaUrl:s}=g(o,i);return t?(0,c.jsx)(v,{BlockEdit:e,siteUrl:n,mediaUrl:s,...r}):(0,c.jsx)(e,{...r},"edit")},"withMediaResourceChecker"),x=(0,t.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:t,wrapperProps:n={}}=o,{hasInvalidResource:s}=g(i,t),a=s?{...n,className:r(n.className,"wporg-media-resource-checker-has-invalid-resource")}:n;return(0,c.jsx)(e,{...o,wrapperProps:a})},"withInvalidResourceClassName");(0,i.addFilter)("editor.BlockEdit","wporg-media-resource-checker/with-media-resource-checker",f),(0,i.addFilter)("editor.BlockListBlock","wporg-media-resource-checker/with-invalid-resource-class-name",x)}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.m=r,e=[],i.O=(r,o,t,n)=>{if(!o){var s=1/0;for(d=0;d=n)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(a=!1,n0&&e[d-1][2]>n;d--)e[d]=e[d-1];e[d]=[o,t,n]},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={57:0,350:0};i.O.j=r=>0===e[r];var r=(r,o)=>{var t,n,[s,a,c]=o,l=0;if(s.some(r=>0!==e[r])){for(t in a)i.o(a,t)&&(i.m[t]=a[t]);if(c)var d=c(i)}for(r&&r(o);li(566));t=i.O(t)})(); \ No newline at end of file +(()=>{"use strict";var e,r={566(){function e(r){var o,i,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var n=r.length;for(o=0;o{const o=(0,w.useSelect)(e=>{const r=e(m.store).getEntityRecord("root","__unstableBase");return r?.home||r?.url||null},[]),i=((e,r)=>{const o=h.find(r=>r.name===e);return o?r[o.urlKey]:null})(e,r),t=i&&((e,r)=>{if(!r)return!1;if(!e||(0,u.isBlobURL)(e))return!1;if(!(0,l.isURL)(e))return!0;const o=(0,l.getAuthority)(r),i=(0,l.getAuthority)(e);if(!i)return!0;if(o===i)return!1;const t=p.find(e=>i.match(e.domainRegex));if(!t)return!0;if(t.pathRegex){const r=new URL(e).pathname;if(!r||!t.pathRegex.test(r))return!0}return!1})(i,o);return{hasInvalidResource:t,siteUrl:o,mediaUrl:i}},f=({BlockEdit:e,siteUrl:r,mediaUrl:i,...t})=>{const a=[(0,l.getAuthority)(r),...p.map(e=>e.authority)];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(e,{...t}),t.isSelected&&(0,c.jsx)(n.BlockControls,{children:(0,c.jsx)(s.Dropdown,{contentClassName:"",renderToggle:({isOpen:e,onToggle:r})=>(0,c.jsx)(s.ToolbarGroup,{children:(0,c.jsx)(s.ToolbarButton,{"aria-expanded":e,"aria-haspopup":"true",onClick:r,label:(0,o.__)("Media resource error"),icon:d,className:"wporg-media-resource-checker-toolbar-button"})}),renderContent:()=>(0,c.jsxs)("div",{className:"wporg-media-resource-checker-popover-content",children:[(0,c.jsx)("p",{children:(0,o.__)("This media resource is from a domain other than the recommended ones.","wporg-media-resource-checker")}),(0,c.jsx)("p",{children:i&&(0,c.jsx)(s.ExternalLink,{href:i,children:i})}),(0,c.jsx)("p",{children:(0,o.__)("Please use a media resource from the following recommended domains:","wporg-media-resource-checker")}),(0,c.jsx)("ul",{children:a.map(e=>(0,c.jsx)("li",{children:e},e))})]})})})]})},v=(0,t.createHigherOrderComponent)(e=>r=>{const{name:o,attributes:i}=r,{hasInvalidResource:t,siteUrl:n,mediaUrl:s}=g(o,i);return t?(0,c.jsx)(f,{BlockEdit:e,siteUrl:n,mediaUrl:s,...r}):(0,c.jsx)(e,{...r},"edit")},"withMediaResourceChecker"),x=(0,t.createHigherOrderComponent)(e=>o=>{const{name:i,attributes:t,wrapperProps:n={}}=o,{hasInvalidResource:s}=g(i,t),a=s?{...n,className:r(n.className,"wporg-media-resource-checker-has-invalid-resource")}:n;return(0,c.jsx)(e,{...o,wrapperProps:a})},"withInvalidResourceClassName");(0,i.addFilter)("editor.BlockEdit","wporg-media-resource-checker/with-media-resource-checker",v),(0,i.addFilter)("editor.BlockListBlock","wporg-media-resource-checker/with-invalid-resource-class-name",x)}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.m=r,e=[],i.O=(r,o,t,n)=>{if(!o){var s=1/0;for(l=0;l=n)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(a=!1,n0&&e[l-1][2]>n;l--)e[l]=e[l-1];e[l]=[o,t,n]},i.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={57:0,350:0};i.O.j=r=>0===e[r];var r=(r,o)=>{var t,n,[s,a,c]=o,d=0;if(s.some(r=>0!==e[r])){for(t in a)i.o(a,t)&&(i.m[t]=a[t]);if(c)var l=c(i)}for(r&&r(o);di(566));t=i.O(t)})(); \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js index f417187c2b..e655146b25 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/index.js @@ -22,7 +22,7 @@ import { getAuthority } from '@wordpress/url'; /** * Internal dependencies */ -import { ALLOWED_DOMAINS } from './utils'; +import { ALLOWED_RESOURCES } from './utils'; import { useHasInvalidSource } from './hooks'; import './style.scss'; @@ -37,7 +37,7 @@ const BlockEditWithWarning = ( { BlockEdit, siteUrl, mediaUrl, ...props } ) => { const siteAuthority = getAuthority( siteUrl ); const allowedDomainList = [ siteAuthority, - ...ALLOWED_DOMAINS.map( ( domain ) => domain.authority ), + ...ALLOWED_RESOURCES.map( ( resource ) => resource.authority ), ]; return ( diff --git a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js index a93b26df94..fb52e0dc53 100644 --- a/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js +++ b/wordpress.org/public_html/wp-content/plugins/wporg-media-resource-checker/src/utils.js @@ -2,7 +2,7 @@ * WordPress dependencies */ import { isBlobURL } from '@wordpress/blob'; -import { getAuthority } from '@wordpress/url'; +import { getAuthority, isURL } from '@wordpress/url'; // List of blocks to check. const BLOCKS_TO_CHECK = [ @@ -23,19 +23,20 @@ const BLOCKS_TO_CHECK = [ }, ]; -// List of allowed domain regexes. -export const ALLOWED_DOMAINS = [ +// List of allowed resources. +export const ALLOWED_RESOURCES = [ { authority: 'wordpress.org', - regex: /^(.*\.)?wordpress\.org$/, + domainRegex: /^(.*\.)?wordpress\.org$/, }, { authority: 'w.org', - regex: /^(.*\.)?w\.org$/, + domainRegex: /^(.*\.)?w\.org$/, }, { authority: 'wp.com', - regex: /^(.*\.)?wp\.com$/, + domainRegex: /^(.*\.)?wp\.com$/, + pathRegex: /^\/wordpress\.org\//, }, ]; @@ -59,6 +60,15 @@ export const getBlockMediaResourceToCheck = ( blockName, attributes ) => { /** * Checks whether the block has an invalid resource. * + * The following URLs are allowed; any other URLs will not be + * recommended as media resource URLs: + * + * - https://wordpress.org/image.jpg + * - https://make.wordpress.org/image.jpg + * - https://w.org/image.jpg + * - https://s.w.org/images/core/6.9/image.jpg + * - https://i0.wp.com/wordpress.org/image.jpg + * * @param {string} mediaUrl The media URL to check. * @param {string} siteUrl The site URL. * @return {boolean} True if the resource is invalid. @@ -73,6 +83,11 @@ export const isInvalidResource = ( mediaUrl, siteUrl ) => { return false; } + // If the media URL doesn't look like a URL, it means the media is not an external resource. + if ( ! isURL( mediaUrl ) ) { + return true; + } + const siteAuthority = getAuthority( siteUrl ); const mediaAuthority = getAuthority( mediaUrl ); @@ -87,14 +102,22 @@ export const isInvalidResource = ( mediaUrl, siteUrl ) => { } // Check if the authority is from an allowed domain. - if ( - ALLOWED_DOMAINS.some( ( domain ) => - mediaAuthority.match( domain.regex ) - ) - ) { - return false; + const allowedResource = ALLOWED_RESOURCES.find( ( resource ) => + mediaAuthority.match( resource.domainRegex ) + ); + + if ( ! allowedResource ) { + return true; + } + + // If pathRegex is defined, also check the path. + if ( allowedResource.pathRegex ) { + const url = new URL( mediaUrl ); + const path = url.pathname; + if ( ! path || ! allowedResource.pathRegex.test( path ) ) { + return true; + } } - // The media is not from an allowed domain. - return true; + return false; };