Skip to content

Commit 9ebc547

Browse files
authored
Feature/tailwind (#415)
* add tailwind-related helpers * add function to unregister default style overrides * rename functions * tweak naming * Tailwind cli setup (#411) * updating new arguments for the new setup * adding tailwind cli commands
1 parent be156b5 commit 9ebc547

File tree

147 files changed

+3418
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+3418
-379
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@ All notable changes to this project will be documented in this file.
33

44
This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
55

6+
## [9.0.0]
7+
8+
### Changed
9+
- WP-CLI command `reusable-header-footer` is renamed to `patterns-header-footer`.
10+
- `Reusable blocks` admin menu is now named `Patterns` when moved to project.
11+
- WP-CLI command `admin-reusable-blocks-menu` is renamed to `admin-patterns-menu`.
12+
- Plugin now has WP-CLI prefix as `boilerplate-plugin`.
13+
- WP-CLI command `theme-options` is renamed to `theme-options-acf`.
14+
15+
### Added
16+
- WP-CLI command `admin-menu` now supports `view_component` prop.
17+
- WP-CLI command `admin-sub-menu` now supports `view_component` prop.
18+
- WP-CLI command `admin-theme-options-menu`
19+
- WP-CLI commands can now detect if they are used in the standard or Tailwind setup.
20+
- WP-CLI global param `g_frontend_libs_type`.
21+
- WP-CLI parent command name `ìnit-setup`.
22+
- WP-CLI command `init-setup theme`.
23+
- WP-CLI command `init-setup theme-clean`.
24+
- WP-CLI command `init-setup plugin`.
25+
- WP-CLI command `init-setup plugin-clean`.
26+
- Enqueue function to deregister all WP default styles that should not be there.
27+
- Tailwind trait for all Tailwind helpers used in the new setup.
28+
- New setups for Tailwind setup for plugin and theme.
29+
- WP-CLI command `theme-options`.
30+
31+
### Fixed
32+
- Admin assets dependency is needed to support the Tailwind setup.
33+
634
## [8.0.7]
735

836
### Fixed
@@ -586,6 +614,7 @@ Init setup
586614

587615
[Unreleased]: https://github.com/infinum/eightshift-libs/compare/main...HEAD
588616

617+
[9.0.0]: https://github.com/infinum/eightshift-libs/compare/8.0.7...9.0.0
589618
[8.0.7]: https://github.com/infinum/eightshift-libs/compare/8.0.6...8.0.7
590619
[8.0.6]: https://github.com/infinum/eightshift-libs/compare/8.0.5...8.0.6
591620
[8.0.5]: https://github.com/infinum/eightshift-libs/compare/8.0.4...8.0.5

phpcs.xml.dist

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,52 @@
5757

5858
<rule ref="PSR12.Operators.OperatorSpacing.NoSpaceAfter">
5959
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
60-
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
61-
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
60+
<exclude-pattern>*/src/InitSetup/clean/theme/</exclude-pattern>
61+
<exclude-pattern>*/src/InitSetup/clean/plugin/</exclude-pattern>
62+
<exclude-pattern>*/src/InitSetup/standard/theme/</exclude-pattern>
63+
<exclude-pattern>*/src/InitSetup/standard/plugin/</exclude-pattern>
64+
<exclude-pattern>*/src/InitSetup/tailwind/theme/</exclude-pattern>
65+
<exclude-pattern>*/src/InitSetup/tailwind/plugin/</exclude-pattern>
6266
</rule>
6367

6468
<rule ref="PSR12.Operators.OperatorSpacing.NoSpaceBefore">
6569
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
66-
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
67-
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
70+
<exclude-pattern>*/src/InitSetup/clean/theme/</exclude-pattern>
71+
<exclude-pattern>*/src/InitSetup/clean/plugin/</exclude-pattern>
72+
<exclude-pattern>*/src/InitSetup/standard/theme/</exclude-pattern>
73+
<exclude-pattern>*/src/InitSetup/standard/plugin/</exclude-pattern>
74+
<exclude-pattern>*/src/InitSetup/tailwind/theme/</exclude-pattern>
75+
<exclude-pattern>*/src/InitSetup/tailwind/plugin/</exclude-pattern>
6876
</rule>
6977

7078
<rule ref="Eightshift.Security.HelpersEscape.OutputNotEscaped">
7179
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
72-
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
73-
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
80+
<exclude-pattern>*/src/InitSetup/clean/theme/</exclude-pattern>
81+
<exclude-pattern>*/src/InitSetup/clean/plugin/</exclude-pattern>
82+
<exclude-pattern>*/src/InitSetup/standard/theme/</exclude-pattern>
83+
<exclude-pattern>*/src/InitSetup/standard/plugin/</exclude-pattern>
84+
<exclude-pattern>*/src/InitSetup/tailwind/theme/</exclude-pattern>
85+
<exclude-pattern>*/src/InitSetup/tailwind/plugin/</exclude-pattern>
7486
</rule>
7587

7688
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants.NonFullyQualified">
7789
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
78-
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
79-
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
90+
<exclude-pattern>*/src/InitSetup/clean/theme/</exclude-pattern>
91+
<exclude-pattern>*/src/InitSetup/clean/plugin/</exclude-pattern>
92+
<exclude-pattern>*/src/InitSetup/standard/theme/</exclude-pattern>
93+
<exclude-pattern>*/src/InitSetup/standard/plugin/</exclude-pattern>
94+
<exclude-pattern>*/src/InitSetup/tailwind/theme/</exclude-pattern>
95+
<exclude-pattern>*/src/InitSetup/tailwind/plugin/</exclude-pattern>
8096
</rule>
8197

8298
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">
8399
<exclude-pattern>*/src/*/*Example.php</exclude-pattern>
84-
<exclude-pattern>*/src/Init/theme/</exclude-pattern>
85-
<exclude-pattern>*/src/Init/plugin/</exclude-pattern>
100+
<exclude-pattern>*/src/InitSetup/clean/theme/</exclude-pattern>
101+
<exclude-pattern>*/src/InitSetup/clean/plugin/</exclude-pattern>
102+
<exclude-pattern>*/src/InitSetup/standard/theme/</exclude-pattern>
103+
<exclude-pattern>*/src/InitSetup/standard/plugin/</exclude-pattern>
104+
<exclude-pattern>*/src/InitSetup/tailwind/theme/</exclude-pattern>
105+
<exclude-pattern>*/src/InitSetup/tailwind/plugin/</exclude-pattern>
86106
</rule>
87107

88108
<rule ref="Internal.NoCodeFound">

phpstan.neon.dist

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ parameters:
1212
- src/
1313
excludePaths:
1414
- src/**/*Example.php
15-
- src/Init/theme/
16-
- src/Init/plugin/
15+
- src/InitSetup/clean/theme/
16+
- src/InitSetup/clean/plugin/
17+
- src/InitSetup/standard/theme/
18+
- src/InitSetup/standard/plugin/
19+
- src/InitSetup/tailwind/theme/
20+
- src/InitSetup/tailwind/plugin/
1721
ignoreErrors:
1822
# Ignore errors about reflection class variable being undefined. Errors are caught.
1923
- '/^Variable \$reflectionClass might not be defined\.$/'

src/AdminMenus/AdminMenuCli.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function getDefaultArgs(): array
5353
'menu_slug' => 'example-menu-slug',
5454
'menu_icon' => 'dashicons-admin-generic',
5555
'menu_position' => 100,
56+
'view_component' => 'layout',
5657
];
5758
}
5859

