generator-chisel 2.1.2 → 2.2.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 +10 -0
- package/README.md +1 -11
- package/lib/commands/create/creators/app/chisel-starter-theme/404.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/archive.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/fonts/manrope-700.woff2 +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/fonts/manrope-regular.woff2 +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/fonts/roboto-300.woff2 +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/fonts/roboto-700.woff2 +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/assets/fonts/roboto-regular.woff2 +0 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/author.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/composer.json +7 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/footer.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/functions.php +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Controllers/AjaxController.php +20 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Enums/AcfOptionsPageType.php +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Enums/BlocksType.php +17 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Factories/RegisterAcfOptionsPage.php +78 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Factory → Factories}/RegisterBlocks.php +41 -30
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Factory → Factories}/RegisterCustomPostType.php +44 -32
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Factory → Factories}/RegisterCustomTaxonomy.php +39 -27
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/AcfHelpers.php +12 -12
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helpers/AjaxHelpers.php +36 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/AssetsHelpers.php +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/BlocksHelpers.php +22 -18
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helpers/CacheHelpers.php +43 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/CommentsHelpers.php +8 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/DataHelpers.php +5 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/GravityFormsHelpers.php +13 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/ImageHelpers.php +30 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/ThemeHelpers.php +29 -25
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/WoocommerceHelpers.php +15 -9
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Helper → Helpers}/YoastHelpers.php +6 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/HooksInterface.php +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Interfaces/InstanceInterface.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Plugin → Plugins}/GravityForms.php +13 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Plugin → Plugins}/Woocommerce.php +14 -14
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/{Plugin → Plugins}/Yoast.php +6 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/PageBlocks.php +67 -14
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Traits/Singleton.php +28 -7
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Acf.php +16 -15
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/AcfBlocks.php +19 -19
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/{AjaxEnpoints.php → AjaxEndpoints.php} +13 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Assets.php +42 -68
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Blocks.php +23 -23
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Cache.php +10 -11
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselImage.php +7 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselPost.php +14 -7
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselProduct.php +13 -11
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselProductCategory.php +12 -11
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Comments.php +27 -35
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Components.php +58 -61
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomPostTypes.php +13 -14
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/CustomTaxonomies.php +12 -13
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Sidebars.php +6 -6
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Site.php +8 -8
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Theme.php +22 -22
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/Twig.php +54 -49
- package/lib/commands/create/creators/app/chisel-starter-theme/index.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/page.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/search.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/single.php +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks/accordion/style.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/blocks-acf/slider/block.json +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_buttons.scss +31 -66
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_colors.scss +5 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_icon.scss +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_index.scss +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/design/tools/_link.scss +1 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/admin/acf.js +1 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/editor/blocks-styles.js +3 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/scripts/modules/utils.js +15 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-button.scss +13 -27
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-latest-posts.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-media-text.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core-query.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/blocks/_core.scss +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_badge.scss +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_buttons.scss +14 -28
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_footer.scss +6 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_header.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_main-nav.scss +5 -5
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_pagination.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_post-card.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_post.scss +3 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_posts-items.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_sidebar.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/components/_slider.scss +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_form.scss +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/elements/_shared.scss +4 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/login.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/objects/_wrapper.scss +5 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/vendor/_breadcrumbs.scss +6 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_general.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_notices.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/woo/_product.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_block-edit-selector.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_core-spacer.scss +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/src/styles/wp-editor/_render-appender.scss +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/style.chisel-tpl.css +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/theme.json +150 -37
- package/lib/commands/create/creators/app/chisel-starter-theme/views/components/footer.twig +8 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/views/index.twig +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-blog.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/sidebar-woocommerce.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/single.twig +6 -4
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/archive-product.twig +2 -2
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/linked-products.twig +1 -1
- package/lib/commands/create/creators/app/chisel-starter-theme/views/woocommerce/single-product.twig +3 -3
- package/lib/commands/create/creators/app/chisel-starter-theme/webpack.config.js +11 -0
- package/lib/commands/create/creators/app/chisel-starter-theme/woocommerce.php +4 -4
- package/lib/commands/create/packages-versions.js +1 -1
- package/package.json +2 -2
- 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/inc/Factory/RegisterAcfOptionsPage.php +0 -62
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/AjaxHelpers.php +0 -33
- package/lib/commands/create/creators/app/chisel-starter-theme/inc/Helper/CacheHelpers.php +0 -41
|
@@ -4,7 +4,7 @@ namespace Chisel\WP;
|
|
|
4
4
|
|
|
5
5
|
use Timber\Post as TimberPost;
|
|
6
6
|
use Timber\Timber;
|
|
7
|
-
use Chisel\
|
|
7
|
+
use Chisel\Helpers\ImageHelpers;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Extend Timber Post class with custom functionality. This is a woocommerce product class.
|
|
@@ -16,30 +16,32 @@ class ChiselProduct extends TimberPost {
|
|
|
16
16
|
/**
|
|
17
17
|
* Product thumbnail.
|
|
18
18
|
*
|
|
19
|
-
* @var
|
|
19
|
+
* @var ?string
|
|
20
20
|
*/
|
|
21
|
-
public $thumbnail_html = null;
|
|
21
|
+
public ?string $thumbnail_html = null;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Category thumbnail id.
|
|
25
25
|
*
|
|
26
|
-
* @var int
|
|
26
|
+
* @var ?int
|
|
27
27
|
*/
|
|
28
|
-
public $thumbnail_id = null;
|
|
28
|
+
public ?int $thumbnail_id = null;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Get the product thumbnail. Returns the thumbnail responsive image html.
|
|
32
32
|
*
|
|
33
33
|
* @param string $size Thumbnail size.
|
|
34
|
-
* @
|
|
34
|
+
* @param array $attrs Image attributes.
|
|
35
|
+
*
|
|
36
|
+
* @return string Responsive <img> HTML, or empty string.
|
|
35
37
|
*/
|
|
36
|
-
public function get_thumbnail( $size = 'woocommerce_thumbnail' ) {
|
|
38
|
+
public function get_thumbnail( string $size = 'woocommerce_thumbnail', array $attrs = array() ): string {
|
|
37
39
|
$size = apply_filters( 'single_product_archive_thumbnail_size', $size );
|
|
38
40
|
|
|
39
41
|
if ( $this->thumbnail_html === null ) {
|
|
40
|
-
$thumbnail_id = $this->get_thumbnail_id(
|
|
42
|
+
$thumbnail_id = $this->get_thumbnail_id();
|
|
41
43
|
|
|
42
|
-
$this->thumbnail_html = $thumbnail_id ? ImageHelpers::get_responsive_image( $thumbnail_id, $size ) : '';
|
|
44
|
+
$this->thumbnail_html = $thumbnail_id ? ImageHelpers::get_responsive_image( $thumbnail_id, $size, $attrs ) : '';
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
return $this->thumbnail_html;
|
|
@@ -50,7 +52,7 @@ class ChiselProduct extends TimberPost {
|
|
|
50
52
|
*
|
|
51
53
|
* @return int
|
|
52
54
|
*/
|
|
53
|
-
public function get_thumbnail_id() {
|
|
55
|
+
public function get_thumbnail_id(): int {
|
|
54
56
|
if ( $this->thumbnail_id === null ) {
|
|
55
57
|
$thumbnail_id = get_post_thumbnail_id( $this->ID );
|
|
56
58
|
|
|
@@ -61,6 +63,6 @@ class ChiselProduct extends TimberPost {
|
|
|
61
63
|
$this->thumbnail_id = $thumbnail_id;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
return $this->thumbnail_id;
|
|
66
|
+
return (int) $this->thumbnail_id;
|
|
65
67
|
}
|
|
66
68
|
}
|
package/lib/commands/create/creators/app/chisel-starter-theme/inc/WP/ChiselProductCategory.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Term as TimberTerm;
|
|
6
|
-
use Chisel\
|
|
6
|
+
use Chisel\Helpers\ImageHelpers;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Extend Timber Term class with custom functionality.
|
|
@@ -15,31 +15,32 @@ class ChiselProductCategory extends TimberTerm {
|
|
|
15
15
|
/**
|
|
16
16
|
* Category thumbnail.
|
|
17
17
|
*
|
|
18
|
-
* @var
|
|
18
|
+
* @var ?string
|
|
19
19
|
*/
|
|
20
|
-
public $thumbnail_html = null;
|
|
20
|
+
public ?string $thumbnail_html = null;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Category thumbnail id.
|
|
24
24
|
*
|
|
25
|
-
* @var int
|
|
25
|
+
* @var ?int
|
|
26
26
|
*/
|
|
27
|
-
public $thumbnail_id = null;
|
|
27
|
+
public ?int $thumbnail_id = null;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Get the product thumbnail. Returns the thumbnail responsive image html.
|
|
31
31
|
*
|
|
32
32
|
* @param string $size Thumbnail size.
|
|
33
|
+
* @param array $attrs Image attributes.
|
|
33
34
|
*
|
|
34
|
-
* @return
|
|
35
|
+
* @return string Responsive <img> HTML, or empty string.
|
|
35
36
|
*/
|
|
36
|
-
public function get_thumbnail( $size = 'woocommerce_thumbnail' ) {
|
|
37
|
+
public function get_thumbnail( string $size = 'woocommerce_thumbnail', array $attrs = array() ): string {
|
|
37
38
|
$size = apply_filters( 'subcategory_archive_thumbnail_size', $size );
|
|
38
39
|
|
|
39
40
|
if ( $this->thumbnail_html === null ) {
|
|
40
|
-
$thumbnail_id = $this->get_thumbnail_id(
|
|
41
|
+
$thumbnail_id = $this->get_thumbnail_id();
|
|
41
42
|
|
|
42
|
-
$this->thumbnail_html = $thumbnail_id ? ImageHelpers::get_responsive_image( $thumbnail_id, $size ) : '';
|
|
43
|
+
$this->thumbnail_html = $thumbnail_id ? ImageHelpers::get_responsive_image( $thumbnail_id, $size, $attrs ) : '';
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
return $this->thumbnail_html;
|
|
@@ -50,9 +51,9 @@ class ChiselProductCategory extends TimberTerm {
|
|
|
50
51
|
*
|
|
51
52
|
* @return int
|
|
52
53
|
*/
|
|
53
|
-
public function get_thumbnail_id() {
|
|
54
|
+
public function get_thumbnail_id(): int {
|
|
54
55
|
if ( $this->thumbnail_id === null ) {
|
|
55
|
-
$thumbnail_id = $this->meta( 'thumbnail_id' );
|
|
56
|
+
$thumbnail_id = (int) $this->meta( 'thumbnail_id' );
|
|
56
57
|
|
|
57
58
|
if ( ! $thumbnail_id ) {
|
|
58
59
|
$thumbnail_id = get_option( 'woocommerce_placeholder_image', 0 );
|
|
@@ -11,7 +11,7 @@ use Chisel\Traits\Singleton;
|
|
|
11
11
|
*
|
|
12
12
|
* @package Chisel
|
|
13
13
|
*/
|
|
14
|
-
class Comments implements InstanceInterface, HooksInterface {
|
|
14
|
+
final class Comments implements InstanceInterface, HooksInterface {
|
|
15
15
|
|
|
16
16
|
use Singleton;
|
|
17
17
|
|
|
@@ -20,14 +20,14 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
20
20
|
*
|
|
21
21
|
* @var bool
|
|
22
22
|
*/
|
|
23
|
-
private $disable_comments;
|
|
23
|
+
private bool $disable_comments = true;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Post types for which comments are disabled.
|
|
27
27
|
*
|
|
28
28
|
* @var array
|
|
29
29
|
*/
|
|
30
|
-
private $post_types = array(
|
|
30
|
+
private array $post_types = array(
|
|
31
31
|
'post',
|
|
32
32
|
'page',
|
|
33
33
|
);
|
|
@@ -47,14 +47,14 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
47
47
|
/**
|
|
48
48
|
* Set properties.
|
|
49
49
|
*/
|
|
50
|
-
public function set_properties() {
|
|
50
|
+
public function set_properties(): void {
|
|
51
51
|
$this->disable_comments = apply_filters( 'chisel_disable_comments', true );
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Register action hooks.
|
|
56
56
|
*/
|
|
57
|
-
public function action_hooks() {
|
|
57
|
+
public function action_hooks(): void {
|
|
58
58
|
add_action( 'after_setup_theme', array( $this, 'disable_comments_for_post_types' ), 99 );
|
|
59
59
|
add_action( 'admin_menu', array( $this, 'remove_admin_menu' ), 999 );
|
|
60
60
|
|
|
@@ -74,7 +74,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
74
74
|
/**
|
|
75
75
|
* Register filter hooks.
|
|
76
76
|
*/
|
|
77
|
-
public function filter_hooks() {
|
|
77
|
+
public function filter_hooks(): void {
|
|
78
78
|
add_filter( 'wp_headers', array( $this, 'filter_wp_headers' ) );
|
|
79
79
|
add_filter( 'pre_option_default_pingback_flag', '__return_zero' );
|
|
80
80
|
add_filter( 'comments_open', '__return_false', 20 );
|
|
@@ -102,7 +102,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
102
102
|
*
|
|
103
103
|
* @return void
|
|
104
104
|
*/
|
|
105
|
-
public function disable_comments_for_post_types() {
|
|
105
|
+
public function disable_comments_for_post_types(): void {
|
|
106
106
|
$this->post_types = apply_filters( 'chisel_disable_comments_post_types', $this->post_types );
|
|
107
107
|
|
|
108
108
|
if ( $this->post_types ) {
|
|
@@ -121,7 +121,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
121
121
|
/**
|
|
122
122
|
* Remove comments related admin menus.
|
|
123
123
|
*/
|
|
124
|
-
public function remove_admin_menu() {
|
|
124
|
+
public function remove_admin_menu(): void {
|
|
125
125
|
global $pagenow;
|
|
126
126
|
|
|
127
127
|
if ( in_array( $pagenow, array( 'comment.php', 'edit-comments.php', 'options-discussion.php' ), true ) ) {
|
|
@@ -135,7 +135,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
135
135
|
/**
|
|
136
136
|
* Add custom CSS to dashboard.
|
|
137
137
|
*/
|
|
138
|
-
public function admin_css() {
|
|
138
|
+
public function admin_css(): void {
|
|
139
139
|
?>
|
|
140
140
|
<style>
|
|
141
141
|
#dashboard_right_now .comment-count,
|
|
@@ -152,14 +152,14 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
152
152
|
/**
|
|
153
153
|
* Remove comments from dashboard.
|
|
154
154
|
*/
|
|
155
|
-
public function filter_dashboard() {
|
|
155
|
+
public function filter_dashboard(): void {
|
|
156
156
|
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
160
|
* Disable recent comments widget.
|
|
161
161
|
*/
|
|
162
|
-
public function disable_rc_widget() {
|
|
162
|
+
public function disable_rc_widget(): void {
|
|
163
163
|
unregister_widget( 'WP_Widget_Recent_Comments' );
|
|
164
164
|
add_filter( 'show_recent_comments_widget_style', '__return_false' );
|
|
165
165
|
}
|
|
@@ -167,7 +167,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
167
167
|
/**
|
|
168
168
|
* Filter feed query
|
|
169
169
|
*/
|
|
170
|
-
public function filter_query() {
|
|
170
|
+
public function filter_query(): void {
|
|
171
171
|
if ( is_comment_feed() ) {
|
|
172
172
|
wp_die( esc_html__( 'Comments are closed.' ), '', array( 'response' => 403 ) );
|
|
173
173
|
}
|
|
@@ -176,7 +176,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
176
176
|
/**
|
|
177
177
|
* Remove comment links from admin bar.
|
|
178
178
|
*/
|
|
179
|
-
public function filter_admin_bar() {
|
|
179
|
+
public function filter_admin_bar(): void {
|
|
180
180
|
remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
|
|
181
181
|
|
|
182
182
|
if ( is_multisite() ) {
|
|
@@ -187,7 +187,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
187
187
|
/**
|
|
188
188
|
* Disable comments template on single posts.
|
|
189
189
|
*/
|
|
190
|
-
public function check_comment_template() {
|
|
190
|
+
public function check_comment_template(): void {
|
|
191
191
|
if ( is_singular() ) {
|
|
192
192
|
// Kill the comments' template.
|
|
193
193
|
add_filter( 'comments_template', '__return_empty_string', 20 );
|
|
@@ -201,14 +201,14 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
201
201
|
/**
|
|
202
202
|
* Add hook to run custom script.
|
|
203
203
|
*/
|
|
204
|
-
public function filter_gutenberg() {
|
|
204
|
+
public function filter_gutenberg(): void {
|
|
205
205
|
add_action( 'admin_footer', array( $this, 'print_footer_scripts' ) );
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* Unregister comments blocks and panels.
|
|
210
210
|
*/
|
|
211
|
-
public function print_footer_scripts() {
|
|
211
|
+
public function print_footer_scripts(): void {
|
|
212
212
|
?>
|
|
213
213
|
<script>
|
|
214
214
|
wp.domReady( () => {
|
|
@@ -221,7 +221,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
221
221
|
wp.blocks.unregisterBlockType( blockType );
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
wp.data.dispatch( 'core/
|
|
224
|
+
wp.data.dispatch( 'core/editor')?.removeEditorPanel( 'discussion-panel' ); // Discussion
|
|
225
225
|
} );
|
|
226
226
|
</script>
|
|
227
227
|
<?php
|
|
@@ -234,16 +234,8 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
234
234
|
*
|
|
235
235
|
* @return array
|
|
236
236
|
*/
|
|
237
|
-
public function filter_rest_endpoints( $endpoints ) {
|
|
238
|
-
|
|
239
|
-
unset( $endpoints['comments'] );
|
|
240
|
-
}
|
|
241
|
-
if ( isset( $endpoints['/wp/v2/comments'] ) ) {
|
|
242
|
-
unset( $endpoints['/wp/v2/comments'] );
|
|
243
|
-
}
|
|
244
|
-
if ( isset( $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] ) ) {
|
|
245
|
-
unset( $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] );
|
|
246
|
-
}
|
|
237
|
+
public function filter_rest_endpoints( array $endpoints ): array {
|
|
238
|
+
unset( $endpoints['comments'], $endpoints['/wp/v2/comments'], $endpoints['/wp/v2/comments/(?P<id>[\d]+)'] );
|
|
247
239
|
|
|
248
240
|
return $endpoints;
|
|
249
241
|
}
|
|
@@ -255,7 +247,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
255
247
|
*
|
|
256
248
|
* @return array
|
|
257
249
|
*/
|
|
258
|
-
public function disable_xmlrc_comments( $methods ) {
|
|
250
|
+
public function disable_xmlrc_comments( array $methods ): array {
|
|
259
251
|
unset( $methods['wp.newComment'] );
|
|
260
252
|
|
|
261
253
|
return $methods;
|
|
@@ -264,23 +256,23 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
264
256
|
/**
|
|
265
257
|
* Remove comments from REST API
|
|
266
258
|
*
|
|
267
|
-
* @param array
|
|
268
|
-
* @param WP_REST_Request $request
|
|
259
|
+
* @param array $prepared_comment
|
|
260
|
+
* @param \WP_REST_Request $request
|
|
269
261
|
*
|
|
270
|
-
* @return WP_Error
|
|
262
|
+
* @return \WP_Error
|
|
271
263
|
*/
|
|
272
|
-
public function disable_rest_api_comments( $prepared_comment, $request ) {
|
|
264
|
+
public function disable_rest_api_comments( array $prepared_comment, \WP_REST_Request $request ): \WP_Error {
|
|
273
265
|
return new \WP_Error( 'rest_comment_disabled', 'Commenting is disabled.', array( 'status' => 403 ) );
|
|
274
266
|
}
|
|
275
267
|
|
|
276
268
|
/**
|
|
277
269
|
* Remove comment links from network admin bar.
|
|
278
270
|
*
|
|
279
|
-
* @param WP_Admin_Bar $wp_admin_bar
|
|
271
|
+
* @param \WP_Admin_Bar $wp_admin_bar
|
|
280
272
|
*
|
|
281
273
|
* @return void
|
|
282
274
|
*/
|
|
283
|
-
public function remove_network_comment_links( $wp_admin_bar ) {
|
|
275
|
+
public function remove_network_comment_links( \WP_Admin_Bar $wp_admin_bar ): void {
|
|
284
276
|
if ( is_user_logged_in() ) {
|
|
285
277
|
foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
|
|
286
278
|
$wp_admin_bar->remove_menu( 'blog-' . $blog->userblog_id . '-c' );
|
|
@@ -295,7 +287,7 @@ class Comments implements InstanceInterface, HooksInterface {
|
|
|
295
287
|
*
|
|
296
288
|
* @return array
|
|
297
289
|
*/
|
|
298
|
-
public function filter_wp_headers( $headers ) {
|
|
290
|
+
public function filter_wp_headers( array $headers ): array {
|
|
299
291
|
unset( $headers['X-Pingback'] );
|
|
300
292
|
|
|
301
293
|
return $headers;
|
|
@@ -3,80 +3,75 @@
|
|
|
3
3
|
namespace Chisel\WP;
|
|
4
4
|
|
|
5
5
|
use Timber\Timber;
|
|
6
|
-
use Chisel\
|
|
7
|
-
use Chisel\
|
|
8
|
-
use Chisel\
|
|
6
|
+
use Chisel\Helpers\ImageHelpers;
|
|
7
|
+
use Chisel\Helpers\AcfHelpers;
|
|
8
|
+
use Chisel\Helpers\CacheHelpers;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Use this class to get site components.
|
|
12
12
|
*
|
|
13
13
|
* @package Chisel
|
|
14
14
|
*/
|
|
15
|
-
class Components {
|
|
15
|
+
final class Components {
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The site nav menus.
|
|
19
19
|
*
|
|
20
20
|
* @var array
|
|
21
21
|
*/
|
|
22
|
-
private static $menus = array();
|
|
22
|
+
private static array $menus = array();
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* The logo.
|
|
26
26
|
*
|
|
27
|
-
* @var
|
|
27
|
+
* @var string
|
|
28
28
|
*/
|
|
29
|
-
private static $logo =
|
|
29
|
+
private static string $logo = '';
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* The sidebar widgets.
|
|
33
33
|
*
|
|
34
34
|
* @var array
|
|
35
35
|
*/
|
|
36
|
-
private static $sidebar = array();
|
|
36
|
+
private static array $sidebar = array();
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* The footer sidebars.
|
|
40
40
|
*
|
|
41
41
|
* @var array
|
|
42
42
|
*/
|
|
43
|
-
private static $footer_sidebars = array();
|
|
43
|
+
private static array $footer_sidebars = array();
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* The page / post title.
|
|
47
47
|
*
|
|
48
48
|
* @var array
|
|
49
49
|
*/
|
|
50
|
-
private static $the_title = array();
|
|
50
|
+
private static array $the_title = array();
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* The svg icons.
|
|
54
54
|
*
|
|
55
55
|
* @var array
|
|
56
56
|
*/
|
|
57
|
-
private static $icons = array();
|
|
57
|
+
private static array $icons = array();
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Get the site nav menus.
|
|
61
61
|
*
|
|
62
62
|
* @return array
|
|
63
63
|
*/
|
|
64
|
-
public static function get_menus() {
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
if ( strpos( $menu, 'chisel', 0 ) === false ) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
$menu_name = str_replace( 'chisel_', '', $menu );
|
|
72
|
-
|
|
73
|
-
if ( ! has_nav_menu( $menu ) ) {
|
|
74
|
-
$menus[$menu_name] = '';
|
|
64
|
+
public static function get_menus(): array {
|
|
65
|
+
if ( empty( self::$menus ) ) {
|
|
66
|
+
$nav_menus = get_registered_nav_menus();
|
|
75
67
|
|
|
68
|
+
foreach ( array_keys( $nav_menus ) as $menu ) {
|
|
69
|
+
if ( strpos( $menu, 'chisel', 0 ) === false ) {
|
|
76
70
|
continue;
|
|
77
71
|
}
|
|
78
72
|
|
|
79
|
-
$
|
|
73
|
+
$menu_name = str_replace( 'chisel_', '', $menu );
|
|
74
|
+
$menus[$menu_name] = has_nav_menu( $menu ) ? Timber::get_menu( $menu ) : '';
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
|
|
@@ -88,7 +83,7 @@ class Components {
|
|
|
88
83
|
*
|
|
89
84
|
* @return string
|
|
90
85
|
*/
|
|
91
|
-
public static function get_logo() {
|
|
86
|
+
public static function get_logo(): string {
|
|
92
87
|
if ( self::$logo ) {
|
|
93
88
|
return self::$logo;
|
|
94
89
|
}
|
|
@@ -107,27 +102,36 @@ class Components {
|
|
|
107
102
|
*
|
|
108
103
|
* @param string $sidebar_id The sidebar id.
|
|
109
104
|
*
|
|
110
|
-
* @return array
|
|
105
|
+
* @return ?array
|
|
111
106
|
*/
|
|
112
|
-
public static function get_sidebar( $sidebar_id =
|
|
113
|
-
|
|
114
|
-
return self::$sidebar;
|
|
115
|
-
}
|
|
107
|
+
public static function get_sidebar( string $sidebar_id = '' ): ?array {
|
|
108
|
+
$sidebar_name = null;
|
|
116
109
|
|
|
117
110
|
if ( $sidebar_id ) {
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
$sidebar_name = 'chisel-sidebar-' . $sidebar_id;
|
|
112
|
+
} elseif ( is_singular( 'post' ) ) {
|
|
113
|
+
$sidebar_name = 'chisel-sidebar-blog';
|
|
114
|
+
} elseif ( function_exists( 'is_shop' ) && is_shop() ) {
|
|
115
|
+
$sidebar_name = 'chisel-sidebar-woocommerce';
|
|
120
116
|
}
|
|
121
117
|
|
|
122
|
-
if (
|
|
123
|
-
|
|
118
|
+
if ( ! $sidebar_name ) {
|
|
119
|
+
return null;
|
|
124
120
|
}
|
|
125
121
|
|
|
126
|
-
if (
|
|
127
|
-
self::$sidebar
|
|
122
|
+
if ( isset( self::$sidebar[ $sidebar_name ] ) ) {
|
|
123
|
+
return self::$sidebar[ $sidebar_name ];
|
|
128
124
|
}
|
|
129
125
|
|
|
130
|
-
|
|
126
|
+
$sidebar_content = Timber::get_widgets( $sidebar_name );
|
|
127
|
+
|
|
128
|
+
self::$sidebar[ $sidebar_name ] = array(
|
|
129
|
+
'id' => $sidebar_id,
|
|
130
|
+
'name' => $sidebar_name,
|
|
131
|
+
'content' => $sidebar_content,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return self::$sidebar[ $sidebar_name ];
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
/**
|
|
@@ -135,8 +139,8 @@ class Components {
|
|
|
135
139
|
*
|
|
136
140
|
* @return array
|
|
137
141
|
*/
|
|
138
|
-
public static function get_footer_sidebars() {
|
|
139
|
-
if ( self::$footer_sidebars ) {
|
|
142
|
+
public static function get_footer_sidebars(): array {
|
|
143
|
+
if ( ! empty( self::$footer_sidebars ) ) {
|
|
140
144
|
return self::$footer_sidebars;
|
|
141
145
|
}
|
|
142
146
|
|
|
@@ -154,20 +158,14 @@ class Components {
|
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
$column_class = 'o-layout__item--6-large';
|
|
166
|
-
break;
|
|
167
|
-
default:
|
|
168
|
-
$column_class = 'o-layout__item--12';
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
161
|
+
$column_count = count( self::$footer_sidebars['columns'] );
|
|
162
|
+
|
|
163
|
+
$column_class = match ( $column_count ) {
|
|
164
|
+
4 => 'o-layout__item--3-large',
|
|
165
|
+
3 => 'o-layout__item--4-large',
|
|
166
|
+
2 => 'o-layout__item--6-large',
|
|
167
|
+
default => 'o-layout__item--12',
|
|
168
|
+
};
|
|
171
169
|
|
|
172
170
|
self::$footer_sidebars['column_class'] = $column_class;
|
|
173
171
|
|
|
@@ -175,17 +173,16 @@ class Components {
|
|
|
175
173
|
}
|
|
176
174
|
|
|
177
175
|
/**
|
|
178
|
-
* Get the current page title.
|
|
176
|
+
* Get the current page title data.
|
|
179
177
|
*
|
|
180
178
|
* @return array
|
|
181
179
|
*/
|
|
182
|
-
public static function get_the_title() {
|
|
183
|
-
if ( self::$the_title ) {
|
|
180
|
+
public static function get_the_title(): array {
|
|
181
|
+
if ( ! empty( self::$the_title ) ) {
|
|
184
182
|
return self::$the_title;
|
|
185
183
|
}
|
|
186
184
|
|
|
187
185
|
$classname = 'c-title';
|
|
188
|
-
$the_title = array();
|
|
189
186
|
$title_text = '';
|
|
190
187
|
$title_class = '';
|
|
191
188
|
|
|
@@ -202,7 +199,7 @@ class Components {
|
|
|
202
199
|
}
|
|
203
200
|
}
|
|
204
201
|
} elseif ( is_home() ) {
|
|
205
|
-
$posts_page_id =
|
|
202
|
+
$posts_page_id = (int) get_option( 'page_for_posts' );
|
|
206
203
|
|
|
207
204
|
if ( $posts_page_id ) {
|
|
208
205
|
$title_text = get_the_title( $posts_page_id );
|
|
@@ -230,7 +227,7 @@ class Components {
|
|
|
230
227
|
$title_text = __( '404 - Page not found', 'chisel' );
|
|
231
228
|
}
|
|
232
229
|
|
|
233
|
-
if ( $title_text ) {
|
|
230
|
+
if ( $title_text !== '' ) {
|
|
234
231
|
self::$the_title = array(
|
|
235
232
|
'text' => esc_html( $title_text ),
|
|
236
233
|
'class' => $title_class ? esc_attr( $title_class ) : $classname,
|
|
@@ -245,12 +242,12 @@ class Components {
|
|
|
245
242
|
*
|
|
246
243
|
* @param array $args
|
|
247
244
|
*
|
|
248
|
-
* @return
|
|
245
|
+
* @return string
|
|
249
246
|
*/
|
|
250
|
-
public static function get_icon( $args ) {
|
|
247
|
+
public static function get_icon( array $args ): string {
|
|
251
248
|
$icon_slug = sanitize_title( $args['name'] );
|
|
249
|
+
$icon_key = '';
|
|
252
250
|
|
|
253
|
-
$icon_key = '';
|
|
254
251
|
foreach ( $args as $key => $value ) {
|
|
255
252
|
if ( is_bool( $value ) ) {
|
|
256
253
|
$value = $value ? 'yes' : 'no';
|
|
@@ -5,14 +5,14 @@ namespace Chisel\WP;
|
|
|
5
5
|
use Chisel\Interfaces\InstanceInterface;
|
|
6
6
|
use Chisel\Interfaces\HooksInterface;
|
|
7
7
|
use Chisel\Traits\Singleton;
|
|
8
|
-
use Chisel\
|
|
8
|
+
use Chisel\Factories\RegisterCustomPostType;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Custom post types and taxonomies wrapper class.
|
|
12
12
|
*
|
|
13
13
|
* @package Chisel
|
|
14
14
|
*/
|
|
15
|
-
class CustomPostTypes implements InstanceInterface, HooksInterface {
|
|
15
|
+
final class CustomPostTypes implements InstanceInterface, HooksInterface {
|
|
16
16
|
|
|
17
17
|
use Singleton;
|
|
18
18
|
|
|
@@ -21,21 +21,21 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
|
|
|
21
21
|
*
|
|
22
22
|
* @var array
|
|
23
23
|
*/
|
|
24
|
-
private $post_types = array();
|
|
24
|
+
private array $post_types = array();
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Default post type supports.
|
|
28
28
|
*
|
|
29
29
|
* @var array
|
|
30
30
|
*/
|
|
31
|
-
private $default_post_type_supports = array();
|
|
31
|
+
private array $default_post_type_supports = array();
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Default post type rewrite args.
|
|
35
35
|
*
|
|
36
36
|
* @var array
|
|
37
37
|
*/
|
|
38
|
-
private $default_post_type_rewrite_args = array();
|
|
38
|
+
private array $default_post_type_rewrite_args = array();
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Class constructor.
|
|
@@ -50,9 +50,9 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
|
|
|
50
50
|
/**
|
|
51
51
|
* Set properties.
|
|
52
52
|
*/
|
|
53
|
-
public function set_properties() {
|
|
54
|
-
$this->default_post_type_supports = apply_filters( 'chisel_default_post_type_supports', array( 'title', 'page-attributes', 'revisions', 'author' ) );
|
|
55
|
-
$this->default_post_type_rewrite_args = apply_filters(
|
|
53
|
+
public function set_properties(): void {
|
|
54
|
+
$this->default_post_type_supports = (array) apply_filters( 'chisel_default_post_type_supports', array( 'title', 'page-attributes', 'revisions', 'author' ) );
|
|
55
|
+
$this->default_post_type_rewrite_args = (array) apply_filters(
|
|
56
56
|
'chisel_default_post_type_rewrite_args',
|
|
57
57
|
array(
|
|
58
58
|
'slug' => '',
|
|
@@ -69,20 +69,19 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
|
|
|
69
69
|
/**
|
|
70
70
|
* Register action hooks.
|
|
71
71
|
*/
|
|
72
|
-
public function action_hooks() {
|
|
72
|
+
public function action_hooks(): void {
|
|
73
73
|
add_action( 'init', array( $this, 'register_post_types' ) );
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Register filter hooks.
|
|
78
78
|
*/
|
|
79
|
-
public function filter_hooks() {
|
|
80
|
-
}
|
|
79
|
+
public function filter_hooks(): void {}
|
|
81
80
|
|
|
82
81
|
/**
|
|
83
82
|
* Register custom post types.
|
|
84
83
|
*/
|
|
85
|
-
public function register_post_types() {
|
|
84
|
+
public function register_post_types(): void {
|
|
86
85
|
$this->post_types = apply_filters( 'chisel_custom_post_types', $this->post_types );
|
|
87
86
|
|
|
88
87
|
if ( empty( $this->post_types ) ) {
|
|
@@ -103,14 +102,14 @@ class CustomPostTypes implements InstanceInterface, HooksInterface {
|
|
|
103
102
|
/**
|
|
104
103
|
* Set custom post types.
|
|
105
104
|
*/
|
|
106
|
-
private function set_post_types() {
|
|
105
|
+
private function set_post_types(): void {
|
|
107
106
|
$this->post_types = array(
|
|
108
107
|
// phpcs:disable
|
|
109
108
|
// 'chisel-cpt' => array(
|
|
110
109
|
// 'singular' => __( 'Chisel CPT', 'chisel' ),
|
|
111
110
|
// 'plural' => __( 'Chisel CPTs', 'chisel' ),
|
|
112
111
|
// 'supports' => array( 'editor', 'thumbnail', 'excerpt' ),
|
|
113
|
-
// '
|
|
112
|
+
// 'menu_icon' => 'dashicons-location-alt',
|
|
114
113
|
// 'hierarchical' => true,
|
|
115
114
|
// 'public' => true,
|
|
116
115
|
// 'menu_position' => 20,
|