diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 69671cfb..745251be 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.8' services: wordpress: diff --git a/.gitignore b/.gitignore index babb946f..b871314e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,5 @@ package-lock.json c3.php **/*.local.php /.idea/ -*.bak \ No newline at end of file +*.bak +/.sisyphus/* \ No newline at end of file diff --git a/Makefile b/Makefile index 0a5d663f..3cb3372d 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,10 @@ down: ### Stop the containers inside the ./docker folder @$(DOCKER_DIR) docker-compose down --remove-orphans --volumes @echo "Containers stopped" +.PHONY: restart +restart: down up ### Restart the containers inside the ./docker folder + @echo "Containers restarted" + # Composer commands .PHONY: composer/install @@ -164,6 +168,11 @@ metrics: up ### Run the composer/metrics @echo "Running the psalm" @$(DOCKER_DIR) ./composer metrics +.PHPHONY: ssh +ssh: ### Run bash in the php74 container + @echo "Running bash in the php74 container" + @$(DOCKER_DIR) ./ssh + # Generate commands .PHONY: generate diff --git a/comments.php b/comments.php index 2014d31c..4027ac17 100644 --- a/comments.php +++ b/comments.php @@ -13,8 +13,6 @@ use Auryn\Injector; use ItalyStrap\Config\ConfigInterface; -use ItalyStrap\Event\EventDispatcher; -use ItalyStrap\Event\EventDispatcherInterface; use ItalyStrap\Event\ListenerRegisterInterface; use function _n; use function do_blocks; diff --git a/composer.json b/composer.json index 01261e7c..179e4270 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "homepage": "https://github.com/ItalyStrap/italystrap/graphs/contributors" } ], - "minimum-stability": "stable", + "minimum-stability": "dev", + "prefer-stable": true, "repositories": [ { "type": "package", @@ -28,11 +29,15 @@ "url": "https://github.com/WordPress/WordPress/archive/master.zip" } } + }, + { + "type": "vcs", + "url": "https://github.com/ItalyStrap/empress" } ], "require": { "php" : ">=7.4", - "italystrap/empress": "dev-modularized", + "italystrap/empress": "dev-modularized as 2.0.x-dev", "italystrap/event": "dev-master", "italystrap/config": "^2.0", "italystrap/helpers": "^1.0", @@ -40,14 +45,13 @@ "italystrap/view": "^1.0", "italystrap/finder": "dev-master", "italystrap/asset": "dev-master", - "rdlowrey/auryn": "^1.4", "overclokk/minimum-requirements": "dev-master", "cmb2/cmb2": "2.6.0", "yiisoft/json": "^1.0", "symfony/polyfill-php80": "^1.0" }, "require-dev": { - "lucatume/wp-browser": "^3.0.0", + "lucatume/wp-browser": "<3.5", "lucatume/function-mocker-le": "^1.0.0", "lucatume/function-mocker": "^1.3", "codeception/c3": "2.*", @@ -146,39 +150,39 @@ "@php vendor/bin/phpcbf -p" ], "psalm": [ - "@php vendor//bin//psalm --no-cache" + "@php vendor/bin/psalm --no-cache" ], "analyze": [ - "@php vendor//bin//phpstan analyze --level=max && vendor//bin//psalm" + "@php vendor/bin/phpstan analyze --level=max && vendor//bin//psalm" ], "infection": [ - "@php vendor//bin//infection --threads=8" + "@php vendor/bin/infection --threads=8" ], "unit": [ - "@php vendor//bin//codecept run unit", + "@php vendor/bin/codecept run unit", "@clean" ], "unit:cov": [ - "@php vendor//bin//codecept run unit --coverage", + "@php vendor/bin/codecept run unit --coverage", "@clean" ], "unit:debug": [ - "@php vendor//bin//codecept run unit --debug", + "@php vendor/bin/codecept run unit --debug", "@clean" ], "integration": [ - "@php vendor//bin//codecept run integration", + "@php vendor/bin/codecept run integration", "@clean" ], "integration:debug": [ - "@php vendor//bin//codecept run integration --debug", + "@php vendor/bin/codecept run integration --debug", "@clean" ], "functional": [ - "@php vendor//bin//codecept run functional" + "@php vendor/bin/codecept run functional" ], "bench": [ - "@php vendor//bin//phpbench run --report=performance" + "@php vendor/bin/phpbench run --report=performance" ], "metrics": [ "@php vendor//bin//phpmetrics --report-html='./tests/_output/report' ./src", diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index a579d1c5..f139315f 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -4,7 +4,6 @@ namespace ItalyStrap; -use Auryn\Injector; use ItalyStrap\Config\Config; use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Customizer\CustomizerAssetsSubscriber; diff --git a/config/dependencies.config.php b/config/dependencies.config.php index b7108baf..a88b9ad0 100644 --- a/config/dependencies.config.php +++ b/config/dependencies.config.php @@ -2,12 +2,12 @@ declare(strict_types=1); +use Auryn\Injector; use ItalyStrap\Asset\Module as AssetModule; use ItalyStrap\Config\ConfigFactory; use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Config\ConfigProviderExtension; use ItalyStrap\Config\ConfigThemeModsProvider; -use ItalyStrap\Empress\Injector; use ItalyStrap\Empress\PhpFileProvider; use ItalyStrap\Empress\ProvidersCacheInterface; use ItalyStrap\Empress\ProvidersCollection; @@ -18,9 +18,11 @@ use ItalyStrap\UI\Module as UIModule; return static function (Injector $injector): ConfigInterface { + $config = (new ConfigFactory())->make(); $collection = new ProvidersCollection( $injector, - ConfigFactory::make(), + $config, + null, [ // First we load Modules from packages EventModule::class, @@ -34,9 +36,9 @@ '/config/autoload/{{,*.}global,{,*.}local}.php', $injector->execute(ExperimentalThemeFileFinderFactory::class) ), - // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', + // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', fn(): array => [ - // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', + // ProvidersCacheInterface::CACHE_PATH => get_template_directory() . '/config/cache/config-cache.php', ProvidersCacheInterface::ENABLE_CACHE => true, ], /** This must run after all */ @@ -51,5 +53,5 @@ $collection->build(); - return $collection->collection(); + return $config; }; diff --git a/functions/factory.php b/functions/factory.php index bba07f21..fd783cca 100644 --- a/functions/factory.php +++ b/functions/factory.php @@ -9,14 +9,8 @@ namespace ItalyStrap\Factory; use Auryn\ConfigException; -use Auryn\InjectionException; use Auryn\Injector as AurynInjector; -use Exception; -use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Debug\Injector as DebugInjector; -use ItalyStrap\Empress\Injector as EmpressInjector; -use ItalyStrap\Config\Config; -use ItalyStrap\View\View; use function ItalyStrap\Core\is_debug; @@ -35,8 +29,7 @@ function injector(): AurynInjector $injector = apply_filters('italystrap_injector', false); if (!$injector) { - $injector = new EmpressInjector(); - $injector->alias(AurynInjector::class, EmpressInjector::class); + $injector = new AurynInjector(); $injector->share($injector); add_filter('italystrap_injector', function () use ($injector) { return $injector; diff --git a/parts/comments.html b/parts/comments.html index a0b2ba2c..8f8df7e3 100644 --- a/parts/comments.html +++ b/parts/comments.html @@ -1,49 +1 @@ - -
- - - - - -
- -
- -
- - - -
- - - -
- - - -
- - - - - -
- - -
- - - - - - - - - - - - - - -
- \ No newline at end of file + \ No newline at end of file diff --git a/patterns/hidden-comments.php b/patterns/hidden-comments.php new file mode 100644 index 00000000..53992576 --- /dev/null +++ b/patterns/hidden-comments.php @@ -0,0 +1,64 @@ + + +
+ + + + + + +
+ + +
+ +
+ + + +
+ + +
+ + + + + + + + + +
+ + + + +
+ + +
+ + + + + + + + + + + + + + +
+ diff --git a/patterns/hidden-post-comments-form.php b/patterns/hidden-post-comments-form.php new file mode 100644 index 00000000..3f76c112 --- /dev/null +++ b/patterns/hidden-post-comments-form.php @@ -0,0 +1,25 @@ + + diff --git a/patterns/hidden-search.php b/patterns/hidden-search.php new file mode 100644 index 00000000..6f629513 --- /dev/null +++ b/patterns/hidden-search.php @@ -0,0 +1,24 @@ + \esc_attr_x('Search again with the form below.', 'search form label', 'italystrap'), + 'placeholder' => \esc_attr_x('Search …', 'placeholder for search form', 'italystrap'), + 'buttonText' => \esc_attr_x('Search', 'search button text', 'italystrap'), + 'buttonPosition' => 'button-inside', + 'buttonUseIcon' => true, + 'fontSize' => 'small' +]; + +?> + diff --git a/patterns/widget-area.php b/patterns/widget-area.php new file mode 100644 index 00000000..8185dd2d --- /dev/null +++ b/patterns/widget-area.php @@ -0,0 +1,27 @@ +make(ViewInterface::class); +//$view = $injector->make(ViewBlockInterface::class); + +echo $view->render(FooterWidgetArea::TEMPLATE_NAME, [ + FooterWidgetArea::REGISTERED_WIDGET_AREAS => ConfigSidebarProvider::FOOTERS, +]); diff --git a/phpcs.xml b/phpcs.xml index b4c01a9e..8eee3861 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -28,4 +28,5 @@ */vendor/* */tests/_support/* + */tests/_output/* diff --git a/src/Asset/ThemeJson.php b/src/Asset/ThemeJson.php index 7eac7684..a5c561d9 100644 --- a/src/Asset/ThemeJson.php +++ b/src/Asset/ThemeJson.php @@ -5,13 +5,7 @@ namespace ItalyStrap\Asset; use ItalyStrap\Config\ConfigFactory; -use ItalyStrap\ThemeJsonGenerator\Factory\Color as FClr; -use ItalyStrap\ThemeJsonGenerator\Factory\Spacing as FSpace; -use ItalyStrap\ThemeJsonGenerator\Factory\Typography as FTypo; -use ItalyStrap\ThemeJsonGenerator\SectionNames; -use ItalyStrap\ThemeJsonGenerator\Settings\CustomCollection as Custom; -use ItalyStrap\ThemeJsonGenerator\Settings\PresetCollection as Preset; -use ItalyStrap\ThemeJsonGenerator\Styles\Border; +use ItalyStrap\ThemeJsonGenerator\Domain\Input\SectionNames; class ThemeJson { @@ -19,7 +13,7 @@ public static function writeJson(): array { $data = new self(); - $config = ConfigFactory::make(); + $config = (new ConfigFactory())->make(); $result = $data->buildJsonData(); diff --git a/src/Config/AlignmentChoicesTrait.php b/src/Config/AlignmentChoicesTrait.php index 9ac0348e..fcfe1a46 100644 --- a/src/Config/AlignmentChoicesTrait.php +++ b/src/Config/AlignmentChoicesTrait.php @@ -4,7 +4,7 @@ namespace ItalyStrap\Config; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; trait AlignmentChoicesTrait { diff --git a/src/Config/ConfigProviderExtension.php b/src/Config/ConfigProviderExtension.php index 99372e4c..07fb125a 100644 --- a/src/Config/ConfigProviderExtension.php +++ b/src/Config/ConfigProviderExtension.php @@ -4,9 +4,9 @@ namespace ItalyStrap\Config; +use Auryn\Injector; use ItalyStrap\Empress\AurynConfigInterface; use ItalyStrap\Empress\Extension; -use ItalyStrap\Empress\Injector; class ConfigProviderExtension implements Extension { diff --git a/src/Customizer/ColophonFields.php b/src/Customizer/ColophonFields.php index e74ac751..7f5e64af 100644 --- a/src/Customizer/ColophonFields.php +++ b/src/Customizer/ColophonFields.php @@ -7,7 +7,7 @@ use ItalyStrap\Config\ConfigColophonProvider; use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Config\TemplatePositionTrait; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; class ColophonFields { diff --git a/src/Customizer/CustomHeaderFields.php b/src/Customizer/CustomHeaderFields.php index e8417fc7..e5e1d041 100644 --- a/src/Customizer/CustomHeaderFields.php +++ b/src/Customizer/CustomHeaderFields.php @@ -7,7 +7,7 @@ use ItalyStrap\Config\AlignmentChoicesTrait; use ItalyStrap\Config\ConfigCustomHeaderProvider; use ItalyStrap\Config\ConfigInterface; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use ItalyStrap\Theme\Infrastructure\Config\ConfigThemeProvider; class CustomHeaderFields diff --git a/src/Customizer/CustomizerProviderExtension.php b/src/Customizer/CustomizerProviderExtension.php index 99588f38..b0c1f457 100644 --- a/src/Customizer/CustomizerProviderExtension.php +++ b/src/Customizer/CustomizerProviderExtension.php @@ -4,8 +4,8 @@ namespace ItalyStrap\Customizer; +use Auryn\Injector; use ItalyStrap\Empress\AurynConfigInterface; -use ItalyStrap\Empress\Injector; use ItalyStrap\Event\ListenerRegisterInterface; class CustomizerProviderExtension implements \ItalyStrap\Empress\Extension diff --git a/src/Customizer/PostThumbnailFields.php b/src/Customizer/PostThumbnailFields.php index 8b59130f..704467b3 100644 --- a/src/Customizer/PostThumbnailFields.php +++ b/src/Customizer/PostThumbnailFields.php @@ -6,7 +6,7 @@ use ItalyStrap\Config\AlignmentChoicesTrait; use ItalyStrap\Config\ConfigInterface; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use ItalyStrap\Theme\Infrastructure\Config\ConfigPostThumbnailProvider; class PostThumbnailFields diff --git a/src/Customizer/SiteLogoFields.php b/src/Customizer/SiteLogoFields.php index 4d4e4251..4c91480c 100644 --- a/src/Customizer/SiteLogoFields.php +++ b/src/Customizer/SiteLogoFields.php @@ -6,7 +6,7 @@ use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Config\ConfigSiteLogoProvider; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use ItalyStrap\Theme\Infrastructure\Config\ConfigThemeProvider; class SiteLogoFields @@ -97,7 +97,7 @@ protected function render_content() { $old_logo_id = \get_theme_mod('logo'); $brand_image_id = ConfigSiteLogoProvider::BRAND_IMAGE_ID; if (! empty($old_logo_id)) { - $this->config->add('navbar_logo_image', \absint($old_logo_id)); + $this->config->set('navbar_logo_image', \absint($old_logo_id)); \set_theme_mod('navbar_logo_image', \absint($old_logo_id)); \update_option('site_logo', \absint($old_logo_id)); \remove_theme_mod($brand_image_id); diff --git a/src/Debug/Injector.php b/src/Debug/Injector.php index 494fe645..6126f98f 100644 --- a/src/Debug/Injector.php +++ b/src/Debug/Injector.php @@ -7,7 +7,6 @@ use Auryn\Injector as MainInjector; use Auryn\ConfigException; use Auryn\InjectionException; -use ItalyStrap\Empress\Injector as EmpressInjector; use Throwable; /** @@ -22,7 +21,7 @@ * Class DebugInjector * @package ItalyStrap */ -class Injector extends EmpressInjector { +class Injector extends MainInjector { private MainInjector $injector; diff --git a/src/Experimental/ExperimentalCustomizerOptionWithAndPositionSubscriber.php b/src/Experimental/ExperimentalCustomizerOptionWithAndPositionSubscriber.php index 99e006bf..e110f291 100644 --- a/src/Experimental/ExperimentalCustomizerOptionWithAndPositionSubscriber.php +++ b/src/Experimental/ExperimentalCustomizerOptionWithAndPositionSubscriber.php @@ -30,6 +30,7 @@ public function registerThemePositions(array $new_position): array { return array_merge( [ + 'none' => \__('None', 'italystrap'), 'italystrap_before' => \__('After the </body>', 'italystrap'), 'italystrap_before_header' => \__('Before the header', 'italystrap'), diff --git a/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php b/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php index ddfa5625..879c03fa 100644 --- a/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php +++ b/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php @@ -209,12 +209,12 @@ public function onFooterAfter(FooterAfter $event) $this->appendContent(['italystrap_after_footer'], FooterAfter::class, $event); } - private function appendContent(array $eventName, string $replacement, object $event): void + private function appendContent(array $eventsName, string $replacement, object $event): void { ob_start(); - foreach ($eventName as $name) { - $this->globalDispatcher->trigger($name); - $this->deprecatedEventName($name, $replacement); + foreach ($eventsName as $eventName) { +// $this->globalDispatcher->trigger($eventName); +// $this->deprecatedEventName($eventName, $replacement); } $event->appendContent((string)ob_get_clean()); } @@ -228,13 +228,13 @@ private function deprecatedEventName(string $eventName, string $replacement): vo return; } - _deprecated_hook( - $eventName, - '4.0.0', - sprintf( - 'Use %s instead', - $replacement - ) - ); +// _deprecated_hook( +// $eventName, +// '4.0.0', +// sprintf( +// 'Use %s instead', +// $replacement +// ) +// ); } } diff --git a/src/Navigation/Domain/NavMenu.php b/src/Navigation/Domain/NavMenu.php index 59f57eff..0ad643b9 100644 --- a/src/Navigation/Domain/NavMenu.php +++ b/src/Navigation/Domain/NavMenu.php @@ -34,7 +34,7 @@ class NavMenu implements NavMenuInterface public function __construct( Walker_Nav_Menu $walker, - callable $fallback_cb = null + ?callable $fallback_cb = null ) { $this->walker = $walker; $this->fallback_cb = $fallback_cb ?? 'wp_page_menu'; diff --git a/src/Navigation/Infrastructure/BootstrapNavMenu.php b/src/Navigation/Infrastructure/BootstrapNavMenu.php index 48025a0c..82af877d 100644 --- a/src/Navigation/Infrastructure/BootstrapNavMenu.php +++ b/src/Navigation/Infrastructure/BootstrapNavMenu.php @@ -34,7 +34,7 @@ */ class BootstrapNavMenu extends Walker_Nav_Menu { - public function __construct( ListenerRegisterInterface $listenerRegister = null ) { + public function __construct( ?ListenerRegisterInterface $listenerRegister = null ) { $this->listenerRegister = $listenerRegister ?? new GlobalOrderedListenerProvider(); } diff --git a/src/Navigation/Module.php b/src/Navigation/Module.php index 1d2e35fe..583afc38 100644 --- a/src/Navigation/Module.php +++ b/src/Navigation/Module.php @@ -4,9 +4,9 @@ namespace ItalyStrap\Navigation; +use Auryn\Injector; use ItalyStrap\Config\ConfigProviderExtension; use ItalyStrap\Empress\AurynConfig; -use ItalyStrap\Empress\Injector; use ItalyStrap\Event\SubscribersConfigExtension; use ItalyStrap\Navigation\Admin\ItemCustomFieldsSubscriber; use ItalyStrap\Navigation\Application\NavMenusSubscriber; @@ -50,7 +50,10 @@ public function __invoke(): iterable ], NavMenuPrimary::class => [ - '+fallback' => static fn(string $named_param, Injector $injector): callable => $injector->make(NavMenuFallback::class), + '+fallback' => static fn( + string $named_param, + Injector $injector + ): callable => $injector->make(NavMenuFallback::class), ], ], diff --git a/src/Navigation/UI/Components/LinkPages.php b/src/Navigation/UI/Components/LinkPages.php index 0eec0012..aa669449 100644 --- a/src/Navigation/UI/Components/LinkPages.php +++ b/src/Navigation/UI/Components/LinkPages.php @@ -4,7 +4,7 @@ namespace ItalyStrap\Navigation\UI\Components; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use function wp_link_pages; @@ -14,7 +14,7 @@ */ class LinkPages { - private \ItalyStrap\Event\EventDispatcherInterface $dispatcher; + private EventDispatcherInterface $dispatcher; /** * LinkPages constructor. diff --git a/src/Navigation/UI/Components/MainNavigation.php b/src/Navigation/UI/Components/MainNavigation.php index b1fe1021..4e4be820 100644 --- a/src/Navigation/UI/Components/MainNavigation.php +++ b/src/Navigation/UI/Components/MainNavigation.php @@ -6,7 +6,7 @@ use ItalyStrap\Components\SubscribedEventsAware; use ItalyStrap\Config\ConfigInterface; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use ItalyStrap\Event\SubscriberInterface; use ItalyStrap\UI\Components\ComponentInterface; use ItalyStrap\View\ViewInterface; diff --git a/src/Navigation/UI/Components/MiscNavigation.php b/src/Navigation/UI/Components/MiscNavigation.php index 12880a16..3d8ac495 100644 --- a/src/Navigation/UI/Components/MiscNavigation.php +++ b/src/Navigation/UI/Components/MiscNavigation.php @@ -6,7 +6,7 @@ use ItalyStrap\Components\SubscribedEventsAware; use ItalyStrap\Config\ConfigInterface; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use ItalyStrap\Event\SubscriberInterface; use ItalyStrap\UI\Components\ComponentInterface; use ItalyStrap\View\ViewInterface; diff --git a/src/Navigation/UI/Components/NavMenuPrimary.php b/src/Navigation/UI/Components/NavMenuPrimary.php index e18d9b3c..f75c3940 100644 --- a/src/Navigation/UI/Components/NavMenuPrimary.php +++ b/src/Navigation/UI/Components/NavMenuPrimary.php @@ -34,7 +34,7 @@ public function __construct( ViewInterface $view, NavMenuInterface $menu, NavMenuLocationInterface $location, - callable $fallback = null + ?callable $fallback = null ) { $this->config = $config; $this->view = $view; diff --git a/src/Navigation/UI/Components/NavMenuToggleButton.php b/src/Navigation/UI/Components/NavMenuToggleButton.php index 629bb8a9..7768ec2b 100644 --- a/src/Navigation/UI/Components/NavMenuToggleButton.php +++ b/src/Navigation/UI/Components/NavMenuToggleButton.php @@ -6,11 +6,12 @@ use ItalyStrap\Components\SubscribedEventsAware; use ItalyStrap\Config\ConfigInterface; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; +use ItalyStrap\Event\SubscriberInterface; use ItalyStrap\UI\Components\ComponentInterface; use ItalyStrap\View\ViewInterface; -class NavMenuToggleButton implements ComponentInterface, \ItalyStrap\Event\SubscriberInterface +class NavMenuToggleButton implements ComponentInterface, SubscriberInterface { use SubscribedEventsAware; diff --git a/src/Navigation/UI/Components/Navbar.php b/src/Navigation/UI/Components/Navbar.php index 1b99f669..d479c89c 100644 --- a/src/Navigation/UI/Components/Navbar.php +++ b/src/Navigation/UI/Components/Navbar.php @@ -55,6 +55,8 @@ class Navbar */ private $fallback_cb; + private NavMenu $menu; + /** * Init the constructor * @@ -244,9 +246,14 @@ public function get_navbar_brand( array $attr = [] ) {// phpcs:ignore return apply_filters('italystrap_navbar_brand_none', '', $this->navbar_id); } + /** + * @TODO Find out why HOME_URL in local is empty + */ + $homeUrl = $this->config->get('HOME_URL'); + $default = [ 'class' => 'navbar-brand', - 'href' => esc_url($this->config->get('HOME_URL')), + 'href' => $homeUrl ? esc_url($homeUrl) : '', 'title' => sprintf( '%s - %s', \get_option('blogname'), diff --git a/src/Navigation/UI/Components/Pagination.php b/src/Navigation/UI/Components/Pagination.php index 4d4f332c..c947e885 100644 --- a/src/Navigation/UI/Components/Pagination.php +++ b/src/Navigation/UI/Components/Pagination.php @@ -8,13 +8,14 @@ use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Event\SubscriberInterface; use ItalyStrap\UI\Components\ComponentInterface; +use ItalyStrap\UI\Components\Posts\Events\PostsContentAfter; use ItalyStrap\View\ViewInterface; class Pagination implements SubscriberInterface, ComponentInterface { use SubscribedEventsAware; - public const EVENT_NAME = 'italystrap_after_loop'; + public const EVENT_NAME = PostsContentAfter::class; public const EVENT_PRIORITY = 10; public const TEMPLATE_NAME = 'navigation/pagination'; diff --git a/src/Theme/Application/ConfigWpSubscriber.php b/src/Theme/Application/ConfigWpSubscriber.php index 7acee5b0..f7ecae81 100644 --- a/src/Theme/Application/ConfigWpSubscriber.php +++ b/src/Theme/Application/ConfigWpSubscriber.php @@ -34,12 +34,12 @@ public function __invoke(): void $id = $this->query->get_queried_object_id(); if (is_singular()) { - $this->config->add( + $this->config->set( ConfigLayoutProvider::POST_CONTENT_TEMPLATE, (array) get_post_meta($id, '_italystrap_template_settings', true) ); } else { - $this->config->add( + $this->config->set( ConfigLayoutProvider::POST_CONTENT_TEMPLATE, explode( ',', @@ -54,14 +54,14 @@ public function __invoke(): void * If in page settings are set then override the global settings for the layout. */ if ($page_layout = (string) get_post_meta($id, '_italystrap_layout_settings', true)) { - $this->config->add(ConfigLayoutProvider::SITE_LAYOUT, $page_layout); + $this->config->set(ConfigLayoutProvider::SITE_LAYOUT, $page_layout); } /** * If in page settings are set then override the global settings for the layout. */ if ($container_width = (string) get_post_meta($id, '_italystrap_width_settings', true)) { - $this->config->add(ConfigLayoutProvider::CONTAINER_WIDTH, $container_width); + $this->config->set(ConfigLayoutProvider::CONTAINER_WIDTH, $container_width); } $array = [ diff --git a/src/Theme/Application/SidebarsSubscriber.php b/src/Theme/Application/SidebarsSubscriber.php index 656d0ada..082e7afb 100644 --- a/src/Theme/Application/SidebarsSubscriber.php +++ b/src/Theme/Application/SidebarsSubscriber.php @@ -6,15 +6,11 @@ use ItalyStrap\Config\ConfigInterface as Config; use ItalyStrap\Event\SubscriberInterface; -use ItalyStrap\HTML\Tag; use function array_filter; use function array_merge; use function register_sidebar; -/** - * There are a standard sidebar and 4 footer dynamic sidebars - */ final class SidebarsSubscriber implements SubscriberInterface { public const NAME = 'name'; @@ -26,13 +22,6 @@ final class SidebarsSubscriber implements SubscriberInterface public const BEFORE_TITLE = 'before_title'; public const AFTER_TITLE = 'after_title'; - private Tag $tag; - - /** - * @var array - */ - private array $registered_sidebars; - public function getSubscribedEvents(): iterable { yield 'widgets_init' => 'register'; @@ -41,17 +30,15 @@ public function getSubscribedEvents(): iterable private Config $config; - public function __construct(Config $config, Tag $tag) + public function __construct(Config $config) { $this->config = $config; - $this->tag = $tag; - $this->registered_sidebars = []; } public function register(): void { foreach ((array)$this->config->get(self::class, []) as $key => $sidebar) { - $this->registered_sidebars[$key] = register_sidebar($sidebar); + register_sidebar($sidebar); } } @@ -60,9 +47,14 @@ public function register(): void */ public function parseDynamicSidebarBefore($index): void { - /** @var array $wp_registered_sidebars */ + /** @var array $wp_registered_sidebars */ global $wp_registered_sidebars; - $wp_registered_sidebars[ $index ] = array_merge( + + if (!\array_key_exists($index, $wp_registered_sidebars)) { + return; + } + + $wp_registered_sidebars[$index] = array_merge( (array)$wp_registered_sidebars[$index], array_filter($this->getDefault($index)) ); @@ -81,24 +73,24 @@ private function getDefault($id): array self::ID => '', self::DESCRIPTION => '', self::CLASS_NAME => '', - self::BEFORE_WIDGET => $this->tag->open( - $widget_context, - 'div', - ['id' => '%1$s', 'class' => 'widget %2$s'] - ), - self::AFTER_WIDGET => $this->tag->close($widget_context), - self::BEFORE_TITLE => $this->tag->open( - $title_context, - 'h3', - ['class' => 'widgettitle widget-title'] - ), - self::AFTER_TITLE => $this->tag->close($title_context), - ]; - } + self::BEFORE_WIDGET => <<<'GROUP' + +
+GROUP +, + self::AFTER_WIDGET => <<<'GROUP' +
+ +GROUP, + self::BEFORE_TITLE => <<<'HEADING' + +

