diff --git a/.env b/.env new file mode 100644 index 0000000..9903255 --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +BROWSERSYNC_PROXY_URL=http://tofino.test +THEME_PATH=/wp-content/themes/tofino +DEPLOYMENT_PATH= +SSH_LOGIN= +DEPLOY=FALSE \ No newline at end of file diff --git a/.env.example b/.env.example deleted file mode 100644 index 19baf21..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -BROWSERSYNC_PROXY_URL=http://tofino.test -THEME_PATH=/wp-content/themes/tofino/ \ No newline at end of file diff --git a/.git-ftp-ignore b/.git-ftp-ignore new file mode 100644 index 0000000..863c511 --- /dev/null +++ b/.git-ftp-ignore @@ -0,0 +1,25 @@ +src +node_modules +.vscode +.editorconfig +.env +.git +.github +.gitignore +.gitkeep +.git-ftp-ignore +.git-ftp-include +.gitattributes +.gitignore +.babelrc +.stylelintrc.js +.prettierrc.js +.eslintrc.js +postcss.config.js +composer.json +composer.lock +package.json +package-lock.json +tailwind.config.js +webpack.mix.js +*.md \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..862d4a9 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,63 @@ +name: Development Build + +on: + push: + branches: [dev] + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install Composer Dependencies + run: composer install -o + + - name: Get NPM Cache Directory + uses: actions/cache@v2 + with: + path: '~/.npm' + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install NPM Dependencies + run: npm install + + - name: Build Dev Scripts + run: npm run dev + + - name: Get .env Variables + id: dotenv + uses: falti/dotenv-action@v0.2.7 + + - name: Sync Files to Server + env: + dest: '${{ steps.dotenv.outputs.SSH_LOGIN }}:${{ steps.dotenv.outputs.DEPLOYMENT_PATH }}${{ steps.dotenv.outputs.THEME_PATH }}' + deploy: '${{ steps.dotenv.outputs.DEPLOY }}' + if: ${{ env.deploy == 'TRUE' }} + run: | + echo "${{secrets.DEPLOY_KEY}}" > deploy_key + chmod 600 ./deploy_key + rsync -chav --delete \ + -e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \ + --exclude-from='.git-ftp-ignore' \ + --exclude /deploy_key \ + ./ ${{env.dest}} diff --git a/.gitignore b/.gitignore index 341da5b..445c2db 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,8 @@ !.env !.prettierrc.js !.babelrc -!.env.example +!.git-ftp-ignore +!.github # ignore node/grunt dependency directories node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ccf152..c0de87e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +# 3.2.2: (2021-10-10) + +### Features + +- Add auto build & deploy Github action. Fixes [#312](https://github.com/creativedotdesign/tofino/issues/312). ([45f032](https://github.com/creativedotdesign/tofino/commit/45f032f8b39c8d9505a45fa57eba93de2bd3aa85)) +- Add body open hook for GTM script. Fixes [#326](https://github.com/creativedotdesign/tofino/issues/326). ([2a4e092](https://github.com/creativedotdesign/tofino/commit/2a4e09267affcfa5ecbf84cb9f073b26dcf69a85)) + +### Bug Fixes + +- Update PHP min version. ([e7afd8](https://github.com/creativedotdesign/tofino/commit/e7afd841cca824d28ac3c93adf8c2599f22679ee)) +- Update Tailwind Purge Paths Fixes [#323](https://github.com/creativedotdesign/tofino/issues/323). ([ebf510](https://github.com/creativedotdesign/tofino/commit/ebf510302fdd1a79cb226d990d372b9a4acb831c)) +- Correct paths & add prefetch scripts. Fixes [#322](https://github.com/creativedotdesign/tofino/issues/322). ([c0f50a0](https://github.com/creativedotdesign/tofino/commit/c0f50a013407760bf3e199de18f735c30e892125)) +- Update menu class filter, fixes [#324](https://github.com/creativedotdesign/tofino/issues/324) & [#301](https://github.com/creativedotdesign/tofino/issues/301). ([4dc9638](https://github.com/creativedotdesign/tofino/commit/4dc963865240f0be8d4f92f7a80655f74f851177)) +- Add back in Fragment Cache script. Fixes [#325](https://github.com/creativedotdesign/tofino/issues/325). ([3933403](https://github.com/creativedotdesign/tofino/commit/39334032db792625172db73b9cbc51d8e1871596)) + # 3.2.1: (2021-09-26) ### Style diff --git a/README.md b/README.md index 32ec9af..a4441ef 100644 --- a/README.md +++ b/README.md @@ -73,33 +73,35 @@ We use [GitHub Actions](https://github.com/features/actions). The deployment scr ``` composer install npm install -npm run prod +npm run dev ``` The following files and directories should not be deployed on the server: ``` -.babelrc +src +node_modules +.vscode .editorconfig .env .git .github -.eslintrc.js .gitignore .gitkeep .git-ftp-ignore .git-ftp-include .gitattributes .gitignore -.prettierrc.js +.babelrc .stylelintrc.js -assets -node_modules +.prettierrc.js +.eslintrc.js +postcss.config.js composer.json composer.lock package.json package-lock.json tailwind.config.js webpack.mix.js -**/*.md +*.md ``` diff --git a/functions.php b/functions.php index 35d8d1c..bcbaf18 100644 --- a/functions.php +++ b/functions.php @@ -14,6 +14,7 @@ "inc/lib/helpers.php", "inc/lib/clean.php", "inc/lib/CustomizrTextEditor.php", + "inc/lib/FragmentCache.php", "inc/shortcodes/copyright.php", "inc/shortcodes/social-icons.php", "inc/shortcodes/svg.php", @@ -104,4 +105,21 @@ function acf_json_load_point($paths) { * Turn off YYYY/MM Media folders * */ -add_filter('option_uploads_use_yearmonth_folders', '__return_false', 100); \ No newline at end of file +add_filter('option_uploads_use_yearmonth_folders', '__return_false', 100); + + +/** + * Prefetch_scripts that might be needed later + * + * @since 3.3.0 + */ +function prefetch_scripts() { + $scripts = [ + // Add scripts here + ]; + + foreach ($scripts as $script) { + echo ''; + } +} +add_action('wp_head', 'prefetch_scripts'); diff --git a/header.php b/header.php index e8c7434..07e6967 100644 --- a/header.php +++ b/header.php @@ -11,6 +11,8 @@ > + +
diff --git a/inc/lib/clean.php b/inc/lib/clean.php index 4d689d8..c69cb9d 100644 --- a/inc/lib/clean.php +++ b/inc/lib/clean.php @@ -168,10 +168,26 @@ function add_defer_attribute($tag, $handle) { // Clean nav classes function clean_nav_classes($classes, $item) { - $classes = ['menu-item']; + $new_classes = ['menu-item']; if ($item->current) { - $classes[] = 'current'; + $new_classes[] = 'current'; + } + + if (in_array('menu-item-has-children', $classes)) { + $new_classes[] = 'menu-item-has-children'; + } + + if ($item->menu_item_parent == 0 && in_array('current-menu-parent', $classes)) { + $new_classes[] = 'current-parent'; + } + + $custom_classes = get_post_meta($item->ID, '_menu_item_classes', true); + + if (!empty(array_filter($custom_classes))) { + $classes = array_merge($new_classes, $custom_classes); + } else { + $classes = $new_classes; } return $classes; diff --git a/inc/lib/init.php b/inc/lib/init.php index 92837d6..f61dda2 100644 --- a/inc/lib/init.php +++ b/inc/lib/init.php @@ -17,8 +17,8 @@ */ function php_version_check() { $php_version = phpversion(); - if (version_compare($php_version, '5.5.9', '<')) { - wp_die('

' . __('PHP version >= 7.2.0 is required for this theme to work correctly.', 'tofino') . '

', 'An error occured.'); + if (version_compare($php_version, '7.3.0', '<')) { + wp_die('

' . __('PHP version >= 7.3.0 is required for this theme to work correctly.', 'tofino') . '

', 'An error occured.'); } } add_action('after_setup_theme', __NAMESPACE__ . '\\php_version_check'); @@ -106,3 +106,17 @@ function add_post_name_body_class(array $classes) { return $classes; } add_filter('body_class', __NAMESPACE__ . '\\add_post_name_body_class'); + + +/** + * Add Google Tag Manager function call which is + * supposed to be placed after opening body tag. + * + * @since 3.3.0 + */ +function add_custom_body_open_code() { + if (function_exists('gtm4wp_the_gtm_tag')) { + gtm4wp_the_gtm_tag(); + } +} +add_action('wp_body_open', __NAMESPACE__ . '\\add_custom_body_open_code'); diff --git a/package.json b/package.json index b620940..56a7d3c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tofino", "private": true, - "version": "3.2.1", + "version": "3.3.2", "description": "A WordPress starter theme for jumpstarting custom theme development.", "keywords": ["WordPress", "theme", "tofino"], "scripts": { diff --git a/style.css b/style.css index 5c3e506..74a0424 100644 --- a/style.css +++ b/style.css @@ -2,7 +2,7 @@ Theme Name: Tofino Theme URI: https://github.com/creativedotdesign/tofino Description: Tofino is a WordPress starter theme. Contribute on GitHub -Version: 3.2.1 +Version: 3.2.2 Author: Creative Dot Author URI: https://creativedotdesign.com Text Domain: tofino diff --git a/tailwind.config.js b/tailwind.config.js index 60378ee..d5ba1db 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -5,8 +5,8 @@ module.exports = { './*.php', './inc/**/*.php', './templates/**/*.php', - './assets/vue/*.vue', - './assets/styles/safelist.txt', + './src/vue/*.vue', + './src/styles/safelist.txt', ], }, theme: { diff --git a/webpack.mix.js b/webpack.mix.js index e7dfec6..69fad13 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -85,7 +85,7 @@ mix.webpackConfig({ }, output: { chunkFilename: 'js/chunks/[name].js', - publicPath: process.env.THEME_PATH + '/dist' || '/wp-content/themes/tofino/dist/', + publicPath: process.env.THEME_PATH + '/dist/' || '/wp-content/themes/tofino/dist/', }, });