Skip to content

Commit

Permalink
Merge pull request #327 from creativedotdesign/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
danimalweb authored Oct 10, 2021
2 parents 576463d + 22d5535 commit d51c1ed
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BROWSERSYNC_PROXY_URL=http://tofino.test
THEME_PATH=/wp-content/themes/tofino
DEPLOYMENT_PATH=
SSH_LOGIN=
DEPLOY=FALSE
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

25 changes: 25 additions & 0 deletions .git-ftp-ignore
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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}}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
!.env
!.prettierrc.js
!.babelrc
!.env.example
!.git-ftp-ignore
!.github

# ignore node/grunt dependency directories
node_modules/
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
20 changes: 19 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
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 '<link rel="prefetch" as="script" href="' . mix('js/chunks/' . $script . '.js', 'dist') . '" crossorigin="anonymous"/>';
}
}
add_action('wp_head', 'prefetch_scripts');
2 changes: 2 additions & 0 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
</head>
<body <?php body_class(); ?>>

<?php wp_body_open(); ?>

<?php n\notification('top'); ?>

<header class="<?php echo m\menu_sticky(); ?>">
Expand Down
20 changes: 18 additions & 2 deletions inc/lib/clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 16 additions & 2 deletions inc/lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
function php_version_check() {
$php_version = phpversion();
if (version_compare($php_version, '5.5.9', '<')) {
wp_die('<div class="error notice"><p>' . __('PHP version >= 7.2.0 is required for this theme to work correctly.', 'tofino') . '</p></div>', 'An error occured.');
if (version_compare($php_version, '7.3.0', '<')) {
wp_die('<div class="error notice"><p>' . __('PHP version >= 7.3.0 is required for this theme to work correctly.', 'tofino') . '</p></div>', 'An error occured.');
}
}
add_action('after_setup_theme', __NAMESPACE__ . '\\php_version_check');
Expand Down Expand Up @@ -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');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Theme Name: Tofino
Theme URI: https://github.com/creativedotdesign/tofino
Description: Tofino is a WordPress starter theme. <a href="https://github.com/creativedotdesign/tofino">Contribute on GitHub</a>
Version: 3.2.1
Version: 3.2.2
Author: Creative Dot
Author URI: https://creativedotdesign.com
Text Domain: tofino
Expand Down
4 changes: 2 additions & 2 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion webpack.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
},
});

Expand Down

0 comments on commit d51c1ed

Please sign in to comment.