/**
* Afegim accions dins de les llistes de media l'admin
*/
function modify_list_row_actions($actions, $post) {
// Build your links URL.
$url = wp_get_attachment_image_url($post->ID);
$actions['see'] = sprintf(
'<a href="%1$s" targte="blank">%2$s</a>',
esc_url($url),
esc_html(__('Ver Media', 'infinite'))
);
return $actions;
}
add_filter('media_row_actions', 'modify_list_row_actions', 10, 2);
Si volem fer el mateix a posts, hem de canviar el filtre i podem afegir un of per filtrar per custo post type. Exemple:
add_filter('post_row_actions', 'modify_list_row_actions', 10, 2);
function modify_list_row_actions($actions, $post)
{
// Check for your post type.
if ($post->post_type == "attachment") {
// Build your links URL.
$url = wp_get_attachment_image_url($post->ID);
// Maybe put in some extra arguments based on the post status.
$edit_link = add_query_arg(array('action' => 'view'), $url);
// The default $actions passed has the Edit, Quick-edit and Trash links.
$trash = $actions['trash'];
/*
* You can reset the default $actions with your own array, or simply merge them
* here I want to rewrite my Edit link, remove the Quick-link, and introduce a
* new link 'Copy'
*/
$actions = array(
'view' => sprintf(
'<a href="%1$s">%2$s</a>',
esc_url($edit_link),
esc_html(__('View', 'infinite'))
)
);
}
return $actions;
}
add_filter('post_row_actions', 'modify_list_row_actions', 10, 2);