admin管理员组文章数量:1130349
** This question is outdated! **
I use the bellow function to disable a plugin update. It works, because I use an old version of this plugin and it does not show me that a newer version exists, but, however, I get a warning on line 2: Attempt to modify property of non-object. How to fix this?
function my_filter_plugin_updates( $value ) {
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
UPDATE
I am not a PHP coder, so I do not know if what I did is correct, but this works - no errors, no warnings, no plugin update:
// Disable plugin update
function my_filter_plugin_updates() {
$value = new StdClass;
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
** This question is outdated! **
I use the bellow function to disable a plugin update. It works, because I use an old version of this plugin and it does not show me that a newer version exists, but, however, I get a warning on line 2: Attempt to modify property of non-object. How to fix this?
function my_filter_plugin_updates( $value ) {
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
UPDATE
I am not a PHP coder, so I do not know if what I did is correct, but this works - no errors, no warnings, no plugin update:
// Disable plugin update
function my_filter_plugin_updates() {
$value = new StdClass;
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
Share
Improve this question
edited Nov 23, 2018 at 16:55
Iurie
asked Jun 26, 2014 at 20:19
IurieIurie
1,1314 gold badges25 silver badges46 bronze badges
3
|
2 Answers
Reset to default 7Some simple php, check if it's set before trying to unset it.
function my_filter_plugin_updates( $value ) {
if( isset( $value->response['duplicator/duplicator.php'] ) )
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
This could be late but assigning a new instance of an object, you are overwritten the proper value of $value
** This question is outdated! **
I use the bellow function to disable a plugin update. It works, because I use an old version of this plugin and it does not show me that a newer version exists, but, however, I get a warning on line 2: Attempt to modify property of non-object. How to fix this?
function my_filter_plugin_updates( $value ) {
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
UPDATE
I am not a PHP coder, so I do not know if what I did is correct, but this works - no errors, no warnings, no plugin update:
// Disable plugin update
function my_filter_plugin_updates() {
$value = new StdClass;
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
** This question is outdated! **
I use the bellow function to disable a plugin update. It works, because I use an old version of this plugin and it does not show me that a newer version exists, but, however, I get a warning on line 2: Attempt to modify property of non-object. How to fix this?
function my_filter_plugin_updates( $value ) {
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
UPDATE
I am not a PHP coder, so I do not know if what I did is correct, but this works - no errors, no warnings, no plugin update:
// Disable plugin update
function my_filter_plugin_updates() {
$value = new StdClass;
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
Share
Improve this question
edited Nov 23, 2018 at 16:55
Iurie
asked Jun 26, 2014 at 20:19
IurieIurie
1,1314 gold badges25 silver badges46 bronze badges
3
- 1 I'm not sure you can. The code you have looks to be taken from wordpress.stackexchange/questions/25358/… - and had the same problem there. There are also other solutions on that post. – vancoder Commented Jun 26, 2014 at 20:35
- @vancoder Thank you! You are right, but I like this solution and I hope it can be improved. – Iurie Commented Jun 27, 2014 at 5:50
-
1
It looks like you're disabling all plugin updates this way, since
$valueis always a new empty object? – birgire Commented Jun 27, 2014 at 12:14
2 Answers
Reset to default 7Some simple php, check if it's set before trying to unset it.
function my_filter_plugin_updates( $value ) {
if( isset( $value->response['duplicator/duplicator.php'] ) )
unset( $value->response['duplicator/duplicator.php'] ); //Duplicator
return $value;
}
add_filter( 'site_transient_update_plugins', 'my_filter_plugin_updates' );
This could be late but assigning a new instance of an object, you are overwritten the proper value of $value
本文标签: functions39Attempt to modify property of nonobject39 warning
版权声明:本文标题:functions - 'Attempt to modify property of non-object' warning 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749155838a2324574.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


$valueis always a new empty object? – birgire Commented Jun 27, 2014 at 12:14