Skip to content

Commit

Permalink
Updating library docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chido committed Oct 27, 2018
1 parent a896c71 commit 13f2a55
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 71 deletions.
16 changes: 8 additions & 8 deletions docs/DataAccess-PostType.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ id: da-posttypes
title: Post Type
---

Accessing data saved through a Post Type Page is done through the `Query` method of the Post Type. This returns a object of type wpOOWQueryObject,
which use a linq type syntax to fetch data. The `Fetch` method is the last method called, which executes the query and returns the data.
Accessing data saved through a PostType Page is done through the `Query` method of the created PostType page. This returns a object of type WPooWQueryObject,
which uses a linq type syntax to fetch data. The `Fetch` method is the last method called, which executes the query and returns the data.

```php
$bookReviews = wpAPIObjects::GetInstance()->GetObject("_bookReview");
Expand All @@ -20,26 +20,26 @@ foreach ($bookReviews->Query()->Select()->Fetch() as $book)

```yaml
Description:
Used to specify thee columns you want returned. Returns all columns if nothing specified
Used to specify the columns you want returned. Returns all columns if nothing is specified

Paramters:
$colums:
Type: array
Description: Array of Post Type fieldname
Description: Array of PostType field/column names to return

Returns: wpOOWQueryObject
Returns: WPooWQueryObject
```
* ### OrderBy($fieldname, $asc_desc, $use_numbers=false)
```yaml
Description:
Added a field element to the Post Type
Used to specify field to order by

Paramters:
$fieldname:
Type: string
Decription: Post Type field name you want to order by
Decription: PostType field name you want to order by
$asc_desc:
Type: string
Description: ASC for ascending order based on the fieldname and DESC for descending
Expand All @@ -49,7 +49,7 @@ foreach ($bookReviews->Query()->Select()->Fetch() as $book)
Description: if you want to treat the value from the colum as a number when ordering,
else treat as a string

Returns: wpOOWQueryObject
Returns: WPooWQueryObject
```
* ### Fetch()
Expand Down
6 changes: 2 additions & 4 deletions docs/DataAccess.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ title: Overview
---

In WordPress the are ways to access/manipulate the data saved in the database. These methods can be used to access the data
saved by declared wpOOW Page Types'. wpOOW does however have wrapper class linked to a declared Page Type which makes
it easier to manipulating data saved through a declared wpOOW Page Types

Note on access Page Type from frontend
saved by the declared WPooW PageTypes'. The WPooW library does however have wrapper class for this which you can use with declared PageTypes. This making
it easier to access data saved through a declared WPooW PageTypes.
6 changes: 3 additions & 3 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Getting Started
---

As previously mentioned this project is not a WordPress plugin, but rather a library.
To use it you need to either clone it or download it from github (https://github.com/walisc/wpAPI)
To use it you need to either clone or download it from github (https://github.com/walisc/wpAPI)

Once downloaded place the wpAPI folder anywhere in your theme or plugin you are working on.

Expand All @@ -28,7 +28,7 @@ Once downloaded place the wpAPI folder anywhere in your theme or plugin you are
└── uploads
```

Once moved, you can `include` the wpAPI.php file in your main class. ([plugin_name].php for plugins and functions.php of themes). Once all references have been set you can create a instance of wpAPI, which you can the use to create *Page Types*.
Once moved, you can `include` the wpAPI.php file in your main class. ([plugin_name].php for plugins and functions.php for themes). Once included you can create a wpAPI instance, which you can then use to interact with the library.

```php
include 'wpAPI/wpAPI.php';
Expand Down Expand Up @@ -75,4 +75,4 @@ register_activation_hook(__FILE__, [$wpOOWBookReviewer, 'OnActivate']);
register_deactivation_hook(__FILE__, [$wpOOWBookReviewer, 'OnDeactivate']);
```

