PluginProbe
Metricool – Social media and site statistics / 2.1.1
Metricool – Social media and site statistics v2.1.1
2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
← All changes | app/Features/AdminNotices/AbstractAdminNotice.php +51 -51 2.0.2 → 2.1.1 View file →
@@ -43,16 +43,24 @@
43 43 $this->env = $env;
44 44 }
45 45
46 46 /**
47 - * Get the unique identifier
47 + * Notice-specific display conditions, use this to check for things like
48 + * required capabilities, specific admin pages, etc.
48 49 */
49 - public function getId(): string
50 - {
51 - return static::IDENTIFIER;
52 - }
50 + abstract protected function canDisplay(): bool;
53 51
54 52 /**
53 + * Returns the view path for the inner content of the notice
54 + */
55 + abstract protected function getContentView(): string;
56 +
57 + /**
58 + * Returns the variables passed to the content view
59 + */
60 + abstract protected function getContentVariables(): array;
61 +
62 + /**
55 63 * Returns whether the notice can be permanently dismissed
56 64 */
57 65 public function isDismissable(): bool
58 66 {
@@ -75,16 +83,48 @@
75 83 return 1;
76 84 }
77 85
78 86 /**
79 - * Permanently dismiss the notice
87 + * Returns the URL for the call-to-action button, or empty string if none
80 88 */
81 - final public function dismiss(): void
89 + public function getCtaUrl(): string
82 90 {
83 - update_option('metricool_notice_' . $this->getId() . '_dismissed', true, false);
91 + return '';
84 92 }
85 93
86 94 /**
95 + * Returns the label for the call-to-action button, or empty string if none
96 + */
97 + public function getCtaLabel(): string
98 + {
99 + return '';
100 + }
101 +
102 + /**
103 + * Render the notice
104 + */
105 + public function render(): void
106 + {
107 + $this->traitRender('admin/notices/layout', $this->viewData());
108 + }
109 +
110 + /**
111 + * Get the unique identifier
112 + */
113 + final public function getId(): string
114 + {
115 + return static::IDENTIFIER;
116 + }
117 +
118 + /**
119 + * Returns whether the notice should be displayed
120 + */
121 + final public function shouldDisplay(): bool
122 + {
123 + return $this->canDisplay() && !$this->isDismissed() && !$this->isSnoozed();
124 + }
125 +
126 + /**
87 127 * Snooze the notice for the configured number of days
88 128 */
89 129 final public function snooze(): void
90 130 {
@@ -114,32 +154,16 @@
114 154 return time() < $snoozedUntil;
115 155 }
116 156
117 157 /**
118 - * Returns the URL for the call-to-action button, or empty string if none
158 + * Permanently dismiss the notice
119 159 */
120 - public function getCtaUrl(): string
160 + final public function dismiss(): void
121 161 {
122 - return '';
162 + update_option('metricool_notice_' . $this->getId() . '_dismissed', true, false);
123 163 }
124 164
125 165 /**
126 - * Returns the label for the call-to-action button, or empty string if none
127 - */
128 - public function getCtaLabel(): string
129 - {
130 - return '';
131 - }
132 -
133 - /**
134 - * Render the notice
135 - */
136 - public function render(): void
137 - {
138 - $this->traitRender('admin/notices/layout', $this->viewData());
139 - }
140 -
141 - /**
142 166 * Get the data passed to the notice layout view
143 167 */
144 168 protected function viewData(): array
145 169 {
@@ -163,29 +187,5 @@
163 187 'wpNonce' => wp_create_nonce('wp_rest'),
164 188 'content' => $this->view($this->getContentView(), $this->getContentVariables()),
165 189 ];
166 190 }
167 -
168 - /**
169 - * Returns whether the notice should be displayed
170 - */
171 - final public function shouldDisplay(): bool
172 - {
173 - return $this->canDisplay() && !$this->isDismissed() && !$this->isSnoozed();
174 - }
175 -
176 - /**
177 - * Notice-specific display conditions, use this to check for things like
178 - * required capabilities, specific admin pages, etc.
179 - */
180 - abstract protected function canDisplay(): bool;
181 -
182 - /**
183 - * Returns the view path for the inner content of the notice
184 - */
185 - abstract protected function getContentView(): string;
186 -
187 - /**
188 - * Returns the variables passed to the content view
189 - */
190 - abstract protected function getContentVariables(): array;
191 191 }