Skip to content

Commit

Permalink
(feat): add show on to settings, openpub-item and api
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdhoek1 committed May 12, 2021
1 parent 379bc6e commit d4727d7
Show file tree
Hide file tree
Showing 17 changed files with 286 additions and 112 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version [2.0.5]

### Feat

- Add 'show on' setting to openpub-settings.
- Add 'show on' setting in editor of openpub-item.
- Add filtering on 'show on' to items endpoint.

## Version [2.0.4]

### Feat
Expand Down
42 changes: 30 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# README #
# README

This README documents whatever steps are necessary to get this plugin up and running.

## How do I get set up ##
## How do I get set up

* Unzip and/or move all files to the /wp-content/plugins/openpub-base directory
* Log into WordPress admin and activate the ‘OpenPub Base’ plugin through the ‘Plugins’ menu
* Go to the 'OpenPub instellingen pagina' in the left-hand menu to enter some of the required settings
- Unzip and/or move all files to the /wp-content/plugins/openpub-base directory
- Log into WordPress admin and activate the ‘OpenPub Base’ plugin through the ‘Plugins’ menu
- Go to the 'OpenPub instellingen pagina' in the left-hand menu to enter some of the required settings

## Hooks ##
## Hooks

See [Hooks](/docs/hooks.md)

## REST API ##
## REST API

See [REST API](/docs/restapi.md)

## Translations ##
## Translations

If you want to use your own set of labels/names/descriptions and so on you can do so.
All text output in this plugin is controlled via the gettext methods.
Expand All @@ -32,7 +32,7 @@ This plugin provides an easy interface for custom translations and a way to stor
For instructions how to use the 'Loco Translate' plugin, we advice you to read the Beginners's guide page on their website: https://localise.biz/wordpress/plugin/beginners
or start at the homepage: https://localise.biz/wordpress/plugin

## Running tests ##
## Running tests

To run the Unit tests go to a command-line.

