Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: 10up/safe-svg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.0
Choose a base ref
...
head repository: 10up/safe-svg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: trunk
Choose a head ref
Loading
Showing with 27,749 additions and 1,064 deletions.
  1. +9 −2 .distignore
  2. +18 −0 .gitattributes
  3. +8 −0 .github/CODEOWNERS
  4. +46 −0 .github/workflows/build-release-zip.yml
  5. +18 −12 .github/workflows/{no-response.yml → close-stale-issues.yml}
  6. +87 −0 .github/workflows/cypress.yml
  7. +24 −0 .github/workflows/dependency-review.yml
  8. +32 −0 .github/workflows/php-compatibility.yml
  9. +31 −0 .github/workflows/phpcs.yml
  10. +53 −0 .github/workflows/phpunit.yml
  11. +32 −0 .github/workflows/repo-automator.yml
  12. +21 −10 .github/workflows/wordpress-plugin-asset-update.yml
  13. +3 −1 .github/workflows/wordpress-plugin-deploy.yml
  14. +23 −0 .github/workflows/wordpress-version-checker.yml
  15. +12 −0 .gitignore
  16. +1 −0 .nvmrc
  17. +53 −0 .wordpress-org/blueprints/Info-icon_Wikipedians.svg
  18. +33 −0 .wordpress-org/blueprints/blueprint.json
  19. +91 −0 .wordpress-org/blueprints/demo-data.xml
  20. +4 −0 .wordpress-version-checker.json
  21. +14 −0 .wp-env.json
  22. +210 −2 CHANGELOG.md
  23. +11 −5 CONTRIBUTING.md
  24. +1 −1 CREDITS.md
  25. +4 −36 LICENSE.md
  26. +31 −24 README.md
  27. +308 −0 assets/js/admin/admin.js
  28. +0 −7 assets/safe-svg.css
  29. +49 −3 composer.json
  30. +2,601 −13 composer.lock
  31. +59 −0 includes/blocks.php
  32. +54 −0 includes/blocks/safe-svg/block.json
  33. +239 −0 includes/blocks/safe-svg/edit.js
  34. +3 −0 includes/blocks/safe-svg/frontend.js
  35. +15 −0 includes/blocks/safe-svg/frontend.scss
  36. +35 −0 includes/blocks/safe-svg/index.js
  37. +110 −0 includes/blocks/safe-svg/register.php
  38. +6 −0 includes/blocks/safe-svg/save.js
  39. +189 −0 includes/optimizer.php
  40. +10 −1 includes/safe-svg-attributes.php
  41. +193 −0 includes/safe-svg-settings.php
  42. +10 −1 includes/safe-svg-tags.php
  43. BIN languages/safe-svg-da_DK.mo
  44. +0 −38 languages/safe-svg-da_DK.po
  45. BIN languages/safe-svg-de_DE.mo
  46. +0 −38 languages/safe-svg-de_DE.po
  47. BIN languages/safe-svg-en_GB.mo
  48. +0 −38 languages/safe-svg-en_GB.po
  49. BIN languages/safe-svg-es_ES.mo
  50. +0 −38 languages/safe-svg-es_ES.po
  51. BIN languages/safe-svg-fr_FR.mo
  52. +0 −38 languages/safe-svg-fr_FR.po
  53. BIN languages/safe-svg-nl_NL.mo
  54. +0 −38 languages/safe-svg-nl_NL.po
  55. BIN languages/safe-svg-ru_RU.mo
  56. +0 −38 languages/safe-svg-ru_RU.po
  57. +21,065 −0 package-lock.json
  58. +57 −0 package.json
  59. +10 −0 phpcs.xml
  60. +20 −0 phpunit.xml.dist
  61. +95 −147 readme.txt
  62. +744 −533 safe-svg.php
  63. +3 −0 tests/bin/initialize.sh
  64. +46 −0 tests/bin/set-wp-config.js
  65. +2 −0 tests/bin/wp-cli.yml
  66. +27 −0 tests/cypress/cypress.config.js
  67. +27 −0 tests/cypress/e2e/admin.cy.js
  68. +145 −0 tests/cypress/e2e/safe-svg.cy.js
  69. +15 −0 tests/cypress/fixtures/badXmlTestOne.svg
  70. +20 −0 tests/cypress/fixtures/custom.svg
  71. +5 −0 tests/cypress/fixtures/example.json
  72. +35 −0 tests/cypress/plugins/index.js
  73. +46 −0 tests/cypress/support/commands.js
  74. +19 −0 tests/cypress/support/index.js
  75. +12 −0 tests/cypress/test-plugin/e2e-test-plugin-optimizer.php
  76. +39 −0 tests/cypress/test-plugin/e2e-test-plugin.php
  77. +7 −0 tests/cypress/tsconfig.json
  78. +20 −0 tests/unit/bootstrap.php
  79. +15 −0 tests/unit/files/badXmlTestOne.svg
  80. +10 −0 tests/unit/files/svgCleanOne.svg
  81. +10 −0 tests/unit/files/svgNoDimensions.svg
  82. +15 −0 tests/unit/files/svgTestOne.svg
  83. +50 −0 tests/unit/test-safe-svg-attributes.php
  84. +50 −0 tests/unit/test-safe-svg-tags.php
  85. +374 −0 tests/unit/test-safe-svg.php
  86. +15 −0 webpack.config.js
