0

I've got the following code:

add_filter('media_row_actions','delete_link', 2, 1);
function delete_link( $wp_query_obj ) {
    echo "it is in this one";
    //if( !current_user_can( 'delete_plugins' ) ){
        unset($wp_query_obj['delete']);
        return $wp_query_obj;
    //}
}

I'm trying to determine if the hook is actually executed so I printed out an echo just to see if some text is returned. I don't see the text so I don't think it was executed but don't know for sure. If I look at the trac for that function at the following URL:
https://core.trac.wordpress.org/browser/tags/4.1/src/wp-admin/includes/class-wp-media-list-table.php#L551

The hook is:

$actions = apply_filters( 'media_row_actions', $actions, $post, $this->detached );

I also tried to make the hook be:

add_action('media_row_actions','delete_link', 2, 1);

I still didn't see the echo when I did this. I'm just displaying the Media page and clicking on the images to display the attachment details. I want to eventually do a print_r($wp_query_obj) so I know what is in the object and see what actions I can unset.

2

media_row_actions only filters the links in the Media Library (/wp-admin/upload.php?mode=list)

And $wp_query_obj really should be $actions, since that's whats being filtered.

What's in the object is an array of action keys and corresponding action links:

(
    [edit] => <a href="http://domain.com/wp-admin/post.php?post=XX&amp;action=edit">Edit</a>
    [delete] => <a class='submitdelete' onclick='return showNotice.warn();' href='post.php?action=delete&amp;post=XX&amp;_wpnonce=XXXX'>Delete Permanently</a>
    [view] => <a href="http://domain.com/?attachment_id=XX" title="View &#8220;Attachment Title&#8221;" rel="permalink">View</a>
)
  • I see what you mean now. I was hoping to do this in the Attachment details when the image is clicked. Thanks for pointing this out. – user1048676 Jan 14 '15 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.