0

我正在尝试将链接添加到现有插件的管理菜单。此链接应指向服务器上从服务器下载 csv 文件的脚本。

我添加了这一行 - *'all_items' => __( 'Download Donors', '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' );
4

1 回答 1

0

do not double post again, please.

try this:

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;
}
于 2013-02-14T09:52:14.590 回答