11 changes: 9 additions & 2 deletions .distignore
Original file line number Diff line number Diff line change
@@ -2,15 +2,22 @@
/.git
/.github
/.wordpress-org
/node_modules
/tests

# Files
.distignore
.gitignore
.*
CHANGELOG.md
CODE_OF_CONDUCT.md
composer.json
composer.lock
CONTRIBUTING.md
CREDITS.md
LICENSE.md
package-lock.json
package.json
phpcs.xml
phpunit.xml.dist
README.md
webpack.config.js
/assets/js/admin/admin.js
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/.distignore export-ignore
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.nvmrc export-ignore
/.wordpress-org/ export-ignore
/.wordpress-version-checker.json export-ignore
/.wp-env.json export-ignore
/CHANGELOG.md export-ignore
/CODE_OF_CONDUCT.md export-ignore
/CONTRIBUTING.md export-ignore
/CREDITS.md export-ignore
/composer.lock export-ignore
/package-lock.json export-ignore
/phpcs.xml export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
/webpack.config.js export-ignore
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# These owners will be the default owners for everything in the repo. Unless a later match takes precedence, @jeffpaul and @dkotter, as primary maintainers will be requested for review when someone opens a Pull Request.
* @jeffpaul @dkotter

# GitHub and WordPress.org specifics
/.github/ @jeffpaul
/.wordpress-org/ @jeffpaul
CODE_OF_CONDUCT.md @jeffpaul
LICENSE.md @jeffpaul
46 changes: 46 additions & 0 deletions .github/workflows/build-release-zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build release zip

on:
workflow_dispatch:
workflow_call:
push:
branches:
- trunk

jobs:
build:
name: Build release zip
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'

- name: Cache vendor
id: cache-composer
uses: actions/cache@v3
env:
cache-name: cache-vendor
with:
path: |
vendor
~/.composer/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}

- name: Install Composer dependencies
if: steps.cache-vendor.outputs.cache-hit != 'true'
run: composer install --no-dev

- name: Install Node dependencies
run: npm ci --no-optional

- name: Build plugin
run: npm run build

- name: Generate ZIP file
uses: 10up/action-wordpress-plugin-build-zip@stable
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
name: No Response
name: 'Close stale issues'

# **What it does**: Closes issues where the original author doesn't respond to a request for information.
# **Why we have it**: To remove the need for maintainers to remember to check back on issues periodically to see if contributors have responded.
# **Who does it impact**: Everyone that works on docs or docs-internal.

