From 6496fc67904355432a3c16ee10d2f6fc76fcaac9 Mon Sep 17 00:00:00 2001 From: Enea Date: Sun, 10 Dec 2023 19:36:50 +0100 Subject: [PATCH 01/23] introduce comments template and patterns --- parts/comments.html | 50 +------------------- patterns/hidden-comments.php | 64 ++++++++++++++++++++++++++ patterns/hidden-post-comments-form.php | 25 ++++++++++ templates/comments/comments.php | 52 ++------------------- 4 files changed, 93 insertions(+), 98 deletions(-) create mode 100644 patterns/hidden-comments.php create mode 100644 patterns/hidden-post-comments-form.php 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..a32d50d5 --- /dev/null +++ b/patterns/hidden-post-comments-form.php @@ -0,0 +1,25 @@ + + 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; -
- - - - - - - - - - - - - - -
- +?> + From 7abb7aae397fb8e1fbe3c2f9a2aa587f30223ffd Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 10 Mar 2026 12:21:33 +0100 Subject: [PATCH 02/23] Refactor event dispatcher interface usage and improve code readability --- comments.php | 2 - config/autoload/dependencies.global.php | 1 - config/dependencies.config.php | 12 ++-- functions/factory.php | 9 +-- patterns/hidden-search.php | 24 +++++++ patterns/widget-area.php | 27 ++++++++ src/Config/AlignmentChoicesTrait.php | 2 +- src/Config/ConfigProviderExtension.php | 2 +- src/Customizer/ColophonFields.php | 2 +- src/Customizer/CustomHeaderFields.php | 2 +- .../CustomizerProviderExtension.php | 2 +- src/Customizer/PostThumbnailFields.php | 2 +- src/Customizer/SiteLogoFields.php | 4 +- ...talHookComponentsDeprecationSubscriber.php | 16 ++--- src/Navigation/Domain/NavMenu.php | 2 +- .../Infrastructure/BootstrapNavMenu.php | 2 +- src/Navigation/Module.php | 2 +- src/Navigation/UI/Components/LinkPages.php | 4 +- .../UI/Components/MainNavigation.php | 2 +- .../UI/Components/MiscNavigation.php | 2 +- .../UI/Components/NavMenuPrimary.php | 2 +- .../UI/Components/NavMenuToggleButton.php | 5 +- src/Navigation/UI/Components/Navbar.php | 9 ++- src/Theme/Application/ConfigWpSubscriber.php | 8 +-- src/Theme/Application/SidebarsSubscriber.php | 62 ++++++++----------- .../Config/ConfigThemeProvider.php | 2 +- src/Theme/Infrastructure/Json.php | 4 +- src/UI/Components/Footer/FooterWidgetArea.php | 4 +- .../ComponentSubscriberExtension.php | 2 +- src/bootstrap.php | 10 +-- templates/elements/search.php | 11 +++- templates/footer/widget-area.php | 8 --- templates/navigation/navigation.php | 2 +- tests/src/BaseUnitTrait.php | 4 +- 34 files changed, 151 insertions(+), 103 deletions(-) create mode 100644 patterns/hidden-search.php create mode 100644 patterns/widget-area.php 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/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..a24eff76 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/patterns/hidden-search.php b/patterns/hidden-search.php new file mode 100644 index 00000000..70b24c23 --- /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/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/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php b/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php index ddfa5625..07e7d34d 100644 --- a/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php +++ b/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php @@ -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..0d3da828 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; 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/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/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/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/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/elements/search.php b/templates/elements/search.php index d31f534f..c99e689c 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/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/tests/src/BaseUnitTrait.php b/tests/src/BaseUnitTrait.php index 13749b34..1a646117 100644 --- a/tests/src/BaseUnitTrait.php +++ b/tests/src/BaseUnitTrait.php @@ -9,7 +9,7 @@ use ItalyStrap\Customizer\FieldControlFactory; use ItalyStrap\Empress\AurynConfigInterface; use ItalyStrap\Empress\Injector; -use ItalyStrap\Event\EventDispatcherInterface; +use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use ItalyStrap\Event\SubscriberRegisterInterface; use ItalyStrap\Finder\FileInfoFactoryInterface; use ItalyStrap\Finder\FinderInterface; @@ -193,6 +193,6 @@ abstract protected function getInstance(); */ public function itShouldBeInstantiable() { - $sut = $this->getInstance(); + $sut = $this->makeInstance(); } } From f6df4646e53d80908359b60ebe21b5e788172503 Mon Sep 17 00:00:00 2001 From: Enea Date: Tue, 10 Mar 2026 12:30:39 +0100 Subject: [PATCH 03/23] Refactor namespace imports in ThemeJson.php --- src/Asset/ThemeJson.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Asset/ThemeJson.php b/src/Asset/ThemeJson.php index 7eac7684..d8e72349 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 { From 6304ad15f20630a811b0acb4facf5fe727d0fba1 Mon Sep 17 00:00:00 2001 From: Enea Date: Wed, 11 Mar 2026 06:53:59 +0100 Subject: [PATCH 04/23] Add return type declaration to __invoke method in Footer.php --- src/UI/Components/Footer/Footer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From 3cf5084680e87f753205abde8d954a99ca1e2842 Mon Sep 17 00:00:00 2001 From: Enea Date: Wed, 11 Mar 2026 06:54:50 +0100 Subject: [PATCH 05/23] Refactor condition to check for empty colophon content --- src/UI/Components/Footer/Colophon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From 4a9dda5b4812078020cf82d185a58c7338edd341 Mon Sep 17 00:00:00 2001 From: Enea Date: Wed, 11 Mar 2026 06:55:19 +0100 Subject: [PATCH 06/23] Update composer.json for stability and dependency adjustments --- composer.json | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) 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", From 121fb8eb8323d0250044be40bc27bb132dab18cb Mon Sep 17 00:00:00 2001 From: Enea Date: Wed, 11 Mar 2026 06:56:49 +0100 Subject: [PATCH 07/23] Add 'None' option to ExperimentalCustomizerOptionWithAndPositionSubscriber --- .../ExperimentalCustomizerOptionWithAndPositionSubscriber.php | 1 + 1 file changed, 1 insertion(+) 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'), From 835a6fb33c35fa380cd7e93dabb811abd152b56c Mon Sep 17 00:00:00 2001 From: Enea Date: Wed, 11 Mar 2026 06:57:57 +0100 Subject: [PATCH 08/23] Refactor appendContent method to improve variable naming and comment out event handling --- .../ExperimentalHookComponentsDeprecationSubscriber.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php b/src/Experimental/ExperimentalHookComponentsDeprecationSubscriber.php index 07e7d34d..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()); } From e61f78d05fa3c8f2dea90a2ea3a34532bd025c13 Mon Sep 17 00:00:00 2001 From: Enea Date: Wed, 11 Mar 2026 21:46:46 +0100 Subject: [PATCH 09/23] Remove version specification from docker-compose.yml --- .docker/docker-compose.yml | 1 - 1 file changed, 1 deletion(-) 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: From f18ed18eda9f7efee750fdb6a6ca62b45173cfc3 Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 08:11:33 +0100 Subject: [PATCH 10/23] Add restart and ssh targets to Makefile for container management --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) 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 From 54d81a78e72ade1625492ead7ccc6de70d47fce8 Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 11:54:54 +0100 Subject: [PATCH 11/23] Enable cache path in FunctionMocker initialization and restore WP_Customize_Manager class definition --- tests/unit/bootstrap.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index e2829ebd..b1c5c41a 100644 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -8,7 +8,7 @@ FunctionMocker::init([ 'blacklist' => dirname(__DIR__), -// 'cache-path' => dirname(__DIR__) . '/_output/patchwork-cache', + 'cache-path' => codecept_output_dir('patchwork-cache'), ]); /** Stubs */ @@ -18,16 +18,16 @@ public function display(string $header) { } } -//if ( ! \class_exists( 'WP_Customize_Manager' ) ) { -// class WP_Customize_Manager { -// public function get_setting(string $string) { -// return new \stdClass(); -// } -// public function get_section(string $string) { -// return new \stdClass(); -// } -// public function add_setting(string $string, array $array) { -// return $this; -// } -// } -//} +if ( ! \class_exists( 'WP_Customize_Manager' ) ) { + class WP_Customize_Manager { + public function get_setting(string $string) { + return new \stdClass(); + } + public function get_section(string $string) { + return new \stdClass(); + } + public function add_setting(string $string, array $array) { + return $this; + } + } +} From 6c8ebe42f9ebf92803bc79606c4c9f567bf2ae1a Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 14:03:16 +0100 Subject: [PATCH 12/23] Refactor BaseUnitTrait: update method signatures and format namespace imports --- tests/src/BaseUnitTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/BaseUnitTrait.php b/tests/src/BaseUnitTrait.php index 1a646117..8c605d2f 100644 --- a/tests/src/BaseUnitTrait.php +++ b/tests/src/BaseUnitTrait.php @@ -4,11 +4,11 @@ namespace ItalyStrap\Tests; +use Auryn\Injector; use ItalyStrap\Asset\Infrastructure\InlineStyleGenerator; use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Customizer\FieldControlFactory; use ItalyStrap\Empress\AurynConfigInterface; -use ItalyStrap\Empress\Injector; use ItalyStrap\Event\GlobalDispatcherInterface as EventDispatcherInterface; use ItalyStrap\Event\SubscriberRegisterInterface; use ItalyStrap\Finder\FileInfoFactoryInterface; @@ -157,7 +157,7 @@ protected function _after() { $this->tearDownProphet(); } - private function setUpProphet() + private function setUpProphet(): void { $this->prophet = new Prophet(); $this->config = $this->prophet->prophesize(ConfigInterface::class); @@ -191,7 +191,7 @@ abstract protected function getInstance(); /** * @test */ - public function itShouldBeInstantiable() + public function itShouldBeInstantiable(): void { $sut = $this->makeInstance(); } From b997b6854214d00f0972d9a398b855a8cec80b9a Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 16:32:30 +0100 Subject: [PATCH 13/23] Refactor injector classes to remove EmpressInjector dependency --- src/Debug/Injector.php | 3 +-- tests/src/UnitTestCase.php | 2 +- tests/unit/functions/FactoryInjectorTest.php | 10 +++------- 3 files changed, 5 insertions(+), 10 deletions(-) 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/tests/src/UnitTestCase.php b/tests/src/UnitTestCase.php index f4b1ec00..07651aa8 100644 --- a/tests/src/UnitTestCase.php +++ b/tests/src/UnitTestCase.php @@ -4,12 +4,12 @@ namespace ItalyStrap\Tests; +use Auryn\Injector; use Codeception\Test\Unit; use ItalyStrap\Asset\Infrastructure\InlineStyleGenerator; use ItalyStrap\Config\ConfigInterface; use ItalyStrap\Customizer\FieldControlFactory; use ItalyStrap\Empress\AurynConfigInterface; -use ItalyStrap\Empress\Injector; use ItalyStrap\Event\GlobalDispatcherInterface; use ItalyStrap\Event\ListenerRegisterInterface; use ItalyStrap\Event\SubscriberRegisterInterface; diff --git a/tests/unit/functions/FactoryInjectorTest.php b/tests/unit/functions/FactoryInjectorTest.php index 6adf5262..c1cc9c23 100644 --- a/tests/unit/functions/FactoryInjectorTest.php +++ b/tests/unit/functions/FactoryInjectorTest.php @@ -6,7 +6,6 @@ use Auryn\Injector as AurynInjector; use ItalyStrap\Debug\Injector as DebugInjector; -use ItalyStrap\Empress\Injector as EmpressInjector; use ItalyStrap\Tests\UnitTestCase; use function ItalyStrap\Factory\injector; @@ -75,7 +74,6 @@ public function instanceOkWithFilterFalse() $this->assertEquals(1, $this->add_filter_called, 'Add filter should be called'); $this->assertInstanceOf(AurynInjector::class, $injector, ''); - $this->assertInstanceOf(EmpressInjector::class, $injector, ''); $this->assertNotInstanceOf(DebugInjector::class, $injector, ''); } @@ -94,27 +92,25 @@ public function instanceOkWithFilterReturnPrevInstanceOfAuryn() $this->assertEquals(0, $this->add_filter_called, 'Add filter should NOT be called'); $this->assertInstanceOf(AurynInjector::class, $injector, ''); - $this->assertNotInstanceOf(EmpressInjector::class, $injector, ''); $this->assertNotInstanceOf(DebugInjector::class, $injector, ''); } /** * */ - public function instanceOkWithFilterReturnPrevInstanceOfEmpress() + public function instanceOkWithFilterReturnPrevInstanceOfDebugInjector() { $this->is_debug = false; replace('\ItalyStrap\Core\is_debug', $this->is_debug); - $this->injectorFactory = new EmpressInjector(); + $this->injectorFactory = new DebugInjector(new AurynInjector()); $injector = injector(); $this->assertEquals(1, $this->apply_filters_called, 'Apply filters should be called'); $this->assertEquals(0, $this->add_filter_called, 'Add filter should NOT be called'); $this->assertInstanceOf(AurynInjector::class, $injector, ''); - $this->assertInstanceOf(EmpressInjector::class, $injector, ''); - $this->assertNotInstanceOf(DebugInjector::class, $injector, ''); + $this->assertInstanceOf(DebugInjector::class, $injector, ''); } /** From 31be50a6251ade2e5c1ac4f01da6644696447ca1 Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 16:33:17 +0100 Subject: [PATCH 14/23] Implement listener register mock in ComponentSubscriberExtensionTest --- .../ComponentSubscriberExtensionTest.php | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/tests/unit/UI/Infrastructure/ComponentSubscriberExtensionTest.php b/tests/unit/UI/Infrastructure/ComponentSubscriberExtensionTest.php index c105728e..83afb493 100644 --- a/tests/unit/UI/Infrastructure/ComponentSubscriberExtensionTest.php +++ b/tests/unit/UI/Infrastructure/ComponentSubscriberExtensionTest.php @@ -5,6 +5,7 @@ namespace ItalyStrap\Tests\Unit\UI\Infrastructure; use ItalyStrap\Empress\Extension; +use ItalyStrap\Event\ListenerRegisterInterface; use ItalyStrap\Tests\UnitTestCase; use ItalyStrap\UI\Components\Main\Main; use ItalyStrap\UI\Infrastructure\ComponentSubscriberExtension; @@ -27,17 +28,52 @@ public function testItShouldHaveName() public function testItShouldExecute() { - $this->markTestSkipped('TODO'); - $sut = $this->makeInstance(); + $listenerRegister = new class implements ListenerRegisterInterface { + public string $eventName = ''; + public $listener = null; + public int $priority = 0; + public int $acceptedArgs = 0; + + public function addListener( + string $eventName, + callable $listener, + int $priority = self::PRIORITY, + int $accepted_args = self::ACCEPTED_ARGS + ): bool { + $this->eventName = $eventName; + $this->listener = $listener; + $this->priority = $priority; + $this->acceptedArgs = $accepted_args; + + return true; + } + + public function removeListener(string $eventName, callable $listener, int $priority): bool + { + return true; + } - $this->listenerRegister->addListener( - Argument::type('string'), - Argument::type('callable'), - Argument::type('int'), - Argument::type('int') - )->shouldBeCalledOnce(); + public function removeAllListener(string $eventName, $priority = false): bool + { + return true; + } + public function hasListener(string $eventName, $callback = false) + { + return false; + } + }; + + $sut = new ComponentSubscriberExtension($this->makeSubscriberRegister(), $listenerRegister); + + $this->aurynConfigInterface->walk(ComponentSubscriberExtension::class, $sut)->shouldBeCalledTimes(2); $sut->execute($this->makeAurynConfigInterface()); + + $this->assertSame('template_include', $listenerRegister->eventName, ''); + $this->assertIsCallable($listenerRegister->listener); + $this->assertSame(PHP_INT_MAX - 5, $listenerRegister->priority, ''); + $this->assertSame(ListenerRegisterInterface::ACCEPTED_ARGS, $listenerRegister->acceptedArgs, ''); + $this->assertSame('index.php', ($listenerRegister->listener)('index.php')); } public function testItShouldWalk() From 6392058d4aebdd342e671c400dc2e25cfc2bb814 Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 16:33:36 +0100 Subject: [PATCH 15/23] Exclude test output directory from PHPCS checks --- phpcs.xml | 1 + 1 file changed, 1 insertion(+) 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/* From 6c3df353b0b42ecc042f9a5c4f8936235d0a88f8 Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 16:34:46 +0100 Subject: [PATCH 16/23] Refactor Search class to use ViewBlockInterface and update related tests --- src/UI/Elements/Search.php | 6 +++--- templates/elements/search.php | 6 +++--- tests/functional/SearchCest.php | 15 +++++++++++++++ tests/integration/UI/Elements/SearchTest.php | 10 ++++++++++ tests/unit/UI/Elements/SearchTest.php | 2 +- 5 files changed, 32 insertions(+), 7 deletions(-) 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/templates/elements/search.php b/templates/elements/search.php index c99e689c..bbedc2e5 100644 --- a/templates/elements/search.php +++ b/templates/elements/search.php @@ -5,9 +5,9 @@ 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' ), + '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/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(' -
+
@@ -42,4 +44,3 @@ dispatch(new Footer()); ?> - 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()); ?> - From 6f7201ecba2894d307cc6b98fced3782567c2461 Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 17:16:21 +0100 Subject: [PATCH 22/23] Update event name in Pagination class to use PostsContentAfter --- src/Navigation/UI/Components/Pagination.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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'; From e8223d207038fe369492a6842b7d558253b77b77 Mon Sep 17 00:00:00 2001 From: Enea Date: Thu, 12 Mar 2026 17:46:46 +0100 Subject: [PATCH 23/23] chore: update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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