Skip to content

Commit

Permalink
update docs and structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jjgrainger committed Aug 27, 2018
1 parent a5d34c7 commit e132a8e
Show file tree
Hide file tree
Showing 16 changed files with 263 additions and 274 deletions.
2 changes: 2 additions & 0 deletions .gitbook.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
root: ./docs/
structure:
readme: ../README.md
220 changes: 0 additions & 220 deletions docs/02-posttypes.md

This file was deleted.

File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions docs/README.md

This file was deleted.

35 changes: 14 additions & 21 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
# Table of Contents

* [Getting Started](01-getting-started.md)
* [Requirements](01-getting-started.md#requirements)
* [Installation](01-getting-started.md#installation)
* [Basic Usage](01-getting-started.md#basic-usage)
* [PostTypes](02-posttypes.md)
* [Create a new PostType](02-posttypes.md#create-a-new-posttype)
* [Working with exisiting PostTypes](02-posttypes.md#working-with-exisiting-posttypes)
* [Add Taxonomies](02-posttypes.md#add-taxonomies)
* [Filters](02-posttypes.md#filters)
* [Columns](02-posttypes.md#columns)
* [Menu Icons](02-posttypes.md#menu-icons)
* [Flush Rewrite Rules](02-posttypes.md#flush-rewrite-rules)
* [Taxonomies](03-taxonomies.md)
* [Create a new Taxonomy](03-taxonomies.md#create-a-new-taxonomy)
* [Working with exisiting Taxonomies](03-taxonomies.md#working-with-exisiting-taxonomies)
* [Add to PostType](03-taxonomies.md#add-to-posttype)
* [Columns](03-taxonomies.md#columns)
* [Notes](04-notes.md)
* [Translations](04-notes.md#translations)
* [Custom Fields](04-notes.md#custom-fields)
* [Examples](04-notes.md#examples)
* [Getting Started](Getting-started.md)
* [PostTypes](posttypes/README.md)
* [Create a new PostType](posttypes/Create-a-new-posttype.md)
* [Add Taxonomies](posttypes/Add-taxonomies.md)
* [Filters](posttypes/Filters.md)
* [Columns](posttypes/Columns.md)
* [Menu Icons](posttypes/Menu-icons.md)
* [Flush Rewrite Rules](posttypes/Flush-rewrite-rules.md)
* [Taxonomies](taxonomies/README.md)
* [Create a new Taxonomy](taxonomies/Create-a-new-taxonomy.md)
* [Add to PostType](taxonomies/Add-to-post-type.md)
* [Columns](taxonomies/Columns.md)
* [Notes](Notes.md)
* [Changelog](../Changelog.md)
15 changes: 15 additions & 0 deletions docs/posttypes/Add-taxonomies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Add Taxonomies

New and existing Taxonomies can be added to a PostType using its `taxonomy()` method by passing the taxonomy name.

```php
// Create a books post type
$books = new PostType('book');

// Add the genre taxonomy to the book post type
$books->taxonomy('genre');

// Register the post type to WordPress
$books->register();
```
See the [documentation](#) on creating a new Taxonomy. Taxonomies and PostTypes can be created in any order.
76 changes: 76 additions & 0 deletions docs/posttypes/Columns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Columns

You can now modify a PostTypes admin columns using the `column()` manager.

#### Adding Columns

You can add columns to the admin edit screen by passing an array of slugs and labels to the `add()` method.

```php
// add multiple columns and set their labels
$books->columns()->add([
'rating' => __('Rating'),
'price' => __('Price')
]);
```

#### Hiding Columns

You can hide columns by passing the column slug to the `hide()` method. You can hide multiple columns by passing an array of column slugs.

```php
$books->columns()->hide('author');

$books->columns()->hide(['author', 'date']);
```

#### Set Columns

You can force set all the columns to display on the admin page with the `set()` method by passing an array of the column slugs and labels.

```php
$books->columns()->set([
'cb' => '<input type="checkbox" />',
'title' => __("Title"),
'genre' => __("Genres"),
'rating' => __("Rating"),
'date' => __("Date")
]);
```

#### Column Order

After hiding and adding columns you may want to rearrange the column order. To do this use the `order()` method. You only have to pass through an array of the columns you want to reposition, not all of them. Their positions are based on a zero based index.

```php
$books->columns()->order([
'rating' => 2,
'genre' => 4
]);
```

#### Populating Columns

You can populate any column using the `populate()` method and passing the column slug and function.

```php
$books->columns()->populate('rating', function($column, $post_id) {
echo get_post_meta($post_id, 'rating', true) . '/10';
});
```

#### Sorting Columns

You can choose which custom columns are sortable with the `sortable()` method. This method accepts an array of column slugs and an array of sorting options.

The first option is the `meta_key` to sort the colums by.

The second option is whether to order the items numerically (`true`) or alphabetically (`false`) by default.

```php
// will make both the price and rating columns sortable and ordered numerically
$books->columns()->sortable([
'price' => ['price', true],
'rating' => ['rating', true]
]);
```
Loading

0 comments on commit e132a8e

Please sign in to comment.