-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLibWordPressReviews.php
71 lines (55 loc) · 2.06 KB
/
LibWordPressReviews.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace PublishPress_Statuses;
use PublishPress\WordPressReviews\ReviewsController;
class LibWordPressReviews
{
/**
* @var \PublishPress\WordPressReviews\ReviewsController
*/
private $reviewController = null;
public function __construct()
{
if (! class_exists('PublishPress\\WordPressReviews\\ReviewsController')) {
$includeFile = __DIR__ . '/lib/vendor/publishpress/wordpress-reviews/ReviewsController.php';
if (is_file($includeFile) && is_readable($includeFile)) {
// phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable
require_once $includeFile;
}
}
$this->reviewController = new ReviewsController(
'publishpress-statuses',
'PublishPress Statuses',
__DIR__ . 'assets/images/publishpress-statuses-256.png'
);
add_action('admin_init', [$this, 'init']);
}
public function init()
{
add_filter('publishpress-statuses_wp_reviews_allow_display_notice', [$this, 'shouldDisplayBanner']);
$this->reviewController->init();
}
public function shouldDisplayBanner($shouldDisplay): bool
{
global $pagenow;
if (defined('DOING_AJAX') && DOING_AJAX) {
return false;
}
if (defined('DOING_CRON') && DOING_CRON) {
return false;
}
if (! current_user_can('manage_options')) {
return false;
}
if ($pagenow === 'admin.php' && isset($_GET['page'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
$pages = [
'publishpress-statuses',
'publishpress-statuses-add-new',
'publishpress-statuses-settings'
];
if (in_array($_GET['page'], $pages)) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
return true;
}
}
return false;
}
}