generator-chisel 1.0.0 → 2.0.0-alpha.1
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/CHANGELOG.md +33 -0
- package/README.md +2 -4
- package/bin/chisel.js +2 -22
- package/lib/commands/create/creators/app/chisel-starter-theme/.nvmrc +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/.twig-cs-fixer.php +13 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/404.php +16 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/README.md +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_666eb7f38d2ed.json +59 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/acf-json/group_66d5a4ebb41cd.json +148 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +38 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/fonts/quicksand-700.woff2 +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/fonts/quicksand-regular.woff2 +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons/loader.svg +17 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons/minus.svg +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/icons/plus.svg +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/images/chisel.png +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/author.php +18 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Acf.php +191 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/AcfBlocks.php +190 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/AcfSync.php +230 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Ajax.php +161 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/AjaxEnpoints.php +103 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Assets.php +607 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Blocks.php +270 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ChiselCache.php +87 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Components.php +208 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/CustomPostTypes.php +442 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedImage.php +24 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedPost.php +42 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedProduct.php +41 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/ExtendedTerm.php +13 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Helpers.php +135 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/RegisterBlocks.php +273 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Sidebars.php +110 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Site.php +123 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Theme.php +277 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Twig.php +241 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/Woocommerce.php +183 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/classes/interfaces/Instance.php +31 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/composer.json +18 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/composer.lock +2180 -0
- package/lib/commands/create/creators/{wp → app}/chisel-starter-theme/footer.php +11 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +47 -0
- package/lib/commands/create/creators/{wp → app}/chisel-starter-theme/header.php +3 -1
- package/lib/commands/create/creators/{wp/chisel-starter-theme/index.chisel-tpl.php → app/chisel-starter-theme/index.php} +15 -8
- package/lib/commands/create/creators/app/chisel-starter-theme/languages/.gitkeep +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/lint-staged.config.mjs +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/package.chisel-tpl.json +40 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/page.php +25 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/patterns/cta.php +39 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/phpcs.xml +63 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/screenshot.jpg +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/search.php +15 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/single.php +19 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/accordion-item.js +79 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/block.json +36 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/edit.js +80 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/editor.scss +24 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/index.js +44 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/save.js +40 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/style.scss +81 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/view.js +146 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/acf-json/group_66462c70b851f.json +131 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/block.json +28 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/script.js +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/slider.twig +26 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/style.scss +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/_index.scss +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/settings/_index.scss +24 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_breakpoints.scss +70 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_buttons.scss +104 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_icon.scss +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_index.scss +9 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_link.scss +15 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_media.scss +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_px-to-rem.scss +21 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_screen-readers.scss +30 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_theme.scss +57 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_width.scss +14 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/acf-sync.js +26 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/admin/acf.js +27 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/admin.js +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/app.js +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/blog.js +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks-attributes.js +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks-styles.js +124 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks.js +55 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/components/BlockEditSelector.js +39 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/components/RenderAppender.js +32 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor.js +2 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/login.js +29 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/load-more.js +93 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/main-nav.js +99 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/slider.js +385 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/utils.js +43 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/acf-sync.scss +64 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/admin.scss +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-button.scss +62 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-details.scss +18 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-gallery.scss +9 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-latest-comments.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-latest-posts.scss +82 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-media-text.scss +34 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-post-date.scss +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-post-title.scss +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-query.scss +65 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-search.scss +15 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-spacer.scss +33 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core.scss +66 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_badge.scss +24 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +67 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_content.scss +42 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_footer.scss +18 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_header.scss +34 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_icon.scss +19 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_load-more.scss +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav-toggle.scss +804 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav.scss +305 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_pagination.scss +34 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_post-card.scss +12 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_post.scss +22 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_posts-items.scss +90 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_select2.scss +45 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_sidebar.scss +20 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_slider.scss +122 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/editor.scss +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_form.scss +346 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_html.scss +17 -0
- package/lib/commands/create/creators/app/{template → chisel-starter-theme}/src/styles/elements/_images.scss +2 -12
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_link.scss +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_shared.scss +44 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_table.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/generic/_reset.scss +84 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/login.scss +156 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/main.scss +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_grid.scss +30 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_layout.scss +62 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_wrapper.scss +18 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/utilities/_sr.scss +9 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/.gitkeep +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/_gravity-forms.scss +140 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/widgets/_nav-menu.scss +20 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/widgets/_widget.scss +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_account.scss +25 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_archive.scss +32 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_btn.scss +49 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_cart.scss +9 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_checkout.scss +53 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_general.scss +68 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_notices.scss +60 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_product-item.scss +29 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_product.scss +24 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woocommerce.scss +3 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_block-edit-selector.scss +47 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_block-sidebar.scss +30 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_core-button.scss +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_core-pagination.scss +12 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_core-spacer.scss +14 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_editor.scss +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_render-appender.scss +33 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_swiper-sliders.scss +12 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +12 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/theme.json +481 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/twig_cs.php +14 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/404.twig +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/archive.twig +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/author.twig +11 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/base.twig +43 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/footer.twig +9 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/header.twig +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav-item.twig +21 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/main-nav.twig +27 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/page-title.twig +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/pagination.twig +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/post-item.twig +26 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/search-form.twig +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/slider.twig +12 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +36 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/page-plugin.twig +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/page.twig +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/logo.twig +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/pagination.twig +70 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/partials/the-title.twig +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/search.twig +10 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-blog.twig +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-woocommerce.twig +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/single-password.twig +7 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +56 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/archive-product.twig +83 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/content-product.twig +51 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/linked-products.twig +15 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/single-product.twig +76 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/webpack.config.js +6 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/woocommerce.php +57 -0
- package/lib/commands/create/creators/app/index.js +28 -75
- package/lib/commands/create/creators/app/template/.gitignore.chisel-tpl +2 -2
- package/lib/commands/create/creators/init.js +2 -4
- package/lib/commands/create/creators/wp/index.js +28 -36
- package/lib/commands/create/creators/wp-plugins/index.js +3 -1
- package/lib/commands/create/creators/wp-plugins/plugins.json +0 -1
- package/lib/commands/create/packages-versions.js +3 -9
- package/lib/commands/create/priorities.js +0 -3
- package/lib/utils/sort-package.js +3 -9
- package/package.json +3 -9
- package/lib/commands/create/creators/app/template/.browserslistrc.chisel-tpl +0 -19
- package/lib/commands/create/creators/app/template/.editorconfig +0 -17
- package/lib/commands/create/creators/app/template/.eslintignore +0 -4
- package/lib/commands/create/creators/app/template/.eslintrc.js +0 -25
- package/lib/commands/create/creators/app/template/.prettierignore +0 -4
- package/lib/commands/create/creators/app/template/.stylelintignore +0 -3
- package/lib/commands/create/creators/app/template/babel.config.js +0 -16
- package/lib/commands/create/creators/app/template/chisel.config.chisel-tpl.js +0 -48
- package/lib/commands/create/creators/app/template/package.chisel-tpl.json +0 -43
- package/lib/commands/create/creators/app/template/postcss.config.js +0 -8
- package/lib/commands/create/creators/app/template/prettier.config.js +0 -4
- package/lib/commands/create/creators/app/template/src/scripts/app.chisel-tpl.js +0 -8
- package/lib/commands/create/creators/app/template/src/scripts/modules/greeting.chisel-tpl.js +0 -17
- package/lib/commands/create/creators/app/template/src/styles/components/_btn.scss +0 -60
- package/lib/commands/create/creators/app/template/src/styles/components/_footer.scss +0 -10
- package/lib/commands/create/creators/app/template/src/styles/components/_header.scss +0 -9
- package/lib/commands/create/creators/app/template/src/styles/elements/_blockquote.scss +0 -20
- package/lib/commands/create/creators/app/template/src/styles/elements/_headings.scss +0 -33
- package/lib/commands/create/creators/app/template/src/styles/elements/_html.scss +0 -40
- package/lib/commands/create/creators/app/template/src/styles/elements/_links.scss +0 -12
- package/lib/commands/create/creators/app/template/src/styles/elements/_lists.scss +0 -23
- package/lib/commands/create/creators/app/template/src/styles/elements/_tables.scss +0 -11
- package/lib/commands/create/creators/app/template/src/styles/generic/_box-sizing.scss +0 -20
- package/lib/commands/create/creators/app/template/src/styles/generic/_font-face.scss +0 -8
- package/lib/commands/create/creators/app/template/src/styles/generic/_normalize.scss +0 -5
- package/lib/commands/create/creators/app/template/src/styles/generic/_reset.scss +0 -51
- package/lib/commands/create/creators/app/template/src/styles/generic/_shared.scss +0 -32
- package/lib/commands/create/creators/app/template/src/styles/main.chisel-tpl.scss +0 -13
- package/lib/commands/create/creators/app/template/src/styles/objects/_layout.scss +0 -49
- package/lib/commands/create/creators/app/template/src/styles/objects/_list-bare.scss +0 -13
- package/lib/commands/create/creators/app/template/src/styles/objects/_list-inline.scss +0 -16
- package/lib/commands/create/creators/app/template/src/styles/objects/_media.scss +0 -53
- package/lib/commands/create/creators/app/template/src/styles/objects/_table.scss +0 -26
- package/lib/commands/create/creators/app/template/src/styles/objects/_wrapper.scss +0 -14
- package/lib/commands/create/creators/app/template/src/styles/settings/_global.scss +0 -50
- package/lib/commands/create/creators/app/template/src/styles/tools/_breakpoints.scss +0 -67
- package/lib/commands/create/creators/app/template/src/styles/tools/_clearfix.scss +0 -18
- package/lib/commands/create/creators/app/template/src/styles/tools/_hidden.scss +0 -17
- package/lib/commands/create/creators/app/template/src/styles/utilities/_align.scss +0 -27
- package/lib/commands/create/creators/app/template/src/styles/utilities/_clearfix.scss +0 -11
- package/lib/commands/create/creators/app/template/src/styles/utilities/_hide.scss +0 -28
- package/lib/commands/create/creators/app/template/src/templates/components/footer.chisel-tpl.twig +0 -3
- package/lib/commands/create/creators/app/template/src/templates/components/header.chisel-tpl.twig +0 -3
- package/lib/commands/create/creators/app/template/src/templates/layouts/base.chisel-tpl.twig +0 -42
- package/lib/commands/create/creators/app/template/src/templates/layouts/page.twig +0 -8
- package/lib/commands/create/creators/app/template/stylelint.config.js +0 -3
- package/lib/commands/create/creators/fe/index-styles.css +0 -147
- package/lib/commands/create/creators/fe/index.js +0 -51
- package/lib/commands/create/creators/fe/template/.htmlhintrc +0 -3
- package/lib/commands/create/creators/fe/template-index/index.chisel-tpl.html +0 -77
- package/lib/commands/create/creators/fe/template-index/index.chisel-tpl.html.rej +0 -13
- package/lib/commands/create/creators/wp/chisel-starter-theme/.gitignore.chisel-tpl +0 -1
- package/lib/commands/create/creators/wp/chisel-starter-theme/404.chisel-tpl.php +0 -9
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Extensions/ChiselExtension.php +0 -14
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Extensions/ChiselTwig.php +0 -234
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Extensions/DataType.php +0 -27
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Extensions/Theme.php +0 -21
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Extensions/Twig.php +0 -137
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Helpers.php +0 -29
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Image.php +0 -29
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Media.php +0 -79
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Performance.php +0 -59
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Post.php +0 -82
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Security.php +0 -30
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Settings.php +0 -38
- package/lib/commands/create/creators/wp/chisel-starter-theme/Chisel/Site.php +0 -50
- package/lib/commands/create/creators/wp/chisel-starter-theme/README.chisel-tpl.md +0 -5
- package/lib/commands/create/creators/wp/chisel-starter-theme/archive.chisel-tpl.php +0 -36
- package/lib/commands/create/creators/wp/chisel-starter-theme/author.chisel-tpl.php +0 -16
- package/lib/commands/create/creators/wp/chisel-starter-theme/functions.php +0 -31
- package/lib/commands/create/creators/wp/chisel-starter-theme/page.chisel-tpl.php +0 -23
- package/lib/commands/create/creators/wp/chisel-starter-theme/screenshot.png +0 -0
- package/lib/commands/create/creators/wp/chisel-starter-theme/search.chisel-tpl.php +0 -14
- package/lib/commands/create/creators/wp/chisel-starter-theme/single.chisel-tpl.php +0 -18
- package/lib/commands/create/creators/wp/chisel-starter-theme/style.chisel-tpl.css +0 -5
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/404.twig +0 -5
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/author.twig +0 -7
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/components/comment.twig +0 -7
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/components/main-nav.twig +0 -20
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/components/tease-post.twig +0 -9
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/components/tease.twig +0 -9
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/index.twig +0 -7
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/page-plugin.twig +0 -7
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/page.twig +0 -10
- package/lib/commands/create/creators/wp/chisel-starter-theme/templates/single.twig +0 -31
- package/lib/commands/create/creators/wp/template/src/styles/components/_comment-form.scss +0 -21
- package/lib/commands/create/creators/wp/template/src/styles/components/_comment.scss +0 -17
- package/lib/commands/create/creators/wp/template/src/styles/components/_main-nav.scss +0 -54
- package/lib/commands/create/creators/wp/template/src/styles/components/_post.scss +0 -36
- package/lib/commands/create/creators/wp/template/wp/.gitignore.chisel-tpl +0 -2
- package/lib/commands/create/creators/wp/template/wp-cli.yml +0 -1
- /package/lib/commands/create/creators/app/{template/src → chisel-starter-theme}/assets/fonts/.keep +0 -0
- /package/lib/commands/create/creators/app/{template/src → chisel-starter-theme}/assets/images/.keep +0 -0
- /package/lib/commands/create/creators/app/{template/src/styles/vendor/.keep → chisel-starter-theme/classes/Comments.php} +0 -0
- /package/lib/commands/create/creators/{fe/template/public/.keep → app/chisel-starter-theme/classes/Yoast.php} +0 -0
- /package/lib/commands/create/creators/app/{template → chisel-starter-theme}/src/styles/elements/_hr.scss +0 -0
- /package/lib/commands/create/creators/{wp/template/wp → app/template}/.htaccess +0 -0
- /package/lib/commands/create/creators/{wp/template/wp → app/template}/wp-config.php +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel;
|
|
4
|
+
|
|
5
|
+
use Timber\Timber;
|
|
6
|
+
use Chisel\ChiselCache;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ACF blocks related functionalities.
|
|
10
|
+
*
|
|
11
|
+
* @package Chisel
|
|
12
|
+
*/
|
|
13
|
+
class AcfBlocks extends RegisterBlocks implements Instance {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Blocks twig file base path.
|
|
17
|
+
*
|
|
18
|
+
* @var string
|
|
19
|
+
*/
|
|
20
|
+
protected $blocks_twig_base_path;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Class constructor.
|
|
24
|
+
*/
|
|
25
|
+
private function __construct() {
|
|
26
|
+
$this->set_properties();
|
|
27
|
+
|
|
28
|
+
parent::__construct( 'acf' );
|
|
29
|
+
|
|
30
|
+
$this->action_hooks();
|
|
31
|
+
$this->filter_hooks();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Set properties.
|
|
36
|
+
*/
|
|
37
|
+
public function set_properties() {
|
|
38
|
+
$this->blocks_twig_base_path = 'src/blocks-acf/';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Register action hooks.
|
|
43
|
+
*/
|
|
44
|
+
public function action_hooks() {
|
|
45
|
+
add_action( 'acf/init', array( $this, 'register_blocks' ) );
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Register filter hooks.
|
|
50
|
+
*/
|
|
51
|
+
public function filter_hooks() {
|
|
52
|
+
add_filter( 'timber/locations', array( $this, 'tiwg_files_locations' ) );
|
|
53
|
+
add_filter( 'acf/settings/load_json', array( $this, 'load_acf_field_group' ) );
|
|
54
|
+
add_filter( 'acf/settings/save_json', array( $this, 'save_acf_field_group' ) );
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Register ACF blocks and their assets.
|
|
59
|
+
*/
|
|
60
|
+
public function register_blocks() {
|
|
61
|
+
$this->register_custom_blocks();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Add custom Twig files locations.
|
|
66
|
+
*
|
|
67
|
+
* @param array $locations The locations.
|
|
68
|
+
* @return array
|
|
69
|
+
*/
|
|
70
|
+
public function tiwg_files_locations( $locations ) {
|
|
71
|
+
if ( ! is_array( $this->blocks ) || ! $this->blocks ) {
|
|
72
|
+
return $locations;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
foreach ( $this->blocks as $block ) {
|
|
76
|
+
$locations[] = array( $this->blocks_path_src . '/' . $block . '/' );
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return $locations;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Load ACF field group.
|
|
84
|
+
*
|
|
85
|
+
* @param array $paths The paths.
|
|
86
|
+
* @return array
|
|
87
|
+
*/
|
|
88
|
+
public function load_acf_field_group( $paths ) {
|
|
89
|
+
if ( ! is_array( $this->blocks ) || ! $this->blocks ) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
foreach ( $this->blocks as $block ) {
|
|
94
|
+
$paths[] = $this->blocks_path_src . '/' . $block . '/acf-json';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return $paths;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Save ACF field group.
|
|
102
|
+
*
|
|
103
|
+
* @param string $path The path.
|
|
104
|
+
* @return string
|
|
105
|
+
*/
|
|
106
|
+
public function save_acf_field_group( $path ) {
|
|
107
|
+
|
|
108
|
+
$action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : ''; // phpcs:ignore
|
|
109
|
+
$post_type = isset( $_REQUEST['post_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['post_type'] ) ) : ''; // phpcs:ignore
|
|
110
|
+
|
|
111
|
+
if ( $action === 'editpost' && $post_type === 'acf-field-group' ) {
|
|
112
|
+
$location = isset( $_REQUEST['acf_field_group']['location'] ) ? $_REQUEST['acf_field_group']['location'] : array(); // phpcs:ignore
|
|
113
|
+
|
|
114
|
+
foreach ( $location as $group ) {
|
|
115
|
+
foreach ( $group as $rules ) {
|
|
116
|
+
if ( sanitize_text_field( $rules['param'] ) === 'block' && sanitize_text_field( $rules['operator'] ) === '==' ) {
|
|
117
|
+
$block_name = explode( '/', sanitize_text_field( $rules['value'] ) )[1];
|
|
118
|
+
|
|
119
|
+
if ( ! $block_name ) {
|
|
120
|
+
return $path;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return $this->blocks_path_src . '/' . $block_name . '/acf-json';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return $path;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Render ACF block.
|
|
134
|
+
*
|
|
135
|
+
* @param array $block The block.
|
|
136
|
+
* @param string $content The content.
|
|
137
|
+
* @param bool $is_preview Is preview.
|
|
138
|
+
* @param int $post_id The post ID.
|
|
139
|
+
*
|
|
140
|
+
* @return void
|
|
141
|
+
*/
|
|
142
|
+
public static function acf_block_render( $block, $content = '', $is_preview = false, $post_id = 0 ) {
|
|
143
|
+
$context = Timber::context();
|
|
144
|
+
|
|
145
|
+
$block_slug = str_replace( 'chisel/', '', $block['name'] );
|
|
146
|
+
|
|
147
|
+
$slug = 'b-' . $block_slug;
|
|
148
|
+
$context['block'] = $block;
|
|
149
|
+
$context['post_id'] = $post_id;
|
|
150
|
+
$context['slug'] = $slug;
|
|
151
|
+
$context['is_preview'] = $is_preview;
|
|
152
|
+
$context['fields'] = get_fields();
|
|
153
|
+
$classes = array_merge(
|
|
154
|
+
array( $slug ),
|
|
155
|
+
isset( $block['className'] ) ? array( $block['className'] ) : array(),
|
|
156
|
+
$is_preview ? array( 'is-preview' ) : array(),
|
|
157
|
+
$block['supports']['align'] ? array( 'align' . $context['block']['align'] ) : array(),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
$context['block']['class_names'] = $classes;
|
|
161
|
+
$context['block']['block_id'] = isset( $block['anchor'] ) ? $block['anchor'] : $block['id'];
|
|
162
|
+
|
|
163
|
+
// allow to use filters to manipulate the output.
|
|
164
|
+
$context = apply_filters( 'chisel_timber_acf_blocks_data', $context );
|
|
165
|
+
$context = apply_filters( 'chisel_timber_acf_blocks_data_' . $slug, $context );
|
|
166
|
+
$context = apply_filters( 'chisel_timber_acf_blocks_data_' . $block['id'], $context );
|
|
167
|
+
|
|
168
|
+
$context['wrapper_attributes'] = get_block_wrapper_attributes(
|
|
169
|
+
array(
|
|
170
|
+
'id' => $context['block']['block_id'],
|
|
171
|
+
'class' => implode( ' ', $context['block']['class_names'] ),
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
Timber::render( self::get_instance()->blocks_twig_base_path . $block_slug . '/' . $block_slug . '.twig', $context, ChiselCache::expiry() );
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Get the instance of the class.
|
|
180
|
+
*/
|
|
181
|
+
public static function get_instance() {
|
|
182
|
+
static $instance = null;
|
|
183
|
+
|
|
184
|
+
if ( null === $instance ) {
|
|
185
|
+
$instance = new self();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return $instance;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ACF related functionalities.
|
|
7
|
+
*
|
|
8
|
+
* @package Chisel
|
|
9
|
+
*/
|
|
10
|
+
class AcfSync extends \ACF_Admin_Internal_Post_Type_List implements Instance {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The acf groups post type.
|
|
14
|
+
*
|
|
15
|
+
* @var string
|
|
16
|
+
*/
|
|
17
|
+
public $post_type = 'acf-field-group';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The acf groups sync data.
|
|
21
|
+
*
|
|
22
|
+
* @var array
|
|
23
|
+
*/
|
|
24
|
+
public $sync = array();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The acf group single post id.
|
|
28
|
+
*
|
|
29
|
+
* @var null|int
|
|
30
|
+
*/
|
|
31
|
+
protected $post_id = null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The key of acf field group to sync.
|
|
35
|
+
*
|
|
36
|
+
* @var null|string
|
|
37
|
+
*/
|
|
38
|
+
protected $single_post_key = null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The acf groups sync page url.
|
|
42
|
+
*
|
|
43
|
+
* @var string
|
|
44
|
+
*/
|
|
45
|
+
protected $sync_page_url = '';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* ACF section current page
|
|
49
|
+
*
|
|
50
|
+
* @var string
|
|
51
|
+
*/
|
|
52
|
+
public $view = '';
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Class constructor.
|
|
57
|
+
*/
|
|
58
|
+
private function __construct() {
|
|
59
|
+
$this->action_hooks();
|
|
60
|
+
$this->filter_hooks();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Register action hooks.
|
|
65
|
+
*/
|
|
66
|
+
public function action_hooks() {
|
|
67
|
+
add_action( 'admin_notices', array( $this, 'acf_sync_notice' ) );
|
|
68
|
+
add_action( 'init', array( $this, 'set_properties' ) );
|
|
69
|
+
|
|
70
|
+
add_filter( 'chisel_admin_styles', array( $this, 'load_plugin_scripts' ) );
|
|
71
|
+
add_filter( 'chisel_admin_scripts', array( $this, 'load_plugin_scripts' ) );
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Register filter hooks.
|
|
76
|
+
*/
|
|
77
|
+
public function filter_hooks() {
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Set properties.
|
|
82
|
+
*/
|
|
83
|
+
public function set_properties() {
|
|
84
|
+
if ( wp_doing_ajax() || wp_doing_cron() ) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Stop if parent method doesn't exist.
|
|
89
|
+
if ( ! method_exists( $this, 'setup_sync' ) ) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
global $pagenow;
|
|
94
|
+
$this->view = acf_request_arg( 'post_status', '' );
|
|
95
|
+
|
|
96
|
+
if ( $pagenow === 'edit.php' && isset( $_GET['post_type'] ) && sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) === $this->post_type ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
97
|
+
$this->view = 'all';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if ( $pagenow === 'post.php' && isset( $_GET['post'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
101
|
+
$post_id = absint( $_GET['post'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
102
|
+
$post_type = get_post_type( $post_id );
|
|
103
|
+
|
|
104
|
+
if ( $post_type === $this->post_type ) {
|
|
105
|
+
$this->post_id = $post_id;
|
|
106
|
+
$this->view = 'single';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if ( ! $this->view ) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Check for unsynced fields groups. Call a parent method.
|
|
115
|
+
$this->setup_sync();
|
|
116
|
+
|
|
117
|
+
if ( $this->view === 'single' && $this->sync ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
|
118
|
+
foreach ( $this->sync as $key => $field_group ) {
|
|
119
|
+
if ( $field_group['ID'] === $this->post_id ) {
|
|
120
|
+
$this->single_post_key = $key;
|
|
121
|
+
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
$this->sync_page_url = add_query_arg(
|
|
128
|
+
array(
|
|
129
|
+
'post_type' => $this->post_type,
|
|
130
|
+
'post_status' => 'sync',
|
|
131
|
+
),
|
|
132
|
+
admin_url( 'edit.php' )
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Enqueue plugin scripts
|
|
138
|
+
*
|
|
139
|
+
* @param array $scripts
|
|
140
|
+
*
|
|
141
|
+
* @return array
|
|
142
|
+
*/
|
|
143
|
+
public function load_plugin_scripts( $scripts ) {
|
|
144
|
+
$scripts['acf-sync'] = array();
|
|
145
|
+
|
|
146
|
+
return $scripts;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Check if sync notice needs to be displayed.
|
|
151
|
+
*
|
|
152
|
+
* @return void
|
|
153
|
+
*/
|
|
154
|
+
public function acf_sync_notice() {
|
|
155
|
+
if ( $this->post_id && $this->single_post_key ) { // We're on a single page.
|
|
156
|
+
$this->display_modal_notice();
|
|
157
|
+
} elseif ( $this->sync ) {
|
|
158
|
+
$this->display_admin_notice();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Display ACF sync admin notice.
|
|
164
|
+
*
|
|
165
|
+
* @return void
|
|
166
|
+
*/
|
|
167
|
+
protected function display_admin_notice() {
|
|
168
|
+
?>
|
|
169
|
+
<div class="error">
|
|
170
|
+
<p><?php esc_html_e( 'You have unsynced ACF fields.', 'chisel' ); ?> <a href="<?php echo esc_url( $this->sync_page_url ); ?>"><?php esc_html_e( ' View fields available for sync', 'chisel' ); ?></a></p>
|
|
171
|
+
</div>
|
|
172
|
+
<?php
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Display ACF sync modal notice.
|
|
177
|
+
*
|
|
178
|
+
* @return void
|
|
179
|
+
*/
|
|
180
|
+
protected function display_modal_notice() {
|
|
181
|
+
$url = $this->get_admin_url( '&acfsync=' . $this->single_post_key . '&_wpnonce=' . wp_create_nonce( 'bulk-posts' ) );
|
|
182
|
+
?>
|
|
183
|
+
<div class="xfive-acf-sync-modal js-xfive-acf-sync-modal is-open" role="dialog">
|
|
184
|
+
<div class="xfive-acf-sync-modal__box">
|
|
185
|
+
<div class="xfive-acf-sync-modal__content">
|
|
186
|
+
<div class="xfive-acf-sync-modal__icon">
|
|
187
|
+
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
|
|
188
|
+
<path stroke="#d63638" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path>
|
|
189
|
+
</svg>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<h3>
|
|
193
|
+
<?php esc_html_e( 'The field group you are editing has not been synced with your local acf json file.', 'chisel' ); ?>
|
|
194
|
+
<?php esc_html_e( 'Making any changes will overwrite the local json file and result in losing data.', 'chisel' ); ?>
|
|
195
|
+
<?php esc_html_e( 'This is irreversible.', 'chisel' ); ?>
|
|
196
|
+
</h3>
|
|
197
|
+
|
|
198
|
+
<div class="xfive-acf-sync-modal__actions">
|
|
199
|
+
<a href="<?php echo esc_url( $this->sync_page_url ); ?>" class="acf-btn"><?php esc_html_e( 'View changes', 'chisel' ); ?></a>
|
|
200
|
+
<a href="<?php echo esc_url( $url ); ?>" class="acf-btn"><?php esc_html_e( 'Sync data', 'chisel' ); ?></a>
|
|
201
|
+
<button type="button" class="acf-btn acf-btn-secondary js-xfive-acf-sync-modal-close"><?php esc_html_e( 'Ignore', 'chisel' ); ?></button>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
<?php
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Check if the sync notice scripts should be loaded.
|
|
211
|
+
*
|
|
212
|
+
* @return bool
|
|
213
|
+
*/
|
|
214
|
+
public static function load_scripts() {
|
|
215
|
+
return self::get_instance()->post_id && self::get_instance()->single_post_key;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Get the instance of the class.
|
|
220
|
+
*/
|
|
221
|
+
public static function get_instance() {
|
|
222
|
+
static $instance = null;
|
|
223
|
+
|
|
224
|
+
if ( null === $instance ) {
|
|
225
|
+
$instance = new self();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return $instance;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel;
|
|
4
|
+
|
|
5
|
+
use Chisel\AjaxEnpoints;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Custom Ajax class based on REST API.
|
|
9
|
+
*
|
|
10
|
+
* @package Chisel
|
|
11
|
+
*/
|
|
12
|
+
class Ajax extends \WP_REST_Controller implements Instance {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Ajax custom route namespace.
|
|
16
|
+
*
|
|
17
|
+
* @var string
|
|
18
|
+
*/
|
|
19
|
+
const ROUTE_NAMESPACE = 'chisel/v2';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Ajax custom route base.
|
|
23
|
+
*
|
|
24
|
+
* @var string
|
|
25
|
+
*/
|
|
26
|
+
const ROUTE_BASE = 'ajax';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Ajax custom routes.
|
|
30
|
+
*
|
|
31
|
+
* @var array
|
|
32
|
+
*/
|
|
33
|
+
protected $routes = array();
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Class constructor.
|
|
37
|
+
*/
|
|
38
|
+
private function __construct() {
|
|
39
|
+
$this->set_properties();
|
|
40
|
+
$this->action_hooks();
|
|
41
|
+
$this->filter_hooks();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Set properties.
|
|
46
|
+
*/
|
|
47
|
+
public function set_properties() {
|
|
48
|
+
$this->routes = apply_filters(
|
|
49
|
+
'chisel_ajax_routes',
|
|
50
|
+
array(
|
|
51
|
+
'load-more' => array(),
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Register action hooks.
|
|
58
|
+
*/
|
|
59
|
+
public function action_hooks() {
|
|
60
|
+
add_action( 'rest_api_init', array( $this, 'register_endpoints' ) );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Register filter hooks.
|
|
65
|
+
*/
|
|
66
|
+
public function filter_hooks() {}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Register endpoints
|
|
70
|
+
*
|
|
71
|
+
* @return void
|
|
72
|
+
*/
|
|
73
|
+
public function register_endpoints() {
|
|
74
|
+
foreach ( $this->routes as $route_name => $route_params ) {
|
|
75
|
+
$route = sprintf( self::ROUTE_BASE . '/%s/', $route_name );
|
|
76
|
+
$methods = isset( $route_params['methods'] ) ? $route_params['methods'] : array( 'POST' );
|
|
77
|
+
|
|
78
|
+
register_rest_route(
|
|
79
|
+
self::ROUTE_NAMESPACE,
|
|
80
|
+
$route,
|
|
81
|
+
array(
|
|
82
|
+
'methods' => $methods,
|
|
83
|
+
'callback' => array( $this, 'callback' ),
|
|
84
|
+
'permission_callback' => array( $this, 'permissions_check' ),
|
|
85
|
+
'args' => $this->get_endpoint_args_for_item_schema( true ),
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Create dynamic route callback
|
|
93
|
+
*
|
|
94
|
+
* @param \WP_REST_Request $request WP_REST_Request.
|
|
95
|
+
*
|
|
96
|
+
* @return callable
|
|
97
|
+
*/
|
|
98
|
+
public function callback( $request ) {
|
|
99
|
+
$route = $request->get_route();
|
|
100
|
+
$route_parts = explode( '/', $route );
|
|
101
|
+
$callback = str_replace( '-', '_', end( $route_parts ) );
|
|
102
|
+
|
|
103
|
+
$ajax_endpoints = new AjaxEnpoints();
|
|
104
|
+
|
|
105
|
+
if ( method_exists( $ajax_endpoints, $callback ) ) {
|
|
106
|
+
if ( ! defined( 'DOING_AJAX' ) ) {
|
|
107
|
+
define( 'DOING_AJAX', true );
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if ( ! defined( 'DOING_CHISEL_AJAX' ) ) {
|
|
111
|
+
define( 'DOING_CHISEL_AJAX', true );
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return call_user_func( array( $ajax_endpoints, $callback ), $request );
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check ajax request permissions.
|
|
120
|
+
*
|
|
121
|
+
* @param \WP_REST_Request $request WP_REST_Request.
|
|
122
|
+
*
|
|
123
|
+
* @return boolean
|
|
124
|
+
*/
|
|
125
|
+
public function permissions_check( $request ) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Get custom ajax endpint
|
|
131
|
+
*
|
|
132
|
+
* @return string
|
|
133
|
+
*/
|
|
134
|
+
public static function get_ajax_endpoint_url() {
|
|
135
|
+
return sprintf( '%s/wp-json/%s/%s', esc_url( get_bloginfo( 'url' ) ), self::ROUTE_NAMESPACE, self::ROUTE_BASE );
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Decode json string from ajax request
|
|
140
|
+
*
|
|
141
|
+
* @param string $value
|
|
142
|
+
*
|
|
143
|
+
* @return array
|
|
144
|
+
*/
|
|
145
|
+
public static function ajax_json_decode( $value ) {
|
|
146
|
+
return (array) json_decode( stripslashes( $value ) );
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get the instance of the class.
|
|
151
|
+
*/
|
|
152
|
+
public static function get_instance() {
|
|
153
|
+
static $instance = null;
|
|
154
|
+
|
|
155
|
+
if ( null === $instance ) {
|
|
156
|
+
$instance = new self();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return $instance;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Chisel;
|
|
4
|
+
|
|
5
|
+
use Timber\Timber;
|
|
6
|
+
use Chisel\ChiselCache;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Custom Ajax enpoints callbacks
|
|
10
|
+
*
|
|
11
|
+
* @package Chisel
|
|
12
|
+
*/
|
|
13
|
+
class AjaxEnpoints {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Ajax call for load more feature.
|
|
17
|
+
*
|
|
18
|
+
* @param \WP_REST_Request $request WP_REST_Request.
|
|
19
|
+
*
|
|
20
|
+
* @return json
|
|
21
|
+
*/
|
|
22
|
+
public function load_more( $request ) {
|
|
23
|
+
if ( ! $request ) {
|
|
24
|
+
return $this->error( 'No request data' );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
$data = $this->get_data( $request );
|
|
28
|
+
|
|
29
|
+
$post_type = sanitize_text_field( $data['post_type'] );
|
|
30
|
+
$per_page = absint( $data['per_page'] );
|
|
31
|
+
$page = absint( $data['page'] );
|
|
32
|
+
|
|
33
|
+
$response = '';
|
|
34
|
+
|
|
35
|
+
$posts = Timber::get_posts(
|
|
36
|
+
array(
|
|
37
|
+
'post_type' => $post_type,
|
|
38
|
+
'posts_per_page' => $per_page,
|
|
39
|
+
'paged' => $page,
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
$templates = array( 'components/post-item.twig', 'components/' . $post_type . '-item.twig' );
|
|
44
|
+
|
|
45
|
+
if ( $post_type === 'product' ) {
|
|
46
|
+
array_unshift( $templates, 'woocommerce/content-product.twig' );
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ( $posts ) {
|
|
50
|
+
foreach ( $posts as $post ) {
|
|
51
|
+
$response .= Timber::compile( $templates, array( 'post' => $post ), ChiselCache::expiry() );
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return $this->success( $response );
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get data from request.
|
|
60
|
+
*
|
|
61
|
+
* @param \WP_REST_Request $request WP_REST_Request.
|
|
62
|
+
*
|
|
63
|
+
* @return array
|
|
64
|
+
*/
|
|
65
|
+
protected function get_data( $request ) {
|
|
66
|
+
return $request->get_body_params();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* This function will return a success response.
|
|
71
|
+
*
|
|
72
|
+
* @param array $data
|
|
73
|
+
*
|
|
74
|
+
* @return \WP_REST_Response
|
|
75
|
+
*/
|
|
76
|
+
protected function success( $data = array() ) {
|
|
77
|
+
return new \WP_REST_Response(
|
|
78
|
+
array(
|
|
79
|
+
'error' => 0,
|
|
80
|
+
'message' => 'ok',
|
|
81
|
+
'data' => $data,
|
|
82
|
+
),
|
|
83
|
+
200
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* This function will return an error response.
|
|
89
|
+
*
|
|
90
|
+
* @param string $message
|
|
91
|
+
*
|
|
92
|
+
* @return \WP_REST_Response
|
|
93
|
+
*/
|
|
94
|
+
protected function error( $message ) {
|
|
95
|
+
return new \WP_REST_Response(
|
|
96
|
+
array(
|
|
97
|
+
'error' => 1,
|
|
98
|
+
'message' => $message,
|
|
99
|
+
),
|
|
100
|
+
400
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|