2017 © Pedro Peláez
 

library wp-page-templates

Register and render Page templates from your plugin

image

codelight-eu/wp-page-templates

Register and render Page templates from your plugin

  • Tuesday, January 9, 2018
  • by indrek_k
  • Repository
  • 3 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PageTemplates

A simple class that allows registering WordPress Page templates from plugins., (*1)

Installation

composer require codelight-eu/page-templates

Usage

It's super simple. Run this somewhere in your WordPress plugin:, (*2)

<?php

    $pageTemplates = new Codelight\PageTemplates\PageTemplates();
    $pageTemplates->addTemplate(
        WP_PLUGIN_DIR . '/my-custom-plugin/templates/my-awesome-template.php',
        "My Awesome Template's Human-Readable Name"
    );

This adds the template to your WordPress site's Page edit interface. The addTemplate() function takes two params:, (*3)


/** * Add a new custom template. * * @param $file string Full path to the template file * @param $name string Human-readable template name */ public function addTemplate($file, $name) { $this->templates[$file] = $name; }

Credits

This library was adapted from http://www.wpexplorer.com/wordpress-page-templates-plugin/, (*4)

The Versions

09/01 2018

dev-master

9999999-dev https://github.com/codelight-eu/wp-page-templates

Register and render Page templates from your plugin

  Sources   Download

MIT

The Requires

  • php >=5.3.0