├── .env
├── .gitignore
├── Dockerfile
├── README.md
├── docker-compose.yml
├── readme-assets
├── docker-logo.png
├── gulp-sass-logo.png
└── wp-logo.png
├── scripts
├── export_all.sh
├── export_db.sh
├── export_src.sh
└── functions.sh
├── src
├── gulp
│ ├── gulp-tasks
│ │ ├── JsPlugins.js
│ │ ├── JsTask.js
│ │ ├── cssTask.js
│ │ └── utils.js
│ └── paths.js
├── gulpfile.js
├── package-lock.json
├── package.json
├── plugins
│ └── index.php
├── themes
│ └── my-site
│ │ ├── .eslintrc
│ │ ├── .stylelintrc.json
│ │ ├── 404.php
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── archive.php
│ │ ├── comments.php
│ │ ├── composer.json
│ │ ├── footer.php
│ │ ├── functions.php
│ │ ├── header.php
│ │ ├── inc
│ │ ├── custom-header.php
│ │ ├── customizer.php
│ │ ├── jetpack.php
│ │ ├── template-functions.php
│ │ └── template-tags.php
│ │ ├── index.php
│ │ ├── js
│ │ ├── main.min.js
│ │ └── plugins.min.js
│ │ ├── languages
│ │ ├── my-site.pot
│ │ └── readme.txt
│ │ ├── layouts
│ │ ├── content-sidebar.css
│ │ └── sidebar-content.css
│ │ ├── package.json
│ │ ├── page.php
│ │ ├── phpcs.xml.dist
│ │ ├── readme.txt
│ │ ├── rtl.css
│ │ ├── screenshot.png
│ │ ├── search.php
│ │ ├── sidebar.php
│ │ ├── single.php
│ │ ├── src
│ │ ├── js
│ │ │ ├── main.js
│ │ │ └── plugins
│ │ │ │ └── jquery.js
│ │ └── sass
│ │ │ ├── _normalize.scss
│ │ │ ├── elements
│ │ │ ├── _elements.scss
│ │ │ ├── _lists.scss
│ │ │ └── _tables.scss
│ │ │ ├── forms
│ │ │ ├── _buttons.scss
│ │ │ ├── _fields.scss
│ │ │ └── _forms.scss
│ │ │ ├── layout
│ │ │ ├── _content-sidebar.scss
│ │ │ ├── _no-sidebar.scss
│ │ │ └── _sidebar-content.scss
│ │ │ ├── media
│ │ │ ├── _captions.scss
│ │ │ ├── _galleries.scss
│ │ │ └── _media.scss
│ │ │ ├── mixins
│ │ │ └── _mixins-master.scss
│ │ │ ├── modules
│ │ │ ├── _accessibility.scss
│ │ │ ├── _alignments.scss
│ │ │ ├── _clearings.scss
│ │ │ └── _infinite-scroll.scss
│ │ │ ├── navigation
│ │ │ ├── _links.scss
│ │ │ ├── _menus.scss
│ │ │ └── _navigation.scss
│ │ │ ├── site
│ │ │ ├── _site.scss
│ │ │ ├── primary
│ │ │ │ ├── _comments.scss
│ │ │ │ └── _posts-and-pages.scss
│ │ │ └── secondary
│ │ │ │ └── _widgets.scss
│ │ │ ├── style.scss
│ │ │ ├── typography
│ │ │ ├── _copy.scss
│ │ │ ├── _headings.scss
│ │ │ └── _typography.scss
│ │ │ └── variables-site
│ │ │ ├── _colors.scss
│ │ │ ├── _columns.scss
│ │ │ ├── _structure.scss
│ │ │ ├── _typography.scss
│ │ │ └── _variables-site.scss
│ │ ├── style.css
│ │ └── template-parts
│ │ ├── content-none.php
│ │ ├── content-page.php
│ │ ├── content-search.php
│ │ └── content.php
└── uploads
│ └── index.php
└── uploads.conf
/.env:
--------------------------------------------------------------------------------
1 | # The site domain
2 | SITE_URL=test.suthanbala.com
3 |
4 | # Wordpress Version | For all versions available visit https://hub.docker.com/_/wordpress?tab=tags&page=1
5 | WP_VERSION=6.4.0-apache
6 |
7 | # Database for MYSQL
8 | DB_USER=root
9 | MYSQL_DATABASE=my_wordpress
10 | MYSQL_ROOT_PASSWORD=mydbP@$$word
11 |
12 | # Additional WordPress configs to allow for plugins to be installed
13 | # For more info visit https://hub.docker.com/_/wordpress?tab=description&page=1
14 | WORDPRESS_CONFIG_EXTRA="define('FS_METHOD', 'direct');"
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /src/node_modules
2 | /build
3 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:14
2 | WORKDIR /var/www/html
3 |
4 | # Copying our package.json containing all the necessary dependencies
5 | COPY package.json /var/www/html/package.json
6 |
7 | # Installing Gulp, BrowserSync and other necessary packages
8 | RUN npm i
9 |
10 | # Copy all the Gulp related files
11 | COPY gulp ./gulp
12 | COPY ./gulpfile.js ./gulpfile.js
13 |
14 | # Exposing port 3000 for the page to be served via BrowserSync
15 | EXPOSE 3000
16 |
17 | # Exposing port 3001 for the admin console for BrowserSync
18 | EXPOSE 3001
19 |
20 | CMD ["npm run watch"]
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | 
3 | 
4 | 
5 |
6 | # WordPress Docker Gulp
7 | If you are one of those people who has to configure Gulp to compile SASS assets, concat and minify JS files, and Hot Reload for every single one of your WordPress projects, then this project is for you. On this project, we've utilized Docker to setup a container with latest version of WordPress and setup Gulp. All you need to do is, run `docker-compose up` on your terminal and it will fire up the docker running **Webserver to serve the WordPress** and **Node Server** to compile **SASS to CSS**, minify and concatenate JavaScript and to hot reload.
8 |
9 | You can then access your site at the domain you've set in the `.env` file. For example, if you site the `SITE_URL` to be yourdomain.com, then accessin this URL on your browser will bring up the normal WordPress site without the hot reloading enabled. You can access the hot reloading enabled version of the site at http://yourdomain.com/:3000.
10 |
11 | ## Features
12 | - Just worry about the things you are actually working with (`themes` and `plugins` folders from `wp-content`)
13 | - Less configuration
14 | - Comes with the PHPMyAdmin built-in, so you can manage the database
15 | - You can benefit from what [BrowserSync](https://www.browsersync.io/) has to offer:
16 | - Hot reloading for JavaScripts and Style Injection for CSS changes
17 | - Mobile Debugging
18 | - Your scrolls, clicks, refresh and form actions are mirrored between different devices and browsersers
19 | - ..these are just a few to list, visit [BrowserSync](https://www.browsersync.io/) for more details
20 | - The JS is configured such a way so that, all the JS found within the `themes/theme/src/js/*.js` gets combined and minified and exported into `main.min.js`
21 | - Similarly, the vendor JS files, found in the `themes/theme/src/js/plugins/*.js` gets combined and minified into `plugins.min.js`
22 | - The SASS file from within `themes/theme/src/sass/*.scss` gets combined and minified into `themes/theme/style.css`
23 |
24 | ## Installing / Getting started
25 |
26 | You may start by **cloning** this repo your machine. If you are working on an existing site, then copy the themes in to `src/themes/`, plugins into `src/plugins/` and the uploads into `src/uploads`. Also, if you have the Database SQL file, then place it inside the `src/initial-db` directory.
27 |
28 | ```shell
29 | git clone https://github.com/suthanbala/wordpress-docker-gulp.git dev.yourdomain.com
30 | git remote rm origin
31 | ```
32 | The command above clones the repo to your machine, then disassociate the repo. You can then commit to your own repo.
33 |
34 | You should now have the following structure:
35 |
36 | ```
37 | dev.yourdomain.com
38 | │ readme-assets
39 | └───wordpress
40 | └───src
41 | │ └───initial-db
42 | │ └───...
43 | └───scripts
44 | │ └───...
45 | │ .env
46 | │ docker-compose.yml
47 | │ Dockerfile
48 | │ ...
49 | ```
50 |
51 | The working directory will be **wordpress**.
52 |
53 | Once cloned, you must setup the folder permissions correctly. Otherwise, you'll face issues when saving files, or installing plugins.
54 | First, you'll need to change the owner of the `wordpress` directory to `www-data:www-data`. This will set the owner and the group to `www-data`.
55 | Then you'll need to grant permission the group to write. You do this by running `chmod g+w -Rf wordpress`. You may have to run it with `sudo`.
56 |
57 | ## Development
58 |
59 | ### Built With
60 | - [Docker](https://www.docker.com/)
61 | - [WordPress](https://wordpress.org/)
62 | - [BrowserSync](http://browsersync.io)
63 | - [NodeJS](https://nodejs.org/)
64 | - [SASS](https://sass-lang.com/)
65 |
66 | ### Pre-requisites
67 | You must have [Docker](https://www.docker.com/) installed on your machine. Everything outlined in this project gets run within the Docker container. Docker will download them and install them into the container during the build process.
68 |
69 | ### Setup
70 |
71 | You may want to add a `host` entry to your machine for the website you'll be creating. Run `sudo nano /etc/hosts` in your terminal if you're on Unix/MacOS, or, open NotePad as administrator, then open `C:\Windows\System32\drivers\etc\hosts` if you're on Windows. Then append the following line `127.0.0.1 yourdomain.com` to the hosts file. This will ensure, whenever you hit `yourdomain.com` on your machine, it points to your machine than going out to the internet.
72 |
73 | ```shell
74 | git clone https://github.com/suthanbala/wordpress-docker-gulp.git dev.yourdomain.com
75 | ```
76 |
77 | #### Setting the environment
78 |
79 | Go into the working directory and update the `SITE_URL` in your `.env`. Make sure you add that domain to your host file [Instructions here](https://support.rackspace.com/how-to/modify-your-hosts-file/). Once that's done, in your terminal, run the following command to build the containers:
80 | ```
81 | docker-compose build
82 | ```
83 |
84 | Now that you have the toolkit ready, you need a skeleton theme to start . You can create one at [Underscores](http://underscores.me/), it comes pre-packaged with a lot of WordPress recommended presets, and all necessary templates, HTML5 markup, and even SASS. To get the SASS enabled theme, click on **Advanced Options**, then check the `_sassify` option. Download the theme, and extract it into the `src/themes/` directory.
85 |
86 | Currently three directories are mounted into the projects:
87 |
88 | - `src/themes/*` --> `wp-content/themes/`
89 | - `src/plugins/*` --> `wp-content/plugins/`
90 | - `src/uploads/*` --> `wp-content/uploads/`
91 |
92 | #### Paths
93 | Gulp is configured to watch for any JS and SCSS files within your themes. JS is split into two categories, one being the plugins, and the second being the app.js. We separated the plugins so they can be loaded first to the page. Then the app.js can utilize that.
94 |
95 | The files must be placed like the following:
96 | ```
97 | - themes
98 | │ └───my-theme
99 | │ └───src
100 | │ └───sass
101 | │ └───styles.scss
102 | │ └───...
103 | │ └───js
104 | │ └───script1.js
105 | │ └───script2.js
106 | │ └───plugins
107 | │ └───jquery.js
108 | │ └───flexslider.js
109 | │ └───...
110 | ```
111 |
112 | #### Working with SASS
113 | The project is set to watch for any changes made to any sass files located in the directory **src/themes/yourtheme/src/sass/**. If you are using Underscores generated theme, then please move the `themename/sass` folder into `themename/src/sass`. Gulp watches and compiles the SASS from **src/themes/themename/src/sass/style.scss** to **src/themes/themename/style.css**.
114 |
115 | If you have multiple scss files, be sure to import them into the `style.scss` using `@import` directive.
116 |
117 | #### Working with JS
118 | Please your Javascripts in the **src/themes/themename/src/js**. If it's a plugin, then place them in **src/themes/themename/src/js/plugins/**. Anything else can go directly in the **src/themes/themename/src/js**.
119 |
120 | This ensures we combine and concat all the plugins together and load them ahead of the `app.js`. When we load the `app.js`, we can be sure that all the plugins have been loaded.
121 |
122 | Gulp is set to watch for any changes made in the **src/themes/yourtheme/src/js/*.js** folder and create a combined and minified **src/themes/yourtheme/js/main.min.js**. Also, the **src/themes/yourtheme/src/js/plugins/*.js** folder and create a combined and minified **src/themes/yourtheme/js/plugins.min.js**
123 |
124 | #### Managing Database
125 | The project comes with the PHPMyAdmin configured to connect to the MYSQL database without any credentials. You can access the PHPMyAdmin at [localhost:8080](http://localhost:8080).
126 |
127 | ### Deploying / Publishing
128 |
129 | While developing a WordPress theme, you are only making changes to either theme and plugins folder. However, when you are ready to deploy, you need the WordPress core files and database.
130 |
131 | Not to worry, we have that covered as well. You can run the `./scripts/export_all.sh` bash command. This will copy the WordPress core files and database SQL from the Docker container and place them in the `./build` folder.
132 |
133 | You can then upload them to your server.
134 |
135 | ## Build
136 | - To fully export the project, run the `export_all.sh` bash script located in the `scripts` folder. This will export all the source code and the SQL file into the `build` directory.
137 | - When you export the files, they are optimized. The JS and CSS files are minified with the sourcemaps removed. Also, the `src` directories are removed within the theme folders.
138 | - The `build` directory is git-ignored on this repo. This gives you the flexibility to have the contents of `build` directory in a different repo (Production files only).
139 | - If you just need the database, you can run the `/scripts/export_db.sh` Bash script. This will create a `db.sql` in the `build` directory.
140 | - If you just need the source files to be exported, you can run the `/scripts/export_src.sh` Bash script. This will copy all the source code including the themes, and plugins with the proper WordPress structure in to `build/html` directory.
141 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3.1"
2 | services:
3 | wordpress:
4 | image: wordpress:${WP_VERSION}
5 | restart: unless-stopped
6 | depends_on:
7 | - mysql-wordpress
8 | volumes:
9 | - ./wordpress:/var/www/html/
10 | - ./uploads.conf:/usr/local/etc/php/conf.d/uploads.ini
11 | - ./logs:/var/log/apache2
12 | ports:
13 | - 80:80
14 | env_file:
15 | - ./.env
16 | environment:
17 | - WORDPRESS_DB_HOST=mysql-wordpress
18 | - WORDPRESS_DB_USER=${DB_USER}
19 | - WORDPRESS_DB_PASSWORD=${MYSQL_ROOT_PASSWORD}
20 | - WORDPRESS_DB_NAME=${MYSQL_DATABASE}
21 | browsersync:
22 | depends_on:
23 | - wordpress
24 | build:
25 | context: ./src
26 | dockerfile: ../Dockerfile
27 | restart: unless-stopped
28 | links:
29 | - wordpress:${SITE_URL}
30 | env_file:
31 | - ./.env
32 | ports:
33 | - 3000:3000
34 | - 3001:3001
35 | volumes:
36 | - ./wordpress/wp-content/themes/:/var/www/html/themes
37 | - ./src/gulp/:/var/www/html/gulp
38 | - ./src/gulpfile.js:/var/www/html/gulpfile.js
39 | command: "npm run watch"
40 | mysql-wordpress:
41 | image: mysql
42 | restart: unless-stopped
43 | volumes:
44 | - ./src/initial-db:/docker-entrypoint-initdb.d
45 | env_file:
46 | - ./.env
47 | command: "--default-authentication-plugin=mysql_native_password"
48 | phpmyadmin:
49 | image: phpmyadmin/phpmyadmin
50 | links:
51 | - mysql-wordpress:db
52 | restart: unless-stopped
53 | ports:
54 | - 8080:80
55 | environment:
56 | - PMA_ARBITRARY=1
57 | - PMA_USER=${DB_USER}
58 | - PMA_PASSWORD=${MYSQL_ROOT_PASSWORD}
59 |
--------------------------------------------------------------------------------
/readme-assets/docker-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/suthanbala/wordpress-docker-gulp/73bbecb11e1fce691ea9f4936a733daf4200a9e6/readme-assets/docker-logo.png
--------------------------------------------------------------------------------
/readme-assets/gulp-sass-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/suthanbala/wordpress-docker-gulp/73bbecb11e1fce691ea9f4936a733daf4200a9e6/readme-assets/gulp-sass-logo.png
--------------------------------------------------------------------------------
/readme-assets/wp-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/suthanbala/wordpress-docker-gulp/73bbecb11e1fce691ea9f4936a733daf4200a9e6/readme-assets/wp-logo.png
--------------------------------------------------------------------------------
/scripts/export_all.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | current_path="`dirname \"$0\"`"
3 |
4 | sh "$current_path/export_db.sh"
5 | sh "$current_path/export_src.sh"
--------------------------------------------------------------------------------
/scripts/export_db.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | current_path="$(dirname "$0")"
3 | source "$current_path/functions.sh"
4 |
5 | # Vars
6 | container_manually_started=false # Has the container started manually or was it already started
7 | image_name="mysql"
8 | service_name="mysql-wordpress"
9 |
10 | # Ensure the build directory exists
11 | create_build_directory
12 |
13 | echo "Please wait until we export your database...";
14 |
15 | # Start the container if it hasn't started
16 | start_container_if_not_started "$image_name" "$service_name"
17 |
18 | # Get the container name
19 | container_name=$(get_container_name $image_name)
20 |
21 | # Run the command to export the MYSQL DB first. Then copy it to the host machine.
22 | docker exec $container_name bash -c 'mysqldump -u$DB_USER -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE > /db.sql; exit';
23 | docker cp $container_name:/db.sql ./build/db.sql
24 |
25 | echo "Database successfully copied."
26 |
27 | # If manually started the container, then let's stop it
28 | if [ "$container_manually_started" = true ] ; then
29 | docker-compose stop "$service_name" > /dev/null
30 | fi
--------------------------------------------------------------------------------
/scripts/export_src.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | current_path="$(dirname "$0")"
3 | source "$current_path/functions.sh"
4 |
5 | # Vars
6 | container_manually_started=false # Has the container started manually or was it already started
7 | image_name="wordpress:latest"
8 | service_name="wordpress"
9 |
10 | # Ensure the build directory exists
11 | create_build_directory
12 |
13 | echo "Please wait while we're exporting the WordPress files..."
14 |
15 | # Start the container if it hasn't started
16 | start_container_if_not_started "$image_name" "$service_name"
17 |
18 | # Get the container name
19 | container_name=$(get_container_name $image_name)
20 |
21 | # Spin up the browsersync service, build the files with the optimized settings
22 | docker-compose run -e NODE_ENV=production browsersync node_modules/.bin/gulp build
23 |
24 | # Run the Docker's COPY method to copy
25 | docker cp $container_name:/var/www/html/ ./build
26 | echo "Successfully exported the files."
27 |
28 |
29 | # Remove the src files from the final build
30 | cd $current_path
31 | cd ../build/html/wp-content/themes
32 | remove_src_directories_in_themes
33 |
34 | # If manually started the container, then let's stop it
35 | if [ "$container_manually_started" = true ] ; then
36 | docker-compose stop "$service_name" > /dev/null
37 | docker-compose stop mysql-wordpress > /dev/null
38 | fi
--------------------------------------------------------------------------------
/scripts/functions.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Create the build directory if it doesn't exist
4 | create_build_directory() {
5 | if [ ! -d ./build ]
6 | then
7 | mkdir -p ./build
8 | fi
9 | }
10 |
11 | # Get the container name that runs on the given image
12 | get_container_name() {
13 | image_name="$1"
14 | container_name=$(docker ps --filter "ancestor=$image_name" --format "{{.Names}}")
15 | echo "$container_name"
16 | }
17 |
18 | # Runs the given container given by it's image_name if it's not already running
19 | start_container_if_not_started() {
20 | image_name="$1"
21 | service_name="$2"
22 | container_name=$(get_container_name $image_name) #Find a running container with the given image name
23 |
24 | # A container is not running for the given image. Let's spin it up
25 | if [ -z "$container_name" ]; then
26 | docker-compose up -d "$service_name" > /dev/null
27 | container_manually_started=true
28 | container_name=$(get_container_name $image_name)
29 | echo ""
30 | echo "**Container wasn't started.. Started the container**"
31 | echo ""
32 | fi
33 | }
34 |
35 | remove_src_directories_in_themes() {
36 | for d in */ ; do
37 | if [ -d "$d/src" ];
38 | then
39 | echo "Removing the src files from the theme: $d"
40 | rm -r "$d/src"
41 | fi
42 | done
43 | }
--------------------------------------------------------------------------------
/src/gulp/gulp-tasks/JsPlugins.js:
--------------------------------------------------------------------------------
1 | const { src, dest } = require("gulp");
2 | const path = require("path");
3 | const rename = require("gulp-rename");
4 | const uglify = require("gulp-uglify");
5 | const concat = require("gulp-concat");
6 | const babel = require("gulp-babel");
7 |
8 | const appPaths = require("../paths");
9 | const { removeThemePathFromFilePath } = require("./utils");
10 |
11 | /**
12 | * The task to minify and concatenate the plugins
13 | */
14 | function jsPlugins(environment = 'development') {
15 | const options = {
16 | sourcemaps: true
17 | };
18 |
19 | if (environment === 'production') {
20 | options.sourcemaps = false;
21 | }
22 |
23 | let relativePath;
24 | return src(appPaths.jsPluginsPath, options)
25 | .pipe(
26 | rename((file) => {
27 | const result = removeThemePathFromFilePath(file, "../../");
28 | relativePath = file.dirname;
29 | return result;
30 | })
31 | )
32 | .pipe(
33 | babel({
34 | presets: ["@babel/env"],
35 | })
36 | )
37 | .pipe(concat("plugins.min.js"))
38 | .pipe(uglify())
39 | .pipe(
40 | dest(
41 | (file) => {
42 | // We go three levels up (`src/js/plugins`), then into `js/`
43 | finalPath = path.resolve(file.base, relativePath, "../../../", "js");
44 | return finalPath;
45 | },
46 | options
47 | )
48 | );
49 | }
50 |
51 | module.exports = jsPlugins;
52 |
--------------------------------------------------------------------------------
/src/gulp/gulp-tasks/JsTask.js:
--------------------------------------------------------------------------------
1 | const { src, dest } = require("gulp");
2 | const path = require("path");
3 | const rename = require("gulp-rename");
4 | const uglify = require("gulp-uglify");
5 | const concat = require("gulp-concat");
6 | const babel = require("gulp-babel");
7 |
8 | const appPaths = require("../paths");
9 | const { removeThemePathFromFilePath } = require("./utils");
10 |
11 | /**
12 | * The task to convert the app js into minified and concat them together.
13 | */
14 | function js(environment = 'development') {
15 | let relativePath;
16 | const options = {
17 | sourcemaps: true
18 | };
19 |
20 | if (environment === 'production') {
21 | options.sourcemaps = false;
22 | }
23 |
24 | return src(appPaths.jsPath, options)
25 | .pipe(
26 | rename((file) => {
27 | const result = removeThemePathFromFilePath(file, "../../");
28 | relativePath = file.dirname;
29 | return result;
30 | })
31 | )
32 | .pipe(
33 | babel({
34 | presets: ["@babel/env"],
35 | })
36 | )
37 | .pipe(concat("main.min.js"))
38 | .pipe(uglify())
39 | .pipe(
40 | dest(
41 | (file) => {
42 | // We go two levels up (`src/js`), then into `js/`
43 | finalPath = path.resolve(file.base, relativePath, "../../", "js");
44 | return finalPath;
45 | },
46 | options
47 | )
48 | );
49 | }
50 |
51 | module.exports = js;
52 |
--------------------------------------------------------------------------------
/src/gulp/gulp-tasks/cssTask.js:
--------------------------------------------------------------------------------
1 | const { src, dest } = require("gulp");
2 | const path = require("path");
3 | const rename = require("gulp-rename");
4 | const uglify = require("gulp-uglify");
5 | const concat = require("gulp-concat");
6 |
7 | const appPaths = require('../paths');
8 | const { removeThemePathFromFilePath } = require("./utils");
9 |
10 |
11 | /**
12 | * NOT IN USE UNTIL BrowserSync UPDATES THEIR DOCS
13 | */
14 |
15 |
16 | /**
17 | * The task to convert the SASS file into css
18 | */
19 | function css(environment = 'development') {
20 | let relativePath;
21 | const options = {
22 | sourcemaps: true
23 | };
24 |
25 | if (environment === 'production') {
26 | options.sourcemaps = false;
27 | }
28 |
29 | return src(appPaths.sass, options)
30 | .pipe(sass())
31 | .pipe(
32 | rename((file) => {
33 | const result = removeThemePathFromFilePath(file, "../../../");
34 | relativePath = file.dirname;
35 | return result;
36 | })
37 | )
38 | .pipe(stream())
39 | .pipe(
40 | dest(
41 | (file) => {
42 | // We go two levels up (`src/sass`), to the root folder
43 | finalPath = path.resolve(file.base, relativePath, "../../");
44 | return finalPath;
45 | },
46 | options
47 | )
48 | )
49 | }
--------------------------------------------------------------------------------
/src/gulp/gulp-tasks/utils.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | /**
4 | * Given the filename, we prepare the fullpath
5 | * @param {Vynil Object} file Gulp Vynil object
6 | */
7 | function concatFileName(file) {
8 | return file.dirname + "/" + file.basename + file.extname;
9 | }
10 |
11 | /**
12 | * Given the file object, we'll remove the src and the js or sass path removed. Then append the
13 | * `append` dirname to the path.
14 | * @param {object} file The file object with `dirname`, `basename` and `extension` properties
15 | * @param {string} levels How many levels to go up
16 | * @param {string} append The folder to append, once the `src` and the `folderName` removed
17 | */
18 | function removeThemePathFromFilePath(file, levels = "../../", append = "") {
19 | const result = JSON.parse(JSON.stringify(file));
20 | result.dirname = path.relative(
21 | path.resolve(),
22 | path.resolve(result.dirname, levels, append)
23 | );
24 |
25 | // console.log("\n\n", concatFileName(file), concatFileName(result));
26 | return result;
27 | }
28 |
29 | module.exports = {
30 | concatFileName,
31 | removeThemePathFromFilePath
32 | }
--------------------------------------------------------------------------------
/src/gulp/paths.js:
--------------------------------------------------------------------------------
1 | const appPaths = {
2 | php: "themes/*/**/*.php",
3 | sass: "themes/*/src/sass/**/*.scss",
4 | sassEntrypoint: "themes/*/src/sass/style.scss",
5 | jsPath: "themes/*/src/js/*.js",
6 | jsPluginsPath: "themes/*/src/js/plugins/*.js",
7 | };
8 |
9 | module.exports = appPaths;
10 |
--------------------------------------------------------------------------------
/src/gulpfile.js:
--------------------------------------------------------------------------------
1 | const { src, dest, parallel, series, watch } = require("gulp");
2 | const sass = require("gulp-sass")(require('sass'));
3 | const browserSync = require("browser-sync");
4 | const path = require("path");
5 | const gulpif = require('gulp-if');
6 | const concat = require("gulp-concat");
7 | const cleanCSS = require('gulp-clean-css');
8 | const rename = require("gulp-rename");
9 | const appPaths = require("./gulp/paths");
10 |
11 |
12 | const { removeThemePathFromFilePath } = require("./gulp/gulp-tasks/utils");
13 |
14 | // Load the tasks
15 | const js = require("./gulp/gulp-tasks/JsTask");
16 | const jsPlugins = require("./gulp/gulp-tasks/JsPlugins");
17 |
18 | const server = browserSync.create();
19 |
20 | const siteUrl = process.env.SITE_URL || 'http://localhost';
21 | const environment = process.env.NODE_ENV === 'production' ? 'production' : 'development';
22 |
23 | /**
24 | * BrowserSync's reload method
25 | * @param {function} done callback method
26 | */
27 | function reload(done) {
28 | server.reload();
29 | done();
30 | }
31 |
32 | /**
33 | * BrowserSync's server initialization
34 | * @param {function} done callback method
35 | */
36 | function serve(done) {
37 | server.init({
38 | proxy: siteUrl
39 | });
40 | done();
41 | }
42 |
43 | /**
44 | * The task to convert the SASS file into css
45 | */
46 | function css() {
47 | let relativePath;
48 | const options = {
49 | sourcemaps: true
50 | };
51 |
52 | if (environment === 'production') {
53 | options.sourcemaps = false;
54 | }
55 |
56 | return src(appPaths.sassEntrypoint, options)
57 | .pipe(sass())
58 | .pipe(
59 | rename((file) => {
60 | const result = removeThemePathFromFilePath(file, "../../../");
61 | relativePath = file.dirname;
62 | return result;
63 | })
64 | )
65 | .pipe(cleanCSS())
66 | .pipe(concat("style.css"))
67 | .pipe(gulpif(environment !== 'production', server.stream()))
68 | .pipe(
69 | dest(
70 | (file) => {
71 | // We go two levels up (`src/sass`), to the root folder
72 | finalPath = path.resolve(file.base, relativePath, "../../");
73 | return finalPath;
74 | },
75 | options
76 | )
77 | )
78 | }
79 |
80 | /**
81 | * The Watch task, that'll watch the JS and SASS files and trigger a reload / style injection
82 | */
83 | function watchTask() {
84 | watch(appPaths.jsPath, series(() => js(environment), reload));
85 | watch(appPaths.jsPluginsPath, series(() => jsPlugins(environment), reload));
86 | watch(appPaths.php, reload);
87 | watch(appPaths.sass, css);
88 | }
89 |
90 | /**
91 | * The dev entry point, it will run the jsPlugins, JS, CSS then start the BrowserSync.
92 | * Then it will watch the files for any changes and run the required tasks.
93 | */
94 | const dev = series(() => jsPlugins(environment), () => js(environment), css, serve, watchTask);
95 |
96 | exports.js = js;
97 | exports.jsPlugins = jsPlugins;
98 | exports.css = css;
99 | exports.dev = dev;
100 | exports.build = parallel(css, () => js('production'), () => jsPlugins('production'));
101 | exports.default = parallel(css, () => js(environment), () => jsPlugins(environment), dev);
102 |
--------------------------------------------------------------------------------
/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "docker-wordpress-gulp",
3 | "version": "1.0.0",
4 | "description": "Docker image for Wordpress using Gulp and BrowserSync.",
5 | "main": "index.php",
6 | "scripts": {
7 | "start": "gulp",
8 | "watch": "gulp dev",
9 | "test": "echo \"Error: no test specified\" && exit 1"
10 | },
11 | "author": "Suthan Bala",
12 | "license": "ISC",
13 | "devDependencies": {
14 | "@babel/core": "^7.16.0",
15 | "@babel/preset-env": "^7.16.0",
16 | "browser-sync": "^2.27.7",
17 | "glob-parent": "^6.0.2",
18 | "gulp": "^4.0.2",
19 | "gulp-babel": "^8.0.0",
20 | "gulp-clean-css": "^4.3.0",
21 | "gulp-concat": "^2.6.1",
22 | "gulp-if": "^3.0.0",
23 | "gulp-rename": "^2.0.0",
24 | "gulp-sass": "^5.0.0",
25 | "gulp-sourcemaps": "^2.6.5",
26 | "gulp-uglify": "^3.0.2",
27 | "sass": "^1.43.4"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/plugins/index.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/suthanbala/wordpress-docker-gulp/73bbecb11e1fce691ea9f4936a733daf4200a9e6/src/plugins/index.php
--------------------------------------------------------------------------------
/src/themes/my-site/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "plugin:@wordpress/eslint-plugin/es5"
4 | ],
5 | "env": {
6 | "browser": true
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/themes/my-site/.stylelintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "stylelint-config-wordpress/scss"
4 | ],
5 | "ignoreFiles": [
6 | "sass/_normalize.scss"
7 | ],
8 | "rules": {
9 | "font-family-no-missing-generic-family-keyword": null,
10 | "no-descending-specificity": null,
11 | "block-no-empty": null,
12 | "no-duplicate-selectors": null,
13 | "font-family-no-duplicate-names": null
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/themes/my-site/404.php:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
24 |
29 |
30 |
46 |
47 | ' . sprintf( esc_html__( 'Try looking in the monthly archives. %1$s', 'my-site' ), convert_smilies( ':)' ) ) . '';
50 | the_widget( 'WP_Widget_Archives', 'dropdown=1', "after_title=$my_site_archive_content" );
51 |
52 | the_widget( 'WP_Widget_Tag_Cloud' );
53 | ?>
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/src/themes/my-site/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/Automattic/_s)
2 |
3 | _s
4 | ===
5 |
6 | Hi. I'm a starter theme called `_s`, or `underscores`, if you like. I'm a theme meant for hacking so don't use me as a Parent Theme. Instead try turning me into the next, most awesome, WordPress theme out there. That's what I'm here for.
7 |
8 | My ultra-minimal CSS might make me look like theme tartare but that means less stuff to get in your way when you're designing your awesome theme. Here are some of the other more interesting things you'll find here:
9 |
10 | * A just right amount of lean, well-commented, modern, HTML5 templates.
11 | * A helpful 404 template.
12 | * A custom header implementation in `inc/custom-header.php` just add the code snippet found in the comments of `inc/custom-header.php` to your `header.php` template.
13 | * Custom template tags in `inc/template-tags.php` that keep your templates clean and neat and prevent code duplication.
14 | * Some small tweaks in `inc/template-functions.php` that can improve your theming experience.
15 | * A script at `js/navigation.js` that makes your menu a toggled dropdown on small screens (like your phone), ready for CSS artistry. It's enqueued in `functions.php`.
16 | * 2 sample CSS layouts in `layouts/` for a sidebar on either side of your content.
17 | Note: `.no-sidebar` styles are not automatically loaded.
18 | * Smartly organized starter CSS in `style.css` that will help you to quickly get your design off the ground.
19 | * Full support for `WooCommerce plugin` integration with hooks in `inc/woocommerce.php`, styling override woocommerce.css with product gallery features (zoom, swipe, lightbox) enabled.
20 | * Licensed under GPLv2 or later. :) Use it to make something cool.
21 |
22 | Getting Started
23 | ---------------
24 |
25 | If you want to keep it simple, head over to https://underscores.me and generate your `_s` based theme from there. You just input the name of the theme you want to create, click the "Generate" button, and you get your ready-to-awesomize starter theme.
26 |
27 | If you want to set things up manually, download `_s` from GitHub. The first thing you want to do is copy the `_s` directory and change the name to something else (like, say, `megatherium-is-awesome`), and then you'll need to do a five-step find and replace on the name in all the templates.
28 |
29 | 1. Search for `'_s'` (inside single quotations) to capture the text domain.
30 | 2. Search for `_s_` to capture all the function names.
31 | 3. Search for `Text Domain: _s` in `style.css`.
32 | 4. Search for _s
(with a space before it) to capture DocBlocks.
33 | 5. Search for `_s-` to capture prefixed handles.
34 | 6. Search for `_S_` (in uppercase) to capture constants.
35 |
36 | OR
37 |
38 | 1. Search for: `'_s'` and replace with: `'megatherium-is-awesome'`.
39 | 2. Search for: `_s_` and replace with: `megatherium_is_awesome_`.
40 | 3. Search for: `Text Domain: _s` and replace with: `Text Domain: megatherium-is-awesome` in `style.css`.
41 | 4. Search for: _s
and replace with: Megatherium_is_Awesome
.
42 | 5. Search for: `_s-` and replace with: `megatherium-is-awesome-`.
43 | 6. Search for: `_S_` and replace with: `MEGATHERIUM_IS_AWESOME_`.
44 |
45 | Then, update the stylesheet header in `style.css`, the links in `footer.php` with your own information and rename `_s.pot` from `languages` folder to use the theme's slug. Next, update or delete this readme.
46 |
47 | Now you're ready to go! The next step is easy to say, but harder to do: make an awesome WordPress theme. :)
48 |
49 | Good luck!
50 |
--------------------------------------------------------------------------------
/src/themes/my-site/archive.php:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
24 |
25 |
47 |
48 |
49 |
50 |
51 |
22 |
23 |
78 |
--------------------------------------------------------------------------------
/src/themes/my-site/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "automattic/underscores",
3 | "type": "wordpress-theme",
4 | "description": "Hi. I'm a starter theme called _s, or underscores, if you like. I'm a theme meant for hacking so don't use me as a Parent Theme. Instead try turning me into the next, most awesome, WordPress theme out there. That's what I'm here for.",
5 | "keywords": [
6 | "WordPress",
7 | "Themes"
8 | ],
9 | "homepage": "https://github.com/Automattic/_s",
10 | "license": "GPL-2.0-or-later",
11 | "authors": [
12 | {
13 | "name": "Contributors",
14 | "homepage": "https://github.com/Automattic/_s/graphs/contributors"
15 | }
16 | ],
17 | "require": {
18 | "php": ">=5.6"
19 | },
20 | "require-dev": {
21 | "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2",
22 | "wptrt/wpthemereview": "^0.2.1",
23 | "php-parallel-lint/php-parallel-lint": "^1.2.0",
24 | "wp-cli/i18n-command": "^2.2"
25 | },
26 | "scripts": {
27 | "lint:wpcs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
28 | "lint:php": "@php ./vendor/bin/parallel-lint --exclude .git --exclude vendor .",
29 | "make-pot": "wp i18n make-pot . languages/_s.pot"
30 | },
31 | "support": {
32 | "issues": "https://github.com/Automattic/_s/issues",
33 | "source": "https://github.com/Automattic/_s"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/themes/my-site/footer.php:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
31 |
32 |
33 |
34 |
35 |
30 | ' . wp_kses_post( get_the_title() ) . '' 37 | ); 38 | } else { 39 | printf( 40 | /* translators: 1: comment count number, 2: title. */ 41 | esc_html( _nx( '%1$s thought on “%2$s”', '%1$s thoughts on “%2$s”', $my_site_comment_count, 'comments title', 'my-site' ) ), 42 | number_format_i18n( $my_site_comment_count ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 43 | '' . wp_kses_post( get_the_title() ) . '' 44 | ); 45 | } 46 | ?> 47 |
48 | 49 | 50 | 51 |52 | 'ol', 56 | 'short_ping' => true, 57 | ) 58 | ); 59 | ?> 60 |
61 | 62 | 68 | 69 | 76 | 77 |