From 3f9d8e24b9e7f681d8c28888595048acd447a41c Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Sat, 20 Apr 2024 13:41:54 -0700 Subject: [PATCH 01/12] Add emogrifier through composer --- composer.json | 3 + composer.lock | 382 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 299 insertions(+), 86 deletions(-) diff --git a/composer.json b/composer.json index edf7b33ec..edb2de62b 100644 --- a/composer.json +++ b/composer.json @@ -50,5 +50,8 @@ "platform": { "php": "7.4" } + }, + "require": { + "pelago/emogrifier": "^7.2" } } diff --git a/composer.lock b/composer.lock index d54a5e2d9..8ddfabef1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,301 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "33fae2736293dd91fdb47d2118163002", - "packages": [], + "content-hash": "0a4381eadf50310f21920b003fe063c3", + "packages": [ + { + "name": "pelago/emogrifier", + "version": "v7.2.0", + "source": { + "type": "git", + "url": "https://github.com/MyIntervals/emogrifier.git", + "reference": "727bdf7255b51798307f17dec52ff8a91f1c7de3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/727bdf7255b51798307f17dec52ff8a91f1c7de3", + "reference": "727bdf7255b51798307f17dec52ff8a91f1c7de3", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "php": "~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "sabberworm/php-css-parser": "^8.4.0", + "symfony/css-selector": "^4.4.23 || ^5.4.0 || ^6.0.0 || ^7.0.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "1.3.2", + "phpunit/phpunit": "9.6.11", + "rawr/cross-data-providers": "2.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "8.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Pelago\\Emogrifier\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Klee", + "email": "github@oliverklee.de" + }, + { + "name": "Zoli Szabó", + "email": "zoli.szabo+github@gmail.com" + }, + { + "name": "John Reeve", + "email": "jreeve@pelagodesign.com" + }, + { + "name": "Jake Hotson", + "email": "jake@qzdesign.co.uk" + }, + { + "name": "Cameron Brooks" + }, + { + "name": "Jaime Prado" + } + ], + "description": "Converts CSS styles into inline style attributes in your HTML code", + "homepage": "https://www.myintervals.com/emogrifier.php", + "keywords": [ + "css", + "email", + "pre-processing" + ], + "support": { + "issues": "https://github.com/MyIntervals/emogrifier/issues", + "source": "https://github.com/MyIntervals/emogrifier" + }, + "time": "2023-12-06T02:00:20+00:00" + }, + { + "name": "sabberworm/php-css-parser", + "version": "v8.5.1", + "source": { + "type": "git", + "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git", + "reference": "4a3d572b0f8b28bb6fd016ae8bbfc445facef152" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/4a3d572b0f8b28bb6fd016ae8bbfc445facef152", + "reference": "4a3d572b0f8b28bb6fd016ae8bbfc445facef152", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "php": ">=5.6.20" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.27" + }, + "suggest": { + "ext-mbstring": "for parsing UTF-8 CSS" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sabberworm\\CSS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Raphael Schweikert" + }, + { + "name": "Oliver Klee", + "email": "github@oliverklee.de" + }, + { + "name": "Jake Hotson", + "email": "jake.github@qzdesign.co.uk" + } + ], + "description": "Parser for CSS Files written in PHP", + "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser", + "keywords": [ + "css", + "parser", + "stylesheet" + ], + "support": { + "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues", + "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.5.1" + }, + "time": "2024-02-15T16:41:13+00:00" + }, + { + "name": "symfony/css-selector", + "version": "v5.4.35", + "source": { + "type": "git", + "url": "https://github.com/symfony/css-selector.git", + "reference": "9e615d367e2bed41f633abb383948c96a2dbbfae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/9e615d367e2bed41f633abb383948c96a2dbbfae", + "reference": "9e615d367e2bed41f633abb383948c96a2dbbfae", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\CssSelector\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Converts CSS selectors to XPath expressions", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/css-selector/tree/v5.4.35" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T13:51:25+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-26T09:26:14+00:00" + } + ], "packages-dev": [ { "name": "amphp/amp", @@ -3799,89 +4092,6 @@ ], "time": "2023-01-26T09:26:14+00:00" }, - { - "name": "symfony/polyfill-php80", - "version": "v1.28.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-01-26T09:26:14+00:00" - }, { "name": "symfony/service-contracts", "version": "v2.5.2", @@ -4389,5 +4599,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } From eb103a533bf0b3ce149d13417880143192bde1a5 Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Sat, 20 Apr 2024 13:42:23 -0700 Subject: [PATCH 02/12] New script for plugin build to include composer dependencies --- package.json | 2 +- scripts/build-plugin.sh | 23 +++++++++++++++++++++++ scripts/exclude.lst | 30 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 scripts/build-plugin.sh create mode 100644 scripts/exclude.lst diff --git a/package.json b/package.json index 41520fa58..49e69e972 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "zx": "^7.2.3" }, "scripts": { - "build": "npm run build:assets && npm run archive", + "build": "./scripts/build-plugin.sh", "build:assets": "wp-scripts build", "build:vendor": "cp ./node_modules/select2/dist/css/select2.min.css ./node_modules/select2/dist/js/select2.full.min.js ./assets/lib/select2", "archive": "composer archive --file=$npm_package_name --format=zip", diff --git a/scripts/build-plugin.sh b/scripts/build-plugin.sh new file mode 100755 index 000000000..88bc4b3c9 --- /dev/null +++ b/scripts/build-plugin.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Step 1: Create a new folder called `build` +mkdir -p build/wp-job-manager + +# Step 2: Copy the current folder to the build folder, excluding undesired directories +rsync -av --progress . build/wp-job-manager --exclude build --exclude node_modules --exclude vendor --exclude .git --exclude .github --exclude .psalm --exclude tests --exclude .husky --exclude docs + +# Navigate to build directory +cd build/wp-job-manager + +# Step 3: Run composer install without development dependencies +composer install --no-dev + +# Step 4: Zip the entire contents of the build folder into `wp-job-manager.zip` excluding the files from the exclude.lst file +# Navigate one level up, so the zip command includes the build directory content +cd .. +zip -r wp-job-manager.zip wp-job-manager -x@../scripts/exclude.lst + +# Step 5: Remove the contents of the build folder except the new zip file +rm -rf wp-job-manager + +echo "Build process complete. The wp-job-manager.zip file is ready in the /build folder." diff --git a/scripts/exclude.lst b/scripts/exclude.lst new file mode 100644 index 000000000..27a306bb6 --- /dev/null +++ b/scripts/exclude.lst @@ -0,0 +1,30 @@ +*.DS_Store +wp-job-manager/.babelrc +wp-job-manager/.editorconfig +wp-job-manager/.eslintignore +wp-job-manager/.eslintrc.js +wp-job-manager/.git-blame-ignore-revs +wp-job-manager/.gitignore +wp-job-manager/.jshintrc +wp-job-manager/.prettierrc +wp-job-manager/bin/* +wp-job-manager/build/* +wp-job-manager/composer.* +wp-job-manager/docs/* +wp-job-manager/jest.config.js +wp-job-manager/node_modules/* +wp-job-manager/package-lock.json +wp-job-manager/package.json +wp-job-manager/*.dist +wp-job-manager/psalm.xml +wp-job-manager/scripts/* +wp-job-manager/tests/* +wp-job-manager/.git/* +wp-job-manager/.github/* +wp-job-manager/readme.md +wp-job-manager/assets/dist/css/*.js +wp-job-manager/assets/css/* +wp-job-manager/assets/font/* +wp-job-manager/assets/js/* +wp-job-manager/renovate.json +wp-job-manager/webpack.config.js From 3a94a31784186d51a1fc20d4b1654617950d826c Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Sat, 20 Apr 2024 13:42:34 -0700 Subject: [PATCH 03/12] Remove previous emogrifier library --- lib/emogrifier/class-emogrifier.php | 1811 --------------------------- 1 file changed, 1811 deletions(-) delete mode 100644 lib/emogrifier/class-emogrifier.php diff --git a/lib/emogrifier/class-emogrifier.php b/lib/emogrifier/class-emogrifier.php deleted file mode 100644 index 412dc276a..000000000 --- a/lib/emogrifier/class-emogrifier.php +++ /dev/null @@ -1,1811 +0,0 @@ - - * @author Roman Ožana - * @author Sander Kruger - * @author Zoli Szabó - */ -class Emogrifier -{ - /** - * @var int - */ - const CACHE_KEY_CSS = 0; - - /** - * @var int - */ - const CACHE_KEY_SELECTOR = 1; - - /** - * @var int - */ - const CACHE_KEY_XPATH = 2; - - /** - * @var int - */ - const CACHE_KEY_CSS_DECLARATIONS_BLOCK = 3; - - /** - * @var int - */ - const CACHE_KEY_COMBINED_STYLES = 4; - - /** - * for calculating nth-of-type and nth-child selectors - * - * @var int - */ - const INDEX = 0; - - /** - * for calculating nth-of-type and nth-child selectors - * - * @var int - */ - const MULTIPLIER = 1; - - /** - * @var string - */ - const ID_ATTRIBUTE_MATCHER = '/(\\w+)?\\#([\\w\\-]+)/'; - - /** - * @var string - */ - const CLASS_ATTRIBUTE_MATCHER = '/(\\w+|[\\*\\]])?((\\.[\\w\\-]+)+)/'; - - /** - * @var string - */ - const CONTENT_TYPE_META_TAG = ''; - - /** - * @var string - */ - const DEFAULT_DOCUMENT_TYPE = ''; - - /** - * @var string - */ - private $html = ''; - - /** - * @var string - */ - private $css = ''; - - /** - * @var bool[] - */ - private $excludedSelectors = []; - - /** - * @var string[] - */ - private $unprocessableHtmlTags = ['wbr']; - - /** - * @var bool[] - */ - private $allowedMediaTypes = ['all' => true, 'screen' => true, 'print' => true]; - - /** - * @var mixed[] - */ - private $caches = [ - self::CACHE_KEY_CSS => [], - self::CACHE_KEY_SELECTOR => [], - self::CACHE_KEY_XPATH => [], - self::CACHE_KEY_CSS_DECLARATIONS_BLOCK => [], - self::CACHE_KEY_COMBINED_STYLES => [], - ]; - - /** - * the visited nodes with the XPath paths as array keys - * - * @var \DOMElement[] - */ - private $visitedNodes = []; - - /** - * the styles to apply to the nodes with the XPath paths as array keys for the outer array - * and the attribute names/values as key/value pairs for the inner array - * - * @var string[][] - */ - private $styleAttributesForNodes = []; - - /** - * Determines whether the "style" attributes of tags in the the HTML passed to this class should be preserved. - * If set to false, the value of the style attributes will be discarded. - * - * @var bool - */ - private $isInlineStyleAttributesParsingEnabled = true; - - /** - * Determines whether the