我正在尝试创建一个自定义按钮,并将其链接到插件中的一个文件。How do I get this link pointing to the path of my choice?
我尝试了以下方法,但现在确实奏效了。
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\' );
}
注意线条
\'download_donors\' => __( \'Download Donors\', \'pfund\' ),
\'all_items\' => __( \'Download Donors\', \'pfund\' ),
“下载捐赠者”标签不起作用。我必须使用“all\\u items”。不知道为什么会这样,但当我尝试添加过滤器时,它不会被覆盖。相反,链接指向
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;
}