2017 © Pedro Peláez
 

wordpress-plugin template-selector

Adds a field to declare templates used by pages dynamically

image

lin3s/template-selector

Adds a field to declare templates used by pages dynamically

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Template selector

Adds a field to declare templates used by pages dynamically, (*1)

Scrutinizer Code Quality Total Downloads      Latest Stable Version Latest Unstable Version, (*2)

DEPRECATED: included in WPFoundation 1.6.0

This feature is included by default in WPFoundation since version 1.6.0. You just need to extend the abstract class LIN3S\WPFoundation\Configuration\Theme\Theme to get it working., (*3)

Why?

LIN3S's WPRouting is a very robust solution to manage the Wordpress routing system in a Symfony way. We came up with this solution in our way to a MVC architecture because many PHP files where scattered in our template root directory with dummy unstructured code., (*4)

This way, we are now able to match routes used by Wordpress with the actions from our Controllers, letting us to keep a simpler a more intuitive theme folder structure for new coming developers., (*5)

We faced some issues when we started using WP-Routing plugin, creating a php file in theme's root folder had no sense just to add an annotation. Therefore, we came up with this alternative to avoid using annotations to declare new page templates., (*6)

With this plugin you can now use a hook to add your custom page templates, and the default template selector items will be replaced with your programatically declared templates., (*7)

Installation

The recommended and the most suitable way to install is through Composer. Be sure that the tool is installed in your system and execute the following command:, (*8)

$ composer require lin3s/template-selector

Remember that Template Selector is a Wordpress plugin so, they can customize the location path easily with Composer ([more info][5]):, (*9)

"extra": {
    "installer-paths": {
        "src/plugins/{$name}/": ["type:wordpress-plugin"],
        "src/themes/{$name}/": ["type:wordpress-theme"],
        "src/mu-plugins/{$name}/": ["type:wordpress-muplugin"]
    }
}

Usage

To declare the templates just add the following hook to your WordPress theme., (*10)

add_filter('template_selector_available', [$this, 'templates']);

public function templates($templates) {
    return array_merge($templates, [
        'template-slug'    => 'Template name shown in admin',
        'another-template' => 'Another template'
    ]);
}

Licensing Options

License, (*11)

The Versions

20/05 2016

dev-master

9999999-dev

Adds a field to declare templates used by pages dynamically

  Sources   Download

MIT

lin3s wp-plugin template-selector

11/05 2016

v1.1.0

1.1.0.0

Adds a field to declare templates used by pages dynamically

  Sources   Download

MIT

lin3s wp-plugin template-selector

30/07 2015

v1.0.1

1.0.1.0

Adds a field to declare templates used by pages dynamically

  Sources   Download

MIT

lin3s wp-plugin template-selector

30/07 2015

v1.0.0

1.0.0.0

Adds a field to declare templates used by pages dynamically

  Sources   Download

MIT

lin3s wp-plugin template-selector