**Note:-** for the example above I used Object Oriented Programing to create the plugin. This is because we are going to work more on this example and will help if the code is well organised. You could have however, created the custom post direct by coping the code in the Introduction section.
**Note:-** for the example above I used Object Oriented Programing (OOP) to create the plugin. This is because we are going to work more on this example and OOP helps organise code better. You could have however, created the custom post directly by copying the code in the Introduction section as is.
25 changes: 13 additions & 12 deletions docs/Introduction.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
If you have had to create a custom theme/plugin in WordPress which requires a lot of backend configuration, this can be tedious task.
This wrapper aims to simplify this process by providing an object-oriented way which abstracts most of these tasks.
Below is a simple example showing you how you can easily create a Custom Post Type you can use to store information of books you have read.
If you have had to create a custom theme/plugin in WordPress (which requires quite a bit of configuration), you know this can be quite cumbersome.
This wrapper aims to simplify this process by providing an object-oriented library which abstracts most of the tasks associated with this.
Below is a simple example showing you how you can easily create a Custom [PostType](https://codex.wordpress.org/Post_Types) using this wrapper.

```php
//functions.php

include 'wpAPI/wpAPI.php';q
include 'wpAPI/wpAPI.php';

$wpOOW = new wpAPI();
$bookReviewPostType = $wpOOW->CreatePostType("_bookReview", "Book Review", true);
$WPoow = new wpAPI();
$bookReviewPostType = $WPoow->CreatePostType("_bookReview", "Book Review", true);

$bookReviewPostType->AddField(new Text("_bookTitle", "Book Title"));
$bookReviewPostType->AddField(new Text("_bookAuthor", "Book Author"));
Expand All @@ -22,15 +22,16 @@ $bookReviewPostType->Render();

```

This will create a Custom Post Type page (available at login) that will look like
This will create a custom page (available via wp-admin). See below:-

![intro_images](/images/intro_output_image_input.png)
<center>*Fig1: Grid Layout of new custom type*</center>

to make a plugin

![intro_images_expanded](/images/intro_main_image_expanded.png)
<center>*Fig2: Adding new custom type*</center>

To access the data added through the Custom Post Type data, you can you use a traditional WordPress query `WP_QUERY` by reference you declared Post Type id (in the case above it will be `_bookReview`). wpOOW however, provides a wrapper class which makes it easier to access this data. An example how you would fetch is below
To access the data added through the custom PostType, you can use a traditional WordPress query ([`WP_QUERY`](https://codex.wordpress.org/Class_Reference/WP_Query) ) by referencing your declared PostType id (in the case above, it will be `_bookReview`). WPoow however, provides a wrapper class which makes it easier to access this data. An example of how you would fetch this data using the WPoow library is below:-

```php+HTML
<style>
Expand Down Expand Up @@ -85,14 +86,14 @@ To access the data added through the Custom Post Type data, you can you use a tr
```



This could be used to produce a web page like: (below:- based on the WordPress TwentySeventeen template )
Modifying the WordPress TwentySeventeen theme template our web page could look like:-

![1529530425830](/images/intro_output_image.png)

**Note:-**

This library is to be used for creating WordPress plugins and themes. It's not a plugin in and off itself. If you are not a developer you might not want to use this library.
This library is designed to be used by developers for creating WordPress themes and plugins. It is not a plugin or a theme in and off itself. Use with care.




Expand Down
23 changes: 11 additions & 12 deletions docs/Menus.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ title: Menus

When creating a plugin or a theme the chances of only having one menu item is rare.
In most cases you will have a parent menu item which consist of other sub menus for
configuring your plugin/theme
configuring your plugin/theme.

The Menu interface allows you to create a parent menu item and then append Page Types to it
as sub menus
The Menu interface allows you to create a parent menu item and then append PageTypes to it
as sub menus.

Building on our example from earlier, let say you want to have another Post Type to
give summaries of authors and their books. Using similar code to the one in the Getting Started section we can have something like
Building on our example from earlier, let's say you want to have another PostType to
give summaries of authors and their books. Using similar code to the one in the Getting Started section we can have something like:-

```php

Expand All @@ -37,13 +37,12 @@ function CreateAuthorSummariesPostPage(){


This would however create two menu items, and a user would find it difficult to distinguish
which menu item belong to your plugin/theme.
which menu item belongs to your plugin/theme.

![book_author_summary_image](/images/menu_book_author_summary_image.png)

menu_combined.png
Using the Menu interface we could group these two items under one Menu for which will have
our plugin name. An example of the is below
our plugin name. An example of this is below:-

```php

Expand Down Expand Up @@ -91,24 +90,24 @@ our plugin name. An example of the is below
...
```

This would produce a menu item like
This would produce a menu item like:-

![book_author_summary_combined_image](/images/menu_combined.png)

Creating the menu item is done through the `CreateMenu` $wpOOW API method. The definition of this is below
Creating the menu item is done through the `CreateMenu` WPooW API method. The definition of this is below

```php

/**
* Create a new menu option that can be added to the wp-admin menu.
*
* @param $page_slug - whcih will be the id of the menu item
* @param $page_slug - which will be the id of the menu item
* @param $menu_title - the title of the menu item
* @param $capability - WordPress capabilities required to access this menu item
* @param $display_path - uses wpAPI_VIEW. can link to a jinja template or render content passed to it
as html. This Page will be shown as the root of the menu item (i.e when you
click the menu item to expand it). This will be deprecated soon. To be replaced
with wpOOW Static Pages
with WPooW Static Pages
* @param string $icon - this icon of the menu item
* @param null $position - the position of the menu item
*
Expand Down
40 changes: 20 additions & 20 deletions docs/PageTypes-PostType.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ title: Post Types

Post Type pages are in essence [Custom Post Types](https://codex.wordpress.org/Post_Types) in WordPress.
You could create a custom post type in Wordpress directly, but this is a bit cumbersome and slightly
confusing. WpOOW abstracts all the nitty-gritties involved in creating custom post types,
include saving and updating the custom post type created.
confusing. WPoow abstracts all the nitty-gritties involved in creating custom post types,
including saving and updating the custom post type created.

To create a PostType Page using the `CreatePostType` method associated with the $wpOOW API. The definition
of this is below
To create a PostType Page use the `CreatePostType` method associated with the WPoow library. The definition
of this is below:-

```php
/**
Expand All @@ -34,8 +34,8 @@ Usage example below
$bookReviewPostType = $wpOOW->CreatePostType("_bookReview", "Book Review", true);
```

This will create a Post Type with the default columns for Custom Post Type. You can specify
your own fields by using the `AddField` method. wpOOW has a few field types you can use (See element types).
This will create a Custom PostType with the default columns set. You can specify
your own fields/add columns, by using the `AddField` method. WPooW has a few field types you can use (See element types below).

The `Render` method is responsible for actually displaying the Custom PostType created.

Expand All @@ -46,38 +46,38 @@ The `Render` method is responsible for actually displaying the Custom PostType c

```yaml
Description:
Added a field element to the Post Type
Add a field element to the PostType

Paramters:
$aField:
Type: wpOOW/BaseElement
Type: WPooW/BaseElement
```
* ### Query()
```yaml
Description:
Gets the query object for the Post Type. See Data Access
Gets the query object for the PostType. See Data Access below

Returns: wpOOWQueryObject
Returns: WPooWQueryObject
```
* ### Render()
```yaml
Description:
Responsible for rendering the Custom Post Type
Responsible for rendering the Custom PostType
```
* ### RegisterAfterSaveEvent ( $method, $class = null)
```yaml
Description:
Class to register methods that are called after saving data for a custom Post Type.
This is useful if you required to do some additional operation once data saving has
been confirmed. An example of this could be sending an email. The method you pass
in needs to expect an array (which will have the $field => $value pair of the custom
post type.
Used to register methods that are called after saving data for a Custom PostType.
This is useful if you required to do some additional operations once your data is saved.
An example of this could be sending an email. The method you pass
in needs to expect an array (which will have the $field => $value pair of the Custom
PostType's columns.

Paramters:
$method:
Expand Down Expand Up @@ -105,7 +105,7 @@ The `Render` method is responsible for actually displaying the Custom PostType c

```yaml
Description:
Register a method that is called before a custom post query is run. This is useful
Used to register a method that is called before a Custom PostType query is run. This is useful
if you want to modify the query in any way, for instance, change the return order.
The method you pass in needs to expect a wp_query objet. No need to return the wp_query
object as it is passed by reference.
Expand Down Expand Up @@ -136,10 +136,10 @@ The `Render` method is responsible for actually displaying the Custom PostType c

```yaml
Description:
Class to register methods that are called before saving data for a custom Post Type.
This is useful if you required to do some additional operation before saving the data.
Used to register methods that are called before saving data for a custom PostType.
This is useful if you required to do some additional operations before saving the data.
An example of this is setting a id field. The method you pass in needs to expect an
array (which will have the $field => $value pair of the custom post type.
array (which will have the $field => $value pair of the custom PostType's columns.
Paramters:
$method:
Expand Down
4 changes: 2 additions & 2 deletions docs/PageTypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ id: pt-introduction
title: Overview
---

Page Types encapsulate most of the functionality of the wpoow. They are class you can use to display and store data as you see fit.
Current there is the page type Post Type Page. Setting Page (wrapper for WordPress settings) and Static Pages are coming soon.
PageTypes encapsulate most of the functionality of the WPoow library. They are classes you can use to display and store data as you see fit.
Currently there is only the PostType page (which you can achieve a lot with). Setting Page (wrapper for WordPress settings) and Static Pages are coming soon.
2 changes: 1 addition & 1 deletion website/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"localized-strings": {
"next": "Next",
"previous": "Previous",
"tagline": "Wordpress Object Oriented Wrapper",
"tagline": "WordPress Object Oriented Wrapper",
"custom_elements-create": "Creating Custom Element",
"custom_elements-full_example": "Full Example",
"custom_elements-using_javascript": "Using Javascript (and CSS)",
Expand Down
12 changes: 6 additions & 6 deletions website/pages/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Logo = props => (
const ProjectTitle = props => (
<h2 className="projectTitle">
{siteConfig.title}
<small>Wordpress Object Oriented Wrapper</small>
<small>WordPress Object Oriented Wrapper</small>
</h2>
);

Expand Down Expand Up @@ -97,10 +97,10 @@ const Features = props => (
title: 'Easily create custom PostTypes',
},
{
content: '',
image: imgUrl('intro_output_image_input.png'),
imageAlign: 'top',
title: 'Display custom PostType data easily in html',
content: '',
image: imgUrl('intro_output_image_input.png'),
imageAlign: 'top',
title: 'Display custom PostType data easily in html',
}

]}
Expand All @@ -112,7 +112,7 @@ const Features = props => (
const Description = props => (
<div className="descriptionWrapper darkBackground">
<div className="inner wrapper">
<h2>This Wordpress Object Oriented Wrapper aims to simplify the process of creating custom plugins and themes by providing a object-oriented api which abstracts common tasks associated with this. </h2>
<h2>This WordPress Object Oriented Wrapper aims to simplify the process of creating custom plugins and themes by providing a object-oriented api which abstracts common tasks associated with this. </h2>
</div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions website/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
var localConfig = require("./siteConfig.local")

const siteConfig = {
title: 'wpOOW' /* title for your website */,
tagline: 'Wordpress Object Oriented Wrapper',
title: 'WPooW' /* title for your website */,
tagline: 'WordPress Object Oriented Wrapper',
url: 'http://wpoow.devchid.com' ,
baseUrl: '/',
gaTrackingId: localConfig.gaTrackingId,
Expand Down Expand Up @@ -68,7 +68,7 @@ const siteConfig = {

/* Open Graph and Twitter card images */
ogImage: 'images/intro_code_meta_main.png',
description:'This Wordpress Object Oriented Wrapper aims to simplify the process of creating custom plugins and themes by providing a object-oriented api which abstracts common tasks associated with this. '
description:'This WordPress Object Oriented Wrapper aims to simplify the process of creating custom plugins and themes by providing a object-oriented api which abstracts common tasks associated with this. '

// You may provide arbitrary config keys to be used as needed by your
// template. For example, if you need your repo's URL...
Expand Down

0 comments on commit 13f2a55

Please sign in to comment.