+HEADING, - private function defaultSidebarConfig(array $sidebar): array - { - $defaults = $this->getDefault($sidebar[ 'id' ]); - return array_merge($defaults, $sidebar); + self::AFTER_TITLE => <<<'HEADING' +

+ +HEADING, + ]; } } diff --git a/src/Theme/Infrastructure/Config/ConfigThemeProvider.php b/src/Theme/Infrastructure/Config/ConfigThemeProvider.php index 452ad8ad..92125555 100644 --- a/src/Theme/Infrastructure/Config/ConfigThemeProvider.php +++ b/src/Theme/Infrastructure/Config/ConfigThemeProvider.php @@ -4,7 +4,7 @@ namespace ItalyStrap\Theme\Infrastructure\Config; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; class ConfigThemeProvider { diff --git a/src/Theme/Infrastructure/Config/ConfigThemeSupportProvider.php b/src/Theme/Infrastructure/Config/ConfigThemeSupportProvider.php index b6f89d50..4c47f633 100644 --- a/src/Theme/Infrastructure/Config/ConfigThemeSupportProvider.php +++ b/src/Theme/Infrastructure/Config/ConfigThemeSupportProvider.php @@ -202,7 +202,8 @@ public function __invoke(): iterable // 'attachments' => [ // 'image-default' => [ // 'post_title' => _x('Default', 'Theme starter content', 'italystrap'), -// 'file' => 'assets/img/italystrap-default-image.png', // URL relative to the template directory. +// 'file' => 'assets/img/italystrap-default-image.png', +// // URL relative to the template directory. // ], // 'image-sandwich' => [ // 'post_title' => _x('Sandwich', 'Theme starter content', 'italystrap'), diff --git a/src/Theme/Infrastructure/Json.php b/src/Theme/Infrastructure/Json.php index c4270790..de68eca1 100644 --- a/src/Theme/Infrastructure/Json.php +++ b/src/Theme/Infrastructure/Json.php @@ -16,7 +16,7 @@ class Json * @return string * @throws \JsonException */ - public function encode($value, int $option = null, int $depth = null): string + public function encode($value, ?int $option = null, ?int $depth = null): string { return \Yiisoft\Json\Json::encode(...func_get_args()); } @@ -31,7 +31,7 @@ public function encode($value, int $option = null, int $depth = null): string * * @throws \JsonException */ - public function decode(string $json, bool $as_array = true, int $depth = null, int $option = null) + public function decode(string $json, bool $as_array = true, ?int $depth = null, ?int $option = null) { return \Yiisoft\Json\Json::decode(...func_get_args()); } diff --git a/src/UI/Components/Comments/Comments.php b/src/UI/Components/Comments/Comments.php index 72df63a7..66acbbf9 100644 --- a/src/UI/Components/Comments/Comments.php +++ b/src/UI/Components/Comments/Comments.php @@ -8,7 +8,7 @@ use ItalyStrap\Event\SubscriberInterface; use ItalyStrap\UI\Components\ComponentInterface; use ItalyStrap\UI\Components\Main\Events\Content; -use ItalyStrap\View\ViewInterface; +use ItalyStrap\UI\Infrastructure\ViewBlockInterface; class Comments implements ComponentInterface, SubscriberInterface { @@ -23,8 +23,9 @@ public function getSubscribedEvents(): iterable public const TEMPLATE_NAME = 'comments/comments'; private ConfigInterface $config; - private ViewInterface $view; - public function __construct(ConfigInterface $config, ViewInterface $view) + private ViewBlockInterface $view; + + public function __construct(ConfigInterface $config, ViewBlockInterface $view) { $this->config = $config; $this->view = $view; diff --git a/src/UI/Components/Footer/Colophon.php b/src/UI/Components/Footer/Colophon.php index a2e20551..6eb15466 100644 --- a/src/UI/Components/Footer/Colophon.php +++ b/src/UI/Components/Footer/Colophon.php @@ -51,7 +51,7 @@ public function __invoke(Content $event): void { $content = (string)$this->config->get(ConfigColophonProvider::COLOPHON, ''); - if (empty($content)) { + if ($content === '') { return; } diff --git a/src/UI/Components/Footer/Footer.php b/src/UI/Components/Footer/Footer.php index e7b4462b..ec234248 100644 --- a/src/UI/Components/Footer/Footer.php +++ b/src/UI/Components/Footer/Footer.php @@ -39,7 +39,7 @@ public function shouldDisplay(): bool return true; } - public function __invoke(\ItalyStrap\UI\Components\Main\Events\Footer $event) + public function __invoke(\ItalyStrap\UI\Components\Main\Events\Footer $event): void { $event->appendContent($this->view->render(self::TEMPLATE_NAME, [ EventDispatcherInterface::class => $this->dispatcher, diff --git a/src/UI/Components/Footer/FooterWidgetArea.php b/src/UI/Components/Footer/FooterWidgetArea.php index da7bca0e..ac948fd3 100644 --- a/src/UI/Components/Footer/FooterWidgetArea.php +++ b/src/UI/Components/Footer/FooterWidgetArea.php @@ -19,6 +19,8 @@ public function getSubscribedEvents(): iterable public const TEMPLATE_NAME = 'footer/widget-area'; + public const REGISTERED_WIDGET_AREAS = 'footer_sidebars'; + private ViewInterface $view; public function __construct( @@ -35,7 +37,7 @@ public function shouldDisplay(): bool public function __invoke(Content $event): void { $event->appendContent($this->view->render(self::TEMPLATE_NAME, [ - 'footer_sidebars' => ConfigSidebarProvider::FOOTERS, + self::REGISTERED_WIDGET_AREAS => ConfigSidebarProvider::FOOTERS, ])); } } diff --git a/src/UI/Elements/Search.php b/src/UI/Elements/Search.php index 63a8e73f..9f9aa844 100644 --- a/src/UI/Elements/Search.php +++ b/src/UI/Elements/Search.php @@ -5,12 +5,12 @@ namespace ItalyStrap\UI\Elements; use ItalyStrap\HTML\TagInterface; -use ItalyStrap\View\ViewInterface; +use ItalyStrap\UI\Infrastructure\ViewBlockInterface; class Search implements ElementInterface { public const TEMPLATE_NAME = 'elements/search'; - private ViewInterface $view; + private ViewBlockInterface $view; private array $attributes = []; private string $context = ''; @@ -18,7 +18,7 @@ class Search implements ElementInterface private TagInterface $tag; public function __construct( - ViewInterface $view, + ViewBlockInterface $view, TagInterface $tag ) { $this->view = $view; diff --git a/src/UI/Infrastructure/ComponentSubscriberExtension.php b/src/UI/Infrastructure/ComponentSubscriberExtension.php index edd4f430..b6ff3933 100644 --- a/src/UI/Infrastructure/ComponentSubscriberExtension.php +++ b/src/UI/Infrastructure/ComponentSubscriberExtension.php @@ -4,9 +4,9 @@ namespace ItalyStrap\UI\Infrastructure; +use Auryn\Injector; use ItalyStrap\Empress\AurynConfigInterface; use ItalyStrap\Empress\Extension; -use ItalyStrap\Empress\Injector; use ItalyStrap\Empress\ProxyFactory; use ItalyStrap\Event\ListenerRegisterInterface; use ItalyStrap\Event\SubscriberInterface; diff --git a/src/bootstrap.php b/src/bootstrap.php index bdc94983..b1e00cb8 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -21,10 +21,12 @@ ':dependencies' => (require __DIR__ . '/../config/dependencies.config.php')($injector) ]); - $injectorConfig->extendFromClassName(ConfigProviderExtension::class); - $injectorConfig->extendFromClassName(SubscribersConfigExtension::class); - $injectorConfig->extendFromClassName(ComponentSubscriberExtension::class); - $injectorConfig->extendFromClassName(CustomizerProviderExtension::class); + $injectorConfig->extend( + ConfigProviderExtension::class, + SubscribersConfigExtension::class, + ComponentSubscriberExtension::class, + CustomizerProviderExtension::class + ); $listenerProvider = $injector ->share(GlobalOrderedListenerProvider::class) diff --git a/templates/comments/comments.php b/templates/comments/comments.php index 111528be..54144b12 100644 --- a/templates/comments/comments.php +++ b/templates/comments/comments.php @@ -2,53 +2,7 @@ declare(strict_types=1); -?> - -
- - - - - -
- -
- -
- - - -
- - - -
- - - -
- - - - - -
- +namespace ItalyStrap; -
- - - - - - - - - - - - - - -
- +?> + diff --git a/templates/elements/search.php b/templates/elements/search.php index d31f534f..bbedc2e5 100644 --- a/templates/elements/search.php +++ b/templates/elements/search.php @@ -4,5 +4,14 @@ namespace ItalyStrap; +$attributes = [ + 'label' => \esc_attr_x('Search again with the form below.', 'search form label', 'italystrap'), + 'placeholder' => \esc_attr_x('Search …', 'placeholder for search form', 'italystrap'), + 'buttonText' => \esc_attr_x('Search', 'search button text', 'italystrap'), + 'buttonPosition' => 'button-inside', + 'buttonUseIcon' => true, + 'fontSize' => 'small' +]; + ?> - + diff --git a/templates/footer/widget-area.php b/templates/footer/widget-area.php index 0716decc..44c87e71 100644 --- a/templates/footer/widget-area.php +++ b/templates/footer/widget-area.php @@ -23,11 +23,3 @@ - - -
-
-

Text

-
-
- diff --git a/templates/main/main.php b/templates/main/main.php index 7b554db9..b59baf35 100644 --- a/templates/main/main.php +++ b/templates/main/main.php @@ -22,7 +22,9 @@ ?> dispatch(new Header()); ?> -
+
@@ -42,4 +44,3 @@ dispatch(new Footer()); ?> - diff --git a/templates/navigation/navigation.php b/templates/navigation/navigation.php index c1ced803..b3efdbea 100644 --- a/templates/navigation/navigation.php +++ b/templates/navigation/navigation.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; /** @var \ItalyStrap\Config\ConfigInterface $config */ $config = $this; diff --git a/templates/posts/post.php b/templates/posts/post.php index b9f47d85..1a83c4fe 100644 --- a/templates/posts/post.php +++ b/templates/posts/post.php @@ -12,7 +12,9 @@ $id = (string)$this->get('id'); $classNames = (string)$this->get('class_names'); ?> - +
dispatch(new PostContent()); ?>
diff --git a/templates/posts/posts.php b/templates/posts/posts.php index ea1ab3a0..3ec3ee5c 100644 --- a/templates/posts/posts.php +++ b/templates/posts/posts.php @@ -29,7 +29,10 @@ ?> dispatch(new PostsContentBefore()); ?> - +
dispatch(new PostsContent()); ?> @@ -37,4 +40,3 @@
dispatch(new PostsContentAfter()); ?> - diff --git a/tests/acceptance/HomePageCest.php b/tests/acceptance/HomePageCest.php index 8428a934..e89e64ca 100644 --- a/tests/acceptance/HomePageCest.php +++ b/tests/acceptance/HomePageCest.php @@ -23,5 +23,7 @@ public function homePage(AcceptanceTester $i): void $i->amOnPage('/'); $i->see('Lorem ipsum dolor sit amet'); + $i->seeElement('.navbar-header'); + $i->seeElement('.navbar-toggler'); } } diff --git a/tests/functional/SearchCest.php b/tests/functional/SearchCest.php index b0fd6efe..3e243962 100644 --- a/tests/functional/SearchCest.php +++ b/tests/functional/SearchCest.php @@ -24,4 +24,19 @@ public function itShouldBeOnSearchPage(FunctionalTester $i): void $i->seeResponseContains('wp-block-query-title'); $i->seeResponseContains('Test Post Title 123'); } + + public function itShouldRenderTheSearchFormWhenNoResultsAreFound(FunctionalTester $i): void + { + $i->havePostInDatabase([ + 'post_title' => 'Unrelated Title', + 'post_content' => '', + 'post_status' => 'publish', + ]); + + $i->amOnPage('/?s=NoMatchTerm'); + $i->seeResponseCodeIs(200); + $i->dontSee('