2013-02-14 178 views
0

我想添加一個鏈接到現有插件的管理菜單。此鏈接應該指向服務器上的一個從服務器下載csv文件的腳本。創建定製鏈接的自定義WordPress的帖子類型

我加了一行 - *'all_items'=> __('捐助者','pfund'),*和Download Donors選項出現在菜單中。目前該項目指向edit.php。 如何獲取此鏈接以指向csv生成腳本所在的插件文件夾?

$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'); 

回答

0

請勿再次發帖。

試試這個:

add_filter('post_row_actions','download_donors', 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; 
} 
+0

什麼都沒有改變,我也應該指出的是,項目出現因以「‘all_items’=> __(‘下載捐助者’,‘普豐德’)」,而不是「'download_donors'=> __('捐助者下載','pfund')」就像我打算的,不知道爲什麼這是... – Julian 2013-02-14 20:02:13

相關問題