Rename a row action label

时间:2013-07-03 作者:Baylock

我想简单地将“Delete permanently”重命名为“Delete”,而不必处理Wordpress核心文件。

值得一提的是,我使用的是Wordpress的翻译版本。因此,“永久删除”操作已经翻译,但翻译的字符串太长,无法满足我的需要。

如何从函数中执行此操作。php?

任何帮助都将不胜感激。

1 个回复
SO网友:tfrommen

把这个放进你的functions.php 文件:

function rename_delete_action($actions) {
    // replace Delete Permanently text, if present
    // (i.e., if the current user is able to delete posts)
    if (isset($actions[\'delete\']))
        $actions[\'delete\'] = preg_replace(\'@>(.*)<@\', \'>WHATEVER<\', $actions[\'delete\']);
    return $actions;
} // function rename_delete_action

if (\'edit.php\' === $GLOBALS[\'pagenow\']) {
    // add filter for Edit pages only
    add_filter(\'post_row_actions\', \'rename_delete_action\');
    add_filter(\'page_row_actions\', \'rename_delete_action\');
}

结束

相关推荐