diff --git a/.gitignore b/.gitignore index 73be39be..ec6a16a4 100644 --- a/.gitignore +++ b/.gitignore @@ -164,6 +164,7 @@ fabric.properties !.vscode/launch.json !.vscode/extensions.json !.vscode/*.code-snippets +!.vscode/*.code-workspace # Local History for Visual Studio Code .history/ diff --git a/.vscode/wp-starter.code-workspace b/.vscode/wp-starter.code-workspace new file mode 100644 index 00000000..8bf5a3c6 --- /dev/null +++ b/.vscode/wp-starter.code-workspace @@ -0,0 +1,13 @@ +{ + "folders": [ + { + "path": "../" + } + ], + "settings": { + "files.trimTrailingWhitespace": true, + "files.associations": { + "*.css": "tailwindcss" + } + } +} \ No newline at end of file diff --git a/bin/composer-scripts/ProjectEvents/PostCreateProjectScript.php b/bin/composer-scripts/ProjectEvents/PostCreateProjectScript.php index 9fb2f384..661d3286 100644 --- a/bin/composer-scripts/ProjectEvents/PostCreateProjectScript.php +++ b/bin/composer-scripts/ProjectEvents/PostCreateProjectScript.php @@ -335,6 +335,16 @@ public static function updateProjectFiles(): void { } } + $defaultWorkspace = self::translatePath( '.vscode/' . self::$defaults['theme-slug'] . '.code-workspace' ); + $projectWorkspace = self::translatePath( '.vscode/' . self::$info['slug'] . '.code-workspace' ); + + // Change the project workspace name. + if ( ! rename( $defaultWorkspace, $projectWorkspace ) ) { + self::writeError( 'Failed to rename project workspace.' ); + } else { + self::writeInfo( 'Project workspace name changed.' ); + } + self::writeInfo( 'Project files updated!' ); } @@ -543,7 +553,7 @@ private static function removeGithubFiles(): void { $deployFile = self::translatePath( '.github/workflows/deploy.yaml', true ); if ( ! file_exists( $deployFile ) ) { - self::writeWarning( 'Deployment script not found. Skipping removal.' ); + self::writeWarning( sprintf( 'Deployment script not found (%s). Skipping removal.', $deployFile ) ); } else { unlink( $deployFile ); self::writeInfo( 'Deployment script removed.' ); @@ -552,12 +562,19 @@ private static function removeGithubFiles(): void { $componentTemplate = self::translatePath( '.github/ISSUE_TEMPLATE/new-component-ticket.md', true ); if ( ! file_exists( $componentTemplate ) ) { - self::writeWarning( 'Component Issue template not found. Skipping removal.' ); + self::writeWarning( sprintf( 'Component Issue template not found (%s). Skipping removal.', $componentTemplate ) ); } else { unlink( $componentTemplate ); self::writeInfo( 'Component Issue template removed.' ); } + $releaseFile = self::translatePath( '.github/workflows/release.yaml', true ); + if ( ! file_exists( $releaseFile ) ) { + self::writeWarning( sprintf( 'Release script not found (%s). Skipping removal.', $releaseFile ) ); + } else { + unlink( $releaseFile ); + self::writeInfo( 'Release script removed.' ); + } } } diff --git a/bin/composer-scripts/ProjectEvents/PostInstallScript.php b/bin/composer-scripts/ProjectEvents/PostInstallScript.php index 81c0efba..2d4b857c 100644 --- a/bin/composer-scripts/ProjectEvents/PostInstallScript.php +++ b/bin/composer-scripts/ProjectEvents/PostInstallScript.php @@ -55,14 +55,12 @@ class PostInstallScript extends ComposerScript { * @var array */ private static array $activatePlugins = [ - 'accessibility-checker' => 'Accessibility Checker', 'viget-blocks-toolkit' => [ 'name' => 'Viget Blocks Toolkit', 'dependencies' => [ 'advanced-custom-fields-pro' => 'Advanced Custom Fields Pro', ], ], - 'seo-by-rank-math' => 'Rank Math SEO', 'safe-svg' => 'Safe SVG', ]; diff --git a/bin/composer-scripts/ProjectEvents/PreScripts.php b/bin/composer-scripts/ProjectEvents/PreScripts.php index af732b0a..9625d880 100644 --- a/bin/composer-scripts/ProjectEvents/PreScripts.php +++ b/bin/composer-scripts/ProjectEvents/PreScripts.php @@ -67,7 +67,7 @@ public static function preUpdate( Event $event ): void { */ private static function checkRepoPlugins(): void { foreach ( self::$repoPlugins as $packageName => $pluginDir ) { - $pluginGitDir = self::translatePath( 'wp-content/plugins/' . $pluginDir . '/.git' ); + $pluginGitDir = self::translatePath( 'wp-content/plugins/' . $pluginDir . '/.git', true ); if ( is_dir( $pluginGitDir ) ) { self::writeInfo( sprintf( 'Skipping installation of %s: directory containing repository exists.', $packageName ) ); diff --git a/wp-content/themes/wp-starter/.phpcs.xml b/wp-content/themes/wp-starter/.phpcs.xml index 45998c2d..602f433e 100644 --- a/wp-content/themes/wp-starter/.phpcs.xml +++ b/wp-content/themes/wp-starter/.phpcs.xml @@ -44,33 +44,17 @@ ############################################################################# --> - - - - - + + + - - + + - @@ -112,7 +96,6 @@ - @@ -121,6 +104,7 @@ + diff --git a/wp-content/themes/wp-starter/blocks/alert-banner/block.php b/wp-content/themes/wp-starter/blocks/alert-banner/block.php index 97a19f4f..b3a0dda5 100644 --- a/wp-content/themes/wp-starter/blocks/alert-banner/block.php +++ b/wp-content/themes/wp-starter/blocks/alert-banner/block.php @@ -5,14 +5,16 @@ * @package WPStarter */ +namespace WPStarter\AlertBanner; + /** * Alert Banner Dismiss Button * - * @param string $id Alert Banner ID + * @param string $id Alert Banner ID. * * @return void */ -function alert_banner_dismiss_button( string $id ): void { +function dismiss_button( string $id ): void { printf( '', esc_attr__( 'Dismiss alert banner', 'wp-starter' ), @@ -20,3 +22,30 @@ function alert_banner_dismiss_button( string $id ): void { esc_attr( $id ) ); } + +/** + * Get the ID for the Alert Banner. + * + * @param array $block The block array. + * + * @return string + */ +function get_id( array $block ): string { + return str_replace( '-', '_', get_block_id( $block ) ); +} + +// Make functions available in Twig. +add_filter( + 'timber/twig/functions', + function ( array $functions ) { + $functions['wpstarter_alertbanner_dismiss_button'] = [ + 'callable' => '\\WPStarter\\AlertBanner\\dismiss_button', + ]; + + $functions['wpstarter_alertbanner_get_id'] = [ + 'callable' => '\\WPStarter\\AlertBanner\\get_id', + ]; + + return $functions; + } +); diff --git a/wp-content/themes/wp-starter/blocks/alert-banner/render.php b/wp-content/themes/wp-starter/blocks/alert-banner/render.php index 47d45be5..8f000634 100644 --- a/wp-content/themes/wp-starter/blocks/alert-banner/render.php +++ b/wp-content/themes/wp-starter/blocks/alert-banner/render.php @@ -7,20 +7,25 @@ * @package WPStarter */ -$id = 'alert' . $block['block_id'] ?? $block['id']; -$inner = [ +use function WPStarter\AlertBanner\dismiss_button; +use function WPStarter\AlertBanner\get_id; + +$id = get_id( $block ); // phpcs:ignore +$inner = [ // phpcs:ignore 'template' => $block['template'] ?? [], ]; -$attrs = []; +$attrs = [ // phpcs:ignore + 'id' => $id, +]; if ( ! is_admin() ) { - $attrs['x-data'] = '{ ' . $id . ': $persist(true) }'; - $attrs['x-show'] = $id; + $attrs['x-data'] = '{ ' . $id . ': $persist(true) }'; // phpcs:ignore + $attrs['x-show'] = $id; // phpcs:ignore } ?>
>
- +
diff --git a/wp-content/themes/wp-starter/blocks/alert-banner/render.twig b/wp-content/themes/wp-starter/blocks/alert-banner/render.twig index 8b61ac64..9c61cf72 100644 --- a/wp-content/themes/wp-starter/blocks/alert-banner/render.twig +++ b/wp-content/themes/wp-starter/blocks/alert-banner/render.twig @@ -2,29 +2,27 @@ Block: Alert Banner #} -{% set id = 'alert' ~ block.id %} - -{% if block.block_id is not empty %} - {% set id = 'alert' ~ block.block_id %} -{% endif %} +{% set id = wpstarter_alertbanner_get_id(block) %} {% set inner = { template: block.template ?? [], } %} -{% set attrs = {} %} +{% set attrs = { + 'id': id +} %} {% if function('is_admin') == false %} - {% set attrs = { + {% set attrs = attrs|merge({ 'x-data': '{ ' ~ id ~ ': $persist(true) }', - 'x-show': id - } %} + 'x-show': '"' ~ id ~ '"' + }) %} {% endif %} -
+
{{ inner_blocks( inner ) }}
- {{ function( 'alert_banner_dismiss_button', id ) }} + {{ wpstarter_alertbanner_dismiss_button(id) }}
diff --git a/wp-content/themes/wp-starter/blocks/breadcrumbs/block.php b/wp-content/themes/wp-starter/blocks/breadcrumbs/block.php index 077821d2..f924708e 100644 --- a/wp-content/themes/wp-starter/blocks/breadcrumbs/block.php +++ b/wp-content/themes/wp-starter/blocks/breadcrumbs/block.php @@ -31,10 +31,11 @@ function () { /** * Breadcrumbs Output * - * @param array $block_template + * @param ?array $block_template The block template array. + * * @return void */ -function wpstarter_breadcrumbs( array|null $block_template = [] ): void { +function wpstarter_breadcrumbs( ?array $block_template = [] ): void { if ( function_exists( 'rank_math_the_breadcrumbs' ) ) { rank_math_the_breadcrumbs(); return; diff --git a/wp-content/themes/wp-starter/blocks/breadcrumbs/render.php b/wp-content/themes/wp-starter/blocks/breadcrumbs/render.php index ed970746..d5c7d9f8 100644 --- a/wp-content/themes/wp-starter/blocks/breadcrumbs/render.php +++ b/wp-content/themes/wp-starter/blocks/breadcrumbs/render.php @@ -7,7 +7,8 @@ * @package WPStarter */ +$template = $block['template'] ?? []; // phpcs:ignore ?>
> - +
diff --git a/wp-content/themes/wp-starter/blocks/breadcrumbs/render.twig b/wp-content/themes/wp-starter/blocks/breadcrumbs/render.twig index b02db3b8..c15a1649 100644 --- a/wp-content/themes/wp-starter/blocks/breadcrumbs/render.twig +++ b/wp-content/themes/wp-starter/blocks/breadcrumbs/render.twig @@ -2,6 +2,7 @@ Block: Breadcrumbs #} +{% set template = block.template ?? [] }
- {{ function( 'wpstarter_breadcrumbs', block.template ) }} + {{ function( 'wpstarter_breadcrumbs', template ) }}
diff --git a/wp-content/themes/wp-starter/blocks/image-caption/render.php b/wp-content/themes/wp-starter/blocks/image-caption/render.php index c4537fd3..539c140f 100644 --- a/wp-content/themes/wp-starter/blocks/image-caption/render.php +++ b/wp-content/themes/wp-starter/blocks/image-caption/render.php @@ -7,7 +7,7 @@ * @package WPStarter */ -$inner = [ +$inner = [ // phpcs:ignore 'template' => $block['template'] ?? [], 'templateLock' => 'all', ]; diff --git a/wp-content/themes/wp-starter/blocks/navigation-container/render.php b/wp-content/themes/wp-starter/blocks/navigation-container/render.php index 1eafe4a5..5a95ece1 100644 --- a/wp-content/themes/wp-starter/blocks/navigation-container/render.php +++ b/wp-content/themes/wp-starter/blocks/navigation-container/render.php @@ -7,12 +7,7 @@ * @package WPStarter */ -$attrs = [ - 'x-data="{menuIsOpen : false}"', - 'x-trap="menuIsOpen"', -]; - -$allowed = [ +$allowed = [ // phpcs:ignore 'core/group', 'core/paragraph', 'core/site-logo', @@ -23,16 +18,16 @@ 'core/spacer', 'core/separator', ]; - -$block_template = [ - [ - 'core/navigation', - ], -]; -$inner = [ - 'template' => $block_template, +$inner = [ // phpcs:ignore + 'template' => $block['template'] ?? [], 'allowedBlocks' => $allowed, ]; +$attrs = []; // phpcs:ignore + +if ( ! is_admin() ) { + $attrs['x-data'] = '{menuIsOpen : false}'; // phpcs:ignore + $attrs['x-trap'] = 'menuIsOpen'; // phpcs:ignore +} ?>
> diff --git a/wp-content/themes/wp-starter/blocks/navigation-container/render.twig b/wp-content/themes/wp-starter/blocks/navigation-container/render.twig index 9f9ff0af..f8146a06 100644 --- a/wp-content/themes/wp-starter/blocks/navigation-container/render.twig +++ b/wp-content/themes/wp-starter/blocks/navigation-container/render.twig @@ -1,11 +1,7 @@ {# Block: Navigation Container #} -{% set template = [ - [ - 'core/navigation' - ] -] %} + {% set allowed = [ 'core/group', 'core/paragraph', @@ -18,10 +14,9 @@ 'core/separator' ] %} {% set inner = { - template: template, + template: block.template ?? [], allowedBlocks: allowed } %} - {% set attrs = {} %} {% if function('is_admin') == false %} diff --git a/wp-content/themes/wp-starter/blocks/navigation-container/template.json b/wp-content/themes/wp-starter/blocks/navigation-container/template.json new file mode 100644 index 00000000..3f704ba7 --- /dev/null +++ b/wp-content/themes/wp-starter/blocks/navigation-container/template.json @@ -0,0 +1,5 @@ +{ + "template": [ + [ "core/navigation" ] + ] +} diff --git a/wp-content/themes/wp-starter/blocks/video-player/block.php b/wp-content/themes/wp-starter/blocks/video-player/block.php index d3523e3b..fa6cc71c 100644 --- a/wp-content/themes/wp-starter/blocks/video-player/block.php +++ b/wp-content/themes/wp-starter/blocks/video-player/block.php @@ -12,7 +12,7 @@ function () { } ); -// Enable the YT JSON API +// Enable the YT JSON API. add_filter( 'embed_oembed_html', function ( string $code ): string { @@ -25,18 +25,20 @@ function ( string $code ): string { ); add_filter( - 'vgtbt_button_icons', + 'vgtbt_block_icons', function ( array $icons ): array { - $block_dir = dirname( __FILE__ ); - $play_icon_path = $block_dir . '/images/video-play-button.svg'; + $play_icon_path = __DIR__ . '/images/video-play-button.svg'; - return array_merge([ - 'video-play-button' => [ - 'label' => __( 'Video Play Button', 'wp-starter' ), - 'icon' => file_get_contents( $play_icon_path ), - 'defaultLeft' => false, + return array_merge( + [ + 'video-play-button' => [ + 'label' => __( 'Video Play Button', 'wp-starter' ), + 'icon' => file_get_contents( $play_icon_path ), + 'defaultLeft' => false, + ], ], - ], $icons ); + $icons + ); }, 9 ); diff --git a/wp-content/themes/wp-starter/blocks/video-player/render.php b/wp-content/themes/wp-starter/blocks/video-player/render.php index f6ebe26e..8ba2ca94 100644 --- a/wp-content/themes/wp-starter/blocks/video-player/render.php +++ b/wp-content/themes/wp-starter/blocks/video-player/render.php @@ -7,13 +7,17 @@ * @package WPStarter */ -$attrs = []; -$inner = [ - 'template' => $block['template'] ?? [], +$attrs = []; // phpcs:ignore +$inner = [ // phpcs:ignore + 'template' => $block['template'] ?? [], + 'allowedBlocks' => [ + 'core/cover', + 'core/embed', + ], ]; -if ( ! is_admin() ) { - $attrs['x-data'] = 'playvideo'; +if ( ! is_admin() ) { + $attrs['x-data'] = 'playvideo'; // phpcs:ignore } ?>
> diff --git a/wp-content/themes/wp-starter/blocks/video-player/render.twig b/wp-content/themes/wp-starter/blocks/video-player/render.twig index 37cfb81b..1e0a8918 100644 --- a/wp-content/themes/wp-starter/blocks/video-player/render.twig +++ b/wp-content/themes/wp-starter/blocks/video-player/render.twig @@ -2,18 +2,15 @@ Block: Video Player #} -{% set allowed = [ - 'core/cover', - 'core/embed' -] %} - +{% set attrs = {} %} {% set inner = { template: block.template ?? [], - allowedBlocks: allowed + allowedBlocks: [ + 'core/cover', + 'core/embed' + ] } %} -{% set attrs = {} %} - {% if function('is_admin') == false %} {% set attrs = { 'x-data': 'playvideo', diff --git a/wp-content/themes/wp-starter/composer.json b/wp-content/themes/wp-starter/composer.json index d4cd2d66..f8e6e4a9 100644 --- a/wp-content/themes/wp-starter/composer.json +++ b/wp-content/themes/wp-starter/composer.json @@ -29,6 +29,8 @@ "squizlabs/php_codesniffer": "^3.11", "timber/timber": "^2.3", "viget/viget-blocks-toolkit": "^1.0", + "viget/viget-form-blocks": "^0.0.1", + "viget/viget-parts-kit": "^1.0", "wpackagist-plugin/accessibility-checker": "^1.17", "wpackagist-plugin/safe-svg": "^2.3", "wpackagist-plugin/seo-by-rank-math": "^1.0", diff --git a/wp-content/themes/wp-starter/composer.lock b/wp-content/themes/wp-starter/composer.lock index f1a940a8..647a553f 100644 --- a/wp-content/themes/wp-starter/composer.lock +++ b/wp-content/themes/wp-starter/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "87c8541027cb975d50ccb30daaa5a567", + "content-hash": "9cb1de6d0a61c67a963d39be6fce9509", "packages": [ { "name": "composer/installers", @@ -1189,6 +1189,99 @@ }, "time": "2025-01-15T00:25:05+00:00" }, + { + "name": "viget/viget-form-blocks", + "version": "0.0.1", + "source": { + "type": "git", + "url": "https://github.com/vigetlabs/viget-form-blocks.git", + "reference": "318220f4d366a029aacdf0c259f19bbac310d8f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vigetlabs/viget-form-blocks/zipball/318220f4d366a029aacdf0c259f19bbac310d8f3", + "reference": "318220f4d366a029aacdf0c259f19bbac310d8f3", + "shasum": "" + }, + "require": { + "composer/installers": "*" + }, + "type": "wordpress-plugin", + "autoload": { + "psr-4": { + "VigetFormBlocks\\": "classes/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Viget", + "homepage": "https://viget.com/" + } + ], + "description": "Create forms in Gutenberg with ACF Blocks by Viget.", + "homepage": "https://github.com/vigetlabs/viget-form-blocks", + "keywords": [ + "Forms", + "editor", + "gutenberg", + "plugin", + "wordpress" + ], + "support": { + "issues": "https://github.com/vigetlabs/viget-form-blocks/issues", + "source": "https://github.com/vigetlabs/viget-form-blocks/tree/v0.0.1" + }, + "time": "2025-01-22T23:15:04+00:00" + }, + { + "name": "viget/viget-parts-kit", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/vigetlabs/viget-parts-kit.git", + "reference": "0a556f1952c121dcf5756ad80debb1490ce1768c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vigetlabs/viget-parts-kit/zipball/0a556f1952c121dcf5756ad80debb1490ce1768c", + "reference": "0a556f1952c121dcf5756ad80debb1490ce1768c", + "shasum": "" + }, + "require": { + "composer/installers": "*" + }, + "type": "wordpress-plugin", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Viget", + "homepage": "https://viget.com/" + } + ], + "description": "Component Parts Kit integration for WordPress made by Viget.", + "homepage": "https://github.com/vigetlabs/viget-parts-kit", + "keywords": [ + "blocks", + "components", + "directory", + "editor", + "gutenberg", + "index", + "wordpress" + ], + "support": { + "issues": "https://github.com/vigetlabs/viget-parts-kit/issues", + "source": "https://github.com/vigetlabs/viget-parts-kit/tree/v1.0.1" + }, + "time": "2025-01-22T23:17:36+00:00" + }, { "name": "wpackagist-plugin/accessibility-checker", "version": "1.17.0", diff --git a/wp-content/themes/wp-starter/functions.php b/wp-content/themes/wp-starter/functions.php index c52d9ccb..5f505cb4 100644 --- a/wp-content/themes/wp-starter/functions.php +++ b/wp-content/themes/wp-starter/functions.php @@ -5,6 +5,8 @@ * @package WPStarter */ +namespace WPStarter; + // Maybe Load Composer dependencies. if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { require_once __DIR__ . '/vendor/autoload.php'; @@ -12,13 +14,13 @@ // Init Vite. require_once get_stylesheet_directory() . '/inc/class-vite.php'; -if ( class_exists( 'Vite' ) ) { +if ( class_exists( __NAMESPACE__ . '\Vite' ) ) { new Vite(); } // Maybe Initialize Timber. -if ( class_exists( 'Timber\Timber' ) ) { - Timber\Timber::init(); +if ( class_exists( '\Timber\Timber' ) ) { + \Timber\Timber::init(); } // Block Functions. diff --git a/wp-content/themes/wp-starter/inc/blocks.php b/wp-content/themes/wp-starter/inc/blocks.php index 61c5097e..5f94f642 100644 --- a/wp-content/themes/wp-starter/inc/blocks.php +++ b/wp-content/themes/wp-starter/inc/blocks.php @@ -5,6 +5,8 @@ * @package WPStarter */ +namespace WPStarter; + // Add Components block Category. add_filter( 'block_categories_all', @@ -23,11 +25,11 @@ function ( array $categories ): array { // Disable some of the default core blocks. add_filter( 'allowed_block_types_all', - function ( array|bool $allowed_block_types, WP_Block_Editor_Context $context ): array|bool { + function ( array|bool $allowed_block_types, \WP_Block_Editor_Context $context ): array|bool { // TODO: Maybe filter by $context. if ( ! is_array( $allowed_block_types ) ) { - $allowed_block_types = array_keys( WP_Block_Type_Registry::get_instance()->get_all_registered() ); + $allowed_block_types = array_keys( \WP_Block_Type_Registry::get_instance()->get_all_registered() ); } $removed_blocks = [ diff --git a/wp-content/themes/wp-starter/inc/class-vite.php b/wp-content/themes/wp-starter/inc/class-vite.php index e5518d6f..84592c94 100644 --- a/wp-content/themes/wp-starter/inc/class-vite.php +++ b/wp-content/themes/wp-starter/inc/class-vite.php @@ -1,63 +1,83 @@ site_url = get_site_url(); @@ -69,10 +89,10 @@ public function __construct() { $this->env = getenv( 'ENVIRONMENT' ); - // set frontend css/js + // Set front-end CSS/JS. $this->entries['default'] = 'main.js'; - // set editor css/js + // Set editor CSS/JS. $this->entries['editor'] = 'main.js'; add_action( 'wp_head', [ $this, 'init' ], 100 ); @@ -82,7 +102,6 @@ public function __construct() { function () { $screen = get_current_screen(); if ( $screen->is_block_editor ) { - // $this->init(); // This breaks the block editor styles. $this->init( 'editor' ); } } @@ -110,7 +129,7 @@ public function init( string $entry = '' ): void { $this->initialized = true; /* Print Vite HTML tags */ - echo $this->vite( $this->get_entry( $entry ) ); + echo $this->vite( $this->get_entry( $entry ) ); // phpcs:ignore } /** @@ -165,10 +184,10 @@ public function vite( string $entry ) { $scripts = []; if ( ! $this->initialized ) { - $scripts[] = ""; + $scripts[] = ""; // phpcs:ignore } - $scripts[] = ""; + $scripts[] = ""; // phpcs:ignore return implode( PHP_EOL, $scripts ); } @@ -198,7 +217,7 @@ private function js( string $entry ): string { return ''; } - return sprintf( '', esc_url( $url ) ); + return sprintf( '', esc_url( $url ) ); // phpcs:ignore } /** @@ -229,7 +248,7 @@ private function css( string $entry ): string { $tags = ''; foreach ( $this->get_css( $entry ) as $url ) { - $tags .= sprintf( '', esc_url( $url ) ); + $tags .= sprintf( '', esc_url( $url ) ); // phpcs:ignore } return $tags; @@ -265,13 +284,13 @@ function () { return []; } - $content = file_get_contents( $manifest ); + $contents = file_get_contents( $manifest ); - if ( ! $content ) { - die( 'Error: The manifest.json file is empty.' ); + if ( ! $contents ) { + die( esc_html__( 'Error: The manifest.json file is empty or doesn\'t exist.', 'wp-starter' ) ); } - return json_decode( $content, true ); + return json_decode( $contents, true ); } /** @@ -285,7 +304,7 @@ private function get_asset_url( string $entry ): string { $manifest = $this->get_manifest(); if ( ! isset( $manifest[ $entry ] ) ) { - die( "Could not find entry in manifest for $entry" ); + die( esc_html__( 'Could not find entry in manifest for', 'wp-starter' ) . ' ' . esc_html( $entry ) ); } return $this->dist_url . $manifest[ $entry ]['file']; @@ -345,7 +364,7 @@ public function script_loader( string $tag, string $handle, string $src ): strin return $tag; } - return sprintf( '', esc_url( $src ) ); + return sprintf( '', esc_url( $src ) ); // phpcs:ignore } /** diff --git a/wp-content/themes/wp-starter/inc/icons.php b/wp-content/themes/wp-starter/inc/icons.php index 46d52428..7d7dd3f3 100644 --- a/wp-content/themes/wp-starter/inc/icons.php +++ b/wp-content/themes/wp-starter/inc/icons.php @@ -5,30 +5,34 @@ * @package WPStarter */ +namespace WPStarter; + /** * Add custom icons to the button icons array. * Place your custom icon(s) in the `src/images/icons` directory. * Then add the icon(s) to the array, the key and label should be unique for each icon. */ - add_filter( - 'vgtbt_button_icons', + 'vgtbt_block_icons', function ( array $icons ): array { $icon_path = get_stylesheet_directory() . '/src/images/icons/'; - /* Remove unused default icons */ - // unset( $icons['wordpress'] ); + /* Remove unused default icons. */ + unset( $icons['wordpress'] ); - return array_merge([ - /* Custom Icons */ - /* Be sure icon fill color is set to `currentColor` */ - /* - 'our-custom-icon' => [ - 'label' => __( 'your custom icon', 'wp-starter' ), - 'icon' => file_get_contents( $icon_path . 'file-name.svg' ), - 'defaultLeft' => false, + return array_merge( + [ + // Add Custom Icons. + /* Be sure icon fill color is set to `currentColor`. */ + /* + 'our-custom-icon' => [ + 'label' => __( 'your custom icon', 'wp-starter' ), + 'icon' => file_get_contents( $icon_path . 'file-name.svg' ), + 'defaultLeft' => false, + ], + */ ], - */ - ], $icons ); + $icons + ); } );