@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
|
@@ -26,16 +26,30 @@ function newspack_blocks_register_author_profile() {
|
|
|
26
26
|
/**
|
|
27
27
|
* Given a numeric ID, get the corresponding WP user or Co-authors Plus guest author.
|
|
28
28
|
*
|
|
29
|
-
* @param int
|
|
30
|
-
* @param int
|
|
29
|
+
* @param int $author_id Author ID to look up.
|
|
30
|
+
* @param int $avatar_size Size of the avatar image to fetch.
|
|
31
|
+
* @param boolean $hide_default If true, don't show default avatars.
|
|
31
32
|
* @return object|boolean Author object in standardized format, or false if none exists.
|
|
32
33
|
*/
|
|
33
|
-
function newspack_blocks_get_author_or_guest_author( $author_id, $avatar_size = 128 ) {
|
|
34
|
-
$
|
|
34
|
+
function newspack_blocks_get_author_or_guest_author( $author_id, $avatar_size = 128, $hide_default = false ) {
|
|
35
|
+
$wp_user = get_user_by( 'id', $author_id );
|
|
36
|
+
$author = false;
|
|
35
37
|
|
|
36
38
|
// First, see if the $author_id is a guest author.
|
|
37
39
|
if ( class_exists( 'CoAuthors_Guest_Authors' ) ) {
|
|
40
|
+
// Check if the ID given is a WP user with linked guest author.
|
|
41
|
+
$linked_guest_author = false;
|
|
42
|
+
|
|
43
|
+
if ( $wp_user ) {
|
|
44
|
+
$linked_guest_author = WP_REST_Newspack_Authors_Controller::get_linked_guest_author( $wp_user->user_login );
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if ( $linked_guest_author && isset( $linked_guest_author->ID ) ) {
|
|
48
|
+
$author_id = $linked_guest_author->ID;
|
|
49
|
+
}
|
|
50
|
+
|
|
38
51
|
$author = ( new CoAuthors_Guest_Authors() )->get_guest_author_by( 'id', $author_id );
|
|
52
|
+
$avatar = function_exists( 'coauthors_get_avatar' ) ? coauthors_get_avatar( $author, $avatar_size ) : false;
|
|
39
53
|
|
|
40
54
|
// Format CAP guest author object to return to the render function.
|
|
41
55
|
if ( $author && isset( $author->ID ) ) {
|
|
@@ -43,22 +57,22 @@ function newspack_blocks_get_author_or_guest_author( $author_id, $avatar_size =
|
|
|
43
57
|
'id' => $author_id,
|
|
44
58
|
'name' => $author->display_name,
|
|
45
59
|
'bio' => $author->description,
|
|
46
|
-
'avatar' => function_exists( 'coauthors_get_avatar' ) ? coauthors_get_avatar( $author, $avatar_size ) : false,
|
|
47
60
|
'url' => esc_urL(
|
|
48
|
-
|
|
49
|
-
null,
|
|
50
|
-
'?author_name=' . get_post_meta( $author_id, 'cap-user_login', true )
|
|
51
|
-
)
|
|
61
|
+
get_author_posts_url( $author_id, $author->user_nicename )
|
|
52
62
|
),
|
|
53
63
|
'email' => WP_REST_Newspack_Authors_Controller::get_email( $author_id ),
|
|
54
64
|
'social' => WP_REST_Newspack_Authors_Controller::get_social( $author_id ),
|
|
55
65
|
];
|
|
66
|
+
|
|
67
|
+
if ( $avatar && ( false === strpos( $avatar, 'avatar-default' ) || ! $hide_default ) ) {
|
|
68
|
+
$author['avatar'] = $avatar;
|
|
69
|
+
}
|
|
56
70
|
}
|
|
57
71
|
}
|
|
58
72
|
|
|
59
73
|
// If $author is still false, see if it's a standard WP User.
|
|
60
74
|
if ( ! $author ) {
|
|
61
|
-
$author =
|
|
75
|
+
$author = $wp_user;
|
|
62
76
|
|
|
63
77
|
// Format WP user object to return to the render function.
|
|
64
78
|
if ( $author && isset( $author->data ) ) {
|
|
@@ -66,11 +80,15 @@ function newspack_blocks_get_author_or_guest_author( $author_id, $avatar_size =
|
|
|
66
80
|
'id' => $author_id,
|
|
67
81
|
'name' => $author->data->display_name,
|
|
68
82
|
'bio' => get_the_author_meta( 'description', $author_id ),
|
|
69
|
-
'avatar' => get_avatar( $author_id, $avatar_size ),
|
|
70
83
|
'url' => esc_urL( get_author_posts_url( $author_id ) ),
|
|
71
84
|
'email' => WP_REST_Newspack_Authors_Controller::get_email( $author_id, false, $author->data->user_email ),
|
|
72
85
|
'social' => WP_REST_Newspack_Authors_Controller::get_social( $author_id ),
|
|
73
86
|
];
|
|
87
|
+
|
|
88
|
+
$avatar = get_avatar( $author_id, $avatar_size );
|
|
89
|
+
if ( $avatar && ( false === strpos( $avatar, 'avatar-default' ) || ! $hide_default ) ) {
|
|
90
|
+
$author['avatar'] = $avatar;
|
|
91
|
+
}
|
|
74
92
|
}
|
|
75
93
|
}
|
|
76
94
|
|
|
@@ -89,7 +107,7 @@ function newspack_blocks_render_block_author_profile( $attributes ) {
|
|
|
89
107
|
}
|
|
90
108
|
|
|
91
109
|
// Get the author by ID.
|
|
92
|
-
$author = newspack_blocks_get_author_or_guest_author( intval( $attributes['authorId'] ), intval( $attributes['avatarSize'] ) );
|
|
110
|
+
$author = newspack_blocks_get_author_or_guest_author( intval( $attributes['authorId'] ), intval( $attributes['avatarSize'] ), $attributes['avatarHideDefault'] );
|
|
93
111
|
|
|
94
112
|
// Bail if there's no author or guest author with the saved ID.
|
|
95
113
|
if ( empty( $author ) ) {
|
|
@@ -98,87 +116,15 @@ function newspack_blocks_render_block_author_profile( $attributes ) {
|
|
|
98
116
|
|
|
99
117
|
Newspack_Blocks::enqueue_view_assets( 'author-profile' );
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Add classes to the block.
|
|
111
|
-
$classes = Newspack_Blocks::block_classes( 'author-profile' );
|
|
112
|
-
|
|
113
|
-
if ( $attributes['avatarAlignment'] ) {
|
|
114
|
-
$classes .= ' avatar-' . $attributes['avatarAlignment'];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if ( isset( $attributes['className'] ) ) {
|
|
118
|
-
$classes .= ' ' . $attributes['className'];
|
|
119
|
-
}
|
|
119
|
+
$content = Newspack_Blocks::template_include(
|
|
120
|
+
'author-profile-card',
|
|
121
|
+
[
|
|
122
|
+
'attributes' => $attributes,
|
|
123
|
+
'author' => $author,
|
|
124
|
+
]
|
|
125
|
+
);
|
|
120
126
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
?>
|
|
124
|
-
<div class="<?php echo esc_attr( $classes ); ?>">
|
|
125
|
-
<?php if ( $attributes['showAvatar'] && $author['avatar'] ) : ?>
|
|
126
|
-
<div class="wp-block-newspack-blocks-author-profile__avatar">
|
|
127
|
-
<figure style="border-radius: <?php echo esc_attr( $attributes['avatarBorderRadius'] ); ?>; width: <?php echo esc_attr( $attributes['avatarSize'] ); ?>px;">
|
|
128
|
-
<?php echo wp_kses_post( $author['avatar'] ); ?>
|
|
129
|
-
</figure>
|
|
130
|
-
</div>
|
|
131
|
-
<?php endif; ?>
|
|
132
|
-
<div class="wp-block-newspack-blocks-author-profile__bio">
|
|
133
|
-
<h3>
|
|
134
|
-
<?php if ( $show_archive_link ) : ?>
|
|
135
|
-
<a href="<?php echo esc_url( $author['url'] ); ?>">
|
|
136
|
-
<?php endif; ?>
|
|
137
|
-
<?php echo esc_html( $author['name'] ); ?>
|
|
138
|
-
<?php if ( $show_archive_link ) : ?>
|
|
139
|
-
</a>
|
|
140
|
-
<?php endif; ?>
|
|
141
|
-
</h3>
|
|
142
|
-
|
|
143
|
-
<?php if ( $attributes['showBio'] && ! empty( $author['bio'] ) ) : ?>
|
|
144
|
-
<?php
|
|
145
|
-
$bio = $author['bio'];
|
|
146
|
-
|
|
147
|
-
if ( $show_archive_link ) {
|
|
148
|
-
$bio .= sprintf(
|
|
149
|
-
// Translators: "more by this author" link.
|
|
150
|
-
__( ' <a href="%1$s">More by %2$s</a>', 'newspack-blocks' ),
|
|
151
|
-
$author['url'],
|
|
152
|
-
$author['name']
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
echo wp_kses_post( wpautop( $bio ) );
|
|
157
|
-
?>
|
|
158
|
-
<?php endif; ?>
|
|
159
|
-
|
|
160
|
-
<?php if ( $attributes['showEmail'] || $attributes['showSocial'] ) : ?>
|
|
161
|
-
<ul class="wp-block-newspack-blocks-author-profile__social-links">
|
|
162
|
-
<?php foreach ( $social_links as $service => $social_data ) : ?>
|
|
163
|
-
<li>
|
|
164
|
-
<a href="<?php echo esc_url( $social_data['url'] ); ?>">
|
|
165
|
-
<?php if ( ! empty( $social_data['svg'] ) ) : ?>
|
|
166
|
-
<span>
|
|
167
|
-
<?php echo Newspack_Blocks::sanitize_svg( $social_data['svg'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
168
|
-
</span>
|
|
169
|
-
<?php endif; ?>
|
|
170
|
-
<span class="<?php echo ! empty( $social_data['svg'] ) ? esc_attr( 'hidden' ) : esc_attr( 'visible' ); ?>">
|
|
171
|
-
<?php echo esc_html( $service ); ?>
|
|
172
|
-
</span>
|
|
173
|
-
</a>
|
|
174
|
-
</li>
|
|
175
|
-
<?php endforeach; ?>
|
|
176
|
-
</ul>
|
|
177
|
-
<?php endif; ?>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
<?php
|
|
181
|
-
return ob_get_clean();
|
|
127
|
+
return $content;
|
|
182
128
|
}
|
|
183
129
|
|
|
184
130
|
add_action( 'init', 'newspack_blocks_register_author_profile' );
|
|
@@ -1 +1,120 @@
|
|
|
1
|
-
@import '
|
|
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
|
+
+ .wp-block-newspack-blocks-author-profile {
|
|
10
|
+
margin-top: 2.5rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
h3 {
|
|
14
|
+
margin-bottom: 0.5em;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
p {
|
|
18
|
+
font-size: 1em !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.text-size-small {
|
|
22
|
+
font-size: 0.75em;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.text-size-large {
|
|
26
|
+
font-size: 1.25em;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.text-size-extra-large {
|
|
30
|
+
font-size: 1.5em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__avatar {
|
|
34
|
+
@include media( mobile ) {
|
|
35
|
+
flex: 0 1 auto;
|
|
36
|
+
margin-right: 1.5em;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
figure {
|
|
40
|
+
margin: 0;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.avatar {
|
|
45
|
+
border-radius: 0;
|
|
46
|
+
display: block;
|
|
47
|
+
height: 100%;
|
|
48
|
+
max-width: none;
|
|
49
|
+
object-fit: cover;
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__bio {
|
|
55
|
+
@include media( mobile ) {
|
|
56
|
+
flex: 4;
|
|
57
|
+
|
|
58
|
+
h3 {
|
|
59
|
+
margin-top: 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&__social-links {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-wrap: wrap;
|
|
67
|
+
list-style: none;
|
|
68
|
+
margin: -8px;
|
|
69
|
+
padding: 0;
|
|
70
|
+
|
|
71
|
+
li {
|
|
72
|
+
margin: 8px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
a,
|
|
76
|
+
svg {
|
|
77
|
+
display: block;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
svg {
|
|
81
|
+
fill: currentColor;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.hidden {
|
|
86
|
+
display: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Avatar: Right
|
|
90
|
+
&.avatar-right {
|
|
91
|
+
@include media( mobile ) {
|
|
92
|
+
.wp-block-newspack-blocks-author-profile__avatar {
|
|
93
|
+
margin-left: 1.5em;
|
|
94
|
+
margin-right: 0;
|
|
95
|
+
order: 2;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Style: Center
|
|
101
|
+
&.is-style-center {
|
|
102
|
+
display: block;
|
|
103
|
+
|
|
104
|
+
.wp-block-newspack-blocks-author-profile__avatar {
|
|
105
|
+
margin: 0 0 1.5em;
|
|
106
|
+
|
|
107
|
+
figure {
|
|
108
|
+
margin: 0 auto;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.wp-block-newspack-blocks-author-profile__bio {
|
|
113
|
+
text-align: center;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.wp-block-newspack-blocks-author-profile__social-links {
|
|
117
|
+
justify-content: center;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
import { speak } from '@wordpress/a11y';
|
|
5
5
|
import { escapeHTML } from '@wordpress/escape-html';
|
|
6
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
-
|
|
8
|
-
import 'swiper/
|
|
7
|
+
// eslint-disable-next-line import/no-unresolved
|
|
8
|
+
import Swiper from 'swiper/bundle';
|
|
9
|
+
// eslint-disable-next-line import/no-unresolved
|
|
10
|
+
import 'swiper/css/bundle';
|
|
9
11
|
|
|
10
12
|
const autoplayClassName = 'wp-block-newspack-blocks-carousel__autoplay-playing';
|
|
11
13
|
|
|
@@ -104,6 +106,7 @@ export default function createSwiper( els, config = {} ) {
|
|
|
104
106
|
) }</span></button>`;
|
|
105
107
|
},
|
|
106
108
|
},
|
|
109
|
+
watchSlidesProgress: config.slidesPerView > 1,
|
|
107
110
|
preventClicksPropagation: false, // Necessary for normal block interactions.
|
|
108
111
|
releaseFormElements: false,
|
|
109
112
|
setWrapperSize: true,
|
|
@@ -111,9 +114,15 @@ export default function createSwiper( els, config = {} ) {
|
|
|
111
114
|
spaceBetween: 16,
|
|
112
115
|
touchStartPreventDefault: false,
|
|
113
116
|
breakpoints: {
|
|
114
|
-
|
|
117
|
+
320: {
|
|
118
|
+
slidesPerView: 1,
|
|
119
|
+
},
|
|
120
|
+
782: {
|
|
115
121
|
slidesPerView: config.slidesPerView > 1 ? 2 : 1,
|
|
116
122
|
},
|
|
123
|
+
1168: {
|
|
124
|
+
slidesPerView: config.slidesPerView,
|
|
125
|
+
},
|
|
117
126
|
},
|
|
118
127
|
on: {
|
|
119
128
|
init() {
|
|
@@ -135,7 +144,7 @@ export default function createSwiper( els, config = {} ) {
|
|
|
135
144
|
* If we're autoplaying, don't announce the slide change, as that would
|
|
136
145
|
* be supremely annoying.
|
|
137
146
|
*/
|
|
138
|
-
if ( ! this.autoplay
|
|
147
|
+
if ( ! this.autoplay?.running ) {
|
|
139
148
|
// Announce the contents of the slide.
|
|
140
149
|
const currentImage = currentSlide.querySelector( 'img' );
|
|
141
150
|
const alt = currentImage ? currentImage?.alt : false;
|
|
@@ -144,7 +153,7 @@ export default function createSwiper( els, config = {} ) {
|
|
|
144
153
|
/* translators: 1: current slide number and 2: total number of slides */
|
|
145
154
|
__( 'Slide %1$s of %2$s', 'newspack-blocks' ),
|
|
146
155
|
this.realIndex + 1,
|
|
147
|
-
this.pagination
|
|
156
|
+
this.pagination?.bullets?.length || 0
|
|
148
157
|
);
|
|
149
158
|
|
|
150
159
|
speak(
|
|
@@ -174,7 +174,9 @@ class Edit extends Component {
|
|
|
174
174
|
const classes = classnames(
|
|
175
175
|
className,
|
|
176
176
|
'wp-block-newspack-blocks-carousel', // Default to make styles work for third-party consumers.
|
|
177
|
-
'
|
|
177
|
+
'wpnbpc', // Shortened version of the default classname.
|
|
178
|
+
'slides-per-view-' + slidesPerView,
|
|
179
|
+
'swiper',
|
|
178
180
|
{
|
|
179
181
|
'wp-block-newspack-blocks-carousel__autoplay-playing': autoplay,
|
|
180
182
|
'newspack-block--disabled': isUIDisabled,
|
|
@@ -339,7 +341,7 @@ class Edit extends Component {
|
|
|
339
341
|
ref={ this.btnNextRef }
|
|
340
342
|
/>
|
|
341
343
|
<div
|
|
342
|
-
className="swiper-pagination-bullets amp-pagination"
|
|
344
|
+
className="swiper-pagination swiper-pagination-bullets amp-pagination"
|
|
343
345
|
ref={ this.paginationRef }
|
|
344
346
|
/>
|
|
345
347
|
</>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@import '../../shared/sass/placeholder';
|
|
2
2
|
|
|
3
|
-
.
|
|
3
|
+
.wpnbpc {
|
|
4
4
|
.swiper-wrapper {
|
|
5
5
|
height: auto;
|
|
6
6
|
pointer-events: none;
|
|
@@ -47,16 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
.editor-block-list__layout
|
|
51
|
-
|
|
52
|
-
.wp-block-newspack-blocks-carousel
|
|
53
|
-
.entry-title
|
|
54
|
-
a,
|
|
55
|
-
.editor-block-list__layout
|
|
56
|
-
.editor-block-list__block
|
|
57
|
-
.wp-block-newspack-blocks-carousel
|
|
58
|
-
.entry-meta
|
|
59
|
-
.byline
|
|
60
|
-
a {
|
|
50
|
+
.editor-block-list__layout .editor-block-list__block .wpnbpc .entry-title a,
|
|
51
|
+
.editor-block-list__layout .editor-block-list__block .wpnbpc .entry-meta .byline a {
|
|
61
52
|
color: inherit;
|
|
62
53
|
}
|
|
@@ -20,7 +20,7 @@ if ( typeof window !== 'undefined' ) {
|
|
|
20
20
|
createSwiper(
|
|
21
21
|
{
|
|
22
22
|
block,
|
|
23
|
-
container: block.querySelector( '.swiper
|
|
23
|
+
container: block.querySelector( '.swiper' ),
|
|
24
24
|
prev: block.querySelector( '.swiper-button-prev' ),
|
|
25
25
|
next: block.querySelector( '.swiper-button-next' ),
|
|
26
26
|
pagination: block.querySelector( '.swiper-pagination-bullets' ),
|
|
@@ -23,12 +23,14 @@ function newspack_blocks_render_block_carousel( $attributes ) {
|
|
|
23
23
|
$autoplay = isset( $attributes['autoplay'] ) ? $attributes['autoplay'] : false;
|
|
24
24
|
$delay = isset( $attributes['delay'] ) ? absint( $attributes['delay'] ) : 3;
|
|
25
25
|
$authors = isset( $attributes['authors'] ) ? $attributes['authors'] : array();
|
|
26
|
-
$is_amp =
|
|
26
|
+
$is_amp = Newspack_Blocks::is_amp();
|
|
27
27
|
|
|
28
28
|
$other = array();
|
|
29
29
|
if ( $autoplay ) {
|
|
30
30
|
$other[] = 'wp-block-newspack-blocks-carousel__autoplay-playing';
|
|
31
31
|
}
|
|
32
|
+
$other[] = 'slides-per-view-' . $attributes['slidesPerView'];
|
|
33
|
+
$other[] = 'wpnbpc';
|
|
32
34
|
$classes = Newspack_Blocks::block_classes( 'carousel', $attributes, $other );
|
|
33
35
|
|
|
34
36
|
$article_query = new WP_Query( Newspack_Blocks::build_articles_query( $attributes, apply_filters( 'newspack_blocks_block_name', 'newspack-blocks/carousel' ) ) );
|
|
@@ -252,21 +254,23 @@ function newspack_blocks_render_block_carousel( $attributes ) {
|
|
|
252
254
|
$slides_to_show = $slides_per_view <= $counter ? $slides_per_view : $counter;
|
|
253
255
|
|
|
254
256
|
if ( $is_amp ) {
|
|
255
|
-
$selector
|
|
257
|
+
$selector = sprintf(
|
|
256
258
|
'<amp-selector id="wp-block-newspack-carousel__amp-pagination__%1$d" class="swiper-pagination-bullets amp-pagination" on="select:wp-block-newspack-carousel__amp-carousel__%1$d.goToSlide(index=event.targetOption)" layout="container" %2$s>%3$s</amp-selector>',
|
|
257
259
|
absint( $newspack_blocks_carousel_id ),
|
|
258
260
|
$attributes['hideControls'] ? 'aria-hidden="true"' : '',
|
|
259
261
|
implode( '', $buttons )
|
|
260
262
|
);
|
|
263
|
+
|
|
261
264
|
$carousel = sprintf(
|
|
262
|
-
'<amp-base-carousel class="wp-block-newspack-carousel__amp-carousel" width="%1$s" height="%2$s" layout="responsive" snap="true"
|
|
265
|
+
'<amp-base-carousel class="wp-block-newspack-carousel__amp-carousel" width="%1$s" height="%2$s" heights="%3$s" layout="responsive" snap="true" data-next-button-aria-label="%4$s" data-prev-button-aria-label="%5$s" controls="auto" loop="true" %6$s id="wp-block-newspack-carousel__amp-carousel__%7$s" on="slideChange:wp-block-newspack-carousel__amp-pagination__%7$s.toggle(index=event.index, value=true)" advance-count="1" visible-count="%8$s">%9$s</amp-base-carousel>',
|
|
263
266
|
$attributes['slidesPerView'] * 1,
|
|
264
267
|
$attributes['aspectRatio'],
|
|
268
|
+
'(min-width: 1168px) ' . ( $attributes['aspectRatio'] / $slides_to_show * 100 ) . '% !important, (min-width: 782px) ' . ( $slides_to_show > 1 ? ( $attributes['aspectRatio'] / 2 * 100 ) . '% !important' : ( $attributes['aspectRatio'] * 100 ) . '% !important' ) . ', ' . ( $attributes['aspectRatio'] * 100 ) . '% !important',
|
|
265
269
|
esc_attr__( 'Next Slide', 'newspack-blocks' ),
|
|
266
270
|
esc_attr__( 'Previous Slide', 'newspack-blocks' ),
|
|
267
271
|
$autoplay ? 'auto-advance="true" auto-advance-interval=' . esc_attr( $delay * 1000 ) : '',
|
|
268
272
|
absint( $newspack_blocks_carousel_id ),
|
|
269
|
-
'(min-width:
|
|
273
|
+
'(min-width: 1168px) ' . $slides_to_show . ', (min-width: 782px) ' . ( $slides_to_show > 1 ? 2 : 1 ) . ', ' . 1,
|
|
270
274
|
$slides
|
|
271
275
|
);
|
|
272
276
|
$autoplay_ui = $autoplay ? newspack_blocks_carousel_block_autoplay_ui_amp( $newspack_blocks_carousel_id ) : '';
|
|
@@ -283,7 +287,7 @@ function newspack_blocks_render_block_carousel( $attributes ) {
|
|
|
283
287
|
$attributes['hideControls'] ? 'aria-hidden="true"' : ''
|
|
284
288
|
);
|
|
285
289
|
$carousel = sprintf(
|
|
286
|
-
'<div class="swiper
|
|
290
|
+
'<div class="swiper"><div class="swiper-wrapper">%s</div>%s</div>',
|
|
287
291
|
$slides,
|
|
288
292
|
$navigation
|
|
289
293
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@import '../../shared/sass/mixins';
|
|
3
3
|
@import '../../shared/sass/colors';
|
|
4
4
|
|
|
5
|
-
.
|
|
5
|
+
.wpnbpc {
|
|
6
6
|
position: relative;
|
|
7
7
|
margin-top: 0;
|
|
8
8
|
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
.post-thumbnail {
|
|
81
81
|
margin: 0;
|
|
82
82
|
height: 100%;
|
|
83
|
+
width: 100%;
|
|
83
84
|
padding: 0;
|
|
84
85
|
position: relative;
|
|
85
86
|
a,
|
|
@@ -177,11 +178,11 @@
|
|
|
177
178
|
margin-top: -24px;
|
|
178
179
|
}
|
|
179
180
|
.swiper-button-prev::after,
|
|
180
|
-
.swiper-
|
|
181
|
+
.swiper-rtl .swiper-button-next::after {
|
|
181
182
|
content: none;
|
|
182
183
|
}
|
|
183
184
|
.swiper-button-next::after,
|
|
184
|
-
.swiper-
|
|
185
|
+
.swiper-rtl .swiper-button-prev::after {
|
|
185
186
|
content: none;
|
|
186
187
|
}
|
|
187
188
|
.amp-carousel-button-next,
|
|
@@ -305,4 +306,29 @@
|
|
|
305
306
|
visibility: hidden;
|
|
306
307
|
}
|
|
307
308
|
}
|
|
309
|
+
|
|
310
|
+
&[data-slides-per-view='2'] article {
|
|
311
|
+
.entry-title {
|
|
312
|
+
@include media( tablet ) {
|
|
313
|
+
font-size: 1.4em;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
&.slides-per-view-3 article,
|
|
319
|
+
&.slides-per-view-4 article {
|
|
320
|
+
.entry-title {
|
|
321
|
+
@include media( tablet ) {
|
|
322
|
+
font-size: 1.2em;
|
|
323
|
+
}
|
|
324
|
+
@include media( desktop ) {
|
|
325
|
+
font-size: 1em;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
.entry-meta {
|
|
329
|
+
@include media( tablet ) {
|
|
330
|
+
font-size: 0.7em;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
308
334
|
}
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
class WP_REST_Newspack_Donate_Controller extends WP_REST_Controller {
|
|
14
14
|
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
|
|
15
15
|
|
|
16
|
+
private static $current_user_id = 0; // phpcs:ignore Squiz.Commenting.VariableComment.Missing
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* Constructs the controller.
|
|
18
20
|
*
|
|
@@ -29,13 +31,15 @@ class WP_REST_Newspack_Donate_Controller extends WP_REST_Controller {
|
|
|
29
31
|
* @access public
|
|
30
32
|
*/
|
|
31
33
|
public function register_routes() {
|
|
34
|
+
self::$current_user_id = get_current_user_id();
|
|
35
|
+
|
|
32
36
|
register_rest_route(
|
|
33
37
|
$this->namespace,
|
|
34
38
|
'/' . $this->rest_base,
|
|
35
39
|
[
|
|
36
40
|
[
|
|
37
41
|
'methods' => WP_REST_Server::EDITABLE,
|
|
38
|
-
'callback' => [ $this, '
|
|
42
|
+
'callback' => [ $this, 'api_process_donation' ],
|
|
39
43
|
'args' => [
|
|
40
44
|
'tokenData' => [
|
|
41
45
|
'type' => 'object',
|
|
@@ -71,6 +75,12 @@ class WP_REST_Newspack_Donate_Controller extends WP_REST_Controller {
|
|
|
71
75
|
'newsletter_opt_in' => [
|
|
72
76
|
'sanitize_callback' => 'rest_sanitize_boolean',
|
|
73
77
|
],
|
|
78
|
+
'agree_to_pay_fees' => [
|
|
79
|
+
'sanitize_callback' => 'rest_sanitize_boolean',
|
|
80
|
+
],
|
|
81
|
+
'payment_method_id' => [
|
|
82
|
+
'sanitize_callback' => 'sanitize_text_field',
|
|
83
|
+
],
|
|
74
84
|
],
|
|
75
85
|
'permission_callback' => '__return_true',
|
|
76
86
|
],
|
|
@@ -84,13 +94,9 @@ class WP_REST_Newspack_Donate_Controller extends WP_REST_Controller {
|
|
|
84
94
|
* @param WP_REST_Request $request Request object.
|
|
85
95
|
* @return WP_REST_Response
|
|
86
96
|
*/
|
|
87
|
-
public function
|
|
97
|
+
public function api_process_donation( $request ) {
|
|
88
98
|
$payment_metadata = [
|
|
89
|
-
'referer'
|
|
90
|
-
// Experimental NRH integration metadata.
|
|
91
|
-
'schema_version' => '1.0',
|
|
92
|
-
'source' => 'newspack',
|
|
93
|
-
'agreed_to_pay_fees' => false,
|
|
99
|
+
'referer' => wp_get_referer(),
|
|
94
100
|
];
|
|
95
101
|
if ( class_exists( 'Newspack\NRH' ) && method_exists( 'Newspack\NRH', 'get_nrh_config' ) ) {
|
|
96
102
|
$nrh_config = \Newspack\NRH::get_nrh_config();
|
|
@@ -101,29 +107,21 @@ class WP_REST_Newspack_Donate_Controller extends WP_REST_Controller {
|
|
|
101
107
|
|
|
102
108
|
$response = \Newspack\Stripe_Connection::handle_donation(
|
|
103
109
|
[
|
|
104
|
-
'frequency'
|
|
105
|
-
'token_data'
|
|
106
|
-
'email_address'
|
|
107
|
-
'full_name'
|
|
108
|
-
'amount'
|
|
109
|
-
'client_metadata'
|
|
110
|
+
'frequency' => $request->get_param( 'frequency' ),
|
|
111
|
+
'token_data' => $request->get_param( 'tokenData' ),
|
|
112
|
+
'email_address' => $request->get_param( 'email' ),
|
|
113
|
+
'full_name' => $request->get_param( 'full_name' ),
|
|
114
|
+
'amount' => $request->get_param( 'amount' ),
|
|
115
|
+
'client_metadata' => [
|
|
110
116
|
'clientId' => $request->get_param( 'clientId' ),
|
|
111
117
|
'newsletterOptIn' => $request->get_param( 'newsletter_opt_in' ),
|
|
118
|
+
'userId' => self::$current_user_id,
|
|
112
119
|
],
|
|
113
|
-
'payment_metadata'
|
|
120
|
+
'payment_metadata' => $payment_metadata,
|
|
121
|
+
'payment_method_id' => $request->get_param( 'payment_method_id' ),
|
|
114
122
|
]
|
|
115
123
|
);
|
|
116
124
|
|
|
117
125
|
return rest_ensure_response( $response );
|
|
118
126
|
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Retrieve Stripe data.
|
|
122
|
-
*/
|
|
123
|
-
public static function get_payment_data() {
|
|
124
|
-
if ( ! Newspack_Blocks::is_rendering_streamlined_block() ) {
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
return \Newspack\Stripe_Connection::get_stripe_data();
|
|
128
|
-
}
|
|
129
127
|
}
|