내 설정에는 버튼을 한 번 클릭하면 CSV 파일을 다운로드하라는 메시지가 표시됩니다. 여기에 코드가 있습니다.Wordpress에서 CSV 파일 내보내기
<?php
/** Step 2 (from text above). */
add_action('admin_menu', 'my_plugin_menu');
/** Step 1. */
function my_plugin_menu() {
add_options_page('Members Log Data',
'Members Log',
'manage_options',
'sj-member-option',
'members_option');
}
/** Step 3. */
function members_option() {
if (!current_user_can('manage_options'))
{
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$name = "member-log-".date('Y-m-d');
$list[] = array('username','no of favorites');
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $name);
$op = fopen('php://output','w');
foreach($list as $row)
{
fputcsv($op,$row);
}
fclose($op);
/*
echo '<div class="wrap">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
*/
}
세션 헤더를 수정할 수 없습니다.
저는 WP에서이 작업을 수행하는 방법에 대해 알고 싶습니다.