codeinwp/full-width-page-templates

A WordPress library to create full width page templates.

dev-master 2019-04-02 11:34 UTC

This package is auto-updated.

Last update: 2024-04-29 03:38:35 UTC


README

A composer library which injects, in WordPress Dashboard, a Full-Width option in the Page Template selector.

Codacy Badge

Supported Builders:

  • A plain simple WordPress page
  • Elementor

Compatible themes?

At this moment this library ensures compatibility with the follwing WordPress themes(and more to come):

How to use it?

Well, this is a Composer library so you will need to add this it as a dependency on your project( either plugin or a theme ) like this:

"require": {
    "codeinwp/full-width-page-templates": "master"
}

And run a via the terminal a composer install and hope that you have Composer installed globally.

The last step is the initialization. Call this wherever you like:

if ( class_exists( '\ThemeIsle\FullWidthTemplates' ) ) {
    \ThemeIsle\FullWidthTemplates::instance();
}

Work with this repository?

To work directly with this repository, I use and recommend the following way.

Clone this repository inside the mu-plugins WordPress directory. This way, we can be sure that the cloned version of this library will have priority before the one loaded from Composer. After cloning you need to create a php file, like load-fwt-lib.php(I'm so bad at naming) and inside you will need to require the loader like this:

<?php
require_once( dirname( __FILE__ ) . '/full-width-page-templates/load.php' );

How to make a theme compatible with the full-width template?

To add a new theme to the compatibility list, clone this repository(as we talked above) create a new directory with the theme's name in the themes directory. This theme directory supports two files:

  • inline-style.php - A file loaded at the right moment to add an inline style
  • functions.php - An optional file to add actions and filters.

Our goal here is to add a CSS snippet which will make sure that the page container width full. So make use of the inline-style.php and add a snipet like this:

<?php
/* Support for the {Theme Name} theme */
$style = '.page-template-builder-fullwidth-std .site-content {
    width: 100%;
    padding: 0;
    margin:0;
}';
wp_add_inline_style( '{theme-style}', $style );

Where {theme-style} must be an enqueued style.(For example, Twenty Seventeen has 'twentyseventeen-style')

Don't forget to add the new theme to this README.md ;)