Expand All @@ -48,15 +48,33 @@ For code coverage report, generate report with command line command and view res
phpunit --coverage-html ./tests/coverage
```

## Contribution guidelines ##
## Shared environment

### Writing tests ###
If the openpub environment is shared by multiple websites and it is required to configure the websites where an openpub-item should be displayed on, follow the steps below:

- Go to the 'OpenPub instellingen pagina' in the left-hand menu and look for the setting 'Show on'. Check the checkbox.

When this setting is enabled this plugin creates a taxonomy 'Show on'.

- Add terms to the taxonomy so the terms can be used in the editor of an openpub-item.

This plugin also adds a select element to the editor of an openpub-item.

- Look for the select beneath the heading 'External'.
- Select the websites you want this item to be displayed on.

The selected websites are able now to make requests to the items endpoint and only retrieve openpub-items that are intended for the selected website.
Example url: https://url/wp-json/owc/openpub/v1/items?source={blog_slug}

## Contribution guidelines

### Writing tests

Have a look at the code coverage reports to see where more coverage can be obtained.
Write tests
Create a Pull request to the OWC repository

### Who do I talk to ###
### Who do I talk to

IF you have questions about or suggestions for this plugin, please contact
[Holgers Peters](mailto:[email protected]) from Gemeente Buren.
2 changes: 1 addition & 1 deletion config/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'notes' => OWC\OpenPub\Base\RestAPI\ItemFields\NotesField::class,
'synonyms' => OWC\OpenPub\Base\RestAPI\ItemFields\SynonymsField::class,
'taxonomies' => OWC\OpenPub\Base\RestAPI\ItemFields\TaxonomyField::class,
'escape_element' => OWC\OpenPub\Base\RestAPI\ItemFields\EscapeElementField::class,
'escape_element' => OWC\OpenPub\Base\RestAPI\ItemFields\EscapeElementField::class
],
],
'theme' => [
Expand Down
8 changes: 4 additions & 4 deletions config/metaboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
'id' => 'openpub_expirationdate',
'name' => __('Select end date', 'openpub-base'),
'type' => 'datetime',
'save_format' => 'Y-m-d H:i',
],
'save_format' => 'Y-m-d H:i'
]
],
'links' => [
'heading' => [
Expand Down Expand Up @@ -83,7 +83,7 @@
],
],
],
'other' => [
'other' => [
'heading' => [
'type' => 'heading',
'name' => __('Other', 'openpub-base'),
Expand All @@ -96,7 +96,7 @@
'cols' => 20,
'rows' => 5,
],
],
]
],
],
];
8 changes: 7 additions & 1 deletion config/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@
],
'openpub_use_escape_element' => [
'name' => __('Escape element', 'openpub-base'),
'desc' => __('Enable escape element.', 'openpub-base'),
'desc' => __("Use an element to leave the website without being able to navigate back via the browser 'Back' button.", 'openpub-base'),
'id' => 'setting_use_escape_element',
'type' => 'checkbox',
],
'openpub_enable_show_on' => [
'name' => __('Show on', 'openpub-base'),
'desc' => __('Used for configuring on which websites an openpub-item should be displayed on.', 'openpub-base'),
'id' => 'setting_openpub_enable_show_on',
'type' => 'checkbox'
]
],
],
Expand Down
26 changes: 26 additions & 0 deletions config/show_on_metabox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

return [
'show_on' => [
'id' => 'show_on',
'title' => __('External', 'openpub-base'),
'post_types' => ['openpub-item'],
'context' => 'normal',
'priority' => 'low',
'autosave' => true,
'fields' => [
'settings' => [
[
'name' => __('Show on', 'openpub-base'),
'desc' => __('Select websites where this item should be displayed on.', 'openpub-base'),
'id' => 'show_on_active',
'type' => 'taxonomy',
'taxonomy' => 'openpub-show-on',
'field_type' => 'select_advanced',
'required' => 1,
'multiple' => 1
],
]
]
]
];
37 changes: 15 additions & 22 deletions config/taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@
'args' => [
'show_in_rest' => true,
'show_admin_column' => true,
'capabilities' => [
// 'manage_terms' => 'manage_openpub_categories',
// 'edit_terms' => 'manage_openpub_categories',
// 'delete_terms' => 'manage_openpub_categories',
// 'assign_terms' => 'edit_openpub_posts'
]
'capabilities' => []
],
'names' => [
# Override the base names used for labels:
'singular' => _x('Audience', 'Taxonomy definition', 'openpub-base'),
'plural' => _x('Audiences', 'Taxonomy definition', 'openpub-base'),
'slug' => 'openpub-doelgroep'
Expand All @@ -30,15 +24,9 @@
'args' => [
'show_in_rest' => true,
'show_admin_column' => true,
'capabilities' => [
// 'manage_terms' => 'manage_openpub_categories',
// 'edit_terms' => 'manage_openpub_categories',
// 'delete_terms' => 'manage_openpub_categories',
// 'assign_terms' => 'edit_openpub_posts'
]
'capabilities' => []
],
'names' => [
# Override the base names used for labels:
'singular' => _x('Type', 'Taxonomy definition', 'openpub-base'),
'plural' => _x('Types', 'Taxonomy definition', 'openpub-base'),
'slug' => 'openpub-type'
Expand All @@ -49,18 +37,23 @@
'args' => [
'show_in_rest' => true,
'show_admin_column' => true,
'capabilities' => [
// 'manage_terms' => 'manage_openpub_categories',
// 'edit_terms' => 'manage_openpub_categories',
// 'delete_terms' => 'manage_openpub_categories',
// 'assign_terms' => 'edit_openpub_posts'
]
'capabilities' => []
],
'names' => [
# Override the base names used for labels:
'singular' => _x('Usage', 'Taxonomy definition', 'openpub-base'),
'plural' => _x('Usages', 'Taxonomy definition', 'openpub-base'),
'slug' => 'openpub-toepassing'
]
]
],
'openpub-show-on' => [
'object_types' => ['openpub-item'],
'args' => [
'show_in_rest' => false,
'show_admin_column' => true
],
'names' => [
'singular' => __('Show on', 'openpub-base'),
'plural' => __('Show on', 'openpub-base')
]
],
];
Binary file modified languages/openpub-base-nl_NL.mo
Binary file not shown.
Loading

0 comments on commit d4727d7

Please sign in to comment.