-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat): PDC item table of contents, enabled by setting
- Loading branch information
Showing
11 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
return [ | ||
'table_of_contents' => [ | ||
'id' => 'table_of_contents', | ||
'title' => __('Table of contents', 'pdc-base'), | ||
'post_types' => ['pdc-item'], | ||
'context' => 'normal', | ||
'priority' => 'high', | ||
'autosave' => true, | ||
'fields' => [ | ||
'table_of_contents' => [ | ||
[ | ||
'name' => __('Table of contents', 'pdc-base'), | ||
'desc' => __('Use this option if you want to use a table of contents', 'pdc-base'), | ||
'id' => 'pdc_use_table_of_contents', | ||
'type' => 'checkbox', | ||
] | ||
], | ||
] | ||
] | ||
]; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Adds boolean field to the output which indicates if the item uses table of contents. | ||
*/ | ||
|
||
namespace OWC\PDC\Base\RestAPI\ItemFields; | ||
|
||
use OWC\PDC\Base\Models\Item; | ||
use OWC\PDC\Base\Support\CreatesFields; | ||
use WP_Post; | ||
|
||
class TableOfContentsField extends CreatesFields | ||
{ | ||
/** | ||
* The condition for the creator. | ||
*/ | ||
protected function condition(): callable | ||
{ | ||
return function () { | ||
return $this->plugin->settings->useTableOfContents(); | ||
}; | ||
} | ||
|
||
public function create(WP_Post $post): bool | ||
{ | ||
$itemModel = new Item($post->to_array()); | ||
|
||
return $itemModel->useTableOfContents(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters