Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
v3.0
Browse files Browse the repository at this point in the history
- New libraries and other tweaks
  • Loading branch information
Hugh Lashbrooke committed Aug 5, 2014
1 parent 5c27378 commit e65c167
Show file tree
Hide file tree
Showing 13 changed files with 863 additions and 1,252 deletions.
905 changes: 285 additions & 620 deletions LICENSE

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions README.md
Expand Up @@ -20,6 +20,30 @@ You can run the script just like you would run any shell script - it does not ta
2. **Destination folder** - this will be the folder where your new plugin will be created - typically this will be your `wp-content/plugins` folder. You can provide a path that is relative to the script, or an absolute path - either will work.
3. **Initialise new git repo (y/n)** - if you enter 'y' here then a git repo will be initialised in the new plugin folder.

### API functions

As of v3.0 of this template, there are a few libraries built into it that will make a number of common tasks a lot easier. I will expand on these libraries in future versions.

#### Registering a new post type

Using the post type API and the wrapper function from the main plugin class you can easily register new post types with one line of code. For exapmle if you wanted to register a `listing` post type then you could do it like this:

`WordPress_Plugin_Template()->register_post_type( 'listing', __( 'Listings', 'wordpress-plugin-template' ), __( 'Listing', 'wordpress-plugin-template' ) );`

*Note that the `WordPress_Plugin_Template()` function name and the `wordpress-plugin-template` text domain will each be unique to your plugin after you have used the cloning script.*

