Skip to content

Commit

Permalink
add postType parameter to hasQueryPermission controller method
Browse files Browse the repository at this point in the history
  • Loading branch information
pryley committed Oct 24, 2024
1 parent 2fcc3e3 commit d2c26f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 0 additions & 2 deletions plugin/Addons/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

abstract class Controller extends AbstractController
{
abstract public function app(): PluginContract;

/**
* @action admin_enqueue_scripts
*/
Expand Down
10 changes: 8 additions & 2 deletions plugin/Controllers/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

use GeminiLabs\SiteReviews\Contracts\CommandContract;
use GeminiLabs\SiteReviews\Contracts\ControllerContract;
use GeminiLabs\SiteReviews\Contracts\PluginContract;
use GeminiLabs\SiteReviews\HookProxy;

abstract class AbstractController implements ControllerContract
{
use HookProxy;

public function app(): PluginContract
{
return glsr();
}

public function download(string $filename, string $content): void
{
if (glsr()->can('edit_others_posts')) {
Expand All @@ -32,12 +38,12 @@ protected function getPostId(): int
return intval(filter_input(INPUT_GET, 'post'));
}

protected function hasQueryPermission(\WP_Query $query): bool
protected function hasQueryPermission(\WP_Query $query, string $postType = ''): bool
{
global $pagenow;
return glsr()->isAdmin()
&& $query->is_main_query()
&& glsr()->post_type === $query->get('post_type')
&& $query->get('post_type') === ($postType ?: glsr()->post_type)
&& 'edit.php' === $pagenow;
}

Expand Down

0 comments on commit d2c26f2

Please sign in to comment.