Rename a row action label

I would like to simply rename "Delete permanently" to "Delete", without having to mess with the Wordpress core files.

It's worth knowing that I'm using a translated version of Wordpress. So the "Delete permanently" action is already translated but the translated string is too long to fit my needs.

How can I do that from functions.php?

Any help would be appreciated.

Topic row-actions Wordpress

Category Web


Put this in your functions.php file:

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');
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.