@automattic/newspack-blocks 1.37.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cache/babel/00255e6096be9e31ec354db849dfefaa.json.gz +0 -0
- package/.cache/babel/0265bee20d709ac92f56456637727f4b.json.gz +0 -0
- package/.cache/babel/02986ba19dc461a152ea1c45f3f36a27.json.gz +0 -0
- package/.cache/babel/06a1700c1a4a989fc7886c86bf6223f7.json.gz +0 -0
- package/.cache/babel/07169c73863508b392f15022920bd0b6.json.gz +0 -0
- package/.cache/babel/0a5083e561829e3884cb5c71388adc3f.json.gz +0 -0
- package/.cache/babel/0a713997b6e4f45849ed6a4bff79cca5.json.gz +0 -0
- package/.cache/babel/0a9506bf649ffbe854e75459cf6b8972.json.gz +0 -0
- package/.cache/babel/0c12c4398bbbf2d771b13dd1d0e64097.json.gz +0 -0
- package/.cache/babel/0f8c18da204f4cc2777ca3191f10c309.json.gz +0 -0
- package/.cache/babel/0fced15ed787cc4239bb53c1d12892e6.json.gz +0 -0
- package/.cache/babel/10faf7c74a89e9aa4d8b9528a654913e.json.gz +0 -0
- package/.cache/babel/1353b411b65a123b5dc35012db11aa1d.json.gz +0 -0
- package/.cache/babel/1729336f326db1cf54b9c1671dc5e36c.json.gz +0 -0
- package/.cache/babel/17a433ab631a32d0712f3f75cf85ea99.json.gz +0 -0
- package/.cache/babel/1948e72d907f681ff771881ad6800ee1.json.gz +0 -0
- package/.cache/babel/1ab4bf44aa14d2eb7e6911900a3b2c12.json.gz +0 -0
- package/.cache/babel/1decfd137cac87a75bd83ffbd39c9106.json.gz +0 -0
- package/.cache/babel/2143ceff6d186bc13bc902e0f1f33dbf.json.gz +0 -0
- package/.cache/babel/23c63332718e167968a7c2a8a5f730eb.json.gz +0 -0
- package/.cache/babel/24bf53676e12293cbf88d01e649fd167.json.gz +0 -0
- package/.cache/babel/26ba0bb46844575022e54a8819fbf405.json.gz +0 -0
- package/.cache/babel/281ca171ce8947f87f574df11059e00b.json.gz +0 -0
- package/.cache/babel/28700b83434e4dbfb9a20d7ec0a7e7a4.json.gz +0 -0
- package/.cache/babel/29cf8eeea8630ade027e34459f2e49ee.json.gz +0 -0
- package/.cache/babel/2b0dd254a46223a93e6259d2b797a7e7.json.gz +0 -0
- package/.cache/babel/2da6786ede3ddda4c86eeac524a6a796.json.gz +0 -0
- package/.cache/babel/2e7ce10fdee94274b48d528f94c32b34.json.gz +0 -0
- package/.cache/babel/2f93fed1706a40d82122281cc3677074.json.gz +0 -0
- package/.cache/babel/3a59b710e9745ef93148d6d74ee7d16f.json.gz +0 -0
- package/.cache/babel/3b2c440027c793c8f7978d7622cbfca0.json.gz +0 -0
- package/.cache/babel/3ca939ace4af88e266942d93837ab37a.json.gz +0 -0
- package/.cache/babel/3e671670c4d395cd1804ef4be31955e4.json.gz +0 -0
- package/.cache/babel/3e69fe002d9973c0030152a51da9477a.json.gz +0 -0
- package/.cache/babel/3f5f8ea603fd57850c6683c750fe53d8.json.gz +0 -0
- package/.cache/babel/41abaaadb68b0657a95fa0c356873def.json.gz +0 -0
- package/.cache/babel/421ac952d6b472ba18e1cb95ef65f42a.json.gz +0 -0
- package/.cache/babel/424185dd50e91d8dee5fdae43086010e.json.gz +0 -0
- package/.cache/babel/427a6423ebde76bcb488747127e47351.json.gz +0 -0
- package/.cache/babel/43e800659f23430a181fb4fc328eb6ef.json.gz +0 -0
- package/.cache/babel/469651017a2b6f3b9f63fda034974b3a.json.gz +0 -0
- package/.cache/babel/480d26447b7ee019a37e4e18422403e9.json.gz +0 -0
- package/.cache/babel/4b58fad313d90a4c1577a2766e6c924c.json.gz +0 -0
- package/.cache/babel/4d2d42fea63650192d1a3a5648b621c5.json.gz +0 -0
- package/.cache/babel/4d8c26a76e77fa64d01f30a5f2d62f85.json.gz +0 -0
- package/.cache/babel/4f606ce6656565507a74aaac8dc21eea.json.gz +0 -0
- package/.cache/babel/505f37592f4c601ccdc1581ca89d9009.json.gz +0 -0
- package/.cache/babel/50aaf34aa54b2cd3058518e42850bb62.json.gz +0 -0
- package/.cache/babel/51fbf389462feb111228ba7ec64c631d.json.gz +0 -0
- package/.cache/babel/51fc90ae5fe129a095172032f304dc2c.json.gz +0 -0
- package/.cache/babel/53dbf5484c5601528c2fd8d7fe728b78.json.gz +0 -0
- package/.cache/babel/58e4535574062eb2d8fa56d002e7190d.json.gz +0 -0
- package/.cache/babel/5aa5e8d1492938c62999de022c4b220e.json.gz +0 -0
- package/.cache/babel/5d64e475284e52c104df17e26066b17b.json.gz +0 -0
- package/.cache/babel/6333c664d69f13036f42bcf575c8e65d.json.gz +0 -0
- package/.cache/babel/635c439786b8522888342779b28ee9ee.json.gz +0 -0
- package/.cache/babel/648cffdd5ec4a2446f8935a17b98080b.json.gz +0 -0
- package/.cache/babel/64b0dd478e6f2dd51de5ee20e311aee7.json.gz +0 -0
- package/.cache/babel/6531721abbc0b3906b28b268ed7914af.json.gz +0 -0
- package/.cache/babel/66bf5585c7901a76c7d4014fa9ffed40.json.gz +0 -0
- package/.cache/babel/6ef313cb6d3a59f73a6b78e1a729fb13.json.gz +0 -0
- package/.cache/babel/6f14eed506421f15710d3dfafe3dcd93.json.gz +0 -0
- package/.cache/babel/70f6c01d8c6bc3efc41c97eaf49f7617.json.gz +0 -0
- package/.cache/babel/72321dde68f0bb9c334d90d6f4584be8.json.gz +0 -0
- package/.cache/babel/76c815fab58595f57e01af6591791d57.json.gz +0 -0
- package/.cache/babel/7c10f4d554daa8efe1e0a4457fb6d27b.json.gz +0 -0
- package/.cache/babel/7dffccddd9780ab37fb79f809947c2cd.json.gz +0 -0
- package/.cache/babel/7e5162e3319cd5d6fca6c0db0516aaeb.json.gz +0 -0
- package/.cache/babel/803192c922f7d419648bab7e1201b22e.json.gz +0 -0
- package/.cache/babel/81f3f0f896d29cdf88f8543dedb77787.json.gz +0 -0
- package/.cache/babel/84c019d3d643195fb37d08110f15f8c9.json.gz +0 -0
- package/.cache/babel/853c31db7c4351f2f36d1021c667224d.json.gz +0 -0
- package/.cache/babel/88ec99735ea4f314937736f04360ff8c.json.gz +0 -0
- package/.cache/babel/8959ab8fcfa783cb56e9418b99c0951c.json.gz +0 -0
- package/.cache/babel/8b9624d721f8706682e33fe1853c8287.json.gz +0 -0
- package/.cache/babel/8de5c373bbc4b6fbeec373d582935887.json.gz +0 -0
- package/.cache/babel/8f24517cff634d2e91c19e51be8816cc.json.gz +0 -0
- package/.cache/babel/901e1bb823eca196b594baa35a35a81c.json.gz +0 -0
- package/.cache/babel/90dbc666ff9fa3b88f305fe90a9917bf.json.gz +0 -0
- package/.cache/babel/91b62dfd9475df7a39dc08fbd43847f9.json.gz +0 -0
- package/.cache/babel/956daf27323e3b87bf8bf9bbf58881ed.json.gz +0 -0
- package/.cache/babel/959e9b81103c539a9d85ac60955451b9.json.gz +0 -0
- package/.cache/babel/963b1e44be998c4dcc6845745c377369.json.gz +0 -0
- package/.cache/babel/966b41ac1317b3e03ca1e59f7eb57e8c.json.gz +0 -0
- package/.cache/babel/969d5992cc682e3b43761ef02c10b851.json.gz +0 -0
- package/.cache/babel/99df128bb528d0f95a56b311801d14c1.json.gz +0 -0
- package/.cache/babel/9b33e7d21f3fc4955a536a033cced71b.json.gz +0 -0
- package/.cache/babel/9c5ec84f77314a621c01ad77da7ccb58.json.gz +0 -0
- package/.cache/babel/9d325af12a88623602a5f8c2fce04847.json.gz +0 -0
- package/.cache/babel/a413e4d325543836d0800684bb26ed04.json.gz +0 -0
- package/.cache/babel/a5405f86b8d1485e62a125275507e60f.json.gz +0 -0
- package/.cache/babel/a7f7461321ca6fd4360df04bb894c106.json.gz +0 -0
- package/.cache/babel/a8a6812e1c7b65cc6d0bdebe2a35c8ca.json.gz +0 -0
- package/.cache/babel/aa89cfc4c88fcc465b8d74af824e7f6b.json.gz +0 -0
- package/.cache/babel/adbaeb5ddf5612b3dcd233a3f6f17bf2.json.gz +0 -0
- package/.cache/babel/ae18cd6ec42a3366c73435b62a9f5f70.json.gz +0 -0
- package/.cache/babel/aea149ee1ec6fa3ca7839c63f5edd78d.json.gz +0 -0
- package/.cache/babel/af1b34067a69854e109c0b0e45d90e43.json.gz +0 -0
- package/.cache/babel/b3a335ab950f502914013810b43b0ad5.json.gz +0 -0
- package/.cache/babel/b6cfba15cda3404d4b1041df448ed2b2.json.gz +0 -0
- package/.cache/babel/ba711530bd319618a0510d8361bebb45.json.gz +0 -0
- package/.cache/babel/ba77e682225df6126b636458055601d9.json.gz +0 -0
- package/.cache/babel/bab8189a74eee8d72702d1510b52b3b3.json.gz +0 -0
- package/.cache/babel/bd8741020db56bb5d999252812d1d717.json.gz +0 -0
- package/.cache/babel/beaa874c5e01203d9dbe23cb89405276.json.gz +0 -0
- package/.cache/babel/c196c9b8c21953c474acdaa9029b3cbf.json.gz +0 -0
- package/.cache/babel/c1e31e6c217023eb3d3fd5d3de486ac3.json.gz +0 -0
- package/.cache/babel/c3aa996443e7f377aa423bcc03ffc617.json.gz +0 -0
- package/.cache/babel/c481eae84d69b65405a44af442dbfea7.json.gz +0 -0
- package/.cache/babel/c4a817d6c4bf6eb3687ffccc5c2df801.json.gz +0 -0
- package/.cache/babel/c8b10cf6f706fb669d6dd7564385768d.json.gz +0 -0
- package/.cache/babel/caa2f98ba4af6eba0605543f690693c6.json.gz +0 -0
- package/.cache/babel/cada4b2cecb2c1fcc48b7a7ecda54907.json.gz +0 -0
- package/.cache/babel/d1bed5404789c427c32965ac6ecad0d9.json.gz +0 -0
- package/.cache/babel/d395e8c0a9c63680f2dcf90ca0e91d4a.json.gz +0 -0
- package/.cache/babel/d4672090e0dd9a73bfb00bd770b23643.json.gz +0 -0
- package/.cache/babel/d4c81f65fe6d78cdbdcf1ef901b7ba1b.json.gz +0 -0
- package/.cache/babel/d515ddc0797ea256ff7271507737e9ce.json.gz +0 -0
- package/.cache/babel/d742848d263503f79168f1a6b8a52097.json.gz +0 -0
- package/.cache/babel/d834b41d7028519ecd0cbc8c65d33dde.json.gz +0 -0
- package/.cache/babel/d9060b9162e7caf974db0b90b6134727.json.gz +0 -0
- package/.cache/babel/d946975b9beac51a39f600461e84b1b6.json.gz +0 -0
- package/.cache/babel/daf0af780cff2270b1ae0e4b97a5a4ab.json.gz +0 -0
- package/.cache/babel/db5215643b0737dc5245972a5c25f736.json.gz +0 -0
- package/.cache/babel/dd57b8d31664b147b9f1e3f5cd18cc2a.json.gz +0 -0
- package/.cache/babel/e0c78bdaae19f15e2dd4a773e842422b.json.gz +0 -0
- package/.cache/babel/e1a2c7e4fc3afe9cc6e03d60f4e4a23d.json.gz +0 -0
- package/.cache/babel/e210ff9aa99df972b8d81c4bda70f642.json.gz +0 -0
- package/.cache/babel/e259a73f84d5b92b94e6d094719264c3.json.gz +0 -0
- package/.cache/babel/e6ce03a9908c9c4dc2c723531f1073f6.json.gz +0 -0
- package/.cache/babel/e8a1501dd8e4b3389ecdc8f722622359.json.gz +0 -0
- package/.cache/babel/eb3bb371036da362c42db50248d0b180.json.gz +0 -0
- package/.cache/babel/eb854e03c810bdb969497b2a36119bfa.json.gz +0 -0
- package/.cache/babel/ec25bb53826070b7f301e64f02355b8c.json.gz +0 -0
- package/.cache/babel/edbaca20e4a65f850c3d8321c1945718.json.gz +0 -0
- package/.cache/babel/f059f1ca9e49d5c3e655d20339860dce.json.gz +0 -0
- package/.cache/babel/f24c559fb42ef906405966598baf5f80.json.gz +0 -0
- package/.cache/babel/f2f333c3c546ad711d722d782decd450.json.gz +0 -0
- package/.cache/babel/f42c854ce8f1dc1a6e6fe7c510b033a5.json.gz +0 -0
- package/.cache/babel/f5211608f22c2e12594eafdbc4e66aa5.json.gz +0 -0
- package/.cache/babel/f645b8c88a49718cd778e3595212d4eb.json.gz +0 -0
- package/.cache/babel/f66dda5c4e4e9d04eb6b7411fcb12a65.json.gz +0 -0
- package/.cache/babel/f9d5b6f3f5438342dba75c2ce6143eef.json.gz +0 -0
- package/.cache/babel/fc9c60ee1d2e8783ba4c08db5cf97d40.json.gz +0 -0
- package/.cache/babel/fd558798cea72d04fb826468a89d72aa.json.gz +0 -0
- package/.cache/babel/fe735cbd0f6e131e28d8b6eb1f39141b.json.gz +0 -0
- package/.eslintrc.js +3 -26
- package/.nvmrc +1 -0
- package/CHANGELOG.md +422 -0
- package/babel.config.js +6 -0
- package/block-list.json +1 -1
- package/composer.json +2 -2
- package/composer.lock +446 -161
- package/dist/author-list/view.asset.php +1 -0
- package/dist/author-list/view.css +1 -0
- package/dist/author-list/view.js +1 -0
- package/dist/author-list/view.rtl.css +1 -0
- package/dist/author-profile/view.asset.php +1 -0
- package/dist/author-profile/view.css +1 -0
- package/dist/author-profile/view.js +1 -0
- package/dist/author-profile/view.rtl.css +1 -0
- package/dist/block_styles.asset.php +1 -0
- package/dist/block_styles.css +1 -0
- package/dist/block_styles.js +1 -0
- package/dist/block_styles.rtl.css +1 -0
- package/dist/carousel/view.asset.php +1 -0
- package/dist/carousel/view.css +1 -0
- package/dist/carousel/view.js +1 -0
- package/dist/carousel/view.rtl.css +1 -0
- package/dist/donate/view.asset.php +1 -0
- package/dist/donate/view.css +1 -0
- package/dist/donate/view.js +1 -0
- package/dist/donate/view.rtl.css +1 -0
- package/dist/donateStreamlined.asset.php +1 -0
- package/dist/donateStreamlined.css +1 -0
- package/dist/donateStreamlined.js +1 -0
- package/dist/donateStreamlined.rtl.css +1 -0
- package/dist/editor.asset.php +1 -0
- package/dist/editor.css +1 -0
- package/dist/editor.js +41 -0
- package/dist/editor.rtl.css +1 -0
- package/dist/homepage-articles/view.asset.php +1 -0
- package/dist/homepage-articles/view.css +1 -0
- package/dist/homepage-articles/view.js +1 -0
- package/dist/homepage-articles/view.rtl.css +1 -0
- package/dist/iframe/view.asset.php +1 -0
- package/dist/iframe/view.css +1 -0
- package/dist/iframe/view.js +1 -0
- package/dist/iframe/view.rtl.css +1 -0
- package/includes/class-newspack-blocks-api.php +14 -69
- package/includes/class-newspack-blocks-patterns.php +4 -1
- package/includes/class-newspack-blocks.php +421 -95
- package/newspack-blocks.php +26 -2
- package/package.json +31 -129
- package/postcss.config.js +11 -0
- package/src/block-patterns/subscribe-2.php +1 -1
- package/src/block-patterns/subscribe-3.php +1 -1
- package/src/block-patterns/subscribe-7.php +12 -0
- package/src/block-patterns/subscribe-8.php +12 -0
- package/src/block-patterns/subscribe-9.php +12 -0
- package/src/block-styles/core/columns/editor.scss +5 -8
- package/src/block-styles/core/columns/view.scss +83 -42
- package/src/blocks/author-list/block.json +82 -0
- package/src/blocks/author-list/class-wp-rest-newspack-author-list-controller.php +387 -0
- package/src/blocks/author-list/edit.js +527 -0
- package/src/blocks/author-list/editor.js +7 -0
- package/src/blocks/author-list/editor.scss +1 -0
- package/src/blocks/author-list/index.js +45 -0
- package/src/blocks/author-list/view.js +5 -0
- package/src/blocks/author-list/view.php +175 -0
- package/src/blocks/author-list/view.scss +46 -0
- package/src/blocks/author-profile/block.json +8 -0
- package/src/blocks/author-profile/class-wp-rest-newspack-authors-controller.php +69 -14
- package/src/blocks/author-profile/edit.js +212 -189
- package/src/blocks/author-profile/editor.scss +1 -1
- package/src/blocks/author-profile/single-author.js +100 -0
- package/src/blocks/author-profile/view.php +38 -92
- package/src/blocks/author-profile/view.scss +120 -1
- package/src/blocks/carousel/create-swiper.js +14 -5
- package/src/blocks/carousel/edit.js +4 -2
- package/src/blocks/carousel/editor.scss +3 -12
- package/src/blocks/carousel/view.js +1 -1
- package/src/blocks/carousel/view.php +9 -5
- package/src/blocks/carousel/view.scss +29 -3
- package/src/blocks/donate/class-wp-rest-newspack-donate-controller.php +22 -24
- package/src/blocks/donate/edit.js +49 -42
- package/src/blocks/donate/editor.scss +27 -3
- package/src/blocks/donate/index.js +31 -4
- package/src/blocks/donate/streamlined/index.js +248 -0
- package/src/blocks/donate/streamlined/index.test.js +125 -0
- package/src/blocks/donate/streamlined/style.scss +324 -0
- package/src/blocks/donate/streamlined/utils.js +174 -0
- package/src/blocks/donate/streamlined/utils.test.js +18 -0
- package/src/blocks/donate/view.php +77 -36
- package/src/blocks/donate/view.scss +291 -0
- package/src/blocks/homepage-articles/block.json +8 -0
- package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +24 -78
- package/src/blocks/homepage-articles/edit.js +26 -0
- package/src/blocks/homepage-articles/store.js +11 -1
- package/src/blocks/homepage-articles/templates/article.php +31 -3
- package/src/blocks/homepage-articles/templates/articles-loop.php +6 -5
- package/src/blocks/homepage-articles/utils.js +11 -10
- package/src/blocks/homepage-articles/view.php +4 -1
- package/src/blocks/homepage-articles/view.scss +69 -24
- package/src/blocks/iframe/block.json +34 -0
- package/src/blocks/iframe/class-wp-rest-newspack-iframe-controller.php +345 -0
- package/src/blocks/iframe/edit.js +252 -0
- package/src/blocks/iframe/editor.js +7 -0
- package/src/blocks/iframe/editor.scss +84 -0
- package/src/blocks/iframe/icons.js +10 -0
- package/src/blocks/iframe/iframe-placeholder.js +180 -0
- package/src/blocks/iframe/index.js +48 -0
- package/src/blocks/iframe/view.js +5 -0
- package/src/blocks/iframe/view.php +130 -0
- package/src/blocks/iframe/view.scss +9 -0
- package/src/blocks/video-playlist/view.php +4 -3
- package/src/components/query-controls.js +5 -4
- package/src/setup/editor.js +0 -1
- package/src/shared/js/utils.js +1 -1
- package/src/templates/author-profile-card.php +99 -0
- package/vendor/autoload.php +7 -0
- package/vendor/composer/ClassLoader.php +572 -0
- package/vendor/composer/InstalledVersions.php +350 -0
- package/vendor/composer/LICENSE +21 -0
- package/vendor/composer/autoload_classmap.php +10 -0
- package/vendor/composer/autoload_namespaces.php +9 -0
- package/vendor/composer/autoload_psr4.php +9 -0
- package/vendor/composer/autoload_real.php +55 -0
- package/vendor/composer/autoload_static.php +20 -0
- package/vendor/composer/installed.json +5 -0
- package/vendor/composer/installed.php +23 -0
- package/webpack.config.js +2 -3
- package/.circleci/config.yml +0 -96
- package/.distignore +0 -36
- package/.editorconfig +0 -22
- package/.github/ISSUE_TEMPLATE/Bug_report.md +0 -21
- package/.github/ISSUE_TEMPLATE/Enhancement.md +0 -17
- package/.github/ISSUE_TEMPLATE/Feature_request.md +0 -17
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -29
- package/.github/workflows/main.yml +0 -15
- package/.phpcs.xml.dist +0 -55
- package/.prettierrc +0 -10
- package/.stylelintrc +0 -21
- package/.travis.yml +0 -67
- package/phpunit.xml.dist +0 -16
- package/src/blocks/author-profile/shared.scss +0 -95
- package/src/blocks/donate/streamlined.js +0 -180
- package/src/blocks/donate/streamlined.scss +0 -124
- package/src/setup/public-path.js +0 -13
- package/src/setup/view.js +0 -4
- package/tests/bootstrap.php +0 -31
- package/tests/test-sample.php +0 -20
package/.editorconfig
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# This file is for unifying the coding style for different editors and IDEs
|
|
2
|
-
# editorconfig.org
|
|
3
|
-
|
|
4
|
-
# WordPress Coding Standards
|
|
5
|
-
# https://make.wordpress.org/core/handbook/coding-standards/
|
|
6
|
-
|
|
7
|
-
root = true
|
|
8
|
-
|
|
9
|
-
[*]
|
|
10
|
-
charset = utf-8
|
|
11
|
-
end_of_line = lf
|
|
12
|
-
insert_final_newline = true
|
|
13
|
-
trim_trailing_whitespace = true
|
|
14
|
-
indent_style = tab
|
|
15
|
-
indent_size = 4
|
|
16
|
-
|
|
17
|
-
[{.jshintrc,*.json,*.yml}]
|
|
18
|
-
indent_style = space
|
|
19
|
-
indent_size = 2
|
|
20
|
-
|
|
21
|
-
[{*.txt,wp-config-sample.php}]
|
|
22
|
-
end_of_line = crlf
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "\U0001F41E Bug report"
|
|
3
|
-
about: Report a bug if something isn't working as expected.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
**Describe the bug**
|
|
8
|
-
A clear and concise description of what the bug is. Please be as descriptive as possible; issues lacking detail, or for any other reason than to report a bug, may be closed without action.
|
|
9
|
-
|
|
10
|
-
**To Reproduce**
|
|
11
|
-
Steps to reproduce the behavior:
|
|
12
|
-
1. Go to '...'
|
|
13
|
-
2. Click on '....'
|
|
14
|
-
3. Scroll down to '....'
|
|
15
|
-
4. See error
|
|
16
|
-
|
|
17
|
-
**Screenshots**
|
|
18
|
-
If applicable, add screenshots to help explain your problem.
|
|
19
|
-
|
|
20
|
-
**Expected behavior**
|
|
21
|
-
A clear and concise description of what you expected to happen.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "✨ New Enhancement"
|
|
3
|
-
about: "If you have an idea to improve an existing feature please let us know or submit a Pull Request!"
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
**Is your feature request related to a problem? Please describe.**
|
|
8
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
9
|
-
|
|
10
|
-
**Describe the solution you'd like**
|
|
11
|
-
A clear and concise description of what you want to happen.
|
|
12
|
-
|
|
13
|
-
**Describe alternatives you've considered**
|
|
14
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
15
|
-
|
|
16
|
-
**Additional context**
|
|
17
|
-
Add any other context or screenshots about the feature request here.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "\U0001F680 Feature request"
|
|
3
|
-
about: "Suggest a new feature \U0001F389 We'll consider building it if it receives sufficient interest! \U0001F44D"
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
**Is your feature request related to a problem? Please describe.**
|
|
8
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
9
|
-
|
|
10
|
-
**Describe the solution you'd like**
|
|
11
|
-
A clear and concise description of what you want to happen.
|
|
12
|
-
|
|
13
|
-
**Describe alternatives you've considered**
|
|
14
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
15
|
-
|
|
16
|
-
**Additional context**
|
|
17
|
-
Add any other context or screenshots about the feature request here.
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
### All Submissions:
|
|
2
|
-
|
|
3
|
-
* [ ] Have you followed the [Newspack Contributing guideline](https://github.com/Automattic/newspack-theme/blob/master/.github/CONTRIBUTING.md)?
|
|
4
|
-
* [ ] Does your code follow the [WordPress' coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/) and [VIP Go coding standards](https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/)?
|
|
5
|
-
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
|
|
6
|
-
|
|
7
|
-
<!-- Mark completed items with an [x] -->
|
|
8
|
-
|
|
9
|
-
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
|
|
10
|
-
|
|
11
|
-
### Changes proposed in this Pull Request:
|
|
12
|
-
|
|
13
|
-
<!-- Describe the changes made to this Pull Request, and the reason for such changes. -->
|
|
14
|
-
|
|
15
|
-
Closes # .
|
|
16
|
-
|
|
17
|
-
### How to test the changes in this Pull Request:
|
|
18
|
-
|
|
19
|
-
1.
|
|
20
|
-
2.
|
|
21
|
-
3.
|
|
22
|
-
|
|
23
|
-
### Other information:
|
|
24
|
-
|
|
25
|
-
* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
|
|
26
|
-
* [ ] Have you written new tests for your changes, as applicable?
|
|
27
|
-
* [ ] Have you successfully ran tests with your changes locally?
|
|
28
|
-
|
|
29
|
-
<!-- Mark completed items with an [x] -->
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
on: pull_request_review
|
|
2
|
-
name: Label approved pull requests
|
|
3
|
-
jobs:
|
|
4
|
-
labelWhenApproved:
|
|
5
|
-
name: Label when approved
|
|
6
|
-
runs-on: ubuntu-latest
|
|
7
|
-
steps:
|
|
8
|
-
- name: Label when approved
|
|
9
|
-
uses: pullreminders/label-when-approved-action@master
|
|
10
|
-
env:
|
|
11
|
-
APPROVALS: '1'
|
|
12
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
13
|
-
ADD_LABEL: '[Status] Approved'
|
|
14
|
-
# Needs to be URL-encoded, see https://github.com/abinoda/label-when-approved-action/pull/3#discussion_r321882620
|
|
15
|
-
REMOVE_LABEL: '%5BStatus%5D%20Needs%20Review'
|
package/.phpcs.xml.dist
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0"?>
|
|
2
|
-
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
|
|
3
|
-
<description>Generally-applicable sniffs for WordPress plugins.</description>
|
|
4
|
-
|
|
5
|
-
<!-- What to scan -->
|
|
6
|
-
<file>.</file>
|
|
7
|
-
<exclude-pattern>/vendor/</exclude-pattern>
|
|
8
|
-
<exclude-pattern>/node_modules/</exclude-pattern>
|
|
9
|
-
|
|
10
|
-
<!-- How to scan -->
|
|
11
|
-
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
|
|
12
|
-
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
|
|
13
|
-
<arg value="sp"/> <!-- Show sniff and progress -->
|
|
14
|
-
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->
|
|
15
|
-
<arg name="colors"/>
|
|
16
|
-
<arg name="extensions" value="php"/>
|
|
17
|
-
<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. -->
|
|
18
|
-
|
|
19
|
-
<!-- Rules: Check PHP version compatibility -->
|
|
20
|
-
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
|
|
21
|
-
<config name="testVersion" value="7.0"/>
|
|
22
|
-
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
|
|
23
|
-
<rule ref="PHPCompatibilityWP"/>
|
|
24
|
-
|
|
25
|
-
<!-- Rules: WordPress Coding Standards -->
|
|
26
|
-
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
|
|
27
|
-
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
|
|
28
|
-
<config name="minimum_supported_wp_version" value="4.6"/>
|
|
29
|
-
<rule ref="WordPress">
|
|
30
|
-
</rule>
|
|
31
|
-
<rule ref="WordPress">
|
|
32
|
-
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
|
|
33
|
-
</rule>
|
|
34
|
-
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
|
|
35
|
-
<properties>
|
|
36
|
-
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
|
|
37
|
-
<property name="prefixes" type="array" value="newspack_blocks,NEWSPACK_BLOCKS"/>
|
|
38
|
-
</properties>
|
|
39
|
-
</rule>
|
|
40
|
-
<rule ref="WordPress.WP.I18n">
|
|
41
|
-
<properties>
|
|
42
|
-
<!-- Value: replace the text domain used. -->
|
|
43
|
-
<property name="text_domain" type="array" value="newspack-blocks"/>
|
|
44
|
-
</properties>
|
|
45
|
-
</rule>
|
|
46
|
-
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
|
|
47
|
-
<properties>
|
|
48
|
-
<property name="blank_line_check" value="true"/>
|
|
49
|
-
</properties>
|
|
50
|
-
</rule>
|
|
51
|
-
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable"/>
|
|
52
|
-
|
|
53
|
-
<!-- Exclude compiled asset files -->
|
|
54
|
-
<exclude-pattern>*.asset.php</exclude-pattern>
|
|
55
|
-
</ruleset>
|
package/.prettierrc
DELETED
package/.stylelintrc
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["@wordpress/stylelint-config/scss", "stylelint-prettier/recommended"],
|
|
3
|
-
"rules": {
|
|
4
|
-
"rule-empty-line-before": null,
|
|
5
|
-
"at-rule-empty-line-before": null,
|
|
6
|
-
"comment-empty-line-before": null,
|
|
7
|
-
"string-quotes": "single",
|
|
8
|
-
"no-descending-specificity": null,
|
|
9
|
-
"function-url-quotes": null,
|
|
10
|
-
"declaration-property-unit-whitelist": null,
|
|
11
|
-
"font-weight-notation": null,
|
|
12
|
-
"color-named": null,
|
|
13
|
-
"function-parentheses-space-inside": "always-single-line",
|
|
14
|
-
"media-feature-parentheses-space-inside": "always",
|
|
15
|
-
"selector-pseudo-class-parentheses-space-inside": "always",
|
|
16
|
-
"selector-class-pattern": null,
|
|
17
|
-
'declaration-property-unit-allowed-list': {
|
|
18
|
-
'line-height': [ 'px', 'em' ],
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
}
|
package/.travis.yml
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
dist: trusty
|
|
3
|
-
|
|
4
|
-
language: php
|
|
5
|
-
|
|
6
|
-
notifications:
|
|
7
|
-
email:
|
|
8
|
-
on_success: never
|
|
9
|
-
on_failure: change
|
|
10
|
-
|
|
11
|
-
branches:
|
|
12
|
-
only:
|
|
13
|
-
- master
|
|
14
|
-
|
|
15
|
-
cache:
|
|
16
|
-
directories:
|
|
17
|
-
- $HOME/.composer/cache
|
|
18
|
-
|
|
19
|
-
matrix:
|
|
20
|
-
include:
|
|
21
|
-
- php: 7.2
|
|
22
|
-
env: WP_VERSION=latest
|
|
23
|
-
- php: 7.1
|
|
24
|
-
env: WP_VERSION=latest
|
|
25
|
-
- php: 7.0
|
|
26
|
-
env: WP_VERSION=latest
|
|
27
|
-
- php: 5.6
|
|
28
|
-
env: WP_VERSION=4.5
|
|
29
|
-
- php: 5.6
|
|
30
|
-
env: WP_VERSION=latest
|
|
31
|
-
- php: 5.6
|
|
32
|
-
env: WP_VERSION=trunk
|
|
33
|
-
- php: 5.6
|
|
34
|
-
env: WP_TRAVISCI=phpcs
|
|
35
|
-
- php: 5.3
|
|
36
|
-
env: WP_VERSION=latest
|
|
37
|
-
dist: precise
|
|
38
|
-
|
|
39
|
-
before_script:
|
|
40
|
-
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
|
41
|
-
- |
|
|
42
|
-
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
|
|
43
|
-
phpenv config-rm xdebug.ini
|
|
44
|
-
else
|
|
45
|
-
echo "xdebug.ini does not exist"
|
|
46
|
-
fi
|
|
47
|
-
- |
|
|
48
|
-
if [[ ! -z "$WP_VERSION" ]] ; then
|
|
49
|
-
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
|
|
50
|
-
composer global require "phpunit/phpunit=4.8.*|5.7.*"
|
|
51
|
-
fi
|
|
52
|
-
- |
|
|
53
|
-
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
|
|
54
|
-
composer global require wp-coding-standards/wpcs
|
|
55
|
-
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
|
|
56
|
-
fi
|
|
57
|
-
|
|
58
|
-
script:
|
|
59
|
-
- |
|
|
60
|
-
if [[ ! -z "$WP_VERSION" ]] ; then
|
|
61
|
-
phpunit
|
|
62
|
-
WP_MULTISITE=1 phpunit
|
|
63
|
-
fi
|
|
64
|
-
- |
|
|
65
|
-
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
|
|
66
|
-
phpcs
|
|
67
|
-
fi
|
package/phpunit.xml.dist
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0"?>
|
|
2
|
-
<phpunit
|
|
3
|
-
bootstrap="tests/bootstrap.php"
|
|
4
|
-
backupGlobals="false"
|
|
5
|
-
colors="true"
|
|
6
|
-
convertErrorsToExceptions="true"
|
|
7
|
-
convertNoticesToExceptions="true"
|
|
8
|
-
convertWarningsToExceptions="true"
|
|
9
|
-
>
|
|
10
|
-
<testsuites>
|
|
11
|
-
<testsuite>
|
|
12
|
-
<directory prefix="test-" suffix=".php">./tests/</directory>
|
|
13
|
-
<exclude>./tests/test-sample.php</exclude>
|
|
14
|
-
</testsuite>
|
|
15
|
-
</testsuites>
|
|
16
|
-
</phpunit>
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
@import '../../shared/sass/variables';
|
|
2
|
-
@import '../../shared/sass/mixins';
|
|
3
|
-
|
|
4
|
-
.wp-block-newspack-blocks-author-profile {
|
|
5
|
-
@include media( mobile ) {
|
|
6
|
-
display: flex;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
&__avatar {
|
|
10
|
-
@include media( mobile ) {
|
|
11
|
-
flex: 0 1 auto;
|
|
12
|
-
margin-right: 1.5em;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
figure {
|
|
16
|
-
margin: 0;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.avatar {
|
|
21
|
-
border-radius: 0;
|
|
22
|
-
display: block;
|
|
23
|
-
height: auto;
|
|
24
|
-
max-width: none;
|
|
25
|
-
width: 100%;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&__bio {
|
|
30
|
-
@include media( mobile ) {
|
|
31
|
-
flex: 4;
|
|
32
|
-
|
|
33
|
-
h3 {
|
|
34
|
-
margin-top: 0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&__social-links {
|
|
40
|
-
display: flex;
|
|
41
|
-
flex-wrap: wrap;
|
|
42
|
-
list-style: none;
|
|
43
|
-
margin: -8px;
|
|
44
|
-
padding: 0;
|
|
45
|
-
|
|
46
|
-
li {
|
|
47
|
-
margin: 8px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
a,
|
|
51
|
-
svg {
|
|
52
|
-
display: block;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
svg {
|
|
56
|
-
fill: currentColor;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.hidden {
|
|
61
|
-
display: none;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Avatar: Right
|
|
65
|
-
&.avatar-right {
|
|
66
|
-
@include media( mobile ) {
|
|
67
|
-
.wp-block-newspack-blocks-author-profile__avatar {
|
|
68
|
-
margin-left: 1.5em;
|
|
69
|
-
margin-right: 0;
|
|
70
|
-
order: 2;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Style: Center
|
|
76
|
-
&.is-style-center {
|
|
77
|
-
display: block;
|
|
78
|
-
|
|
79
|
-
.wp-block-newspack-blocks-author-profile__avatar {
|
|
80
|
-
margin: 0 0 1.5em;
|
|
81
|
-
|
|
82
|
-
figure {
|
|
83
|
-
margin: 0 auto;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.wp-block-newspack-blocks-author-profile__bio {
|
|
88
|
-
text-align: center;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.wp-block-newspack-blocks-author-profile__social-links {
|
|
92
|
-
justify-content: center;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* External dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { loadStripe } from '@stripe/stripe-js';
|
|
10
|
-
import 'regenerator-runtime'; // Required in WP >=5.8.
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import './streamlined.scss';
|
|
16
|
-
|
|
17
|
-
const isValidEmail = string => /\S+@\S+/.test( string );
|
|
18
|
-
const validateFormData = values => {
|
|
19
|
-
const errors = {};
|
|
20
|
-
if ( ! isValidEmail( values.email ) ) {
|
|
21
|
-
errors.email = __( 'Email address is invalid.', 'newspack-blocks' );
|
|
22
|
-
}
|
|
23
|
-
if ( values.amount <= 0 ) {
|
|
24
|
-
errors.amount = __( 'Amount must be greater than zero.', 'newspack-blocks' );
|
|
25
|
-
}
|
|
26
|
-
if ( values.full_name.length === 0 ) {
|
|
27
|
-
errors.amount = __( 'Full name should be provided.', 'newspack-blocks' );
|
|
28
|
-
}
|
|
29
|
-
return errors;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const renderMessages = ( messages, el, type = 'error' ) => {
|
|
33
|
-
el.innerHTML = '';
|
|
34
|
-
messages.forEach( message => {
|
|
35
|
-
const messageEl = document.createElement( 'div' );
|
|
36
|
-
messageEl.classList.add( `type-${ type }` );
|
|
37
|
-
messageEl.innerHTML = message;
|
|
38
|
-
el.appendChild( messageEl );
|
|
39
|
-
} );
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const getCookies = () =>
|
|
43
|
-
document.cookie.split( '; ' ).reduce( ( acc, cookieStr ) => {
|
|
44
|
-
const cookie = cookieStr.split( '=' );
|
|
45
|
-
acc[ cookie[ 0 ] ] = cookie[ 1 ];
|
|
46
|
-
return acc;
|
|
47
|
-
}, {} );
|
|
48
|
-
|
|
49
|
-
const getClientIDValue = () => getCookies()[ 'newspack-cid' ];
|
|
50
|
-
|
|
51
|
-
[ ...document.querySelectorAll( '.stripe-payment' ) ].forEach( async el => {
|
|
52
|
-
const disableForm = () => el.classList.add( 'stripe-payment--disabled' );
|
|
53
|
-
const enableForm = () => el.classList.remove( 'stripe-payment--disabled' );
|
|
54
|
-
enableForm();
|
|
55
|
-
|
|
56
|
-
let stripe, cardElement;
|
|
57
|
-
const initStripe = async () => {
|
|
58
|
-
const stripePublishableKey = el.getAttribute( 'data-stripe-pub-key' );
|
|
59
|
-
stripe = await loadStripe( stripePublishableKey );
|
|
60
|
-
|
|
61
|
-
const elements = stripe.elements();
|
|
62
|
-
|
|
63
|
-
cardElement = elements.create( 'card' );
|
|
64
|
-
cardElement.mount( el.querySelector( '.stripe-payment__card' ) );
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Handle initial form unravelling.
|
|
68
|
-
const submitButtonEl = el.querySelector( 'button[type="submit"]' );
|
|
69
|
-
submitButtonEl.onclick = e => {
|
|
70
|
-
const inputsHiddenEl = el.querySelector( '.stripe-payment__inputs--hidden' );
|
|
71
|
-
if ( inputsHiddenEl ) {
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
initStripe();
|
|
74
|
-
inputsHiddenEl.classList.remove( 'stripe-payment__inputs--hidden' );
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const messagesEl = el.querySelector( '.stripe-payment__messages' );
|
|
79
|
-
|
|
80
|
-
const renderGenericError = () =>
|
|
81
|
-
renderMessages(
|
|
82
|
-
[ __( 'Something went wrong with the payment. Please try again later.', 'newspack-blocks' ) ],
|
|
83
|
-
messagesEl
|
|
84
|
-
);
|
|
85
|
-
const renderSuccessMessageWithEmail = emailAddress => {
|
|
86
|
-
const successMessge = sprintf(
|
|
87
|
-
/* Translators: %s is the email address of the current user. */
|
|
88
|
-
__(
|
|
89
|
-
'Your payment has been processed. Thank you for your contribution! You will receive a confirmation email at %s.',
|
|
90
|
-
'newspack-blocks'
|
|
91
|
-
),
|
|
92
|
-
emailAddress
|
|
93
|
-
);
|
|
94
|
-
renderMessages( [ successMessge ], messagesEl, 'success' );
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const formElement = el.closest( 'form' );
|
|
98
|
-
formElement.onsubmit = async e => {
|
|
99
|
-
e.preventDefault();
|
|
100
|
-
disableForm();
|
|
101
|
-
renderMessages( [ __( 'Processing payment…', 'newspack-blocks' ) ], messagesEl, 'info' );
|
|
102
|
-
|
|
103
|
-
const formValues = Object.fromEntries( new FormData( e.target ) );
|
|
104
|
-
const valueKey = `donation_value_${ formValues.donation_frequency }`;
|
|
105
|
-
formValues.amount = formValues[ valueKey ];
|
|
106
|
-
if ( formValues.amount === 'other' ) {
|
|
107
|
-
formValues.amount = formValues[ `${ valueKey }_other` ];
|
|
108
|
-
}
|
|
109
|
-
if ( ! formValues.amount ) {
|
|
110
|
-
formValues.amount = formValues[ `${ valueKey }_untiered` ];
|
|
111
|
-
}
|
|
112
|
-
if ( formValues.cid.indexOf( 'CLIENT_ID' ) === 0 ) {
|
|
113
|
-
// In non-AMP environment, the value will not be dynamically substituted by AMP runtime.
|
|
114
|
-
formValues.cid = getClientIDValue();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const validationErrors = Object.values( validateFormData( formValues ) );
|
|
118
|
-
if ( validationErrors.length > 0 ) {
|
|
119
|
-
renderMessages( validationErrors, messagesEl );
|
|
120
|
-
enableForm();
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const stripeTokenCreationResult = await stripe.createToken( cardElement );
|
|
125
|
-
if ( stripeTokenCreationResult.error ) {
|
|
126
|
-
validationErrors.push( stripeTokenCreationResult.error.message );
|
|
127
|
-
renderMessages( validationErrors, messagesEl );
|
|
128
|
-
enableForm();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const chargeResult = await fetch( '/wp-json/newspack-blocks/v1/donate', {
|
|
132
|
-
method: 'POST',
|
|
133
|
-
headers: {
|
|
134
|
-
'Content-Type': 'application/json',
|
|
135
|
-
},
|
|
136
|
-
body: JSON.stringify( {
|
|
137
|
-
tokenData: stripeTokenCreationResult.token,
|
|
138
|
-
amount: formValues.amount,
|
|
139
|
-
email: formValues.email,
|
|
140
|
-
full_name: formValues.full_name,
|
|
141
|
-
frequency: formValues.donation_frequency,
|
|
142
|
-
newsletter_opt_in: Boolean( formValues.newsletter_opt_in ),
|
|
143
|
-
clientId: formValues.cid,
|
|
144
|
-
} ),
|
|
145
|
-
} );
|
|
146
|
-
|
|
147
|
-
const chargeResultData = await chargeResult.json();
|
|
148
|
-
|
|
149
|
-
// Error handling.
|
|
150
|
-
if ( chargeResultData.data?.status !== 200 && chargeResultData.message ) {
|
|
151
|
-
renderMessages( [ chargeResultData.message ], messagesEl );
|
|
152
|
-
}
|
|
153
|
-
if ( chargeResultData.error ) {
|
|
154
|
-
renderMessages( [ chargeResultData.error ], messagesEl );
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Additional authentication handling.
|
|
158
|
-
if ( chargeResultData.client_secret ) {
|
|
159
|
-
const { paymentIntent, error } = await stripe.confirmCardPayment(
|
|
160
|
-
chargeResultData.client_secret,
|
|
161
|
-
{
|
|
162
|
-
payment_method: { card: cardElement },
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
if ( error ) {
|
|
166
|
-
renderMessages( [ error.message ], messagesEl );
|
|
167
|
-
enableForm();
|
|
168
|
-
} else if ( paymentIntent.status === 'succeeded' ) {
|
|
169
|
-
// Payment Intent statuses: https://stripe.com/docs/payments/intents#intent-statuses
|
|
170
|
-
renderSuccessMessageWithEmail( formValues.email );
|
|
171
|
-
} else {
|
|
172
|
-
renderGenericError();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if ( chargeResultData.status === 'success' ) {
|
|
177
|
-
renderSuccessMessageWithEmail( formValues.email );
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
} );
|