@@ -31,8 +31,14 @@ public function display_plugin_messages( string $page ) {
31
31
return ;
32
32
}
33
33
34
- $ messages = [];
35
- $ plugin_file = $ this ->get_plugin ()->get_path ();
34
+ $ messages = [];
35
+ $ plugin = $ this ->get_plugin ();
36
+
37
+ if ( ! $ plugin ) {
38
+ return ;
39
+ }
40
+
41
+ $ plugin_file = $ plugin ->get_path ();
36
42
$ plugin_updates = get_plugin_updates ();
37
43
$ resource = $ plugin_updates [ $ plugin_file ] ?? null ;
38
44
@@ -72,7 +78,7 @@ public function display_plugin_messages( string $page ) {
72
78
} else {
73
79
$ update_message = sprintf (
74
80
esc_html__ ( 'There is a new version of %1$s available. %2$s ' , '%TEXTDOMAIN% ' ),
75
- $ this -> get_plugin () ->get_name (),
81
+ $ plugin ->get_name (),
76
82
$ update_now_link
77
83
);
78
84
}
@@ -103,7 +109,7 @@ public function display_plugin_messages( string $page ) {
103
109
);
104
110
105
111
$ this ->plugin_notice = [
106
- 'slug ' => $ this -> get_plugin () ->get_slug (),
112
+ 'slug ' => $ plugin ->get_slug (),
107
113
'message_row_html ' => $ message_row_html ,
108
114
];
109
115
}
@@ -142,7 +148,13 @@ public function store_admin_notices( string $page ) {
142
148
* @return void
143
149
*/
144
150
public function output_notices_script () {
145
- $ slug = $ this ->get_plugin ()->get_slug ();
151
+ $ plugin = $ this ->get_plugin ();
152
+
153
+ if ( ! $ plugin ) {
154
+ return ;
155
+ }
156
+
157
+ $ slug = $ plugin ->get_slug ();
146
158
$ notice = $ this ->get_plugin_notice ();
147
159
148
160
if ( empty ( $ notice ) ) {
@@ -204,7 +216,13 @@ public function get_plugin_message( Plugin $resource ) {
204
216
* @return void
205
217
*/
206
218
public function remove_default_inline_update_msg () {
207
- remove_action ( "after_plugin_row_ {$ this ->get_plugin ()->get_path ()}" , 'wp_plugin_update_row ' );
219
+ $ plugin = $ this ->get_plugin ();
220
+
221
+ if ( ! $ plugin ) {
222
+ return ;
223
+ }
224
+
225
+ remove_action ( "after_plugin_row_ {$ plugin ->get_path ()}" , 'wp_plugin_update_row ' );
208
226
}
209
227
210
228
/**
@@ -214,7 +232,13 @@ public function remove_default_inline_update_msg() {
214
232
*/
215
233
public function check_for_updates ( $ transient ) {
216
234
try {
217
- return $ this ->get_plugin ()->check_for_updates ( $ transient );
235
+ $ plugin = $ this ->get_plugin ();
236
+
237
+ if ( ! $ plugin ) {
238
+ return $ transient ;
239
+ }
240
+
241
+ return $ plugin ->check_for_updates ( $ transient );
218
242
} catch ( \Throwable $ exception ) {
219
243
return $ transient ;
220
244
}
@@ -242,13 +266,19 @@ protected function get_plugin() {
242
266
* @return mixed
243
267
*/
244
268
public function inject_info ( $ result , string $ action = null , $ args = null ) {
245
- $ relevant = ( 'plugin_information ' === $ action ) && is_object ( $ args ) && isset ( $ args ->slug ) && ( $ args ->slug === $ this ->get_plugin ()->get_slug () );
269
+ $ plugin = $ this ->get_plugin ();
270
+
271
+ if ( ! $ plugin ) {
272
+ return $ result ;
273
+ }
274
+
275
+ $ relevant = ( 'plugin_information ' === $ action ) && is_object ( $ args ) && isset ( $ args ->slug ) && ( $ args ->slug === $ plugin ->get_slug () );
246
276
247
277
if ( ! $ relevant ) {
248
278
return $ result ;
249
279
}
250
280
251
- $ plugin_info = $ this -> get_plugin () ->validate_license ();
281
+ $ plugin_info = $ plugin ->validate_license ();
252
282
253
283
if ( $ plugin_info ) {
254
284
return $ plugin_info ->to_wp_format ();
0 commit comments