如何在wordpress管理员帖子网格中添加发布/取消发布快捷按钮(如屏幕截图中的编辑,快速编辑,...)
] 1
这是来自wp-ecommerce插件产品网格的截图(它与wordpress原生帖子网格非常相似)。
例如,来自wp-e-commerce插件的重复按钮的代码是:
function wpsc_action_row( $actions, $post ) {
if ( $post->post_type != "wpsc-product" )
return $actions;
$url = admin_url( 'edit.php' );
$url = add_query_arg( array( 'wpsc_admin_action' => 'duplicate_product', 'product' => $post->ID ), $url );
$actions['duplicate'] = '<a href="'.esc_url( $url ).'">' . esc_html_x( 'Duplicate', 'row-actions', 'wp-e-commerce' ) . '</a>';
$publishUrl = 'edit.php?wpsc_admin_action=toggle_publish&product='.$post->ID;
if($post->post_status == 'publish') {
$published = 'Unpublish';
} else {
$published = 'Publish';
}
/* $actions['publish_toggle'] = '<a href="'.$publishUrl.'">' . esc_html_x( $published, 'row-actions', 'wp-e-commerce' ) . '</a>'; */
return $actions;
}
add_action( 'wp_ajax_update_featured_product', 'wpsc_update_featured_products' );
add_action( 'admin_init' , 'wpsc_update_featured_products' );