diff --git a/.docker/.env b/.docker/.env
index 6fa5f89c..5a33b925 100644
--- a/.docker/.env
+++ b/.docker/.env
@@ -1,32 +1,19 @@
-COMPOSE_PROJECT_NAME=italystrap
-PROJECT_NAME=italystrap
-PHP_VERSION=7.4
-WP_VERSION=6.0
-WP_PORT_TEST=8888
-DB_PORT_TEST=8889
-PMA_PORT_TEST=8890
+# Docker only
+PROJECT_NAME="italystrap"
+PHP_VERSION="7.4"
+WP_VERSION="6.0"
-DB_HOST=mysql
-DB_NAME=test
-DB_USER=root
-DB_PASSWORD=root
-TABLE_PREFIX=wp_
+WP_PORT=8888
+DB_PORT=8889
+PMA_PORT=8890
-TEST_SITE_DB_DSN=mysql:host=localhost;dbname=test
-WP_ROOT_FOLDER="/tmp/wordpress"
-TEST_SITE_WP_ADMIN_PATH="/wp-admin"
-TEST_SITE_DB_NAME="test"
-TEST_SITE_DB_HOST="localhost"
-TEST_SITE_DB_USER="root"
-TEST_SITE_DB_PASSWORD="root"
-TEST_SITE_TABLE_PREFIX="wp_"
-TEST_DB_NAME="test"
-TEST_DB_HOST="localhost"
-TEST_DB_USER="root"
-TEST_DB_PASSWORD="root"
-TEST_TABLE_PREFIX="wp_"
-TEST_SITE_WP_URL="http://wp.localhost"
-TEST_SITE_WP_DOMAIN="wp.localhost"
-TEST_SITE_ADMIN_EMAIL="admin@wp.localhost"
-TEST_SITE_ADMIN_USERNAME="admin"
-TEST_SITE_ADMIN_PASSWORD="password"
\ No newline at end of file
+# Docker and Codeception
+DB_NAME="test"
+DB_HOST="mysql"
+DB_USER="root"
+DB_PASSWORD="root"
+
+# Functional tests
+APP_URL=http://localhost
+ADMIN_USERNAME=root
+ADMIN_PASSWORD=root
diff --git a/.docker/codecept b/.docker/codecept
old mode 100644
new mode 100755
index cd578182..fa3eb03b
--- a/.docker/codecept
+++ b/.docker/codecept
@@ -1,3 +1,6 @@
#!/usr/bin/env bash
-docker exec -w //var/www/html/wp-content/themes/italystrap italystrap_test sh -c "vendor/bin/codecept ${*}"
+# Get project name from .env file
+PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')
+
+docker exec -w /var/www/html/wp-content/themes/"${PROJECT_NAME}" "${PROJECT_NAME}"_test sh -c "vendor/bin/codecept ${*}"
\ No newline at end of file
diff --git a/.docker/composer b/.docker/composer
old mode 100644
new mode 100755
index bd804ad9..c8ebad53
--- a/.docker/composer
+++ b/.docker/composer
@@ -1,3 +1,6 @@
#!/usr/bin/env bash
-docker-compose run -w //var/www/html/wp-content/themes/italystrap --rm wordpress sh -c "composer ${*}"
+# Get project name from .env file
+PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')
+
+docker-compose run -w /var/www/html/wp-content/themes/"${PROJECT_NAME}" --rm wordpress sh -c "composer ${*}"
diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml
index cb7903f1..69671cfb 100644
--- a/.docker/docker-compose.yml
+++ b/.docker/docker-compose.yml
@@ -10,7 +10,7 @@ services:
container_name: ${PROJECT_NAME:-wordpress}_test
restart: always
ports:
- - ${WP_PORT_TEST}:80
+ - ${WP_PORT}:80
environment:
WORDPRESS_DB_HOST: ${DB_HOST:-mysql}
WORDPRESS_DB_NAME: ${DB_NAME:-test}
@@ -20,46 +20,28 @@ services:
WORDPRESS_DEBUG: 1
volumes:
- ../:/var/www/html/wp-content/themes/${PROJECT_NAME:-wordpress}
+ - ../tests/_output/:/var/www/html/wp-content/themes/${PROJECT_NAME:-wordpress}/tests/_output/
+ - ./codeception.yml:/var/www/html/wp-content/themes/${PROJECT_NAME:-wordpress}/codeception.yml
#- ./mu-plugins/:/var/www/html/wp-content/mu-plugins/
depends_on:
- mysql
networks:
- wpbrowser:
-# aliases:
-# - wp
-
-# https://mklasen.com/adding-and-using-wp-cli-in-a-docker-compose-setup/
-# wpcli:
-# container_name: ${PROJECT_NAME:-wp-cli}-cli_test
-# depends_on:
-# - wordpress
-# image: wordpress:cli
-## user: 1000:1000
-# command: tail -f /dev/null
-# volumes:
-# - wordpress:/var/www/html
-# environment:
-# WORDPRESS_DB_HOST: ${NAME}-db:3306
-# WORDPRESS_DB_USER: ${DB_USER}
-# WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
-# WORDPRESS_DB_NAME: ${DB_NAME}
-# profiles:
-# - dev
+ integration_test_networks:
mysql:
image: mysql:${DB_VERSION:-5.7}
container_name: ${PROJECT_NAME:-wordpress}_mysql_test
restart: always
ports:
- - ${DB_PORT_TEST}:3306
+ - ${DB_PORT}:3306
environment:
MYSQL_DATABASE: ${DB_NAME:-test}
- #MYSQL_USER: ${TEST_SITE_DB_USER:-root}
+ #MYSQL_USER: ${DB_USER:-root}
MYSQL_PASSWORD: ${DB_PASSWORD:-root}
#MYSQL_RANDOM_ROOT_PASSWORD: '1'
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
networks:
- - wpbrowser
+ - integration_test_networks
phpmyadmin:
depends_on:
@@ -68,14 +50,14 @@ services:
container_name: ${PROJECT_NAME}_phpmyadmin_test
restart: always
ports:
- - ${PMA_PORT_TEST}:80
+ - ${PMA_PORT}:80
environment:
# For max upload from PHPMYADMIN https://github.com/10up/wp-local-docker-v2/issues/40#issuecomment-719915040
UPLOAD_LIMIT: 1G
PMA_HOST: ${DB_HOST:-mysql}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
networks:
- - wpbrowser
+ - integration_test_networks
chromedriver:
image: selenium/standalone-chrome:4.6.0-20221104
@@ -85,8 +67,8 @@ services:
- "4444:4444"
- "7900:7900"
networks:
- - wpbrowser
+ - integration_test_networks
networks:
- wpbrowser:
+ integration_test_networks:
driver: bridge
diff --git a/.docker/ssh b/.docker/ssh
old mode 100644
new mode 100755
index 51bc0abe..aaae7896
--- a/.docker/ssh
+++ b/.docker/ssh
@@ -1,3 +1,6 @@
#!/usr/bin/env bash
-docker exec -it -w //var/www/html/wp-content/themes/italystrap italystrap_test sh
+# Get project name from .env file
+PROJECT_NAME=$(grep PROJECT_NAME .env | cut -d '=' -f2 | tr -d '"')
+
+docker exec -it -w //var/www/html/wp-content/themes/"${PROJECT_NAME}" "${PROJECT_NAME}"_test sh
diff --git a/.docker/wordpress/Dockerfile b/.docker/wordpress/Dockerfile
index 0bfc4fbf..f2014b35 100644
--- a/.docker/wordpress/Dockerfile
+++ b/.docker/wordpress/Dockerfile
@@ -3,6 +3,20 @@ ARG WP_VERSION
FROM wordpress:${WP_VERSION}-php${PHP_VERSION}
+# Install pcov for code coverage
+RUN set -eux; \
+ pecl install pcov; \
+ docker-php-ext-enable pcov
+
+# If you want to use xdebug, uncomment the following lines
+# Install xdebug for code coverage
+#RUN set -eux; \
+# pecl install xdebug-3.1.4; \
+# docker-php-ext-enable xdebug
+
+# Set XDEBUG_MODE=coverage or xdebug.mode=coverage
+#ENV XDEBUG_MODE=coverage
+
RUN set -eux; \
apt-get update && apt-get install -y \
git \
@@ -10,6 +24,9 @@ RUN set -eux; \
less # Needed for the WP-CLI \
rm -rf /var/lib/apt/lists/*
+# Git add safe directory for the working directory
+
+
# Needed for Db driver
# https://github.com/Codeception/Codeception/issues/3605
RUN docker-php-ext-install \
diff --git a/.docker/wp b/.docker/wp
deleted file mode 100644
index b2c7801c..00000000
--- a/.docker/wp
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-
-docker exec -w /var/www/html/wp-content/plugins/mhh-extended-links mhh-extended-links_test sh -c "wp ${*} --allow-root"
diff --git a/.env b/.env
index 6cd3f106..9d355fbe 100644
--- a/.env
+++ b/.env
@@ -1,7 +1,9 @@
TEST=test
COMPOSE_PROJECT_NAME=italystrap
PROJECT_NAME=italystrap
+FOLDER_NAME=italystrap
PHP_VERSION=7.4
+MATRIX_PHP_VERSION=80
WP_VERSION=6.0
WP_PORT_TEST=8888
DB_PORT_TEST=8889
@@ -19,14 +21,13 @@ TABLE_PREFIX=wp_
TESTS_DIR=tests/php
-#WP_ROOT_FOLDER="../../../"
-WP_ROOT_FOLDER="/var/www/html"
+WP_ROOT_FOLDER="../../../"
# WPUnit Suite config
WPUNIT_ROOT_FOLDER="../../../"
-#WPUNIT_ROOT_FOLDER="/var/www/html"
+
WPUNIT_DB_NAME=test
-WPUNIT_DB_HOST=mysql
+WPUNIT_DB_HOST=localhost
WPUNIT_DB_USER=root
WPUNIT_DB_PASSWORD=root
WPUNIT_TABLE_PREFIX=wp_
@@ -34,48 +35,27 @@ WPUNIT_SITE_WP_DOMAIN=localhost.local
WPUNIT_SITE_ADMIN_EMAIL=admin@localhost.local
# Functional and Acceptance Unit Suite config for WPDB driver
-WPDB_DB_DSN=mysql:host=mysql;dbname=test
+WPDB_DB_DSN=mysql:host=localhost;dbname=test
WPDB_DB_USER=root
WPDB_DB_PASSWORD=root
# This is the url inside the container
-WPDB_WP_URL=http://localhost
-WPDB_WP_DOMAIN=localhost
+WPDB_WP_URL=http://localhost:8888
+#WPDB_WP_DOMAIN=localhost:8888
WPDB_TABLE_PREFIX=wp_
WPDB_DUMP_FILE="tests/_data/dump.sql"
# Functional and Acceptance Unit Suite config for WPBrowser driver
# This is the url inside the container
-WPBROWSER_WP_URL=http://localhost
-#WPBROWSER_ADMIN_USERNAME=root
-#WPBROWSER_ADMIN_PASSWORD=root
-WPBROWSER_ADMIN_USERNAME=admin
-WPBROWSER_ADMIN_PASSWORD=password
+WPBROWSER_WP_URL=http://localhost:8888
+WPBROWSER_ADMIN_USERNAME=root
+WPBROWSER_ADMIN_PASSWORD=root
WPBROWSER_WP_ADMIN_PATH=/wp-admin
# Used only for acceptance.suite.yml tests inside WPWebDriver configuration.
# The value must be the name of the WordPress container
# for resolving the correct IP of the machine if you use Docker as environment.
# This will be also used for replace the hardcoded dump URL with the one below
-CHROMEDRIVER_WP_URL="http://italystrap_test"
+CHROMEDRIVER_WP_URL="http://localhost:8888"
# This must be the name of the Selenium container
-CHROMEDRIVER_HOST=chromedriver
+CHROMEDRIVER_HOST=localhost
CHROMEDRIVER_PORT="4444"
-
-#TEST_SITE_DB_DSN=mysql:host=localhost;dbname=test
-#WP_ROOT_FOLDER="/tmp/wordpress"
-#TEST_SITE_WP_ADMIN_PATH="/wp-admin"
-#TEST_SITE_DB_NAME="test"
-#TEST_SITE_DB_HOST="localhost"
-#TEST_SITE_DB_USER="root"
-#TEST_SITE_DB_PASSWORD="root"
-#TEST_SITE_TABLE_PREFIX="wp_"
-#TEST_DB_NAME="test"
-#TEST_DB_HOST="localhost"
-#TEST_DB_USER="root"
-#TEST_DB_PASSWORD="root"
-#TEST_TABLE_PREFIX="wp_"
-#TEST_SITE_WP_URL="http://wp.localhost"
-#TEST_SITE_WP_DOMAIN="wp.localhost"
-#TEST_SITE_ADMIN_EMAIL="admin@wp.localhost"
-#TEST_SITE_ADMIN_USERNAME="admin"
-#TEST_SITE_ADMIN_PASSWORD="password"
\ No newline at end of file
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
new file mode 100644
index 00000000..573e9af1
--- /dev/null
+++ b/.github/workflows/integration.yml
@@ -0,0 +1,106 @@
+name: CI
+
+env:
+ REPOSITORY_NAME: italystrap
+ PROJECT_KIND: themes
+ DB_HOST: localhost
+ DB_NAME: test
+ DB_USER: root
+ DB_PASSWORD: root
+ TABLE_PREFIX: wp_
+ APP_FOLDER_PATH: /tmp/app
+ APP_PORT: 8888
+ APP_HOST: localhost
+ APP_USER: root
+ APP_PASSWORD: root
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+
+ workflow_dispatch:
+
+jobs:
+
+ tests:
+ name: 🐘 Tests on PHP ${{matrix.php_versions}} & APP version ${{matrix.app_versions}}
+
+ strategy:
+ matrix:
+ php_versions: ['8']
+ app_versions: ['6.0']
+
+ runs-on: ubuntu-latest
+ continue-on-error: ${{ matrix.php_versions == '8.2' }}
+ if: "!contains(github.event.head_commit.message, '--skip ci') && !github.event.pull_request.draft"
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Start Selenium for using later
+ run: docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.6.0-20221104
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{matrix.php_versions}}
+
+ - name: Start MySQL
+ run: |
+ sudo systemctl start mysql.service
+ mysql -e "CREATE DATABASE IF NOT EXISTS ${{env.DB_NAME}};" -u${{env.DB_USER}} -p${{env.DB_PASSWORD}}
+
+ - name: Install CLI
+ run: |
+ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
+ chmod +x wp-cli.phar
+ sudo mv wp-cli.phar /usr/local/bin/wp
+ wp cli info
+
+ - name: Create folder for running the App
+ run: mkdir -p ${{env.APP_FOLDER_PATH}}
+
+ - name: Install App
+ working-directory: ${{env.APP_FOLDER_PATH}}
+ run: |
+ wp core download --version="${{matrix.app_versions}}"
+ wp config create --dbname="${{env.DB_NAME}}" --dbuser="${{env.DB_USER}}" --dbpass="${{env.DB_PASSWORD}}" --dbhost="${{env.DB_HOST}}" --dbprefix="${{env.TABLE_PREFIX}}"
+ wp core install --url="${{env.APP_HOST}}:${{env.APP_PORT}}" --title="Test" --admin_user="${{env.APP_USER}}" --admin_password="${{env.APP_PASSWORD}}" --admin_email="${{env.APP_USER}}@${{env.APP_HOST}}.test" --skip-email
+ wp core update-db
+ cp -r $GITHUB_WORKSPACE ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
+
+ - uses: "ramsey/composer-install@v2"
+ with:
+ working-directory: "${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}"
+
+ - name: Activate ${{env.REPOSITORY_NAME}}
+ working-directory: ${{env.APP_FOLDER_PATH}}
+ run: |
+ wp plugin deactivate --all
+ wp site empty --yes
+ wp theme activate ${{env.REPOSITORY_NAME}}
+ wp theme list --status=active
+ chmod -R 777 wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
+ ls -la wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
+ wp db export wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}/tests/_data/dump.sql
+
+ - name: Build codeception
+ working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
+ run: ./vendor/bin/codecept build
+
+ - name: Run Unit & Integration test
+ working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
+ run: |
+ ./vendor/bin/codecept run unit
+ ./vendor/bin/codecept run integration
+
+ - name: Start dev server
+ run: php -S ${{env.APP_HOST}}:${{env.APP_PORT}} -t ${{env.APP_FOLDER_PATH}} >/dev/null 2>&1 &
+
+ - name: Run Functional and Acceptance test
+ working-directory: ${{env.APP_FOLDER_PATH}}/wp-content/${{env.PROJECT_KIND}}/${{env.REPOSITORY_NAME}}
+ run: |
+ ./vendor/bin/codecept run functional --debug
+ ./vendor/bin/codecept run acceptance --debug
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index e769d17d..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,126 +0,0 @@
-# https://www.theaveragedev.com/installing-and-setting-up-wordpress-and-nginx-for-travis-ci-tests/
-
-language: php
-
-notifications:
- email: false
-
-php:
- - 7.2
- - nightly
-
-matrix:
- fast_finish: true
- allow_failures:
- - php: nightly
- - env: WP_VERSION=nightly
-
-services:
- - mysql
-
-cache:
- apt: true
- directories:
- - $HOME/.composer/cache
-
-addons:
- apt:
- packages:
- - libjpeg-dev
- - libpng12-dev
- - php7.0-fpm
- - php7.0-mysql
- - nginx
- hosts:
- - wp.localhost
-
-env:
- global:
- - WP_FOLDER="/tmp/wordpress"
- - WP_URL="http://wp.localhost"
- - WP_DOMAIN="wp.localhost"
- - DB_NAME="test"
- - TEST_DB_NAME="wploader"
- - WP_TABLE_PREFIX="wp_"
- - WP_ADMIN_USERNAME="admin"
- - WP_ADMIN_PASSWORD="admin"
- matrix:
- - WP_VERSION=latest
- - WP_VERSION=nightly
-
-before_install:
- # create the databases that will be used in the tests
- - mysql -e "create database IF NOT EXISTS $DB_NAME;" -uroot
- - mysql -e "create database IF NOT EXISTS $TEST_DB_NAME;" -uroot
- # set up folders
- - mkdir -p $WP_FOLDER
- - mkdir tools
- # install wp-cli in the `tools` folder
- - wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P $(pwd)/tools/
- - chmod +x tools/wp-cli.phar && mv tools/wp-cli.phar tools/wp
- # append the `tools` folder to the PATH
- - export PATH=$PATH:$(pwd)/tools
- # prepend the `vendor/bin` folder the PATH
- - export PATH=vendor/bin:$PATH
-
-install:
- # install WordPress
- - cd $WP_FOLDER
- - ls
- - wp core download --version=$WP_VERSION
- - wp config create --dbname="$DB_NAME" --dbuser="root" --dbpass="" --dbhost="127.0.0.1" --dbprefix="$WP_TABLE_PREFIX"
- - wp core install --url="$WP_URL" --title="Test" --admin_user="$WP_ADMIN_USERNAME" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="admin@$WP_DOMAIN" --skip-email
- - wp rewrite structure '/%postname%/' --hard
- # update WordPress database to avoid prompts
- - wp core update-db
- # copy the theme in the WordPress themes folder
- - cp -r $TRAVIS_BUILD_DIR $WP_FOLDER/wp-content/themes/italystrap
- # show the themes folder contents to make sure the theme folder is there
- - cd $WP_FOLDER/wp-content/themes/italystrap
- - |
- if [ $TRAVIS_PHP_VERSION = 'nightly' ]; then
- composer install --prefer-dist --no-suggest --ignore-platform-reqs;
- else
- composer install --prefer-dist --no-suggest
- fi
- - ls -l
- # activate the theme
- - wp theme activate italystrap
- # make sure the theme is active on the site
- - wp theme list --status=active
- # export a dump of the just installed database to the _data folder
- - wp db export $TRAVIS_BUILD_DIR/tests/_data/dump.sql
- # get back to the build folder
- - cd $TRAVIS_BUILD_DIR
- - |
- if [ $TRAVIS_PHP_VERSION = 'nightly' ]; then
- composer install --prefer-dist --no-suggest --ignore-platform-reqs;
- else
- composer install --prefer-dist --no-suggest
- fi
- - ls -l
- # open up the site folder to allow the PHP application to read/write/execute on it
- - sudo chmod -R 777 $WP_FOLDER
- # copy the Nginx configuration file to the available sites
- #- sudo cp build/travis-nginx-conf /etc/nginx/sites-available/$WP_DOMAIN
- #- sudo sed -e "s?%WP_FOLDER%?$WP_FOLDER?g" --in-place /etc/nginx/sites-available/$WP_DOMAIN
- #- sudo sed -e "s?%WP_DOMAIN%?$WP_DOMAIN?g" --in-place /etc/nginx/sites-available/$WP_DOMAIN
- # enable the site
- - sudo ln -s /etc/nginx/sites-available/$WP_DOMAIN /etc/nginx/sites-enabled/
-
-before_script:
- # restart Nnginx and PHP-FPM services
- - sudo service php7.0-fpm restart
- - sudo service nginx restart
-
- # build Codeception modules
- - codecept build
-
-script:
- - find ./config/ ./functions/ ./src/ ./templates/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
- - vendor/bin/phpcs --ignore=./tests/_support/* ./config/ ./functions/ ./src/ ./templates/ ./tests/
- - vendor/bin/phpstan analyze
-# - vendor/bin/psalm
- - codecept run wpunit && codecept run unit --coverage-text
-# - vendor/bin/infection --threads=4
-# - vendor/bin/phpbench run --report=performance
\ No newline at end of file
diff --git a/404.php b/404.php
index 71394282..93b63f46 100644
--- a/404.php
+++ b/404.php
@@ -1,4 +1,5 @@
make( EventDispatcherInterface::class );
+/** @var ListenerRegisterInterface $listenerRegister */
+$listenerRegister = $injector->make(ListenerRegisterInterface::class);
/** @var ConfigInterface $config */
$config = $injector->make(ConfigInterface::class);
@@ -105,7 +106,7 @@
addListener(
+ $listenerRegister->addListener(
'comment_form_comments_closed',
static function () {
echo '
';
diff --git a/composer.json b/composer.json
index ac138d6b..01261e7c 100644
--- a/composer.json
+++ b/composer.json
@@ -32,7 +32,7 @@
],
"require": {
"php" : ">=7.4",
- "italystrap/empress": "^2.0.0",
+ "italystrap/empress": "dev-modularized",
"italystrap/event": "dev-master",
"italystrap/config": "^2.0",
"italystrap/helpers": "^1.0",
@@ -43,7 +43,8 @@
"rdlowrey/auryn": "^1.4",
"overclokk/minimum-requirements": "dev-master",
"cmb2/cmb2": "2.6.0",
- "yiisoft/json": "^1.0"
+ "yiisoft/json": "^1.0",
+ "symfony/polyfill-php80": "^1.0"
},
"require-dev": {
"lucatume/wp-browser": "^3.0.0",
@@ -58,32 +59,40 @@
"codeception/module-cli": "^1.0",
"codeception/util-universalframework": "^1.0",
"phpspec/prophecy-phpunit": "^2.0.0",
- "italystrap/debug": "^2.0",
+
+ "italystrap/debug": "dev-master",
"italystrap/theme-json-generator": "dev-master",
+
"squizlabs/php_codesniffer": "*",
"phpcompatibility/php-compatibility": "*",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
- "phpstan/phpstan": "^1.8.2",
- "szepeviktor/phpstan-wordpress": "^v1.1.0",
+
"vimeo/psalm": "^4.8",
+ "humanmade/psalm-plugin-wordpress": "^2.0",
+
"phpbench/phpbench": "@dev",
"infection/infection": "^0.25.0",
"infection/codeception-adapter": "^0.4.0",
+
"phpmetrics/phpmetrics": "^2.7.0",
"brianium/paratest": "^6.0.0",
+
"symfony/asset": "^5.0",
"inpsyde/assets": "^2.1",
"downshiftorg/wp-http": "^2.0",
"wordpress/wordpress": "dev-master",
- "humanmade/psalm-plugin-wordpress": "^2.0",
"monolog/monolog": "^2.3",
"franzl/studio": "^0.15.0",
"rector/rector": "^0.14.0",
- "hoa/console": "^3.17"
+ "hoa/console": "^3.17",
+ "fig/event-dispatcher-util": "^1.0"
},
"autoload": {
"psr-4": {
- "ItalyStrap\\": "src/"
+ "ItalyStrap\\": [
+ "src/",
+ "tests/_data/Experimental/src/"
+ ]
},
"files": [
"functions/core-booleans.php",
@@ -96,11 +105,15 @@
]
},
"autoload-dev": {
- "classmap": [
- "tests/"
- ],
"psr-4": {
- "ItalyStrap\\Tests\\": "tests/"
+ "ItalyStrap\\Tests\\": [
+ "tests/src",
+ "tests/_data/fixtures/src"
+ ],
+ "ItalyStrap\\Tests\\Unit\\": "tests/unit",
+ "ItalyStrap\\Tests\\Integration\\": "tests/integration",
+ "ItalyStrap\\Tests\\Functional\\": "tests/functional",
+ "ItalyStrap\\Tests\\Acceptance\\": "tests/acceptance"
}
},
"extra": {
@@ -108,7 +121,7 @@
"vendor/{$name}/": ["cmb2/cmb2"]
},
"theme-json": {
- "callable": "\\ItalyStrap\\Asset\\JsonData::getJsonData",
+ "callable": "\\ItalyStrap\\Asset\\ThemeJson::writeJson",
"path-for-theme-sass": "assets/sass/"
}
},
@@ -127,58 +140,58 @@
"@infection"
],
"cs": [
- "vendor\\bin\\phpcbf -p --ignore=./tests/_support/* ./config/ ./functions/ ./src/ ./templates/ ./tests/ && vendor\\bin\\phpcs -p --ignore=./tests/_support/* ./config/ ./functions/ ./src/ ./templates/ ./tests/"
+ "@php vendor/bin/phpcs -p"
],
- "psalm": [
- "vendor\\bin\\psalm --no-cache"
+ "cs:fix": [
+ "@php vendor/bin/phpcbf -p"
],
- "phpstan": [
- "vendor\\bin\\phpstan analyze --level=max"
+ "psalm": [
+ "@php vendor//bin//psalm --no-cache"
],
"analyze": [
- "vendor\\bin\\phpstan analyze --level=max && vendor\\bin\\psalm"
+ "@php vendor//bin//phpstan analyze --level=max && vendor//bin//psalm"
],
"infection": [
- "vendor\\bin\\infection --threads=8"
+ "@php vendor//bin//infection --threads=8"
],
"unit": [
- "vendor\\bin\\codecept run unit",
+ "@php vendor//bin//codecept run unit",
"@clean"
],
"unit:cov": [
- "vendor\\bin\\codecept run unit --coverage",
+ "@php vendor//bin//codecept run unit --coverage",
"@clean"
],
"unit:debug": [
- "vendor\\bin\\codecept run unit --debug",
+ "@php vendor//bin//codecept run unit --debug",
"@clean"
],
- "wpunit": [
- "vendor\\bin\\codecept run wpunit",
+ "integration": [
+ "@php vendor//bin//codecept run integration",
"@clean"
],
- "wpunit:debug": [
- "vendor\\bin\\codecept run wpunit --debug",
+ "integration:debug": [
+ "@php vendor//bin//codecept run integration --debug",
"@clean"
],
"functional": [
- "vendor\\bin\\codecept run functional"
+ "@php vendor//bin//codecept run functional"
],
"bench": [
- "vendor\\bin\\phpbench run --report=performance"
+ "@php vendor//bin//phpbench run --report=performance"
],
"metrics": [
- "vendor\\bin\\phpmetrics --report-html='./tests/_output/report' ./src",
+ "@php vendor//bin//phpmetrics --report-html='./tests/_output/report' ./src",
"@clean"
],
"insights": [
- "vendor\\bin\\phpinsights"
+ "@php vendor//bin//phpinsights"
],
"clean": [
- "vendor\\bin\\codecept clean"
+ "@php vendor//bin//codecept clean"
],
"rector": [
- "vendor\\bin\\rector process src"
+ "@php vendor//bin//rector process src"
],
"theme:json": [
"\\ItalyStrap\\ThemeJsonGenerator\\Composer\\Plugin::run"
diff --git a/composer.phar b/composer.phar
deleted file mode 100644
index 3fb713fd..00000000
Binary files a/composer.phar and /dev/null differ
diff --git a/config/assets/scripts.php b/config/assets/scripts.php
index 6e5cf51d..e3ff99fe 100644
--- a/config/assets/scripts.php
+++ b/config/assets/scripts.php
@@ -1,4 +1,5 @@
CURRENT_TEMPLATE_SLUG,
- AssetConfigBuilder::FILE_NAME => experimental_generate_asset_index_filename( 'js' ),
-// Asset::DEPENDENCIES => ['jquery'],
- Asset::IN_FOOTER => true,
- Asset::LOCALIZE => [
- Script::OBJECT_NAME => 'pluginParams',
- Script::PARAMS => [
- 'ajaxurl' => admin_url( '/admin-ajax.php' ),
- 'ajaxnonce' => wp_create_nonce( 'ajaxnonce' ),
- // 'api_endpoint' => site_url( '/wp-json/rest/v1/' ),
- ],
- ],
- ],
+ [
+ Asset::HANDLE => CURRENT_TEMPLATE_SLUG,
+ AssetConfigBuilder::FILE_NAME => experimental_generate_asset_index_filename('js'),
+// Asset::DEPENDENCIES => ['jquery'],
+ Asset::IN_FOOTER => true,
+ Asset::LOCALIZE => [
+ Script::OBJECT_NAME => 'pluginParams',
+ Script::PARAMS => [
+ 'ajaxurl' => admin_url('/admin-ajax.php'),
+ 'ajaxnonce' => wp_create_nonce('ajaxnonce'),
+ // 'api_endpoint' => site_url( '/wp-json/rest/v1/' ),
+ ],
+ ],
+ ],
];
diff --git a/config/assets/styles.php b/config/assets/styles.php
index 9a211ee9..0283ffb0 100644
--- a/config/assets/styles.php
+++ b/config/assets/styles.php
@@ -1,16 +1,18 @@
CURRENT_TEMPLATE_SLUG,
- AssetConfigBuilder::FILE_NAME => experimental_generate_asset_index_filename( 'css' ),
- ],
+ [
+ Asset::HANDLE => CURRENT_TEMPLATE_SLUG,
+ AssetConfigBuilder::FILE_NAME => experimental_generate_asset_index_filename('css'),
+ ],
];
diff --git a/config/autoload/components.global.php b/config/autoload/components.global.php
deleted file mode 100644
index e4c06b69..00000000
--- a/config/autoload/components.global.php
+++ /dev/null
@@ -1,128 +0,0 @@
- [
- AuthorInfo::class,
- ],
-
- AurynConfig::ALIASES => [
-
- ],
-
- AurynConfig::DEFINITIONS => [
-
- \ItalyStrap\Components\Navigations\Navbar::class => [
- ':fallback_cb' => [ \ItalyStrap\Navbar\BootstrapNavMenu::class, 'fallback' ],
- ],
-
- NavMenuPrimary::class => [
- '+fallback' => static function ( string $named_param, Injector $injector ): callable {
- return $injector->make( NavMenuFallback::class );
- },
- ],
- ],
-
- /**
- * ========================================================================
- *
- * Components Subscriber Classes
- *
- * ========================================================================
- */
- ComponentSubscriberExtension::class => [
-
- Breadcrumbs::class,
-
- PostAuthorInfo::class,
- ArchiveAuthorInfo::class,
- ArchiveHeadline::class,
-
- FeaturedImage::class,
- Title::class,
- Meta::class,
- Preview::class,
- Content::class,
- Excerpt::class,
- Modified::class,
- Pager::class,
- Pagination::class,
-// BlockQuery::class,
-
- Sidebar::class,
-
- Entry::class,
-
- EntryNoneImage::class,
- EntryNoneTitle::class,
- EntryNoneContent::class,
- EntryNone::class,
-
- Loop::class,
-
- SiteLogo::class,
- SiteTitle::class,
-// SiteTagline::class,
-
- MiscNavigation::class,
- CustomHeaderImage::class,
-
- NavMenuToggleButton::class,
- NavMenuHeader::class,
- NavMenuPrimary::class,
- NavMenuSecondary::class,
- MainNavigationOlder::class,
-// MainNavigation::class,
-
- Comments::class,
- Colophon::class,
- Header::class,
- FooterWidgetArea::class,
- Footer::class,
- Index::class => Index::class,
- ],
-];
diff --git a/config/autoload/config.global.php b/config/autoload/config.global.php
index e8d24ec9..b141f7cb 100644
--- a/config/autoload/config.global.php
+++ b/config/autoload/config.global.php
@@ -1,48 +1,34 @@
[
- ConfigThemeModsProvider::class => [
- '+theme_mods' => static function () {
- return (array) \get_theme_mods();
- },
- ],
- ],
-
- ConfigProviderExtension::class => [
- ConfigThemeProvider::class,
- ConfigCustomHeaderProvider::class,
- ConfigSiteLogoProvider::class,
- ConfigColorSectionProvider::class,
- ConfigMiscProvider::class,
- ConfigNavigationProvider::class,
- ConfigColophonProvider::class,
+ AurynConfig::DEFINITIONS => [
+ ConfigThemeModsProvider::class => [
+ '+theme_mods' => static function () {
+ return (array) \get_theme_mods();
+ },
+ ],
+ ],
- ConfigNotFoundProvider::class,
- ConfigPostThumbnailProvider::class,
- ConfigThemeSupportProvider::class,
- ConfigPostTypeSupportProvider::class,
- ConfigSidebarProvider::class,
+ ConfigProviderExtension::class => [
+ ConfigCustomHeaderProvider::class,
+ ConfigSiteLogoProvider::class,
+ ConfigColorSectionProvider::class,
+ ConfigMiscProvider::class,
+ ConfigColophonProvider::class,
- /** This must run after all */
- ConfigThemeModsProvider::class,
- ],
+ ConfigNotFoundProvider::class,
+ ],
];
diff --git a/config/autoload/customizer.global.php b/config/autoload/customizer.global.php
index 4a43b9fd..6df74f53 100644
--- a/config/autoload/customizer.global.php
+++ b/config/autoload/customizer.global.php
@@ -1,4 +1,5 @@
[
- SiteLogoFields::class,
- BreadcrumsFields::class,
- CustomCssFields::class,
- SiteIdentityFields::class,
- PanelFields::class,
- BetaFields::class,
- ColorFields::class,
- ColophonFields::class,
- CustomHeaderFields::class,
- LayoutFields::class,
- NavbarFields::class,
- PostThumbnailFields::class,
- PostContentTemplateFields::class,
- NotFoundFields::class,
- ],
- SubscribersConfigExtension::SUBSCRIBERS => [
- DefaultPostThumbnailSubscriber::class,
- ThemeSubmenuPageSubscriber::class,
- ],
+ CustomizerProviderExtension::class => [
+ SiteLogoFields::class,
+ BreadcrumsFields::class,
+ CustomCssFields::class,
+ SiteIdentityFields::class,
+ PanelFields::class,
+ BetaFields::class,
+ ColorFields::class,
+ ColophonFields::class,
+ CustomHeaderFields::class,
+ LayoutFields::class,
+ NavbarFields::class,
+ PostThumbnailFields::class,
+ PostContentTemplateFields::class,
+ NotFoundFields::class,
+ ],
+ SubscribersConfigExtension::SUBSCRIBERS => [
+ DefaultPostThumbnailSubscriber::class,
+ ThemeSubmenuPageSubscriber::class,
+ ],
];
diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php
index a88bb5ed..a579d1c5 100644
--- a/config/autoload/dependencies.global.php
+++ b/config/autoload/dependencies.global.php
@@ -1,287 +1,185 @@
[
- EventDispatcher::class,
- SubscriberRegister::class,
-
- /**
- * Make sure the config is shared.
- * Already shared in bootstrap.php or in ACM if is active.
- */
- Config::class,
-
- Attributes::class,
- Tag::class,
- View\View::class,
-
- ImageSizeInterface::class,
-
- \WP_Theme::class,
- \WP_Query::class,
- ],
-
- /**
- * ==========================================================
- *
- * Autoload Aliases Class
- *
- * string
- *
- * ==========================================================
- */
- AurynConfig::ALIASES => [
- EventDispatcherInterface::class => EventDispatcher::class,
- SubscriberRegisterInterface::class => SubscriberRegister::class,
-
- ConfigInterface::class => Config::class,
-
- AttributesInterface::class => Attributes::class,
- TagInterface::class => Tag::class,
-
- FileInfoFactoryInterface::class => FileInfoFactory::class,
- SearchFileStrategy::class => FilesHierarchyIterator::class,
- FinderInterface::class => Finder::class,
-
- ViewInterface::class => View\View::class,
-
- ImageSizeInterface::class => ImageSize::class,
-
- NavMenuLocationInterface::class => NavMenuLocation::class,
- NavMenuInterface::class => NavMenu::class,
-
- Walker_Nav_Menu::class => Navbar\BootstrapNavMenu::class,
- ],
-
- /**
- * ==========================================================
- *
- * Autoload Classes definitions
- *
- * @example :
- * 'walker' => '\NameSpace\ClassName',
- * ':walker' => new \NameSpace\ClassName(),
- * '+walker' => function () {
- * return new \NameSpace\ClassName();
- * },
- *
- * ==========================================================
- */
- AurynConfig::DEFINITIONS => [
- View\View::class => [
- '+finder' => static function ( string $named_param, Injector $injector ): FinderInterface {
- $config = $injector->make( ConfigInterface::class );
-
- $stylesheet_dir = $config->get( \ItalyStrap\Config\ConfigThemeProvider::STYLESHEET_DIR );
- $template_dir = $config->get( \ItalyStrap\Config\ConfigThemeProvider::TEMPLATE_DIR );
- $view_dir = $config->get( \ItalyStrap\Config\ConfigThemeProvider::VIEW_DIR );
-
- $finder = (new FinderFactory())->make()
- ->in( [
- $stylesheet_dir . '/' . $view_dir,
- $template_dir . '/' . $view_dir,
- ] );
-
- return $finder;
- },
- ],
-
- EditorSubscriber::class => [
- '+finder' => static function ( string $named_param, Injector $injector ) {
- $config = $injector->make( ConfigInterface::class );
-
- $stylesheet_dir = $config->get( \ItalyStrap\Config\ConfigThemeProvider::STYLESHEET_DIR );
- $template_dir = $config->get( \ItalyStrap\Config\ConfigThemeProvider::TEMPLATE_DIR );
-
- $finder = (new FinderFactory())->make()
- ->in( [
- $stylesheet_dir . '/assets/',
- $template_dir . '/assets/',
- ] );
-
- $finder->names([
- '../css/editor-style.css',
- '../assets/css/editor-style.css',
- ]);
-
- return $finder;
- },
- ],
- ],
-
- /**
- * ==========================================================
- *
- * Autoload Parameters Definitions
- *
- * string
- *
- * ==========================================================
- */
- AurynConfig::DEFINE_PARAM => [
- ],
-
- /**
- * ========================================================================
- *
- * Autoload Delegates
- * @link https://github.com/rdlowrey/auryn#instantiation-delegates
- * 'MyComplexClass' => $complexClassFactory,
- * 'SomeClassWithDelegatedInstantiation' => 'MyFactory',
- * 'SomeClassWithDelegatedInstantiation' => 'MyFactory::factoryMethod'
- *
- * string
- *
- * ========================================================================
- */
- AurynConfig::DELEGATIONS => [
- \WP_Theme::class => static function (): \WP_Theme {
- return \wp_get_theme( \get_template() );
- },
- \WP_Query::class => static function (): \WP_Query {
- global $wp_query;
- return $wp_query;
- },
- ],
-
- /**
- * ========================================================================
- *
- * Autoload Prepares
- * @link https://github.com/rdlowrey/auryn#prepares-and-setter-injection
- *
- * string
- *
- * ========================================================================
- */
- AurynConfig::PREPARATIONS => [
-
- /**
- * This class is lazy loaded
- */
- AssetManager::class => new ExperimentalAssetPreparator(),
- ],
-
- /**
- * ========================================================================
- *
- * Lazyload Classes
- * Loaded on admin and front-end
- *
- * Useful if you need to load lazily your classes, for example
- * if you want classes are loaded only when are really needed.
- *
- * ========================================================================
- */
- AurynConfig::PROXY => [
- AssetManager::class,
-// SidebarsSubscriber::class,
- ],
-
- /**
- * ========================================================================
- *
- * Autoload Subscribers Classes
- * Loaded on admin and front-end
- *
- * If you use key => value pair make sure to bind the key with an option name
- * to activate or deactivate the service from an option panel.
- *
- * ========================================================================
- */
- SubscribersConfigExtension::SUBSCRIBERS => [
-
- AfterSetupThemeEvent::class,
- License::class,
- ConfigCurrentTemplateSubscriber::class,
- ConfigWpSubscriber::class,
-
- ExperimentalCustomizerOptionWithAndPosition::class,
- OembedWrapper::class,
-
- /**
- * Register Theme stuff
- */
- NavMenusSubscriber::class,
- SidebarsSubscriber::class,
- SupportSubscriber::class,
- TextDomainSubscriber::class,
- ThumbnailsSubscriber::class,
- PostTypeSupportSubscriber::class,
- Metaboxes::class,
-
- Admin\Nav_Menu\ItemCustomFields::class,
-
- CustomizerBodyTagAttributesSubscriber::class,
- CustomizerAssetsSubscriber::class,
- InlineStyleSubscriber::class,
-
- /**
- * With this class I can lazyload the AssetManager::class
- * see above in the PROXY config.
- */
- AssetsSubscriber::class,
- Asset\EditorSubscriber::class,
- ],
+ /**
+ * ==========================================================
+ *
+ * Autoload Shared Classes
+ *
+ * string|object
+ *
+ * ==========================================================
+ */
+ AurynConfig::SHARING => [
+ /**
+ * Make sure the config is shared.
+ * Already shared in bootstrap.php or in ACM if it is active.
+ */
+ Config::class,
+
+ Attributes::class,
+ Tag::class,
+ View::class,
+
+ \WP_Theme::class,
+ \WP_Query::class,
+ ],
+
+ /**
+ * ==========================================================
+ *
+ * Autoload Aliases Class
+ *
+ * string
+ *
+ * ==========================================================
+ */
+ AurynConfig::ALIASES => [
+
+ ConfigInterface::class => Config::class,
+
+ AttributesInterface::class => Attributes::class,
+ TagInterface::class => Tag::class,
+
+ FileInfoFactoryInterface::class => FileInfoFactory::class,
+ SearchFileStrategy::class => FilesHierarchyIterator::class,
+// FinderInterface::class => Finder::class,
+
+ ViewInterface::class => View::class,
+ ],
+
+ /**
+ * ==========================================================
+ *
+ * Autoload Classes definitions
+ *
+ * @example :
+ * 'walker' => '\NameSpace\ClassName',
+ * ':walker' => new \NameSpace\ClassName(),
+ * '+walker' => function () {
+ * return new \NameSpace\ClassName();
+ * },
+ *
+ * ==========================================================
+ */
+ AurynConfig::DEFINITIONS => [
+ View::class => [
+ '+finder' => new ExperimentalViewFileFinderFactory(),
+ ],
+ ],
+
+ /**
+ * ==========================================================
+ *
+ * Autoload Parameters Definitions
+ *
+ * string
+ *
+ * ==========================================================
+ */
+ AurynConfig::DEFINE_PARAM => [
+ ],
+
+ /**
+ * ========================================================================
+ *
+ * Autoload Delegates
+ * @link https://github.com/rdlowrey/auryn#instantiation-delegates
+ * 'MyComplexClass' => $complexClassFactory,
+ * 'SomeClassWithDelegatedInstantiation' => 'MyFactory',
+ * 'SomeClassWithDelegatedInstantiation' => 'MyFactory::factoryMethod'
+ *
+ * string
+ *
+ * ========================================================================
+ */
+ AurynConfig::DELEGATIONS => [
+ \WP_Theme::class => static function (): \WP_Theme {
+
+ return \wp_get_theme(\get_template());
+ },
+ \WP_Query::class => static function (): \WP_Query {
+
+ global $wp_query;
+ return $wp_query;
+ },
+ ],
+
+ /**
+ * ========================================================================
+ *
+ * Autoload Prepares
+ * @link https://github.com/rdlowrey/auryn#prepares-and-setter-injection
+ *
+ * string
+ *
+ * ========================================================================
+ */
+ AurynConfig::PREPARATIONS => [
+ ],
+
+ /**
+ * ========================================================================
+ *
+ * Lazyload Classes
+ * Loaded on admin and front-end
+ *
+ * Useful if you need to load lazily your classes, for example
+ * if you want classes are loaded only when are really needed.
+ *
+ * ========================================================================
+ */
+ AurynConfig::PROXY => [
+ ],
+
+ /**
+ * ========================================================================
+ *
+ * Autoload Subscribers Classes
+ * Loaded on admin and front-end
+ *
+ * If you use key => value pair make sure to bind the key with an option name
+ * to activate or deactivate the service from an option panel.
+ *
+ * ========================================================================
+ */
+ SubscribersConfigExtension::SUBSCRIBERS => [
+
+ ExperimentalCustomizerOptionWithAndPositionSubscriber::class,
+ OembedWrapperSubscriber::class,
+
+ CustomizerBodyTagAttributesSubscriber::class,
+ CustomizerAssetsSubscriber::class,
+
+ ExperimentalHookComponentsDeprecationSubscriber::class,
+ ],
];
diff --git a/config/autoload/subscribers.global.php b/config/autoload/subscribers.global.php
deleted file mode 100644
index 8ed9605a..00000000
--- a/config/autoload/subscribers.global.php
+++ /dev/null
@@ -1,9 +0,0 @@
- [
- ],
-];
diff --git a/config/index.php b/config/cache/config-cache.php
similarity index 100%
rename from config/index.php
rename to config/cache/config-cache.php
diff --git a/config/dependencies.config.php b/config/dependencies.config.php
index d9ebc9f6..b7108baf 100644
--- a/config/dependencies.config.php
+++ b/config/dependencies.config.php
@@ -1,16 +1,55 @@
execute(ExperimentalThemeFileFinderFactory::class)
+ ),
+ // 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::ENABLE_CACHE => true,
+ ],
+ /** This must run after all */
+ fn(): array => [
+ ConfigProviderExtension::class => [
+ /** This must run after all */
+ ConfigThemeModsProvider::class,
+ ],
+ ],
+ ],
+ );
+
+ $collection->build();
-return static function ( FinderInterface $finder ): ConfigInterface {
- return ConfigFactory::make()->merge(
- ...(new PhpFileProvider(
- '/config/autoload/{{,*.}global,{,*.}local}.php',
- $finder
- ))()
- );
+ return $collection->collection();
};
diff --git a/config/layout.php b/config/layout.php
index d4a44578..d1c7453e 100644
--- a/config/layout.php
+++ b/config/layout.php
@@ -1,4 +1,5 @@
\__( 'Content Sidebar', 'italystrap' ),
- // 'content_sidebar_sidebar' => \__( 'Content Sidebar Sidebar', 'italystrap' ),
- // 'sidebar_content_sidebar' => \__( 'Sidebar Content Sidebar', 'italystrap' ),
- // 'sidebar_sidebar_content' => \__( 'Sidebar Sidebar content', 'italystrap' ),
- 'sidebar_content' => \__( 'Sidebar Content', 'italystrap' ),
- 'full_width' => \__( 'Full width, no sidebar', 'italystrap' ),
- ]
+ 'italystrap_layout_settings',
+ [
+ 'content_sidebar' => \__('Content Sidebar', 'italystrap'),
+ // 'content_sidebar_sidebar' => \__( 'Content Sidebar Sidebar', 'italystrap' ),
+ // 'sidebar_content_sidebar' => \__( 'Sidebar Content Sidebar', 'italystrap' ),
+ // 'sidebar_sidebar_content' => \__( 'Sidebar Sidebar content', 'italystrap' ),
+ 'sidebar_content' => \__('Sidebar Content', 'italystrap'),
+ 'full_width' => \__('Full width, no sidebar', 'italystrap'),
+ ]
);
return $layout;
diff --git a/config/template-content.php b/config/template-content.php
index 023f6645..c97aa3d7 100644
--- a/config/template-content.php
+++ b/config/template-content.php
@@ -1,4 +1,5 @@
\__( 'Hide breadcrumbs', 'italystrap' ),
- 'hide_title' => \__( 'Hide title', 'italystrap' ),
- 'hide_meta' => \__( 'Hide meta info', 'italystrap' ),
- 'hide_thumb' => \__( 'Hide feautured image', 'italystrap' ),
- 'hide_figcaption' => \__( 'Hide figure caption', 'italystrap' ),
- 'hide_content' => \__( 'Hide the content', 'italystrap' ),
- 'hide_author' => \__( 'Hide author box', 'italystrap' ),
- // 'hide_social' => \__( 'Hide builtin social sharing', 'italystrap' ),
+ 'hide_breadcrumbs' => \__('Hide breadcrumbs', 'italystrap'),
+ 'hide_title' => \__('Hide title', 'italystrap'),
+ 'hide_meta' => \__('Hide meta info', 'italystrap'),
+ 'hide_thumb' => \__('Hide feautured image', 'italystrap'),
+ 'hide_figcaption' => \__('Hide figure caption', 'italystrap'),
+ 'hide_content' => \__('Hide the content', 'italystrap'),
+ 'hide_author' => \__('Hide author box', 'italystrap'),
+ // 'hide_social' => \__( 'Hide builtin social sharing', 'italystrap' ),
];
-if ( ! \is_customize_preview() ) {
- $template_content['hide_comments'] = __( 'Hide comments', 'italystrap' );
- $template_content['hide_comments_form'] = __( 'Hide comments form', 'italystrap' );
+if (! \is_customize_preview()) {
+ $template_content['hide_comments'] = __('Hide comments', 'italystrap');
+ $template_content['hide_comments_form'] = __('Hide comments form', 'italystrap');
}
-return \apply_filters( 'italystrap_template_content_settings', $template_content );
+return \apply_filters('italystrap_template_content_settings', $template_content);
diff --git a/functions/asset-helpers.php b/functions/asset-helpers.php
index b8156c2e..603bee42 100644
--- a/functions/asset-helpers.php
+++ b/functions/asset-helpers.php
@@ -1,4 +1,5 @@
$files */
- $files = config_files_finder()->allFiles( $name );
- $last_key = \array_key_last( $files );
+function get_config_file_content_last(string $name): array
+{
- $config_file_content = require $files[ $last_key ];
+ /** @var array $files */
+ $files = (new ExperimentalConfigFilesFinderFactory())()->allFiles($name);
+ $last_key = \array_key_last($files);
- /**
- * removes all NULL, FALSE and Empty Strings but leaves 0 (zero) values
- * https://php.net/manual/en/function.array-filter.php#111091
- */
- return array_filter( $config_file_content, fn( $val ) => ! is_null( $val ) );
-}
+ $config_file_content = require $files[ $last_key ];
-/**
- * This function return a Finder object
- * with config dirs with this order:
- * 0 => Parent
- * 1 => Child
- * @return FinderInterface
- */
-function config_files_finder(): FinderInterface {
-
- static $experimental_finder = null;
-
- if ( ! $experimental_finder ) {
- $experimental_finder = ( new FinderFactory() )
- ->make()
- ->in(
- [
- /**
- * To remember:
- * This is the correct hierarchy to load and override
- * the parent with child config.
- */
- get_template_directory() . '/config/',
- get_stylesheet_directory() . '/config/',
- ]
- );
- }
-
- return $experimental_finder;
+ /**
+ * removes all NULL, FALSE and Empty Strings but leaves 0 (zero) values
+ * https://php.net/manual/en/function.array-filter.php#111091
+ */
+ return array_filter($config_file_content, fn($val) => ! is_null($val));
}
diff --git a/functions/core-booleans.php b/functions/core-booleans.php
index 43bee822..ac42cc9a 100644
--- a/functions/core-booleans.php
+++ b/functions/core-booleans.php
@@ -1,18 +1,20 @@
alias( AurynInjector::class, EmpressInjector::class );
- $injector->share( $injector );
- add_filter( 'italystrap_injector', function () use ( $injector ) {
- return $injector;
- } );
- }
-
- if ( !is_debug() ) {
- return $injector;
- }
-
- if ( !($injector instanceof AurynInjector) ) {
- $injector = new DebugInjector( $injector );
- $injector->alias( AurynInjector::class, DebugInjector::class );
- $injector->share( $injector );
- add_filter( 'italystrap_injector', function () use ( $injector ) {
- return $injector;
- } );
- }
-
- return $injector;
- }
+if (!function_exists('\ItalyStrap\Factory\injector')) {
+
+ /**
+ * @return AurynInjector
+ * @throws ConfigException
+ */
+ function injector(): AurynInjector
+ {
+
+ /**
+ * Injector from ACM if is active
+ */
+ $injector = apply_filters('italystrap_injector', false);
+
+ if (!$injector) {
+ $injector = new EmpressInjector();
+ $injector->alias(AurynInjector::class, EmpressInjector::class);
+ $injector->share($injector);
+ add_filter('italystrap_injector', function () use ($injector) {
+ return $injector;
+ });
+ }
+
+ if (!is_debug()) {
+ return $injector;
+ }
+
+ if (!($injector instanceof AurynInjector)) {
+ $injector = new DebugInjector($injector);
+ $injector->alias(AurynInjector::class, DebugInjector::class);
+ $injector->share($injector);
+ add_filter('italystrap_injector', function () use ($injector) {
+ return $injector;
+ });
+ }
+
+ return $injector;
+ }
}
diff --git a/functions/italystrap.php b/functions/italystrap.php
index 3f1ddb91..98c2d547 100644
--- a/functions/italystrap.php
+++ b/functions/italystrap.php
@@ -1,18 +1,28 @@
make(EventDispatcherInterface::class)
+ ->dispatch(new Index());
- /**
- * @TODO Are they good hooks?
- */
- do_action( 'italystrap_build', $args );
- do_action( 'italystrap', $args );
+ /**
+ * @TODO Are they good hooks?
+ */
+// do_action('italystrap_build', $args);
+// do_action('italystrap', $args);
}
diff --git a/lib/bootstrap.php b/lib/bootstrap.php
index 5ade222e..5b2bc71a 100644
--- a/lib/bootstrap.php
+++ b/lib/bootstrap.php
@@ -1,4 +1,5 @@
require_once dirname( __FILE__ ) . \'/../src/bootstrap.php\'' );
-
-require_once dirname( __FILE__ ) . '/../src/bootstrap.php';
+_deprecated_file(
+ '/lib/bootstrap.php',
+ '4.0.0',
+ '/src/bootstrap.php',
+ 'require_once dirname( __FILE__ ) . \'/../src/bootstrap.php\'
'
+);
+require_once dirname(__FILE__) . '/../src/bootstrap.php';
diff --git a/lib/index.php b/lib/index.php
index daea36f5..40d30d24 100644
--- a/lib/index.php
+++ b/lib/index.php
@@ -1,4 +1,5 @@
+
+
\ No newline at end of file
diff --git a/parts/footer.html b/parts/footer.html
new file mode 100644
index 00000000..e69de29b
diff --git a/parts/header.html b/parts/header.html
new file mode 100644
index 00000000..e69de29b
diff --git a/patterns/colophon.php b/patterns/colophon.php
new file mode 100644
index 00000000..e217ce00
--- /dev/null
+++ b/patterns/colophon.php
@@ -0,0 +1,27 @@
+make(ViewInterface::class);
+$config = $injector->make(ConfigInterface::class);
+
+echo $view->render(Colophon::TEMPLATE_NAME, [
+ Colophon::CONTENT => \wp_strip_all_tags((string)$config->get(ConfigColophonProvider::COLOPHON, '')),
+]);
diff --git a/patterns/footer-default.php b/patterns/footer-default.php
new file mode 100644
index 00000000..82421319
--- /dev/null
+++ b/patterns/footer-default.php
@@ -0,0 +1,30 @@
+make(\Psr\EventDispatcher\EventDispatcherInterface::class);
+?>
+= $dispatcher->dispatch(new Before()); ?>
+
+
+
+
+
+= $dispatcher->dispatch(new After()); ?>
diff --git a/phpcs.xml b/phpcs.xml
index 58a043b3..b4c01a9e 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,7 +1,7 @@
- A custom set of rules to check for a WPized WordPress project
+ A custom set of rules to check for this project
@@ -10,38 +10,22 @@
-
+
+
+ ./config/
+ ./functions/
+ ./lib/
+ ./patterns/
+ ./src/
+ ./templates/
+ ./tests/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
+ */vendor/*
+ */tests/_support/*
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
deleted file mode 100644
index 1b742ad5..00000000
--- a/phpstan.neon.dist
+++ /dev/null
@@ -1,43 +0,0 @@
-#$ composer update --optimize-autoloader
-#$ vendor/bin/phpstan analyze
-
-includes:
- # @see https://github.com/phpstan/phpstan/blob/master/conf/bleedingEdge.neon
- - vendor/phpstan/phpstan/conf/bleedingEdge.neon
- - vendor/szepeviktor/phpstan-wordpress/extension.neon
-parameters:
- level: max
- inferPrivatePropertyTypeFromConstructor: true
- reportUnmatchedIgnoredErrors: false
- paths:
- - %currentWorkingDirectory%/src/
- - %currentWorkingDirectory%/config/
- excludes_analyse:
- - %currentWorkingDirectory%/src/Admin/
- - %currentWorkingDirectory%/src/Asset/
- - %currentWorkingDirectory%/src/Components/
- - %currentWorkingDirectory%/src/Css/
- - %currentWorkingDirectory%/src/Custom/
- - %currentWorkingDirectory%/src/Customizer/
- - %currentWorkingDirectory%/src/Navbar/
- - %currentWorkingDirectory%/src/User/
- - %currentWorkingDirectory%/config/theme/scripts.php
- - %currentWorkingDirectory%/config/theme/styles.php
- - %currentWorkingDirectory%/config/customizer.php
- - %currentWorkingDirectory%/config/html_attrs.php
- - %currentWorkingDirectory%/config/structure.php
- autoload_files:
- # Procedural code
- - %currentWorkingDirectory%/functions/autoload.php
- ignoreErrors:
- # Uses func_get_args()
- - '#^Function apply_filters invoked with [34567] parameters, 2 required\.$#'
- - '#Access to an undefined property ItalyStrap\\Config\\Config::\$[a-zA-Z0-9_]+#'
- - '#Access to an undefined property ItalyStrap\\Config\\ConfigInterface::\$[a-zA-Z0-9_]+#'
- - '#Class ItalyStrap\\Migrations\\Old_Hooks not found#'
- - '#Argument of an invalid type ItalyStrap\\Config\\[a-zA-Z_]+ supplied for foreach, only iterables are supported.#'
- - '#Function new_cmb2_box not found#'
- - '#Constant CURRENT_TEMPLATE_SLUG not found#'
- - '#Constant STYLESHEETPATH not found#'
- - '#Constant TEMPLATEPATH not found#'
- - '#Constant ITALYSTRAP_THEME_VERSION not found.#'
diff --git a/psalm.xml b/psalm.xml
index 95b79516..7583d94c 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -1,6 +1,6 @@
-
+
+
-
+
+
diff --git a/src/Admin/Nav_Menu/ItemCustomFields.php b/src/Admin/Nav_Menu/ItemCustomFields.php
deleted file mode 100644
index b0d92b03..00000000
--- a/src/Admin/Nav_Menu/ItemCustomFields.php
+++ /dev/null
@@ -1,321 +0,0 @@
-
- *
- * @forked from ItalyStrap
- * @package ItalyStrap
- * @since 4.0.0
- * @uses Walker_Nav_Menu_Edit
- * @deprecated
- */
-final class ItemCustomFields implements SubscriberInterface {
-
- /**
- * Holds our custom fields
- *
- */
- private array $fields = [];
-
- private string $key_pattern;
-
- /**
- * Init the constructor
- */
- public function __construct() {
- $this->key_pattern = 'menu-item-%s';
- $this->setFields(
- [
- [
- 'type' => 'text',
- 'id' => 'glyphicon',
- 'name' => 'glyphicon',
- 'label' => __( 'Icon css class', 'italystrap' ),
- 'desc' => __( 'Example: fa fa-icon fa-3x', 'italystrap' ),
- ],
- ]
- );
- }
-
- /**
- * Print field
- *
- * @param int $id Nav menu ID.
- * @param object $item Menu item data object.
- */
- public function printFields( $id, $item ) {
-
- foreach ($this->getFields() as $field) :
- $field = array_merge( $this->defaultField(), $field );
- $key = sprintf( $this->key_pattern, $field[ 'id' ] );
- $id = sprintf( 'edit-%s-%s', $key, $item->ID );
- $name = sprintf( '%s[%s]', $key, $item->ID );
- $value = (string)get_post_meta( $item->ID, $key, true );
- $class = sprintf( 'field-%s', $field[ 'id' ] );
- ?>
-
- $field[ 'type' ],
- 'id' => '%1$s',
- 'class' => 'widefat %1$s',
- 'name' => '%3$s',
- 'value' => '%4$s',
- ]
- );
-
- printf(
- '',
- esc_attr( $id ),
- esc_html( $field[ 'label' ] ),
- esc_attr( $name ),
- esc_attr( $value )
- ) ?>
-
-
-
- getFields() as $field) {
- $var = $field[ 'id' ];
- $menu_item->$var = get_post_meta( $menu_item->ID, sprintf( $this->key_pattern, $var ), true );
- }
-
- return $menu_item;
- }
-
- /**
- * Save custom field value
- *
- * @wp_hook action wp_update_nav_menu_item
- *
- * @param int $menu_id Nav menu ID
- * @param int $menu_item_db_id Menu item ID
- * @param array $menu_item_args Menu item data
- */
- public function saveFields( int $menu_id, int $menu_item_db_id, array $menu_item_args ) {
-
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
- return;
- }
-
- check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
-
- foreach ($this->getFields() as $field) {
- $key = sprintf( $this->key_pattern, $field[ 'id' ] );
-
- if ( empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
- delete_post_meta( $menu_item_db_id, $key );
- continue;
- }
-
- update_post_meta( $menu_item_db_id, $key, sanitize_text_field( $_POST[ $key ][ $menu_item_db_id ] ) );
- }
- }
-
- /**
- * Define new Walker edit
- *
- * @param string $class The walker class to use.
- * Default 'Walker_Nav_Menu_Edit'.
- * @param int $menu_id The menu id, derived from $_POST['menu'].
- *
- * @return string The new walker class to use.
- */
- public function register() {
- return NavMenuEdit::class;
- }
-
- /**
- * Add our fields to the screen options toggle
- *
- * @param array $columns Menu item columns
- *
- * @return array
- */
- public function columns( $columns ): array {
- return array_merge( $columns, iterator_to_array( $this->getColumns() ) );
- }
-
- /**
- * @return Generator
- */
- private function getColumns() {
- foreach ($this->getFields() as $field) {
- yield $field[ 'id' ] => $field[ 'label' ];
- }
- }
-
- /**
- * @return array
- */
- private function getFields(): array {
- return $this->fields;
- }
-
- /**
- * @param array $fields
- */
- private function setFields( array $fields ) {
- $this->fields = $fields;
- }
-
- /**
- * @return array
- */
- private function defaultField(): array {
-
- $uniqid = uniqid();
-
- return [
- 'type' => 'text',
- 'id' => $uniqid,
- 'name' => $uniqid,
- 'label' => __( 'Label not provided', 'italystrap' ),
- 'desc' => '',
- ];
- }
-
- /**
- * Returns an array of events (hooks) that this subscriber wants to register with
- * the Events Manager API.
- *
- * The array key is the name of the hook. The value can be:
- *
- * * The method name
- * * An array with the method name and priority
- * * An array with the method name, priority and number of accepted arguments
- *
- * For instance:
- *
- * array(
- * // 'event_name' => 'method_name',
- * 'italystrap_before_header' => 'render',
- * )
- * array(
- * // 'event_name' => 'method_name',
- * 'italystrap_before_entry_content' => array(
- * 'function_to_add' => 'render',
- * 'priority' => 30, // Default 10
- * 'accepted_args' => 1 // Default 1
- * ),
- * );
- *
- * @return array
- */
- public function getSubscribedEvents(): iterable {
-
- /**
- * Add new checkboxes to the "Screen options" menu
- */
- yield 'manage_nav-menus_columns' => [
- SubscriberInterface::CALLBACK => 'columns',
- SubscriberInterface::PRIORITY => 11,
- ];
-
- /**
- * Add the value fro new custom fields to the object in the Nav Walker
- */
- yield 'wp_setup_nav_menu_item' => 'addCustomNavFields';
-
- /**
- * Save the value
- */
- yield 'wp_update_nav_menu_item' => [
- SubscriberInterface::CALLBACK => 'saveFields',
- SubscriberInterface::PRIORITY => 10,
- SubscriberInterface::ACCEPTED_ARGS => 3,
- ];
-
- /**
- * Display the added custom fields
- */
- yield 'wp_nav_menu_item_custom_fields' => [
- SubscriberInterface::CALLBACK => 'printFields',
- SubscriberInterface::PRIORITY => 10,
- SubscriberInterface::ACCEPTED_ARGS => 5,
- ];
-
-// return [
-
- /**
- * Register new class for Menu Edit
- */
-// 'wp_edit_nav_menu_walker' => [
-// SubscriberInterface::CALLBACK => 'register',
-// 'accepted_args' => 2,
-// ],
-
- /**
- * Add new checkboxes to the "Screen options" menu
- */
-// 'manage_nav-menus_columns' => [
-// SubscriberInterface::CALLBACK => 'columns',
-// SubscriberInterface::PRIORITY => 11,
-// ],
-
- /**
- * Add the value fro new custom fields to the object in the Nav Walker
- */
-// 'wp_setup_nav_menu_item' => 'addCustomNavFields',
-
- /**
- * Save the value
- */
-// 'wp_update_nav_menu_item' => [
-// SubscriberInterface::CALLBACK => 'saveFields',
-// SubscriberInterface::PRIORITY => 10,
-// SubscriberInterface::ACCEPTED_ARGS => 3,
-// ],
-
- /**
- * Display the added custom fields
- */
-// 'wp_nav_menu_item_custom_fields' => [
-// SubscriberInterface::CALLBACK => 'printFields',
-// SubscriberInterface::PRIORITY => 10,
-// SubscriberInterface::ACCEPTED_ARGS => 5,
-// ],
-// ];
- }
-}
diff --git a/src/Asset/Application/EditorSubscriber.php b/src/Asset/Application/EditorSubscriber.php
new file mode 100644
index 00000000..c41188d0
--- /dev/null
+++ b/src/Asset/Application/EditorSubscriber.php
@@ -0,0 +1,75 @@
+ $this;
+ }
+
+ public function __construct(ConfigInterface $config, FinderInterface $finder, GlobalDispatcherInterface $dispatcher)
+ {
+ $this->config = $config;
+ $this->finder = $finder;
+ $this->globalDispatcher = $dispatcher;
+ }
+
+ /**
+ * Add Custom CSS in visual editor
+ *
+ * @link http://codex.wordpress.org/Function_Reference/add_editor_style
+ * @link https://developer.wordpress.org/reference/functions/add_editor_style/
+
+ * Leggere qui perché forse c'è un problema con i font, non prende il path giusto
+ * @link http://codeboxr.com/blogs/adding-twitter-bootstrap-support-in-wordpress-visual-editor
+ * @link https://www.google.it/search?q=wordpress+add+css+bootstrap+visual+editor&oq=wordpress+add+css+bootstrap+visual+editor&gs_l=serp.3...893578.895997.0.896668.10.10.0.0.0.3.388.1849.0j1j4j2.7.0....0...1c.1.52.serp..8.2.732.wb3nJL89Fxk
+ */
+ public function __invoke(): void
+ {
+
+ /** @var SplFileInfo $editor_style */
+ $editor_style = '';
+ foreach ($this->finder as $file) {
+ $editor_style = $file;
+ break;
+ }
+
+ /**
+ * @TODO In fase di test bisogna verificare sia il path to url per il child
+ * che per il parent theme, qui per esempio prendo tutto dal child
+ * e dovrebbe fare la fallback sul parent in caso il child non
+ * sia installato
+ * http:://italystrap.test\dir/dir\dir
+ */
+ $style_url = str_replace(
+ (string) realpath((string) $this->config->get(ConfigThemeProvider::STYLESHEET_DIR)),
+ (string) $this->config->get(ConfigThemeProvider::STYLESHEET_DIR_URI), // Replace
+ $editor_style->getRealPath()
+ );
+
+ $style_url = str_replace('\\', '/', $style_url);
+
+ $arg = (array)$this->globalDispatcher->filter('italystrap_visual_editor_style', [ $style_url ]);
+
+ add_editor_style($arg);
+ }
+}
diff --git a/src/Asset/Application/InlineStyleSubscriber.php b/src/Asset/Application/InlineStyleSubscriber.php
new file mode 100644
index 00000000..72cac82f
--- /dev/null
+++ b/src/Asset/Application/InlineStyleSubscriber.php
@@ -0,0 +1,79 @@
+ [
+ self::CALLBACK => $this,
+ self::PRIORITY => 11,
+ ];
+ }
+
+ public function __construct(ConfigInterface $config, InlineStyleGenerator $style)
+ {
+ $this->style = $style;
+ $this->config = $config;
+ }
+
+ public function __invoke(): void
+ {
+ $output = $this->style->render(
+ '#site-title a',
+ 'color',
+ ConfigColorSectionProvider::HEADER_COLOR,
+ '#'
+ );
+
+ $output .= $this->style->render(
+ 'h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6,.heading',
+ 'color',
+ ConfigColorSectionProvider::HX_COLOR,
+ '#'
+ );
+
+ $output .= $this->style->render(
+ 'a',
+ 'color',
+ ConfigColorSectionProvider::LINK_COLOR,
+ '#'
+ );
+
+ if (! $output) {
+ return;
+ }
+
+ \printf(
+ '',
+ (string) $this->config->get(ConfigThemeProvider::PREFIX),
+ \wp_strip_all_tags($this->minifyOutput($output))
+ );
+ }
+
+ private function minifyOutput(string $style): string
+ {
+ return \str_replace(
+ [
+ "\n",
+ "\r",
+ "\t",
+ ' ',
+ ],
+ '',
+ $style
+ );
+ }
+}
diff --git a/src/Asset/EditorSubscriber.php b/src/Asset/EditorSubscriber.php
deleted file mode 100644
index bdcff577..00000000
--- a/src/Asset/EditorSubscriber.php
+++ /dev/null
@@ -1,78 +0,0 @@
- 'enqueue';
- }
-
- /**
- * Editor constructor.
- * @param Config $config
- * @param Finder $finder
- */
- public function __construct( Config $config, Finder $finder, EventDispatcher $dispatcher ) {
- $this->config = $config;
- $this->finder = $finder;
- $this->dispatcher = $dispatcher;
- }
-
- /**
- * Add Custom CSS in visual editor
- *
- * @link http://codex.wordpress.org/Function_Reference/add_editor_style
- * @link https://developer.wordpress.org/reference/functions/add_editor_style/
-
- * Leggere qui perché forse c'è un problema con i font, non prende il path giusto
- * @link http://codeboxr.com/blogs/adding-twitter-bootstrap-support-in-wordpress-visual-editor
- * @link https://www.google.it/search?q=wordpress+add+css+bootstrap+visual+editor&oq=wordpress+add+css+bootstrap+visual+editor&gs_l=serp.3...893578.895997.0.896668.10.10.0.0.0.3.388.1849.0j1j4j2.7.0....0...1c.1.52.serp..8.2.732.wb3nJL89Fxk
- */
- public function enqueue(): void {
-
- /** @var SplFileInfo $editor_style */
- $editor_style = '';
- foreach ( $this->finder as $file ) {
- $editor_style = $file;
- break;
- }
-
- /**
- * @TODO In fase di test bisogna verificare sia il path to url per il child
- * che per il parent theme, qui per esempio prendo tutto dal child
- * e dovrebbe fare la fallback sul parent in caso il child non
- * sia installato
- * http:://italystrap.test\dir/dir\dir
- */
- $style_url = str_replace(
- (string) realpath( (string) $this->config->get( ConfigThemeProvider::STYLESHEET_DIR ) ),
- (string) $this->config->get( ConfigThemeProvider::STYLESHEET_DIR_URI ), // Replace
- $editor_style->getRealPath()
- );
-
- $style_url = str_replace('\\', '/', $style_url);
-
- $arg = (array)$this->dispatcher->filter( 'italystrap_visual_editor_style', [ $style_url ] );
-
- add_editor_style( $arg );
- }
-}
diff --git a/src/Asset/ExperimentalAssetPreparator.php b/src/Asset/ExperimentalAssetPreparator.php
deleted file mode 100644
index 1d261b15..00000000
--- a/src/Asset/ExperimentalAssetPreparator.php
+++ /dev/null
@@ -1,85 +0,0 @@
-make(EventDispatcher::class);
- $experimental_assets_path_generator = static function ( string $dir ): array {
- $sub_dir = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? 'src/' : '';
-
- return \array_unique(
- [
- STYLESHEETPATH . '/assets/' . $dir,
- STYLESHEETPATH . '/' . $dir, // This is added for avoid BC breaks
- STYLESHEETPATH . '/' . $dir . $sub_dir, // This is added for avoid BC breaks
- TEMPLATEPATH . '/assets/' . $dir,
- ]
- );
- };
-
- $css_finder = ( new FinderFactory() )->make()
- ->in( $experimental_assets_path_generator('css/') );
-
- $js_finder = ( new FinderFactory() )->make()
- ->in( $experimental_assets_path_generator('js/') );
-
- $injector->defineParam('base_url', \get_option( 'siteurl' ) . '/');
- /**
- * @psalm-suppress UndefinedConstant
- */
- $injector->defineParam('base_path', ABSPATH);
-
- /** @var ConfigBuilder $config_builder */
- $config_builder = $injector->make( ConfigBuilder::class );
-
- $config_builder->withType(
- Style::EXTENSION,
- \ItalyStrap\Core\is_debug() ? DebugStyle::class : Style::class
- );
- $config_builder->withFinderForType( Style::EXTENSION, $css_finder);
-
- $config_builder->withType(
- Script::EXTENSION,
- \ItalyStrap\Core\is_debug() ? DebugScript::class : Script::class
- );
- $config_builder->withFinderForType( Script::EXTENSION, $js_finder);
-
- /**
- * @todo Maybe I can add a check for forcing child to load its own assets
- * is_child() ? [] : get_config_file_content_last( 'assets/[styles|scripts]' )
- * because assetss should not be loaded from parent by default.
- * @var array
- */
- $styles = $event_dispatcher->filter(
- 'italystrap_config_enqueue_style',
- get_config_file_content_last( 'assets/styles' )
- );
-
- /** @var array $scripts */
- $scripts = $event_dispatcher->filter(
- 'italystrap_config_enqueue_script',
- get_config_file_content_last( 'assets/scripts' )
- );
-
- $config_builder->addConfig( $styles );
- $config_builder->addConfig( $scripts );
-
- $asset_loader = $injector->make( GeneratorLoader::class );
- $assets = $asset_loader->load( $config_builder->parseConfig() );
-
- $manager->withAssets(...$assets);
- }
-}
diff --git a/src/Asset/Infrastructure/ExperimentalAssetPreparator.php b/src/Asset/Infrastructure/ExperimentalAssetPreparator.php
new file mode 100644
index 00000000..e8732147
--- /dev/null
+++ b/src/Asset/Infrastructure/ExperimentalAssetPreparator.php
@@ -0,0 +1,92 @@
+make(EventDispatcher::class);
+ $experimental_assets_path_generator = static function (string $dir): array {
+ $sub_dir = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? 'src/' : '';
+
+ return \array_unique(
+ [
+ STYLESHEETPATH . '/assets/' . $dir,
+ STYLESHEETPATH . '/' . $dir, // This is added for avoid BC breaks
+ STYLESHEETPATH . '/' . $dir . $sub_dir, // This is added for avoid BC breaks
+ TEMPLATEPATH . '/assets/' . $dir,
+ ]
+ );
+ };
+
+ $css_finder = ( new FinderFactory() )->make()
+ ->in($experimental_assets_path_generator('css/'));
+
+ $js_finder = ( new FinderFactory() )->make()
+ ->in($experimental_assets_path_generator('js/'));
+
+ $injector->defineParam('base_url', \get_option('siteurl') . '/');
+ /**
+ * @psalm-suppress UndefinedConstant
+ */
+ $injector->defineParam('base_path', ABSPATH);
+
+ /** @var ConfigBuilder $config_builder */
+ $config_builder = $injector->make(ConfigBuilder::class);
+
+ $config_builder->withType(
+ Style::EXTENSION,
+ \ItalyStrap\Core\is_debug() ? DebugStyle::class : Style::class
+ );
+ $config_builder->withFinderForType(Style::EXTENSION, $css_finder);
+
+ $config_builder->withType(
+ Script::EXTENSION,
+ \ItalyStrap\Core\is_debug() ? DebugScript::class : Script::class
+ );
+ $config_builder->withFinderForType(Script::EXTENSION, $js_finder);
+
+ /**
+ * @todo Maybe I can add a check for forcing child to load its own assets
+ * is_child() ? [] : get_config_file_content_last( 'assets/[styles|scripts]' )
+ * because assetss should not be loaded from parent by default.
+ * @var array
+ */
+ $styles = $event_dispatcher->filter(
+ 'italystrap_config_enqueue_style',
+ get_config_file_content_last('assets/styles')
+ );
+
+ /** @var array $scripts */
+ $scripts = $event_dispatcher->filter(
+ 'italystrap_config_enqueue_script',
+ get_config_file_content_last('assets/scripts')
+ );
+
+ $config_builder->addConfig($styles);
+ $config_builder->addConfig($scripts);
+
+ $asset_loader = $injector->make(GeneratorLoader::class);
+ $assets = $asset_loader->load($config_builder->parseConfig());
+
+ $manager->withAssets(...$assets);
+ }
+}
diff --git a/src/Asset/Infrastructure/InlineStyleGenerator.php b/src/Asset/Infrastructure/InlineStyleGenerator.php
new file mode 100644
index 00000000..2fd32f79
--- /dev/null
+++ b/src/Asset/Infrastructure/InlineStyleGenerator.php
@@ -0,0 +1,55 @@
+config = $config;
+ }
+
+ /**
+ * This will generate a line of CSS for use in header or footer output.
+ * If the setting ($mod_name) has no defined value, the CSS will not be output.
+ *
+ * @param string $selector CSS selector.
+ * @param string $property The name of the CSS *property* to modify.
+ * @param string $mod_name The name of the 'theme_mod' option to fetch.
+ * @param string $prefix Optional. Anything that needs to be output
+ * before the CSS property. Example '#'.
+ * @param string $postfix Optional. Anything that needs to be output
+ * after the CSS property. Example 'px'.
+ * @return string Returns a single line of CSS with selectors,
+ * property and value.
+ */
+ public function render(
+ string $selector,
+ string $property,
+ string $mod_name,
+ string $prefix,
+ string $postfix = ''
+ ): string {
+
+ $value = (string) $this->config->get($mod_name);
+
+ if (empty($value)) {
+ return '';
+ }
+
+ return \sprintf(
+ '%1$s{%2$s:%3$s%4$s%5$s;}',
+ $selector,
+ $property,
+ $prefix,
+ $value,
+ $postfix
+ );
+ }
+}
diff --git a/src/Asset/InlineStyleGenerator.php b/src/Asset/InlineStyleGenerator.php
deleted file mode 100644
index 4e91c6c8..00000000
--- a/src/Asset/InlineStyleGenerator.php
+++ /dev/null
@@ -1,56 +0,0 @@
-config = $config;
- }
-
- /**
- * This will generate a line of CSS for use in header or footer output.
- * If the setting ($mod_name) has no defined value, the CSS will not be output.
- *
- * @param string $selector CSS selector.
- * @param string $property The name of the CSS *property* to modify.
- * @param string $mod_name The name of the 'theme_mod' option to fetch.
- * @param string $prefix Optional. Anything that needs to be output
- * before the CSS property. Example '#'.
- * @param string $postfix Optional. Anything that needs to be output
- * after the CSS property. Example 'px'.
- * @return string Returns a single line of CSS with selectors,
- * property and value.
- */
- public function render(
- string $selector,
- string $property,
- string $mod_name,
- string $prefix,
- string $postfix = ''
- ): string {
-
- $value = (string) $this->config->get( $mod_name );
-
- if ( empty( $value ) ) {
- return '';
- }
-
- return \sprintf(
- '%1$s{%2$s:%3$s%4$s%5$s;}',
- $selector,
- $property,
- $prefix,
- $value,
- $postfix
- );
- }
-}
diff --git a/src/Asset/InlineStyleSubscriber.php b/src/Asset/InlineStyleSubscriber.php
deleted file mode 100644
index 9dbee4b1..00000000
--- a/src/Asset/InlineStyleSubscriber.php
+++ /dev/null
@@ -1,76 +0,0 @@
- [
- self::CALLBACK => 'enqueue',
- self::PRIORITY => 11,
- ];
- }
-
- public function __construct( ConfigInterface $config, InlineStyleGenerator $style ) {
- $this->style = $style;
- $this->config = $config;
- }
-
- public function enqueue(): void {
- $output = $this->style->render(
- '#site-title a',
- 'color',
- ConfigColorSectionProvider::HEADER_COLOR,
- '#'
- );
-
- $output .= $this->style->render(
- 'h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6,.heading',
- 'color',
- ConfigColorSectionProvider::HX_COLOR,
- '#'
- );
-
- $output .= $this->style->render(
- 'a',
- 'color',
- ConfigColorSectionProvider::LINK_COLOR,
- '#'
- );
-
- if ( ! $output ) {
- return;
- }
-
- \printf(
- '',
- (string) $this->config->get(ConfigThemeProvider::PREFIX),
- \wp_strip_all_tags( $this->minifyOutput( $output ) )
- );
- }
-
- private function minifyOutput( string $style ): string {
- return \str_replace(
- [
- "\n",
- "\r",
- "\t",
- ' ',
- ],
- '',
- $style
- );
- }
-}
diff --git a/src/Asset/JsonData.php b/src/Asset/JsonData.php
deleted file mode 100644
index ccaf193c..00000000
--- a/src/Asset/JsonData.php
+++ /dev/null
@@ -1,259 +0,0 @@
-buildJsonData();
-
-// $result = $data->parseDataAndCleanFromEmptyValue( $result );
-
- if ( \count( $result ) === 0 ) {
- throw new \RuntimeException('The theme.json is empty');
- }
-
- return $result;
- }
-
- private function buildJsonData(): array {
-
- $font_family = new Preset(
- [
- [
- // phpcs:ignore
- 'fontFamily' => 'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
- 'slug' => "base",
- "name" => "Default font family",
- ],
- [
- // phpcs:ignore
- 'fontFamily' => 'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
- 'slug' => "monospace",
- "name" => "Font family for code",
- ],
- ],
- 'fontFamily'
- );
-
- $custom = new Custom(
- [
- 'contentSize' => 'clamp(16rem, 60vw, 60rem)',
- 'wideSize' => 'clamp(16rem, 85vw, 70rem)',
- 'baseFontSize' => "1rem",
- 'spacer' => [
- 'base' => '1rem',
- 'v' => 'calc( {{spacer.base}} * 4 )',
- 'h' => 'calc( {{spacer.base}} * 4 )',
- 's' => 'calc( {{spacer.base}} / 1.5 )',
- 'm' => 'calc( {{spacer.base}} * 2 )',
- 'l' => 'calc( {{spacer.base}} * 3 )',
- 'xl' => 'calc( {{spacer.base}} * 4 )',
- ],
- 'lineHeight' => [
- 'base' => 1.5,
- 'xs' => 1.1,
- 's' => 1.3,
- 'm' => '{{lineHeight.base}}',
- 'l' => 1.7
- ],
- 'body' => [
- 'bg' => '{{color.base}}',
- 'text' => '{{color.bodyBg}}',
- ],
- 'link' => [
- 'bg' => '{{color.base}}',
- 'text' => '{{color.bodyBg}}',
- 'decoration' => 'underline',
- 'hover' => [
- 'text' => '{{color.bodyColor}}',
- 'decoration' => 'underline',
- ],
- ],
- 'button' => [
- 'bg' => '{{color.base}}',
- // 'text' => $button_text_hover->toHex(),
- 'borderColor' => 'transparent',
- 'borderRadius' => 'calc( {{fontSize.base}} /4)',
- 'hover' => [
- // 'bg' => $button_bg_hover->toHex(),
- // 'text' => $button_text_hover->toHex(),
- 'borderColor' => 'transparent',
- ],
- 'padding' => ' 0.25em 0.7em',
- ],
- 'form' => [
- 'border' => [
- 'color' => '',
- 'width' => '',
- ],
- 'input' => [
- 'color' => '',
- ],
- ],
- 'navbar' => [
- 'min' => [
- 'height' => 'calc( {{spacer.base}} * 5.3125 )',
- ],
- ],
- 'query' => [
- 'post' => [
- 'title' => '{{fontSize.h1}}',
- ],
- ],
- // 'site-blocks' => [
- // 'margin' => [
- // 'top' => '',
- // ],
- // ],
- ]
- );
-
- return [
- '$schema' => 'https://schemas.wp.org/trunk/theme.json',
- SectionNames::VERSION => 2,
-
- SectionNames::SETTINGS => [
- 'layout' => [
- 'contentSize' => 'clamp(16rem, 60vw, 60rem)',
- 'wideSize' => 'clamp(16rem, 85vw, 70rem)',
- ],
- ],
-
- /**
- * ============================================
- * Styles for FSE and Front-End
- * ============================================
- */
- SectionNames::STYLES => [
-
- 'typography' => FTypo::make()
- ->fontFamily( $font_family->varOf('base') )
-// ->fontSize( $font_sizes->varOf( 'base' ) )
- ->fontSize( '18px' )
- ->fontStyle( 'normal' )
- ->fontWeight( '300' )
- ->letterSpacing( 'normal' )
- ->lineHeight( $custom->varOf( 'lineHeight.m' ) )
- ->textDecoration( 'none' )
- ->textTransform( 'none' )
- ->toArray(),
-
- /**
- * ============================================
- * Blocks styles
- * ============================================
- */
- 'blocks' => [
-
- /**
- * ============================================
- * Blocks elements for images
- * ============================================
- */
- 'core/site-logo' => [ // wp-block-site-logo {figure element}
- 'spacing' => [
- 'margin' => (string) FSpace::shorthand(['0']),
- 'padding' => (string) FSpace::shorthand(['0']),
- ],
- ],
- 'core/image' => [ // wp-block-image {figure element}
- 'spacing' => [
- 'margin' => (string) FSpace::make()
- ->top( '1rem' )
- ->bottom( '0px' ),
- ],
- ],
- 'core/post-featured-image' => [ // wp-block-post-featured-image {figure element}
-// 'spacing' => [
-// 'margin' => (string) FSpace::make()
-// ->top( '1rem' )
-// ->bottom('0'),
-// ],
- ],
-// 'core/gallery' => [ // wp-block-gallery {figure element}
-// ],
-
- 'core/post-title' => [ // .wp-block-post-title
- 'color' => FClr::make()
- ->text( 'inherit' )
- ->toArray(),
-// 'border' => (new Border())
-// ->style('solid')
-// ->width('1px')
-// ->color('black')
-// ->toArray(),
- 'typography' => FTypo::make()
- ->fontSize( '35px' )
- ->toArray(),
- 'elements' => [
- 'link' => [ // .wp-block-post-title a
- 'color' => FClr::make()
- ->text( 'inherit' )
- ->background( 'transparent' )
- ->toArray(),
- ],
- ],
- ],
-
- 'core/post-date' => [
- 'typography' => FTypo::make()
-// ->fontSize( '0.75rem' )
- ->toArray(),
- ],
- 'core/post-author' => [
- 'typography' => FTypo::make()
-// ->fontSize( '16px' )
- ->toArray(),
- ],
- 'core/post-terms' => [
- 'typography' => FTypo::make()
-// ->fontSize( '0.75rem' )
- ->toArray(),
- ],
-
- /**
- * ============================================
- * Blocks for content
- * ============================================
- */
- 'core/post-content' => [ // .wp-block-post-content
- 'color' => FClr::make()
- ->text( 'inherit' )
- ->toArray(),
- ],
- 'core/post-excerpt' => [ // .wp-block-post-content
- 'color' => FClr::make()
- ->text( 'inherit' )
- ->toArray(),
- ],
- 'core/paragraph' => [ // .wp-block-post-content
- 'color' => FClr::make()
- ->text( 'inherit' )
- ->toArray(),
- 'spacing' => [
- 'margin' => (string) FSpace::make()
- ->top( '1.2rem' )
- ->bottom( '0px' ),
- ],
- ],
-
- ],
- ],
- ];
- }
-}
diff --git a/src/Asset/Module.php b/src/Asset/Module.php
new file mode 100644
index 00000000..26cdfa1e
--- /dev/null
+++ b/src/Asset/Module.php
@@ -0,0 +1,66 @@
+ [
+
+ ],
+ AurynConfig::ALIASES => [
+
+ ],
+ AurynConfig::DEFINITIONS => [
+ EditorSubscriber::class => [
+ '+finder' => static function (string $named_param, Injector $injector): FinderInterface {
+
+ $config = $injector->make(ConfigInterface::class);
+ $stylesheet_dir = (string)$config->get(ConfigThemeProvider::STYLESHEET_DIR);
+ $template_dir = (string)$config->get(ConfigThemeProvider::TEMPLATE_DIR);
+ $finder = (new FinderFactory())->make()
+ ->in([
+ $stylesheet_dir . '/assets/',
+ $template_dir . '/assets/',
+ ]);
+ $finder->names([
+ '../css/editor-style.css',
+ '../assets/css/editor-style.css',
+ ]);
+ return $finder;
+ },
+ ],
+ ],
+ AurynConfig::PREPARATIONS => [
+
+ /**
+ * This class is lazy loaded
+ */
+ AssetManager::class => new ExperimentalAssetPreparator(),
+ ],
+ AurynConfig::PROXY => [
+ AssetManager::class,
+ ],
+ SubscribersConfigExtension::SUBSCRIBERS => [
+ InlineStyleSubscriber::class,
+ AssetsSubscriber::class,
+ EditorSubscriber::class,
+ ]
+ ];
+ }
+}
diff --git a/src/Asset/ThemeJson.php b/src/Asset/ThemeJson.php
new file mode 100644
index 00000000..7eac7684
--- /dev/null
+++ b/src/Asset/ThemeJson.php
@@ -0,0 +1,280 @@
+buildJsonData();
+
+// $result = $data->parseDataAndCleanFromEmptyValue( $result );
+
+ if (\count($result) === 0) {
+ throw new \RuntimeException('The theme.json is empty');
+ }
+
+ return $result;
+ }
+
+ private function buildJsonData(): array
+ {
+
+ $font_family = new Preset(
+ [
+ [
+ // phpcs:ignore
+ 'fontFamily' => 'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
+ 'slug' => "base",
+ "name" => "Default font family",
+ ],
+ [
+ // phpcs:ignore
+ 'fontFamily' => 'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
+ 'slug' => "monospace",
+ "name" => "Font family for code",
+ ],
+ ],
+ 'fontFamily'
+ );
+
+ $custom = new Custom(
+ [
+ 'contentSize' => 'clamp(16rem, 60vw, 60rem)',
+ 'wideSize' => 'clamp(16rem, 85vw, 70rem)',
+ 'baseFontSize' => "1rem",
+ 'spacer' => [
+ 'base' => '1rem',
+ 'v' => 'calc( {{spacer.base}} * 4 )',
+ 'h' => 'calc( {{spacer.base}} * 4 )',
+ 's' => 'calc( {{spacer.base}} / 1.5 )',
+ 'm' => 'calc( {{spacer.base}} * 2 )',
+ 'l' => 'calc( {{spacer.base}} * 3 )',
+ 'xl' => 'calc( {{spacer.base}} * 4 )',
+ ],
+ 'lineHeight' => [
+ 'base' => 1.5,
+ 'xs' => 1.1,
+ 's' => 1.3,
+ 'm' => '{{lineHeight.base}}',
+ 'l' => 1.7
+ ],
+ 'body' => [
+ 'bg' => '{{color.base}}',
+ 'text' => '{{color.bodyBg}}',
+ ],
+ 'link' => [
+ 'bg' => '{{color.base}}',
+ 'text' => '{{color.bodyBg}}',
+ 'decoration' => 'underline',
+ 'hover' => [
+ 'text' => '{{color.bodyColor}}',
+ 'decoration' => 'underline',
+ ],
+ ],
+ 'button' => [
+ 'bg' => '{{color.base}}',
+ // 'text' => $button_text_hover->toHex(),
+ 'borderColor' => 'transparent',
+ 'borderRadius' => 'calc( {{fontSize.base}} /4)',
+ 'hover' => [
+ // 'bg' => $button_bg_hover->toHex(),
+ // 'text' => $button_text_hover->toHex(),
+ 'borderColor' => 'transparent',
+ ],
+ 'padding' => ' 0.25em 0.7em',
+ ],
+ 'form' => [
+ 'border' => [
+ 'color' => '',
+ 'width' => '',
+ ],
+ 'input' => [
+ 'color' => '',
+ ],
+ ],
+ 'navbar' => [
+ 'min' => [
+ 'height' => 'calc( {{spacer.base}} * 5.3125 )',
+ ],
+ ],
+ 'query' => [
+ 'post' => [
+ 'title' => '{{fontSize.h1}}',
+ ],
+ ],
+ // 'site-blocks' => [
+ // 'margin' => [
+ // 'top' => '',
+ // ],
+ // ],
+ ]
+ );
+
+ $custom->withCollection(
+ $font_family
+ );
+
+ return [
+ '$schema' => 'https://schemas.wp.org/trunk/theme.json',
+ SectionNames::VERSION => 2,
+
+ SectionNames::SETTINGS => [
+ 'layout' => [
+ 'contentSize' => 'clamp(16rem, 60vw, 60rem)',
+ 'wideSize' => 'clamp(16rem, 85vw, 70rem)',
+ ],
+// 'custom' => $custom->toArray(),
+ ],
+
+ /**
+ * ============================================
+ * Styles for FSE and Front-End
+ * ============================================
+ */
+ SectionNames::STYLES => [
+
+ 'typography' => FTypo::make()
+ ->fontFamily($font_family->varOf('base'))
+// ->fontSize( $font_sizes->varOf( 'base' ) )
+ ->fontSize('18px')
+ ->fontStyle('normal')
+ ->fontWeight('300')
+ ->letterSpacing('normal')
+ ->lineHeight($custom->varOf('lineHeight.m'))
+ ->textDecoration('none')
+ ->textTransform('none')
+ ->toArray(),
+
+ /**
+ * ============================================
+ * Blocks styles
+ * ============================================
+ */
+ 'blocks' => [
+
+ /**
+ * ============================================
+ * Blocks elements for images
+ * ============================================
+ */
+ 'core/site-logo' => [ // wp-block-site-logo {figure element}
+ 'spacing' => [
+ 'margin' => (string) FSpace::shorthand(['0']),
+ 'padding' => (string) FSpace::shorthand(['0']),
+ ],
+ ],
+ 'core/image' => [ // wp-block-image {figure element}
+ 'spacing' => [
+ 'margin' => (string) FSpace::make()
+ ->top('1rem')
+ ->bottom('0px'),
+ ],
+ ],
+ 'core/post-featured-image' => [ // wp-block-post-featured-image {figure element}
+// 'spacing' => [
+// 'margin' => (string) FSpace::make()
+// ->top( '1rem' )
+// ->bottom('0'),
+// ],
+ ],
+// 'core/gallery' => [ // wp-block-gallery {figure element}
+// ],
+
+ 'core/post-title' => [ // .wp-block-post-title
+ 'color' => FClr::make()
+ ->text('inherit')
+ ->toArray(),
+// 'border' => (new Border())
+// ->style('solid')
+// ->width('1px')
+// ->color('black')
+// ->toArray(),
+ 'typography' => FTypo::make()
+ ->fontSize('35px')
+ ->toArray(),
+ 'elements' => [
+ 'link' => [ // .wp-block-post-title a
+ 'color' => FClr::make()
+ ->text('inherit')
+ ->background('transparent')
+ ->toArray(),
+ ],
+ ],
+ ],
+
+ 'core/post-date' => [
+ 'typography' => FTypo::make()
+// ->fontSize( '0.75rem' )
+ ->toArray(),
+ ],
+ 'core/post-author' => [
+ 'typography' => FTypo::make()
+// ->fontSize( '16px' )
+ ->toArray(),
+ 'spacing' => [
+ 'margin' => (string) FSpace::make()
+// ->top($custom->varOf('spacer.base'))
+ ->top('2rem')
+ ->bottom('0px'),
+ ],
+ ],
+ 'core/post-terms' => [
+ 'typography' => FTypo::make()
+// ->fontSize( '0.75rem' )
+ ->toArray(),
+ ],
+
+ /**
+ * ============================================
+ * Blocks for content
+ * ============================================
+ */
+ 'core/post-content' => [ // .wp-block-post-content
+ 'color' => FClr::make()
+ ->text('inherit')
+ ->toArray(),
+ ],
+ 'core/post-excerpt' => [ // .wp-block-post-content
+ 'color' => FClr::make()
+ ->text('inherit')
+ ->toArray(),
+ ],
+ 'core/paragraph' => [ // .wp-block-post-content
+ 'color' => FClr::make()
+ ->text('inherit')
+ ->toArray(),
+ 'spacing' => [
+ 'margin' => (string) FSpace::make()
+ ->top('2rem')
+ ->bottom('0px'),
+ ],
+ ],
+ 'core/search' => [
+ 'spacing' => [
+ 'margin' => (string) FSpace::make()
+// ->top($custom->varOf('spacer.base'))
+ ->top('2rem')
+ ->bottom('0px'),
+ ],
+ ],
+ ],
+ ],
+ ];
+ }
+}
diff --git a/src/Asset/index.php b/src/Asset/index.php
deleted file mode 100644
index a5bcf147..00000000
--- a/src/Asset/index.php
+++ /dev/null
@@ -1,4 +0,0 @@
-config = $config;
- $this->info = $info;
- }
-
- public function shouldDisplay(): bool {
- return \is_author();
- }
-
- public function display(): void {
- echo $this->info->render(null, []);
- }
-}
diff --git a/src/Components/ArchiveHeadline.php b/src/Components/ArchiveHeadline.php
deleted file mode 100644
index 733efe81..00000000
--- a/src/Components/ArchiveHeadline.php
+++ /dev/null
@@ -1,41 +0,0 @@
-config = $config;
- $this->view = $view;
- $this->dispatcher = $dispatcher;
- }
-
- public function shouldDisplay(): bool {
- return ( \is_archive() || \is_search() ) && ! \is_author();
- }
-
- public function display(): void {
- echo \do_blocks( $this->view->render( 'misc/archive-headline', [
- EventDispatcherInterface::class => $this->dispatcher,
- ] ) );
- }
-}
diff --git a/src/Components/AuthorInfo.php b/src/Components/AuthorInfo.php
deleted file mode 100644
index 11ce11e4..00000000
--- a/src/Components/AuthorInfo.php
+++ /dev/null
@@ -1,19 +0,0 @@
-view = $view;
- }
-
- public function render( $slugs, $data = [] ): string {
- return \do_shortcode( \do_blocks( $this->view->render( $slugs ?? 'temp/author-info', $data ) ) );
- }
-}
diff --git a/src/Components/BlockQuery.php b/src/Components/BlockQuery.php
deleted file mode 100644
index d7286496..00000000
--- a/src/Components/BlockQuery.php
+++ /dev/null
@@ -1,88 +0,0 @@
-config = $config;
-// $this->view = $view;
-// }
-
- public function shouldDisplay(): bool {
- return ! \is_404();
- }
-
- public function display(): void {
- \ob_start();
-
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- dispatcher = $dispatcher;
- $this->config = $config;
- $this->support = $support;
- }
-
- public function shouldDisplay(): bool {
- return $this->support->has('breadcrumbs')
- && \in_array(
- $this->config->get('current_template_file'),
- \explode( ',', $this->config->get( 'breadcrumbs_show_on', '' ) ),
- true
- )
- && ! \in_array( 'hide_breadcrumbs', $this->config->get('post_content_template'), true );
- }
-
- public function display(): void {
- $args = [
- // 'home' => '',
- ];
-
- ob_start();
- $this->dispatcher->dispatch( 'do_breadcrumbs', $args );
- echo (string)ob_get_clean();
- }
-}
diff --git a/src/Components/Colophon.php b/src/Components/Colophon.php
deleted file mode 100644
index 177bd904..00000000
--- a/src/Components/Colophon.php
+++ /dev/null
@@ -1,58 +0,0 @@
-config->get(ConfigColophonProvider::COLOPHON_ACTION, self::EVENT_NAME);
- $event_priority = (int)$this->config->get(ConfigColophonProvider::COLOPHON_PRIORITY, self::EVENT_PRIORITY);
- yield $event_name => [
- static::CALLBACK => 'display',
- static::PRIORITY => $event_priority,
- ];
- }
-
- public function __construct(
- ConfigInterface $config,
- ViewInterface $view,
- EventDispatcherInterface $dispatcher
- ) {
- $this->config = $config;
- $this->view = $view;
- $this->dispatcher = $dispatcher;
- }
-
- public function shouldDisplay(): bool {
- return true;
- }
-
- public function display(): void {
- $content = (string)$this->config->get( ConfigColophonProvider::COLOPHON, '' );
-
- if ( empty( $content ) ) {
- return;
- }
-
- echo \do_blocks( $this->view->render( 'footers/colophon', [
- self::CONTENT => $this->dispatcher->filter( 'italystrap_colophon_output', $content ),
- ] ) );
- }
-}
diff --git a/src/Components/Comments.php b/src/Components/Comments.php
deleted file mode 100644
index 9e533a2a..00000000
--- a/src/Components/Comments.php
+++ /dev/null
@@ -1,37 +0,0 @@
-config = $config;
- $this->view = $view;
- }
-
- public function shouldDisplay(): bool {
- return \is_singular()
- && \post_type_supports( (string)\get_post_type(), 'comments' )
- && ! \in_array( 'hide_comments', $this->config->get('post_content_template'), true );
- }
-
- public function display(): void {
- echo \do_blocks( $this->view->render( 'comments' ) );
- }
-}
diff --git a/src/Components/ComponentInterface.php b/src/Components/ComponentInterface.php
deleted file mode 100644
index a62fcc6e..00000000
--- a/src/Components/ComponentInterface.php
+++ /dev/null
@@ -1,13 +0,0 @@
-subscriberRegister = $subscriberRegister;
- $this->dispatcher = $dispatcher;
- }
-
- /**
- * @inheritDoc
- */
- public function name(): string {
- return self::class;
- }
-
- /**
- * @inheritDoc
- */
- public function execute(AurynConfigInterface $application) {
- $this->dispatcher->addListener(
- 'template_include',
- function ( string $current_template = '' ) use ( $application ): string {
- $application->walk( $this->name(), [$this, 'walk'] );
- return $current_template;
- },
- PHP_INT_MAX - 5,
- 3
- );
- }
-
- /**
- * @return void
- */
- public function walk( string $class, $index_or_optionName, Injector $injector ) {
- /** @var SubscriberInterface|ComponentInterface $instance */
- $instance = $injector
- ->share($class)
- ->proxy($class, $this->proxyCallback())
- ->make($class);
-
- if ( $this->shouldNotDisplay( $instance ) ) {
- return;
- }
-
- $this->subscriberRegister->addSubscriber( $instance );
- }
-
- private function shouldNotDisplay( ComponentInterface $instance ): bool {
- return ! $instance->shouldDisplay();
- }
-
- /**
- * @psalm-return \Closure(string, callable):\ProxyManager\Proxy\ValueHolderInterface