Skip to content

Commit

Permalink
(feat): only authenticated users should be able to view 'draft' and '…
Browse files Browse the repository at this point in the history
…future' pdc-items
  • Loading branch information
Mike van den Hoek committed May 23, 2023
1 parent e230c42 commit 94b2e21
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Version [3.7.8] (2023-05-15)

### Feat

- Only authenticated users should be able to view 'draft' and 'future' pdc-items.

## Version [3.7.7] (2023-05-15)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion pdc-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Yard | PDC Base
* Plugin URI: https://www.openwebconcept.nl/
* Description: Acts as foundation for other PDC related content plugins. This plugin implements actions to allow for other plugins to add and/or change Custom Posttypes, Metaboxes, Taxonomies, en Posts 2 posts relations.
* Version: 3.7.7
* Version: 3.7.8
* Author: Yard | Digital Agency
* Author URI: https://www.yard.nl/
* License: GPL-3.0
Expand Down
2 changes: 1 addition & 1 deletion src/Base/Foundation/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Plugin
*
* @var string
*/
const VERSION = '3.7.7';
const VERSION = '3.7.8';

/**
* Path to the root of the plugin.
Expand Down
20 changes: 12 additions & 8 deletions src/Base/RestAPI/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ protected function addPaginator(array $data, WP_Query $query): array
'data' => $data
], [
'pagination' => [
'total_count' => (int) $query->found_posts,
'total_pages' => $query->max_num_pages,
'total_count' => (int) $query->found_posts,
'total_pages' => $query->max_num_pages,
'current_page' => $page,
'limit' => $query->get('posts_per_page')
'limit' => $query->get('posts_per_page')
]
]);
}
Expand All @@ -57,7 +57,7 @@ protected function getPaginatorParams(WP_REST_Request $request, int $limit = 10)
{
return [
'posts_per_page' => $request->get_param('limit') ?: $limit,
'paged' => $request->get_param('page') ?: 0
'paged' => $request->get_param('page') ?: 0
];
}

Expand All @@ -68,13 +68,17 @@ protected function getPostStatus(\WP_REST_Request $request): array
{
$preview = filter_var($request->get_param('draft-preview'), FILTER_VALIDATE_BOOLEAN);

if (! \is_user_logged_in()) {
$preview = false;
}

return $preview ? ['publish', 'draft', 'future'] : ['publish'];
}

/**
* Check if the source parameter is valid.
*/
protected function showOnParamIsValid(\WP_REST_Request $request): bool
/**
* Check if the source parameter is valid.
*/
protected function showOnParamIsValid(\WP_REST_Request $request): bool
{
if (empty($request->get_param('source'))) {
return false;
Expand Down

0 comments on commit 94b2e21

Please sign in to comment.