I’m trying to create a custom button and link it to a file within the plugin. How do I get this link pointing to the path of my choice?
I’ve tried the following but it does now work.
function _pfund_register_types() {
$pfund_options = get_option( 'pfund_options' );
$template_def = array(
'public' => true,
'query_var' => 'pfund_cause',
'rewrite' => array(
'slug' => $pfund_options['cause_slug'],
'with_front' => false,
),
'hierarchical' => true,
'label' => __( 'Causes', 'pfund' ),
'labels' => array(
'name' => __( 'Causes', 'pfund' ),
'singular_name' => __( 'Cause', 'pfund' ),
'add_new' => __( 'Add New Cause', 'pfund' ),
'add_new_item' => __( 'Add New Cause', 'pfund' ),
'edit_item' => __( 'Edit Cause', 'pfund' ),
'view_item' => __( 'View Cause', 'pfund' ),
'search_items' => __( 'Search Causes', 'pfund' ),
'not_found' => __( 'No Causes Found', 'pfund' ),
'not_found_in_trash' => __( 'No Causes Found In Trash', 'pfund' ),
)
);
register_post_type( 'pfund_cause', $template_def );
register_post_type( 'pfund_cause_list' );
$campaign_def = array(
'public' => true,
'query_var' => 'pfund_campaign',
'rewrite' => array(
'slug' => $pfund_options['campaign_slug'],
'with_front' => false
),
'hierarchical' => true,
'label' => __( 'Campaigns', 'pfund' ),
'labels' => array(
'name' => __( 'Campaigns', 'pfund' ),
'singular_name' => __( 'Campaign', 'pfund' ),
'add_new' => __( 'Add New Campaign', 'pfund' ),
'add_new_item' => __( 'Add New Campaign', 'pfund' ),
'download_donors' => __( 'Download Donors', 'pfund' ),
'all_items' => __( 'Download Donors', 'pfund' ),
'edit_item' => __( 'Edit Campaign', 'pfund' ),
'view_item' => __( 'View Campaign', 'pfund' ),
'search_items' => __( 'Search Campaigns', 'pfund' ),
'not_found' => __( 'No Campaigns Found', 'pfund' ),
'not_found_in_trash' => __( 'No Campaigns Found In Trash', 'pfund' ),
),
'supports' => array(
'title'
),
'capabilities' => array(
'edit_post' => 'edit_campaign'
),
'map_meta_cap' => true
);
register_post_type( 'pfund_campaign', $campaign_def );
register_post_type( 'pfund_campaign_list' );
}
Notice the lines
'download_donors' => __( 'Download Donors', 'pfund' ),
'all_items' => __( 'Download Donors', 'pfund' ),
The ‘download_donors’ label doesn’t work. I have to use the ‘all_items’. Not sure why this is but when I try to add the filter it doesn’t get overwritten. Instead the link points to wp-admin/edit.php?post_type=pfund_campaign
add_filter('post_row_actions','all_items', 10, 2);
function download_donors($actions, $post){
//check for your post type
if ($post->post_type =="pfund_campaign"){
//remove the default edit
unset($actions['edit']);
//set new action
$actions['download_donors'] = '<a href="http://www.google.com">Download Donors</a>';
}
return $actions;
}