dev-master
9999999-deva WordPress Starter Theme
GPL-2.0
The Requires
- php >=7.0
- withfatpanda/ship-lib *
a WordPress Starter Theme
Ship is a WordPress Starter Theme standing on the shoulders of giants like Underscores, UnderStrap, and Sage., (*1)
We called it "Ship" because it helps us ship great web experiences, faster. That speed is achieved through some highly opinionated decisions about tools and process; if you want variety, fork Ship to create your own, or use Sage., (*2)
Ship is released under the terms of the GPL version 2 or (at your option) any later version, (*3)
If you need or can support this project, please head over to issues, (*4)
See changelog, (*5)
You'll need to have Composer installed., (*6)
composer create-project withfatpanda/ship "your/theme/path"
Ship wants your workflow to be as painless as possible. Below we move quickly through several topics that might be new to you, among them Dependency Management, Builds, and Asset Loading., (*7)
For those of you who want a quicker start instead, it goes something like this:, (*8)
composer create-project withfatpanda/ship "path/to/your/project"
npm install
npm build watch
src/js/theme.js
src/js/customizer.js
src/sass/theme/_theme.scss
src/sass/custom-editor-style.scss
All of Ship's JS and CSS is built upon a core set of dependencies, chief among them being Bootstrap., (*9)
Your new build system, Laravel Mix, also loads as a dependency., (*10)
All of these dependencies are managed through NPM. If you don't have NPM installed, you'll need to do that first., (*11)
Next, from the root of your theme project, run npm install
., (*12)
All of your theme's dependencies will appear in a folder named node_modules/
. There are going to be a lot of filesβdon't let this freak you out, and welcome to modern JavaScript development., (*13)
Once your dependencies have loaded, you can test-build by running the following command: npm run dev
., (*14)
If you get a "Compiled successfully..." message, then it's all working. If you don't, post your issue here., (*15)
The JS and CSS source files that underpin your new theme are as followsβthere are other files in there too, but those listed below are the ones relevant to learning this part:, (*16)
βββ src βββ img β βββ header.jpg βββ js β βββ customizer.js β βββ theme.js βββ sass βββ theme β βββ _theme.scss β βββ _variables.scss βββ custom-editor-style.scss βββ theme.scss
You'll want to put your theme's JavaScript into src/js/theme.js
and/or load other modules of code into that file., (*17)
You'll want to put your theme's styles into src/sass/theme/_theme.scss
and/or load other modules of code into that file., (*18)
img/header.jpg is an example so that you know where to place static imagery for your theme; files placed here are optimized and copied to public assets during the build, (*19)
js/customizer.js is where you can write code that will load into the Customizer; there are some examples therein, (*20)
js/theme.js is where you write code that will load into every view of your theme, (*21)
sass/theme/_theme.scss is where you write SCSS for your theme's main stylesheet, (*22)
sass/theme/_variables.scss is where you set variables that influence Bootstrap's styles as well as those in your theme, (*23)
sass/custom-editor-style.scss is where you write SCSS to generate a stylesheet that loads inside TinyMCE; the default just loads your theme's main stylesheet and adds some padding to the <body>
tag, (*24)
sass/theme.scss knits together all of your theme-specific SCSS code with Bootstrap, Font Awesome, and a bit of magic from the Underscores and UnderStrap projects, (*25)
Building your front-end code is as simple as running scripts with NPM at the command line. Just open your terminal, switch to the root of your theme project, and run any of the following:, (*26)
npm run dev
This will build your JS and CSS unminified and (when we finish building it) using development environment settings, (*27)
npm run watch
Use this command for active development sessionsβit will build dev versions of your JS and CSS, unminified, and will begin "watching" your raw source files, recompiling them into the built output anytime you make a change, (*28)
npm run hot
Coming soon: Live Reloading; basically just like the watch
command, except any changes to raw source files (including PHP files) result in your browser refreshing automatically, too, (*29)
npm run production
This will build minified and versioned copies of your JS and CSS, ready for distribution, (*30)
npm run dist
This will build distribution-ready copies of your JS and CSS, just like the production
command; then, this command creates a clean copy of your theme in dist/
ready to ship without all of the dev stuff (build config files, raw JS and Sass code), (*31)
Running any of the front-end build scripts above will generate and place files into an assets/
folder in the root of your project:, (*32)
βββ assets βββ css β βββ custom-editor-style.css β βββ custom-editor-style.css.map β βββ theme.css β βββ theme.css.map βββ fonts β βββ ... all the fonts extracted during the build βββ img β βββ ... all the images from src/img βββ js β βββ customizer.js β βββ customizer.js.map β βββ theme.js β βββ theme.js.map βββ mix-manifest.json
The relationships between these compiled files and the raw source files should be fairly straight-forward (Tip: they're all named the same), but of special note is the mix-manifest.json
file., (*33)
The mix-manifest.json
file, generated automatically during each build, establishes versions for your compiled files, i.e., versioning. When using asset loading (see below), the file version numbers are automatically appended to their URLsβthis helps to force expiration of these resources from visitors' browsers, keeping their experience of your theme up-to-date., (*34)
When loading a theme asset via PHP, use the global function asset($path)
where $path
is relative to your theme's assets folder. For example, invoking asset('css/theme.css')
would generate a URL for your theme's main stylesheet. For an example in context, refer to the script src/php/inc/enqueue.php
., (*35)
Coming soon., (*36)
If you're not using a CSS preprocessor to build your stylesheets, you're wasting a lot of time. If you've only ever used LESS, making the leap to Sass is fairly straightforward, and like us, we think you'll find Sass to be more robust and better-supported. Learn more about Sass here., (*37)
More details coming soon., (*38)
Your front-end build is powered by NPM and Laravel Mix (Webpack). The build commands described above in Building can be found in your package.json
file in the section named scripts
. They all ultimately invoke Webpack builds by way of Laravel Mix., (*39)
Laravel Mix can be configured by editing webpack.mix.js
. Most of the functions available to you for automating your builds are listed in this configuration file. You can also read Mix's documentation here., (*40)
Just add a new file to the themes root folder called rtl.css. Add all alignments to this file according to this description: https://codex.wordpress.org/Right_to_Left_Language_Support, (*41)
Coming soon., (*42)
a WordPress Starter Theme
GPL-2.0