Skip to content

An example WordPress plugin used to show how to include templates with your plugins and programmatically add them to the active theme.

Notifications You must be signed in to change notification settings

sebastianschmid/page-template-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Page Template Example

An example WordPress plugin used to show how to include templates with your plugins and programmatically add them to the active theme.

You can read more about this plugin and how it works in this blog post.

How It Works

The plugin works like this:

  1. Upon activation, it checks to see if a template with the same filename exists within the active theme's root directory.
  2. If so, the plugin will not do anything; however, if no template file exists, then it will create the template in the root of the active theme.
  3. Upon deactivation, the template will be removed from the active theme directory.

Installation

Using The WordPress Dashboard

  1. Navigate to the 'Add New' Plugin Dashboard
  2. Select page-template-example.zip from your computer
  3. Upload
  4. Activate the plugin on the WordPress Plugin Dashboard

Using FTP

  1. Extract page-template-dashboard.zip to your computer
  2. Upload the page-template-dashboard directory to your wp-content/plugins directory
  3. Activate the plugin on the WordPress Plugins Dashboard

Known Issues

Because this plugin is used strictly for example purposes, there are a number of things that are not properly handled:

  • If the user changes a theme, the plugin does not move the template to the new theme's directory.
  • There's practically no error handling for the file operations.
  • If a template with the same file name already exists, there's no notification or error handling in this case so the user has no idea that the bundled template was not activsated.
  • …I'm sure there are more.

This particular plugin is tagged as 0.1 and is open to any and all pull requests to help make this better, so feel free to contribute to resolve any of the above issues or any that you experience.

Changelog

0.1

7 March 2013

  • Initial release

About

An example WordPress plugin used to show how to include templates with your plugins and programmatically add them to the active theme.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%