• Resolved Generosus

    (@generosus)


    *** Useful Tip ***

    Consistency and simplicity are always a winner.

    The code snippet provided below changes all plugin instances (i.e., text string and link text) from “Delete Cache” and “Clear Cache” to “Purge Cache.”

    In order for the code snippet to work, it must be added to your functions.php file and activated for both the backend and frontend of your website.

    After activating the code snippet, this is what you’ll see:

    Backend: https://prnt.sc/21cxRDrwQcvy and https://prnt.sc/YhOU5FkWKHtV
    Frontend: https://prnt.sc/JzPg8H-2kIg5

    Enjoy!

    —————–

    // BACKEND: Change WP Fastest Cache "Delete Cache" and "Clear Cache" Strings to "Purge Cache"

    function my_text_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
    case 'Clear cache files when a post or page is published' :
    $translated_text = 'Purge cache files when a post or page is published';
    break;
    case 'Clear cache files when a post or page is updated' :
    $translated_text = 'Purge cache files when a post or page is updated';
    break;
    case 'Delete Cache' :
    $translated_text = 'Purge Cache';
    break;
    case 'Clear All Cache' :
    $translated_text = 'Purge Cache';
    break;
    case 'Delete Cache and Minified CSS/JS' :
    $translated_text = 'Purge Cache and Minified CSS/JS';
    break;
    }
    return $translated_text;
    }
    add_filter( 'gettext', 'my_text_strings', 20, 3 );

    // FRONTEND: Change WP Fastest Cache "Delete Cache" and "Clear Cache" Strings to "Purge Cache"

    function change_admin_bar_main_link() {

    if ( ! is_admin() ) {

    global $wp_admin_bar;
    $wp_admin_bar->remove_node('wpfc-toolbar-parent');

    $args = array(
    'id' => 'wpfc-toolbar-parent',
    'title' => 'Purge Cache',
    );

    $wp_admin_bar->add_node($args);

    }}
    add_action('wp_before_admin_bar_render', 'change_admin_bar_main_link', 20, 3);

    function change_admin_bar_sub_links() {

    if ( ! is_admin() ) {

    global $wp_admin_bar;
    $wp_admin_bar->remove_node('wpfc-toolbar-parent-delete-cache');

    $args = array(
    'parent' => 'wpfc-toolbar-parent',
    'id' => 'wpfc-toolbar-parent-delete-cache',
    'title' => 'Purge Cache',
    );

    $wp_admin_bar->add_node($args);

    global $wp_admin_bar;
    $wp_admin_bar->remove_node('wpfc-toolbar-parent-clear-cache-of-this-page');

    $args = array(
    'parent' => 'wpfc-toolbar-parent',
    'id' => 'wpfc-toolbar-parent-clear-cache-of-this-page',
    'title' => 'Purge Cache of this Page',
    );

    $wp_admin_bar->add_node($args);

    global $wp_admin_bar;
    $wp_admin_bar->remove_node('wpfc-toolbar-parent-delete-cache-and-minified');

    $args = array(
    'parent' => 'wpfc-toolbar-parent',
    'id' => 'wpfc-toolbar-parent-delete-cache-and-minified',
    'title' => 'Purge Cache and Minified CSS/JS',
    );

    $wp_admin_bar->add_node($args);

    }}
    add_action('wp_before_admin_bar_render', 'change_admin_bar_sub_links', 20, 3);
  • You must be logged in to reply to this topic.