diff --git a/README.md b/README.md index d015105..a4d60ea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,83 @@ # OOP WP A simple library of OOP style helpers for WordPress theme and plugin development. -## What is this? -OOP WP is a package that give you a load of handy classes and methods to use when building things in WordPress. +It gives you well-formatted classes for things like posts for accessing items such as the title or publish date. It can easily be extended into sub-classes in your own projects. -It can give you well-formatted classes like User and Post which can then be extended into sub-classes in your own projects. +Most of the methods are wrappers for already existing functions like `get_the_title()` + +## How to install +It's recommended you install this package via [Composer](https://getcomposer.org/). + +``` +composer require sebkay/oop-wp +``` + +You'll then need to include the Composer autoloader so you have access to the package. Add the following at the top of your `functions.php` file: + +``` +require get_template_directory() . '/vendor/autoload.php'; +``` + +## How to use +Wherever you want to use one of the OOP implementations, you can do like this: + +``` +$blog_post = new OOPWP\Posts\Post(get_the_ID()); + +$blog_post->title(); +``` + +## Available Methods +### Post + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Methods +
->id()Outputs whatever ID is passed to the constructor.
->url()Wrapper for get_permalink().
->slug()Returns ->post_name from the WP_Post object.
->status()Wrapper for get_post_status().
->format()Wrapper for get_post_format().
->title()Wrapper for get_the_title().
->excerpt()Wrapper for get_the_excerpt().
->publishDate()Wrapper for get_the_date().
->modifiedDate()Wrapper for get_the_modified_time().
->content()Returns ->post_content from the WP_Post object and applies the_content filter.
->parent()Returns a new Post object using ->post_parent from the WP_Post object.