@@ -104,6 +105,13 @@ public function getDoc(): array
104105
'optional' => true,
105106
'default' => $this->getDefaultArg('menu_position'),
106107
],
108+
[
109+
'type' => 'assoc',
110+
'name' => 'view_component',
111+
'description' => 'The default view component.',
112+
'optional' => true,
113+
'default' => $this->getDefaultArg('view_component'),
114+
],
107115
],
108116
'longdesc' => $this->prepareLongDesc("
109117
## USAGE
@@ -136,6 +144,7 @@ public function __invoke(array $args, array $assocArgs)
136144
$menuSlug = $this->prepareSlug($this->getArg($assocArgs, 'menu_slug'));
137145
$menuIcon = $this->getArg($assocArgs, 'menu_icon');
138146
$menuPosition = $this->getArg($assocArgs, 'menu_position');
147+
$viewComponent = $this->getArg($assocArgs, 'view_component');
139148

140149
// Get full class name.
141150
$className = $this->getFileName($menuSlug);
@@ -148,7 +157,9 @@ public function __invoke(array $args, array $assocArgs)
148157
->searchReplaceString($this->getArgTemplate('title'), $title)
149158
->searchReplaceString($this->getArgTemplate('menu_title'), $menuTitle)
150159
->searchReplaceString($this->getArgTemplate('capability'), $capability)
151-
->searchReplaceString($this->getArgTemplate('menu_slug'), $menuSlug);
160+
->searchReplaceString($this->getArgTemplate('menu_slug'), $menuSlug)
161+
->searchReplaceString($this->getArgTemplate('view_component'), $viewComponent)
162+
;
152163

153164
if (!empty($menuPosition)) {
154165
$class->searchReplaceString($this->getDefaultArg('menu_position'), $menuPosition);

src/AdminMenus/AdminMenuExample.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function getPosition(): int
130130
*/
131131
protected function getViewComponent(): string
132132
{
133-
return 'layout';
133+
return '%view_component%';
134134
}
135135

136136
/**
@@ -148,7 +148,7 @@ protected function getViewComponent(): string
148148
protected function processAttributes($attr): array
149149
{
150150
return [
151-
'pageTitle' => \esc_html__('%title%', '%g_textdomain%'),
151+
'pageTitle' => $this->getTitle(),
152152
];
153153
}
154154
}

src/AdminMenus/ReusableBlocksHeaderFooterCli.php renamed to src/AdminMenus/AdminPatternsHeaderFooterMenu/AdminPatternsHeaderFooterMenuCli.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?php
22

33
/**
4-
* Class that registers WPCLI command for Reusable header/footer picker creation.
4+
* Class that registers WPCLI command for patterns header/footer picker creation.
55
*
6-
* @package EightshiftLibs\AdminMenus
6+
* @package EightshiftLibs\AdminMenus\AdminPatternsHeaderFooterMenu
77
*/
88

99
declare(strict_types=1);
1010

11-
namespace EightshiftLibs\AdminMenus;
11+
namespace EightshiftLibs\AdminMenus\AdminPatternsHeaderFooterMenu;
1212

1313
use EightshiftLibs\Cli\AbstractCli;
1414
use EightshiftLibs\Cli\ParentGroups\CliCreate;
1515
use EightshiftLibs\Helpers\Helpers;
1616

1717
/**
18-
* Class ReusableBlocksHeaderFooterCli
18+
* Class AdminPatternsHeaderFooterMenuCli
1919
*/
20-
class ReusableBlocksHeaderFooterCli extends AbstractCli
20+
class AdminPatternsHeaderFooterMenuCli extends AbstractCli
2121
{
2222
/**
2323
* Get WPCLI command parent name
@@ -36,7 +36,7 @@ public function getCommandParentName(): string
3636
*/
3737
public function getCommandName(): string
3838
{
39-
return 'reusable-header-footer';
39+
return 'patterns-header-footer';
4040
}
4141

4242
/**
@@ -105,7 +105,7 @@ public function getDoc(): array
105105
## RESOURCES
106106
107107
Service class will be created from this example:
108-
https://github.com/infinum/eightshift-libs/blob/develop/src/AdminMenus/ReusableBlocksHeaderFooterExample.php
108+
https://github.com/infinum/eightshift-libs/blob/develop/src/AdminMenus/AdminPatternsHeaderFooterMenu/AdminPatternsHeaderFooterMenuExample.php
109109
"),
110110
];
111111
}

src/AdminMenus/ReusableBlocksHeaderFooterExample.php renamed to src/AdminMenus/AdminPatternsHeaderFooterMenu/AdminPatternsHeaderFooterMenuExample.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* File that holds class for reusable blocks header/footer example.
4+
* File that holds class for patterns header/footer example.
55
*
66
* @package %g_namespace%\AdminMenus
77
*/
@@ -15,17 +15,17 @@
1515
use WP_Query;
1616

1717
/**
18-
* ReusableBlocksHeaderFooterExample class.
18+
* AdminPatternsHeaderFooterMenuExample class.
1919
*/
20-
class ReusableBlocksHeaderFooterExample extends AbstractAdminMenu
20+
class AdminPatternsHeaderFooterMenuExample extends AbstractAdminMenu
2121
{
2222
/**
23-
* Reusable blocks Capability.
23+
* Patterns Capability.
2424
*/
2525
public const ADMIN_MENU_CAPABILITY = '%capability%';
2626

2727
/**
28-
* Menu slug for reusable blocks menu.
28+
* Menu slug for patterns menu.
2929
*
3030
* @var string
3131
*/
@@ -37,7 +37,7 @@ class ReusableBlocksHeaderFooterExample extends AbstractAdminMenu
3737
public const ADMIN_ICON = 'dashicons-embed-photo';
3838

3939
/**
40-
* Menu position for reusable blocks menu.
40+
* Menu position for patterns menu.
4141
*
4242
* @var int
4343
*/
@@ -103,9 +103,9 @@ protected function getMenuTitle(): string
103103
}
104104

105105
/**
106-
* Get the capability required for reusable block menu to be displayed.
106+
* Get the capability required for patterns menu to be displayed.
107107
*
108-
* @return string The capability required for reusable block menu to be displayed to the user.
108+
* @return string The capability required for patterns menu to be displayed to the user.
109109
*/
110110
protected function getCapability(): string
111111
{
@@ -115,8 +115,8 @@ protected function getCapability(): string
115115
/**
116116
* Get the menu slug.
117117
*
118-
* @return string The slug name to refer to reusable block menu by.
119-
* Should be unique for reusable block menu page and only include lowercase alphanumeric,
118+
* @return string The slug name to refer to patterns menu by.
119+
* Should be unique for patterns menu page and only include lowercase alphanumeric,
120120
* dashes, and underscores characters to be compatible with sanitize_key().
121121
*/
122122
protected function getMenuSlug(): string
@@ -125,9 +125,9 @@ protected function getMenuSlug(): string
125125
}
126126

127127
/**
128-
* Get the URL to the icon to be used for reusable block menu.
128+
* Get the URL to the icon to be used for patterns menu.
129129
*
130-
* @return string The URL to the icon to be used for reusable block menu.
130+
* @return string The URL to the icon to be used for patterns menu.
131131
* * Pass a base64-encoded SVG using a data URI, which will be colored to match
132132
* the color scheme. This should begin with 'data:image/svg+xml;base64,'.
133133
* * Pass the name of a Dashicons helper class to use a font icon,
@@ -140,7 +140,7 @@ protected function getIcon(): string
140140
}
141141

142142
/**
143-
* Get the position of the reusable blocks menu.
143+
* Get the position of the patterns menu.
144144
*
145145
* @return int Number that indicates the position of the menu.
146146
* 5 - below Posts
@@ -270,13 +270,13 @@ public function renderPartialSelector($args): void
270270
?>
271271
</select>
272272
<?php } else { ?>
273-
<i><?php echo \esc_html__('No reusable blocks found.', '%g_textdomain%'); ?></i>
273+
<i><?php echo \esc_html__('No patterns found.', '%g_textdomain%'); ?></i>
274274
<?php
275275
}
276276
}
277277

278278
/**
279-
* Renders a reusable block partial.
279+
* Renders a patterns partial.
280280
*
281281
* @param int|string $partialId Block partial ID.
282282
* @return void

0 commit comments

Comments
 (0)