This will register a new post type with all the standard settings. If you would like to modify the post type settings you can use the `{$post_type}_register_args` filter. See [the WordPress codex page](http://codex.wordpress.org/Function_Reference/register_post_type) for all available arguments.

#### Registering a new taxonomy

Using the taxonomy API and the wrapper function from the main plugin class you can easily register new taxonomies with one line of code. For exapmle if you wanted to register a `location` taxonomy that applies to the `listing` post type then you could do it like this:

`WordPress_Plugin_Template()->register_taxonomy( 'location', __( 'Locations', 'wordpress-plugin-template' ), __( 'Location', 'wordpress-plugin-template' ), 'listing' );`

*Note that the `WordPress_Plugin_Template()` function name and the `wordpress-plugin-template` text domain will each be unique to your plugin after you have used the cloning script.*

This will register a new taxonomy with all the standard settings. If you would like to modify the taxonomy settings you can use the `{$taxonomy}_register_args` filter. See [the WordPress codex page](http://codex.wordpress.org/Function_Reference/register_taxonomy) for all available arguments.

## What does this template give me?

This template includes the following features:
Expand All @@ -30,10 +54,12 @@ This template includes the following features:
+ Full & minified Javascript files
+ Grunt.js support
+ Standard enqueue functions for the dashboard and the frontend
+ A class (not utilised in the template directly) that can be used to create a new custom post type and custom taxonomies
+ A library for easily registering a new post type
+ A library for easily registering a new taxonomy
+ A library for handling common admin functions
+ A complete and versatile settings class like you see [here](http://www.hughlashbrooke.com/complete-versatile-options-page-class-wordpress-plugin/)
+ A .pot file to make localisation easier
+ Full text of the GPLv3 license
+ Full text of the GPLv2 license

See the [changelog](https://github.com/hlashbrooke/WordPress-Plugin-Template/blob/master/changelog.txt) for a complete list of changes as the template develops.

Expand Down
53 changes: 42 additions & 11 deletions build-plugin.sh
Expand Up @@ -106,20 +106,51 @@ sed "s/$DEFAULT_SLUG/$SLUG/g" class-$SLUG-settings.tmp > class-$SLUG-settings.ph
rm class-$SLUG-settings.tmp


cd post-types
mv class-$DEFAULT_SLUG-post_type.php class-$SLUG-post_type.php
cd lib
mv class-$DEFAULT_SLUG-post-type.php class-$SLUG-post-type.php

cp class-$SLUG-post_type.php class-$SLUG-post_type.tmp
sed "s/$DEFAULT_CLASS/$CLASS/g" class-$SLUG-post_type.tmp > class-$SLUG-post_type.php
rm class-$SLUG-post_type.tmp
cp class-$SLUG-post-type.php class-$SLUG-post-type.tmp
sed "s/$DEFAULT_CLASS/$CLASS/g" class-$SLUG-post-type.tmp > class-$SLUG-post-type.php
rm class-$SLUG-post-type.tmp

cp class-$SLUG-post_type.php class-$SLUG-post_type.tmp
sed "s/$DEFAULT_TOKEN/$TOKEN/g" class-$SLUG-post_type.tmp > class-$SLUG-post_type.php
rm class-$SLUG-post_type.tmp
cp class-$SLUG-post-type.php class-$SLUG-post-type.tmp
sed "s/$DEFAULT_TOKEN/$TOKEN/g" class-$SLUG-post-type.tmp > class-$SLUG-post-type.php
rm class-$SLUG-post-type.tmp

cp class-$SLUG-post-type.php class-$SLUG-post-type.tmp
sed "s/$DEFAULT_SLUG/$SLUG/g" class-$SLUG-post-type.tmp > class-$SLUG-post-type.php
rm class-$SLUG-post-type.tmp


mv class-$DEFAULT_SLUG-taxonomy.php class-$SLUG-taxonomy.php

cp class-$SLUG-taxonomy.php class-$SLUG-taxonomy.tmp
sed "s/$DEFAULT_CLASS/$CLASS/g" class-$SLUG-taxonomy.tmp > class-$SLUG-taxonomy.php
rm class-$SLUG-taxonomy.tmp

cp class-$SLUG-taxonomy.php class-$SLUG-taxonomy.tmp
sed "s/$DEFAULT_TOKEN/$TOKEN/g" class-$SLUG-taxonomy.tmp > class-$SLUG-taxonomy.php
rm class-$SLUG-taxonomy.tmp

cp class-$SLUG-taxonomy.php class-$SLUG-taxonomy.tmp
sed "s/$DEFAULT_SLUG/$SLUG/g" class-$SLUG-taxonomy.tmp > class-$SLUG-taxonomy.php
rm class-$SLUG-taxonomy.tmp


mv class-$DEFAULT_SLUG-admin-api.php class-$SLUG-admin-api.php

cp class-$SLUG-admin-api.php class-$SLUG-admin-api.tmp
sed "s/$DEFAULT_CLASS/$CLASS/g" class-$SLUG-admin-api.tmp > class-$SLUG-admin-api.php
rm class-$SLUG-admin-api.tmp

cp class-$SLUG-admin-api.php class-$SLUG-admin-api.tmp
sed "s/$DEFAULT_TOKEN/$TOKEN/g" class-$SLUG-admin-api.tmp > class-$SLUG-admin-api.php
rm class-$SLUG-admin-api.tmp

cp class-$SLUG-admin-api.php class-$SLUG-admin-api.tmp
sed "s/$DEFAULT_SLUG/$SLUG/g" class-$SLUG-admin-api.tmp > class-$SLUG-admin-api.php
rm class-$SLUG-admin-api.tmp

cp class-$SLUG-post_type.php class-$SLUG-post_type.tmp
sed "s/$DEFAULT_SLUG/$SLUG/g" class-$SLUG-post_type.tmp > class-$SLUG-post_type.php
rm class-$SLUG-post_type.tmp

if [ "$NEWREPO" == "y" ]; then
echo "Initialising new git repo..."
Expand Down
68 changes: 37 additions & 31 deletions changelog.txt
@@ -1,37 +1,43 @@
*** WordPress Plugin Template Changelog ***

= 2.1 =
* 2013-06-27
* New - Adding Grunt.js support (kudos kloon)
* New - Including custom post type class by default
* Tweak - Updating custom post type class to be compatible with the rest of the plugin
* Tweak - Improving general syntax
* Tweak - Making build-plugin.sh compatible with more devices (kudos Natrio42)
* Fix - Markup fix (kudos mrsonord)
2014.08.05 - version 3.0.0
* New - Library for registering post types
* New - Library for registering taxonomies
* New - Library for generic admin functions
* New - Adding wrapper functions to main plugin class to emply new libraries
* Tweak - Updating build-plugin.sh to cater for new library files
* Tweak - Bumping compatibility version
* Tweak - Adding correct GPL reference
* Tweak - Updating README.md with a few pointers on how to use the new libraries
* Fix - Markup fix for settings fields

= 2.0 =
* 2013-04-07
* New - Refactoring method for loading main class - see main plugin file for changes and explanation
* New - Minifying JS
* New - Adding default CSS & Less files
* New - Adding script and style enqueue functions
* New - Adding shell script to clone template to new folder
* Tweak - Adding further DocBlock comments
* Tweak - Modifying readme.txt to be more generic
* Fix - Fixing image upload settings field to work with more than one field on the same page
* Fix - Fixing column headers for custom post types (kudos ffabiosales)
2014.06.27 - version 2.1.0
* New - Adding Grunt.js support (kudos kloon)
* New - Including custom post type class by default
* Tweak - Updating custom post type class to be compatible with the rest of the plugin
* Tweak - Improving general syntax
* Tweak - Making build-plugin.sh compatible with more devices (kudos Natrio42)
* Fix - Markup fix (kudos mrsonord)

= 1.1 =
* 2013-02-26
* New - Completely refactoring the settings class
* Tweak - Updating WordPress version compatibility
2014.04.07 - version 2.0.0
* New - Refactoring method for loading main class
* New - Minifying JS
* New - Adding default CSS & Less files
* New - Adding script and style enqueue functions
* New - Adding shell script to clone template to new folder
* Tweak - Adding further DocBlock comments
* Tweak - Modifying readme.txt to be more generic
* Fix - Fixing image upload settings field to work with more than one field on the same page
* Fix - Fixing column headers for custom post types (kudos ffabiosales)

= 1.0.1 =
* 2013-12-05
* Tweak - Adding DocBlock comments
* Tweak - Slight refactor
* Tweak - Updating WordPress version compatibility
2014.02.26 - version 1.1.0
* New - Completely refactoring the settings class
* Tweak - Updating WordPress version compatibility

= 1.0 =
* 2012-12-13
* Initial release
2013.12.05 - version 1.0.1
* Tweak - Adding DocBlock comments
* Tweak - Slight refactor
* Tweak - Updating WordPress version compatibility

2012.12.13 - version 1.0.0
* Initial release

0 comments on commit e65c167

Please sign in to comment.