on:
issue_comment:
types: [created]
schedule:
# Schedule for five minutes after the hour, every hour
- cron: '5 * * * *'
# Schedule for every day at 1:30am UTC
- cron: '30 1 * * *'

permissions:
issues: write

jobs:
noResponse:
stale:
runs-on: ubuntu-latest
steps:
- uses: lee-dohm/no-response@v0.5.0
- uses: actions/stale@v9
with:
token: ${{ github.token }}
daysUntilClose: 14 # Number of days of inactivity before an Issue is closed for lack of response
responseRequiredLabel: "needs:feedback " # Label indicating that a response from the original author is required
closeComment: >
days-before-stale: 7
days-before-close: 7
stale-issue-message: >
It has been 7 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 7 days, but if you have more information to add then please comment and the issue will stay open.
close-issue-message: >
This issue has been automatically closed because there has been no response
to our request for more information. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further. See [this blog post on bug reports and the
importance of repro steps](https://www.lee-dohm.com/2015/01/04/writing-good-bug-reports/)
for more information about the kind of information that may be helpful.
stale-issue-label: 'stale'
close-issue-reason: 'not_planned'
any-of-labels: 'needs:feedback'
remove-stale-when-updated: true

87 changes: 87 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: E2E test

on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop

jobs:
build:
uses: 10up/safe-svg/.github/workflows/build-release-zip.yml@develop
cypress:
needs: build
name: ${{ matrix.core.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
core:
- {name: 'WP latest', version: 'latest'}
- {name: 'WP minimum', version: 'WordPress/WordPress#6.5'}
- {name: 'WP trunk', version: 'WordPress/WordPress#master'}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download build zip
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ${{ github.event.repository.name }}

- name: Display structure of downloaded files
run: ls -R
working-directory: ${{ github.event.repository.name }}

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: |
node_modules
~/.cache
~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
run: npm install

- name: Composer
run: composer install

- name: Set the core version and plugins config
run: ./tests/bin/set-wp-config.js --core=${{ matrix.core.version }} --plugins=./${{ github.event.repository.name }},./tests/cypress/test-plugin

- name: Set up WP environment
run: npm run env:start

- name: Test
run: npm run cypress:run

- name: Update summary
if: always()
run: |
npx mochawesome-merge ./tests/cypress/reports/*.json -o tests/cypress/reports/mochawesome.json
rm -rf ./tests/cypress/reports/mochawesome-*.json
npx mochawesome-json-to-md -p ./tests/cypress/reports/mochawesome.json -o ./tests/cypress/reports/mochawesome.md
npx mochawesome-report-generator tests/cypress/reports/mochawesome.json -o tests/cypress/reports/
cat ./tests/cypress/reports/mochawesome.md >> $GITHUB_STEP_SUMMARY
- name: Make artifacts available
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifact
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/
${{ github.workspace }}/tests/cypress/reports/
24 changes: 24 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Reqest, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: Dependency Review
uses: actions/dependency-review-action@v3
with:
license-check: true
vulnerability-check: false
config-file: 10up/.github/.github/dependency-review-config.yml@trunk
32 changes: 32 additions & 0 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: PHP Compatibility

on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop

jobs:
php_compatibility:
name: PHP minimum 7.4
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
coverage: none

- name: Install dependencies
run: composer install

- name: Run PHP Compatibility
run: vendor/bin/phpcs *.php includes -p --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.4-
31 changes: 31 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: PHPCS

on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop

jobs:
phpcs:
name: phpcs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer:v2

- name: composer install
run: composer install

- name: Run PHPCS
run: composer run phpcs
53 changes: 53 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: PHPUnit

env:
COMPOSER_VERSION: "2"
COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache"

on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop

jobs:
phpunit:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1' ]
os: [ ubuntu-latest ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set standard 10up cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"
- name: Prepare composer cache
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer update -W

- name: PHPUnit
run: './vendor/bin/phpunit'
Loading