Adding a Clone link to product attributes – post_row_actions() filter, or how to override a Class question

WooCommerce have not anticipate the need of adding a new action in this place so there is neither filters nor actions for doing this

there is 2 others solutions :

  • adding the link with JavaScript
  • parsing the HTML result to add the link at this place

.

To add the link in the HTML code, you can try this

add_action("admin_menu", function () {

    $menu_slug = "edit.php?post_type=product";
    $submenu_slug = "product_attributes";

    $hookname = get_plugin_page_hookname($submenu_slug, $menu_slug);


    // removing the original page call
    remove_all_actions($hookname);

    // adding the hook for the new page
    add_action($hookname, "display_newPage_product_attributes");

});


function display_newPage_product_attributes() {

    // original page

    $wc_Admin_Menus = new WC_Admin_Menus();

    ob_start();
    $wc_Admin_Menus->attributes_page();
    $content = ob_get_clean();


    // adding the links, to improve

    $link = "<a href=\"a\">Attack of the Clone</a>";

    $content = str_replace(
        "</a></span></div>"
        , "</a></span> | $link</div>"
        , $content
    );


    // display

    echo $content;

}

I write “to improve” in a comment because you will certainly have to personalise each link and maybe you can think about a remplacement which will work even if the future version of WooCommerce make changes on this page

tech