From 79db233bdb81058391330ebf5889d89f74c108a4 Mon Sep 17 00:00:00 2001 From: chido Date: Sat, 27 Oct 2018 17:31:43 +0200 Subject: [PATCH] Updating documentation for WPooW library --- docs/CustomElements-Create.md | 44 ++++++++++++------------ docs/CustomElements-FullExample.md | 22 ++++++------ docs/CustomElements-UsingJavascript.md | 46 +++++++++++++------------ docs/CustomElements-UsingTwig.md | 8 ++--- docs/DataAccess-PostType.md | 14 ++++---- docs/DataAccess.md | 6 ++-- docs/Elements-Checkbox.md | 4 +-- docs/Elements-Date.md | 8 ++--- docs/Elements-MultiSelect.md | 4 ++- docs/Elements-RichTextArea.md | 6 ++-- docs/Elements-Select.md | 2 ++ docs/Elements-Text.md | 2 +- docs/Elements-TextArea.md | 2 +- docs/Elements-Uploader.md | 2 +- docs/Elements.md | 47 +++++++++++++------------- docs/Introduction.md | 6 ++-- docs/OtherNotes.md | 10 +++--- docs/PageTypes-PostType.md | 14 ++++---- docs/PageTypes.md | 2 +- docs/VideoTutorial.md | 2 +- 20 files changed, 128 insertions(+), 123 deletions(-) diff --git a/docs/CustomElements-Create.md b/docs/CustomElements-Create.md index b6eb898..80a7fe5 100644 --- a/docs/CustomElements-Create.md +++ b/docs/CustomElements-Create.md @@ -3,14 +3,14 @@ id: custom_elements-create title: Creating Custom Element --- -Sometimes there are situation when you might need to create custom elements that utilise the wpOOW elements features. To -do this all you need to do is extend the wpOOW `BaseElement` class and override the methods +Sometimes there are situations when you might need to create custom elements that utilise the WPooW elements' features. To +do this all you need to do is extend the WPooW `BaseElement` class and override the methods * ReadView * EditView * ProcessPostData -This method definitions of each of these methods are highlighted below +These methods are highlighted below in more detail:- ## Methods to Override @@ -19,14 +19,14 @@ This method definitions of each of these methods are highlighted below ```yaml Description: Method called when rendering the ReadView of the element. This method should return a - html string. The curent value of the element can be accessed by using the + html string. The current value of the element can be accessed through the GetDatabaseValue method (highlighted below) - Paramters: + Parameters: $post: Type: PostType - Description: The Post Type associate with the current element when being viewed + Description: The PostType associated with the current element when being viewed Returns: String ``` @@ -43,17 +43,17 @@ This method definitions of each of these methods are highlighted below ```yaml Description: Method called when rendering the EditView of the element. This method should return - a html string, of which the html element must have a 'name' attribute for - its input type which is the same id of the element being render (i.e $this->id). - This is used to process data correct when a POST request is made. + a html string, of which this html string must have an input dom element with + a 'name' attribute that is the same as the id of the element being render (i.e $this->id). + This is used to process data correctly when a POST request is made (see example below)0. - Another important note it to call the parents EditView method, as this generates the - wp_nonce required for the elements input field. + Another important thing to note is to call the parents EditView method first, as this + generates the wp_nonce required for the elements input field. - The curent value of the element can also be accessed by using the GetDatabaseValue + The current value of the element can also be accessed by using the GetDatabaseValue method. - Paramters: + Parameters: $post: Type: PostType Description: The Post Type associate with the current element when being viewed @@ -65,8 +65,7 @@ This method definitions of each of these methods are highlighted below // Example function EditView($post){ parent::EditView($post) - echo sprintf('', - $this->id, + echo sprintf('', $this->id, $this->$this->GetDatabaseValue($post)); } @@ -76,19 +75,20 @@ This method definitions of each of these methods are highlighted below ```yaml Description: - This method is called when we about to save the data for the element. Override this - method to get the correct data to save through the 'SaveElementData' method (see below) + This method is called when saving the data for the element. Override this method + and call the 'SaveElementData' method after obtaining the appropriate data + for the element to persist the data (see example below). - Note - it is important to call the parent ProcessPostData method first before continuing - with operations as this ensure the data being returned has been santised - correctly (although you might still need to do again for your specific element + Note - it is important to call the parent's ProcessPostData method first before continuing + with operations as this ensures that the data being saved has been sanitised + correctly (although you might still need to do so again for your specific element type) - Paramters: + Parameters: $post: Type: PostType ID - Description: The ID of the Post Type being saved + Description: The ID of the PostType being saved Returns: String ``` diff --git a/docs/CustomElements-FullExample.md b/docs/CustomElements-FullExample.md index 6156181..fe3b125 100644 --- a/docs/CustomElements-FullExample.md +++ b/docs/CustomElements-FullExample.md @@ -2,7 +2,7 @@ id: custom_elements-full_example title: Full Example --- -Below is an example in which we replace the rating control with a slider +Below is an example in which we replace the rating text element in our example with a slider. ```php class CustomRatingSelectorSimple extends BaseElement{ @@ -50,8 +50,8 @@ class CustomRatingSelectorSimple extends BaseElement{ } ``` -As can be seen from the example above we are using jquery-ui slider component. This means we are going to have to download -these files and add the components folder. There is also a additional css file we will use to style our slider. The content +As can be seen from the example above we are using the jquery-ui slider component. This means we are going to have to download +these files and add them to the components folder. There is also an additional css file we will use to style our slider. The content of that css file is below:- ```css @@ -68,8 +68,8 @@ of that css file is below:- } ``` -As one would expect when using a jquery library, there is need to usually a need to initialize some javascript somewhere. -For this component we will need to initialize the javascript for both the read_view and edit_view. The javascript we use +As one would expect when using a jquery library, there is need to usually initialize some javascript somewhere. +For this component we will need to initialize the javascript for both the read_view and edit_view. The javascript we will use is highlighted below:- ```js @@ -101,7 +101,7 @@ is highlighted below:- })(); ``` -Lastly we need to create our read_view and edit_view templates. This are highlighted below:- +Lastly we need to create our read_view and edit_view templates. These are highlighted below:- ```twig @@ -120,8 +120,8 @@ Lastly we need to create our read_view and edit_view templates. This are highlig ``` -And that's it! I added this at the root of my plugin, but you can theoretically add it anywhere, resulting in a file -structure as follows:- +And that's it! I added this at the root of my plugin (but you can theoretically add it anywhere) resulting in a file +structure that looks like this:- ```bash wpoowbookreviewer @@ -139,8 +139,8 @@ wpoowbookreviewer └── wpoowbookreviewer.php ``` -All we need to do now is use our custom component in creating a post type. To do this we replace the `_myRating` element -creation with our new component, after including it. +All we need to do now is use our custom component in creating our PostType. To do this we replace the `_myRating` element +creation with our new component (after including it). ```php @@ -155,7 +155,7 @@ function CreateBookReviewPostType(){ ``` -The final element looks something like this +The final element looks something like this:- | Edit View | Read View | | ------------- | ------------- | diff --git a/docs/CustomElements-UsingJavascript.md b/docs/CustomElements-UsingJavascript.md index 864bc5c..d33fd37 100644 --- a/docs/CustomElements-UsingJavascript.md +++ b/docs/CustomElements-UsingJavascript.md @@ -2,13 +2,15 @@ id: custom_elements-using_javascript title: Using Javascript (and CSS) --- -Sometimes you need to create elements that use javascript. Such is the case if you are using some compound/interactive +Sometimes you need to create elements that use javascript. For example if you are creating some compound/interactive UI element. When your element uses javascript you need to use the `EnqueueElementBaseScript` and the `EnqueueElementScript` -methods to enqueue the appropriate scripts. +methods to enqueue your scripts appropriately. -The `EnqueueElementBaseScript` method is used to enqueue scripts that will be used by all instance of your element - type (more like a shared library). **Note:-** This method should only be used in the `BaseScriptsToLoad` method, which - you will have to overwrite from the BaseElements class. If you don't you will get a `doing_it_wrong` WordPress error. And example of this is +The `EnqueueElementBaseScript` method is used to enqueue scripts that will be used by all instances of your element + type (more like a shared library). + + **Note:-** This method should only be used in the `BaseScriptsToLoad` method, which + you will have to overwrite from the BaseElements class. If you don't you will get a `doing_it_wrong` WordPress error. An example of this is below:- ```php @@ -24,7 +26,7 @@ The `EnqueueElementBaseScript` method is used to enqueue scripts that will be us ``` `EnqueueElementScript` is used to enqueue javascript for a particular instance of your custom element type, for - instance if you will require to bind to your custom element id. This method should be used with the `ReadView` method + instance if you require some javascript to use the id of your custom element. This method should be used within the `ReadView` method or the `EditView` method. @@ -43,25 +45,25 @@ The `EnqueueElementBaseScript` method is used to enqueue scripts that will be us **Important Notes:-** -* When you custom element use javascript to get the parsed value, you should set this value to a hidden input field -in you read/edit view that has the name set to you element id. This will allow wpOOW to pick up the value correctly -when a post is made -* All javascript that are enqueued using the the `EnqueueElementBaseScript` or `EnqueueElementScript` go through the +* When your custom element uses javascript to get the parsed value (user inputted value, that might be processed), you should set this value to a hidden input field +in your read/edit view that has the name set to your element's id. This will allow WPooW to pick up the value correctly +when a post is made (see [Full Example below](/docs/custom_elements-full_example.html)) +* All javascript files that are enqueued using the the `EnqueueElementBaseScript` or `EnqueueElementScript` go through the twig template engine. This means you can use twig template placeholders in your javascript. This is useful for passing -value from you code +values from your code. ## JS enqueuing methods ```php /** - * Used to add base script for the element. This script will be shared by all instances for this type. - * Only call this withing the BaseScriptsToLoad method as you will get `doing_it_wrong` word press error + * Used to add base scripts for the element. This script should be shared by all instances of this type. + * Only call this method within the BaseScriptsToLoad method else you will get a `doing_it_wrong` WordPress error * * @param $handle - name used by WordPress to recognise this script * @param $src - location of the file - * @param array $shared_variable - dictionary of variable to use in your javascript file using twig templating placeholders - * @param array $deps - javascript dependancies + * @param array $shared_variable - dictionary of variable to use in your javascript file when replacing the twig templating placeholders + * @param array $deps - javascript dependencies * @param bool $ver - file version, for browser caching * @param bool $in_footer - add to the footer or header of html */ @@ -72,11 +74,11 @@ protected function EnqueueElementBaseScript($handle, $src, $shared_variable = [] ```php /** - * Used to and a instance specific script. The script will be added for each instance of the element. - * Also not this script will be added inline + * Used to add a instance specific script. The script will be added for each instance of the element. + * Also note, this script will be added inline * * @param $src_path - location of the file - * @param array $shared_variables - dictionary of variable to use in your javascript file using twig templating placeholders + * @param array $shared_variables - dictionary of variable to use in your javascript file when replacing the twig templating placeholders * @param null $handler - name used by WordPress to recognise this script */ protected function EnqueueElementScript($src, $shared_variables= [], $handler=null) @@ -85,7 +87,7 @@ protected function EnqueueElementScript($src, $shared_variables= [], $handler=nu # Using CSS in your custom element Similarly to enqueuing a javascript file for your element you can also enqueue a css file. The process is exactly -this same as that of enqueuing a javascript, with the caveat that you use the `EnqueueElementBaseCSS` method instead. +this same as that of enqueuing a javascript file, with the caveat that you use the `EnqueueElementBaseCSS` method instead. Similar to the EnqueueElementBaseScript method you should only call this method within the `BaseScriptsToLoad` method. ```php @@ -104,12 +106,12 @@ function BaseScriptsToLoad() ```php /** - * Used to add base css for the element. The css will be shared by all instances for this type. - * Only call this withing the BaseScriptsToLoad method as you will get `doing_it_wrong` word press error + * Used to add base css for the element. The css should be shared by all instances of this type. + * Only call this within the BaseScriptsToLoad method else you will get `doing_it_wrong` word press error * * @param $handle - name used by WordPress to recognise this script * @param $src - location of the file - * @param array $deps - css dependancies + * @param array $deps - css dependencies * @param bool $ver - file version, for browser caching * @param string $media - what type of media it applies too */ diff --git a/docs/CustomElements-UsingTwig.md b/docs/CustomElements-UsingTwig.md index 8893456..c48da31 100644 --- a/docs/CustomElements-UsingTwig.md +++ b/docs/CustomElements-UsingTwig.md @@ -2,11 +2,11 @@ id: custom_elements-using_twig title: Using Twig for templating --- -For more complex elements you might might want to use a template. wpOOW comes embedded with the [twig](https://twig.symfony.com/) template +For more complex elements you might want to use a html template. WPooW comes embedded with the [twig](https://twig.symfony.com/) template engine (which is used to render the predefined elements). The template engine can also be used to render your custom elements. -Using the examples above we could the change the `ReadView` and the `EditView` to the following +Using the examples above we could the change the `ReadView` and the `EditView` to the following:- ```php // Example @@ -29,5 +29,5 @@ function EditView( $post) ``` In the examples above we are saying use the template `read_view.twig` / `edit_view.twig` to render this elements - with the parameter value...etc. The location of the template files should relative to the php file of your - custom element + with the parameters value...etc. The location of the template files is relative to the php file of your + custom element (unless in the construction of the element you specify a different elementPath See [Elements Overview Above](/docs/elements-introduction.html)) diff --git a/docs/DataAccess-PostType.md b/docs/DataAccess-PostType.md index 5af1bc1..2d8a342 100644 --- a/docs/DataAccess-PostType.md +++ b/docs/DataAccess-PostType.md @@ -22,8 +22,8 @@ foreach ($bookReviews->Query()->Select()->Fetch() as $book) Description: Used to specify the columns you want returned. Returns all columns if nothing is specified - Paramters: - $colums: + Parameters: + $column: Type: array Description: Array of PostType field/column names to return @@ -34,19 +34,19 @@ foreach ($bookReviews->Query()->Select()->Fetch() as $book) ```yaml Description: - Used to specify field to order by + Used to specify the field to order by - Paramters: + Parameters: $fieldname: Type: string - Decription: PostType field name you want to order by + Description: 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 order based on the fieldname $fieldname: Type: boolean - Description: if you want to treat the value from the colum as a number when ordering, + Description: if you want to treat the value from the column as a number when ordering, else treat as a string Returns: WPooWQueryObject @@ -56,7 +56,7 @@ foreach ($bookReviews->Query()->Select()->Fetch() as $book) ```yaml Description: - Excutes the generated wp_query and yeilds the result + Executes the generated wp_query and yields the result Returns: Generator ``` \ No newline at end of file diff --git a/docs/DataAccess.md b/docs/DataAccess.md index 02c88ae..2185ac5 100644 --- a/docs/DataAccess.md +++ b/docs/DataAccess.md @@ -3,6 +3,6 @@ id: da-introduction 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 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. \ No newline at end of file +In WordPress they are ways to access/manipulate the data saved in your database. These methods can be used to access the data +saved by the declared WPooW PageTypes'. The WPooW library does however provide wrapper methods you can use with your declared PageTypes to access the data, making + it easier to access the data saved through a declared WPooW PageType. \ No newline at end of file diff --git a/docs/Elements-Checkbox.md b/docs/Elements-Checkbox.md index 1cf26b9..c960852 100755 --- a/docs/Elements-Checkbox.md +++ b/docs/Elements-Checkbox.md @@ -3,7 +3,7 @@ id: elements-checkbox title: Checkbox --- -Checkbox element for boolean items +Checkbox element for boolean items. | Read View | Edit View | | ------------- | ------------- | @@ -16,7 +16,7 @@ Constructor * @param $id * @param string $label - the label of the element * @param array $permissions - View, edit, read rights of the elemenet. - See wpOOWPermissions in the Overview section. + See WpooWPermissions in the Overview section. * **/ diff --git a/docs/Elements-Date.md b/docs/Elements-Date.md index 73aa072..ea8e72f 100644 --- a/docs/Elements-Date.md +++ b/docs/Elements-Date.md @@ -3,7 +3,7 @@ id: elements-date title: Date --- -Date element for date values. The used the browsers standard datetime picker, hence will appear +Date element for date values. This uses the browser's standard datetime picker, hence will appear slightly different on each browser. | Read View | Edit View | @@ -17,7 +17,7 @@ Constructor * @param $id * @param string $label - the label of the element * @param array $permissions - View, edit, read rights of the elemenet. - See wpOOWPermissions in the Overview section. + See WpooWPermissions in the Overview section. * **/ @@ -43,5 +43,5 @@ foreach ($bookReviewPostType->Query()->Select()->Fetch() as $row) } ``` -**Note:-** for the wpOOW Datetime element we declare it using the class `wpAPIDateTime`. This is because php already has -it own `DateTime` class, which would result in a conflict between the two. \ No newline at end of file +**Note:-** for the WPooW Datetime element we declare it using the class `wpAPIDateTime`. This is because php already has +it's own `DateTime` class, which would result in a conflict between the two. \ No newline at end of file diff --git a/docs/Elements-MultiSelect.md b/docs/Elements-MultiSelect.md index 8924f0e..61acbd8 100755 --- a/docs/Elements-MultiSelect.md +++ b/docs/Elements-MultiSelect.md @@ -2,7 +2,7 @@ id: elements-muilti_select title: MultiSelect --- -MultiSelect element for selecting multiple item from a list of values +MultiSelect element for selecting multiple items from a list of values. | Read View | Edit View | | ------------- | ------------- | @@ -15,6 +15,8 @@ Constructor * @param $id - See BaseElement definitions * @param string $label - See BaseElement definitions * @param array $options - A value => label array. Eg [value1 => label1, value2 => label2] + * @param array $permissions - View, edit, read rights of the elemenet. + See WpooWPermissions in the Overview section. */ function __construct($id, $label, $options, $permissions=[]) ``` diff --git a/docs/Elements-RichTextArea.md b/docs/Elements-RichTextArea.md index 96511cb..ad38459 100755 --- a/docs/Elements-RichTextArea.md +++ b/docs/Elements-RichTextArea.md @@ -3,7 +3,7 @@ id: elements-richtextarea title: RichText Area --- -Textbox element for RichText content. This uses WordPress's wp_editor[L], which in turn uses Tinymce editor +Textbox element for RichText content. This uses WordPress's [wp_editor](https://codex.wordpress.org/Function_Reference/wp_editor), which in turn uses the Tinymce editor. | Read View | Edit View | | ------------- | ------------- | @@ -16,7 +16,7 @@ Constructor * @param $id * @param string $label - the label of the element * @param array $permissions - View, edit, read rights of the elemenet. - See wpOOWPermissions in the Overview section. + See WPooWPermissions in the Overview section. * **/ @@ -41,5 +41,5 @@ foreach ($bookReviewPostType->Query()->Select()->Fetch() as $row) } ``` -Note:- [wpautop](https://codex.wordpress.org/Function_Reference/wpautop) is a WordPress functions which changes double line-breaks in the text into HTML paragraphs (```

...

```). +[wpautop](https://codex.wordpress.org/Function_Reference/wpautop) is a WordPress functions which changes double line-breaks in the text into HTML paragraphs (```

...

```). [html_entity_decode](http://php.net/manual/en/function.html-entity-decode.php) convert all HTML entities to their applicable characters. \ No newline at end of file diff --git a/docs/Elements-Select.md b/docs/Elements-Select.md index 4764c5a..40b5ab3 100755 --- a/docs/Elements-Select.md +++ b/docs/Elements-Select.md @@ -16,6 +16,8 @@ Constructor * @param $id - See BaseElement definitions * @param string $label - See BaseElement definitions * @param array $options - A value => label array. Eg [value1 => label1, value2 => label2] + * @param array $permissions - View, edit, read rights of the elemenet. + See WpooWPermissions in the Overview section. */ function __construct($id, $label, $options, $permissions=[]) ``` diff --git a/docs/Elements-Text.md b/docs/Elements-Text.md index 44ead0e..fbdcbae 100755 --- a/docs/Elements-Text.md +++ b/docs/Elements-Text.md @@ -16,7 +16,7 @@ Constructor * @param $id * @param string $label - the label of the element * @param array $permissions - View, edit, read rights of the elemenet. - See wpOOWPermissions in the Overview section. + See WPooWPermissions in the Overview section. * **/ diff --git a/docs/Elements-TextArea.md b/docs/Elements-TextArea.md index 42d573a..26a06db 100644 --- a/docs/Elements-TextArea.md +++ b/docs/Elements-TextArea.md @@ -3,7 +3,7 @@ id: elements-textarea title: Text Area --- -TextArea element. Similar to the [Text Element](/docs/elements-text.html), with a larger area to capture content. +TextArea element. Similar to the [Text Element](/docs/elements-text.html), with a larger, resizeable area to capture content. | Read View | Edit View | | ------------- | ------------- | diff --git a/docs/Elements-Uploader.md b/docs/Elements-Uploader.md index c4f945b..024550f 100644 --- a/docs/Elements-Uploader.md +++ b/docs/Elements-Uploader.md @@ -3,7 +3,7 @@ id: elements-uploader title: Uploader --- -Uploader element. This element can be used to store media elements such and pictures. The upload element uses +Uploader element. This element can be used to store media items such as pictures. The upload element uses WordPress's Media Library to upload media and store it appropriately. The data saved using the Uploader element is saved as a json object with the properties `id`, `url`, `filename`. diff --git a/docs/Elements.md b/docs/Elements.md index ab3cd53..94a1922 100755 --- a/docs/Elements.md +++ b/docs/Elements.md @@ -3,25 +3,25 @@ id: elements-introduction title: Overview --- -Elements (or Field Elements) are components used to capture and display data. wpOOW has a few elements you can use in conjunction with Page Types. +Elements (or Field Elements) are components used to capture and display data. WPooW has a few elements you can use in conjunction with PageTypes to this end. -To add a field element to a Post Type page use the `AddField` method of the declared post type +To add a field element to a PostType page use the `AddField` method of the declared PostType. -Each element extends the wpOOW Base Elements class. This means for each declared element a minimum of the id parameter is required. Each element type can however specify it own parameter requirements (see field specific requirements below) +Each element extends the WPooW Base Elements class. This means each declared element must at least pass in an id parameter during construction. Each element type can however specify it's own required parameters as well (see field specific requirements below). -Furthermore you can create your own element types by extending the wpOOW base element. +Furthermore you can create your own element types by extending the WPooW Base Element class. -Below is the base constructor, which can be overridden by other elements as need be +Below is the base constructor, which can be overridden by other elements as need be. ```php /** - * Constructor for the a base element + * Constructor for the Base Element * * BaseElement constructor. * @param $id * @param string $label - the label of the element - * @param array $permissions - View, edit, read rights of the elemenet. See wpOOWPermissions below + * @param array $permissions - View, edit, read rights of the elemenet. See WPooWPermissions below * @param string $elementPath - the root of the element static files. Defaults to the directory of the file * @param array $elementCssClasses - css classes to add to the element @@ -30,29 +30,28 @@ function __construct($id, $label="", $permissions=[], $elementPath = '', $elemen ``` -## wpOOWPermissions +## WpooWPermissions -When using wpOOW elements you can pass a permission array which can be used to specify whether - a viewable or editable for a given viewstate for a Page Type (Add, Edit, View). For instance - you might require the id field to be invisible when adding a Post Type record, but visible +When using WPooW elements you can pass in a permissions array which can be used to specify whether + an element is viewable or editable for a given viewstate for a PageType (Add, Edit, View). For instance + you might require the id field to be hidden when adding a PostType record, but visible when viewing. For this you need to pass an array specifying a create, read, update string (e.g "cr" for -create and read or "cru" for create, read and update) for a given viewstate.

+create and read or "cru" for create, read and update) for a given viewstate (see example below).

-### wpOOW ViewStates +### WpooW ViewStates -As already mentioned viewstate refer to the WordPress viewstates, but the wpOOW has wrapper state -you can use. These are +As already mentioned viewstate refer to the WordPress viewstates, of which WPooW has wrapper methods for accessing these states. These are -* AddPage - maps to the create new entry page of a wpOOW Post Type page -* EditPage - maps to the end entry page of a wpOOW Post Type page -* ViewPage - maps to the view entry page a wpOOW Post Type page

+* AddPage - maps to the create new record page of a WPooW PostType page +* EditPage - maps to the edit record page of a WPooW PostType page +* ViewPage - maps to the view record page a WPooW PostType page

### Examples -For the example above we would pass an array like this when we create the element +For the example above (making the id field hidden when adding a new record and read only when editing) we would pass an array like this when we create the element:- ```php @@ -65,9 +64,9 @@ $testElement = new Text("_bookID", "Book ID", $permission) ``` Since each user can be mapped to a WordPress permission, we can map these users permission, to -element permission allowing elements to be viewable or editable to certain users for certain conditions. +element permissions allowing elements to be viewable or editable to certain users for certain conditions. For instance if we wanted someone with `manage_options` capabilities to be able to modify the id if need be, we could -have something like +have something like:- ```php @@ -84,6 +83,6 @@ $testElement = new Text("_bookID", "Book ID", $permission) **Note:-** -wpOOW does not actual query the viewstate of the current page at render. It rather updates a global variable, -`$CURRENT_VIEW_STATE` with the viewstate, and then uses that. This is useful when dealing with wpOOW Pages -that are not Post Types, when you might need to set this directly for a given condition \ No newline at end of file +WPooW does not actually query the viewstate of the current page at render. It rather updates a global variable, +`$CURRENT_VIEW_STATE` with the viewstate, and then uses that. This is useful when dealing with WPooW Pages +that are not PostTypes, when you might need to set this directly for a given condition. \ No newline at end of file diff --git a/docs/Introduction.md b/docs/Introduction.md index 66128c0..243ab62 100644 --- a/docs/Introduction.md +++ b/docs/Introduction.md @@ -7,8 +7,8 @@ Below is a simple example showing you how you can easily create a Custom [PostTy 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")); @@ -31,7 +31,7 @@ This will create a custom page (available via wp-admin). See below:- ![intro_images_expanded](/images/intro_main_image_expanded.png)
*Fig2: Adding new custom type*
-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:- +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