# Wordpress Flow
# Starting WP Project
- Create projects/task/client in todo.vu
- Init WP project using
bash create <project-name>
- Init staic project using
bash create-static <project-name>
- Update permalinks from admin
- DEVELOP!!!!
Helpful reminder: Browsersync port 3000 does not play well with admin and AJAX calls
# Starting WP Project - Steps
# Create The Project
- Use the automation (opens new window) to create project.
- Update permalinks from admin.
- Optionally hide the admin bar in your user profile.
# When Created
- Checkout and evaluate the provided design.
- Define the components.
- Define which components and elements will be reusable.
- Define which elements are repeatable and plan their style: text blocks, headings, icons, etc.
- For images:
- Use SVGs for all icons.
- Use PNGs for icons which cannot be exported as SVGs.
- Use JPGs for content images (images which are subject to change via the WP admin).
- Define which fonts are used and if they are provided or available (opens new window).
# Before Develop
- Export needed images in right format from the provided design.
- If sprite is used, include it before closing body tag.
<?php include_once('assets/dist/sprite.svg'); ?>
(this should be included in the theme by default, if not, include it). - Regarding images:
- SVG icons should be in
assets/images/svg
. - PNG icons should be in
assets/images/sprite
. - PNG icons should be in two sizes - one for normal and one for retina displays, naming should be for normal displays -
name.png
, for retinaname@2x.png
. - Temporary images (which are to be uploaded via WP Admin) should go in
assets/images/temp
.
- SVG icons should be in
- Create a square PNG file out of the logo with sizes at least 512x512 pixels. Upload it in favicomatic (opens new window), select
every damn size
and download the.zip
file. Then copy images in the favicon folder in the project. - If project is one page use the
index.php
file, if not, create aheader.php
,footer.php
andtemplates
folder in main directory.templates
folder is the place where other created pages will stay. - Import the needed font styles (see fonts section below).
- Change
{ Project Title }
with the real project<title>
in the head section. - The
content
of the<meta name="application-name">
should also be updated with the correct project title. - Update also the content of
<meta name="msapplication-TileColor">
and<meta name="theme-color">
with the most used color in the provided design.
# Develop
# For HTML
- Create HTML structure.
- Make sections/components reusable. Each one of them should work the same way regardless of the context is is used.
- Use clean and not too specific html structure, when naming sections, components, classes etc. Be semantic, they should make sense, when reading it in the code.
# For CSS
- Use as much as posible the given predefined classes, mixins, variables etc. (
.o-grid
,.o-shell
, flex-box mixins, @include). - Set default styling, fonts, colors etc.
# Tips
# 1. Import fonts in WP Projects
# If the fonts are provided
- Upload the font files in Transfonter (opens new window) and convert them to
woff/woff2
formats, then download them. - Create
/fonts
folder in/assets
directory and paste files withwoff/woff2
formats. - In
styles/components/generic
, create file named_fonts.scss
and paste the content of the.css
file from the downloaded and unziped folder from Transfonter.
# If the fonts are not provided
1 Go to https://fonts.google.com/
and find the needed font/s. Then add the font styles you need and copy the url given to the head section of your .php
file. Then set the global font-family needed in styles/components/settings/_text.scss
.
# 2. Add theme image to the theme
Make a screenshot of the site theme's design and save it as a .png
file, named screenshot.png. Place it in your theme’s folder (or if we have child theme, nameOfParentTheme-child). Make sure to put it in the top-level directory and not in a subdirectory such as images.
The recommended size is 880 × 660
pixels, although it will be shown as 387 × 290
. The larger dimensions ensure that the image will show up well on high-resolution screens.
Other image formats such as .jpeg
and .gif
would also work, but .png
is recommended.
# 3. Images in WP project
# 1. Put an image as a background inline style
<div
style="background-image: url(<?php bloginfo('stylesheet_directory') ?>/assets/images/temp/your image name.jpg/png)"
></div>
# 2. Use an image in WP project
<img src="<?php bloginfo( 'stylesheet_directory' ); ?>/assets/images/pic.svg" alt="" />
# 3. Use svg icon
<svg class="svg-logo">
<use xlink:href="#svg-logo" />
</svg><!-- /.svg-logo -->
# 3. Import Font Awesome
# 1. Import Font Awesome 4
Write in terminal the command yarn add font-awesome
or npm install font-awesome
.
Go to main.scss
file in style
folder and import font-awesome with\
// External dependencies
@import $fa-font-path: '~font-awesome/fonts';
@import '~font-awesome/scss/font-awesome';`
or
// External dependencies
@import '~font-awesome/css/font-awesome.css' `;
You are done!
# 2. Import Font Awesome 5
Go in your FontAwesome account, then on the menu click on 'Font Awesome CDN'
, and copy the link provided to your head
s` document.
# 3. Import FullPage.js
fullPage.js - docs (opens new window)
- Write the command
yarn add fullpage.js
- Import fullpage.js's CSS at the top of your
main.scss
as
`@import 'fullpage.js/dist/fullpage.css';` (!! Make sure the path is correct !!)
- Import
Fullpage.js
in yourmain.js
file.
@import 'fullpage.js';
- Initialize
fullPage.js
instance.
new fullpage('#fullpage', {
//options here
autoScrolling: true,
scrollHorizontally: true
});
# Tips for CSS
- Don't style elements throught the
.o-shell
, if it's really necessary. - Use
rem
instead ofpx
. - Don't write long selectors. KISS (opens new window)