admin管理员组文章数量:1130349
I'm looking to customize the "There is a new version of XYZ available." text on the Plugins list page. I know the code is in wp-admin/includes/update.php, however I'm not certain how to call this out or pull it out in a filter/callback. Basically, I want to be able to customize this message in a plugin. Thanks for any help or direction!
I'm looking to customize the "There is a new version of XYZ available." text on the Plugins list page. I know the code is in wp-admin/includes/update.php, however I'm not certain how to call this out or pull it out in a filter/callback. Basically, I want to be able to customize this message in a plugin. Thanks for any help or direction!
Share Improve this question asked Dec 26, 2018 at 18:27 ZackZack 534 bronze badges 2 |2 Answers
Reset to default 4Since the text is processed by _() function, then, of course, you can modify it using gettext filter.
function change_update_notification_msg( $translated_text, $untranslated_text, $domain )
{
if ( is_admin() ) {
$texts = array(
'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' => 'My custom notification. There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.',
'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' => 'My custom notification. There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>',
'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' => 'My custom notification. There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.'
);
if ( array_key_exists( $untranslated_text, $texts ) ) {
return $texts[$untranslated_text];
}
}
return $translated_text;
}
add_filter( 'gettext', 'change_update_notification_msg', 20, 3 );
This text can't be filtered afaik. You can append text though: https://developer.wordpress/reference/hooks/in_plugin_update_message-file/
I'm looking to customize the "There is a new version of XYZ available." text on the Plugins list page. I know the code is in wp-admin/includes/update.php, however I'm not certain how to call this out or pull it out in a filter/callback. Basically, I want to be able to customize this message in a plugin. Thanks for any help or direction!
I'm looking to customize the "There is a new version of XYZ available." text on the Plugins list page. I know the code is in wp-admin/includes/update.php, however I'm not certain how to call this out or pull it out in a filter/callback. Basically, I want to be able to customize this message in a plugin. Thanks for any help or direction!
Share Improve this question asked Dec 26, 2018 at 18:27 ZackZack 534 bronze badges 2-
2
Try
gettext– Abhik Commented Dec 26, 2018 at 18:53 - @rudtek Been playing with pre_site_transient_update_plugins per jasonjalbuena/disable-wordpress-update-notifications but no luck. – Zack Commented Dec 26, 2018 at 19:05
2 Answers
Reset to default 4Since the text is processed by _() function, then, of course, you can modify it using gettext filter.
function change_update_notification_msg( $translated_text, $untranslated_text, $domain )
{
if ( is_admin() ) {
$texts = array(
'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' => 'My custom notification. There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.',
'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' => 'My custom notification. There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>',
'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' => 'My custom notification. There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.'
);
if ( array_key_exists( $untranslated_text, $texts ) ) {
return $texts[$untranslated_text];
}
}
return $translated_text;
}
add_filter( 'gettext', 'change_update_notification_msg', 20, 3 );
This text can't be filtered afaik. You can append text though: https://developer.wordpress/reference/hooks/in_plugin_update_message-file/
本文标签: Customize plugin update quotnew version is availablequot text
版权声明:本文标题:Customize plugin update "new version is available" text 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749066220a2310856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


gettext– Abhik Commented Dec 26, 2018 at 18:53