/** * カラム名を取得 * * @param array $columns * @return array $columns */ public function add_form_columns_name($columns) { global $posts; unset($columns['date']); $columns['post_date'] = __('Registed Date', MWF_Config::DOMAIN); $columns['response_status'] = __('Response Status', MWF_Config::DOMAIN); $_columns = array(); foreach ($posts as $post) { $post_custom_keys = get_post_custom_keys($post->ID); if (!empty($post_custom_keys) && is_array($post_custom_keys)) { foreach ($post_custom_keys as $key) { if (preg_match('/^_/', $key)) { continue; } if ($key === MWF_Config::TRACKINGNUMBER) { $_columns[$key] = MWF_Functions::get_tracking_number_title($this->post_type); continue; } $_columns[$key] = $key; } } } ksort($_columns); $columns = array_merge($columns, $_columns); return $columns; }
/** * CSVの各行を生成 * * @param array $posts * @param array $headings * @return array */ protected function get_rows(array $posts, array $headings) { global $post; $rows = array(); foreach ($posts as $post) { setup_postdata($post); $columns = array(); foreach ($headings as $key => $value) { $Contact_Data_Setting = new MW_WP_Form_Contact_Data_Setting($post->ID); $response_statuses = $Contact_Data_Setting->get_response_statuses(); $column = ''; if ($value === __('Response Status', MWF_Config::DOMAIN)) { $response_status = $Contact_Data_Setting->get('response_status'); $column = $response_statuses[$response_status]; } elseif ($value === __('Memo', MWF_Config::DOMAIN)) { $column = $Contact_Data_Setting->get('memo'); } elseif ($value === MWF_Functions::get_tracking_number_title($this->post_type)) { $column = get_post_meta(get_the_ID(), MWF_Config::TRACKINGNUMBER, true); } elseif (isset($post->{$value})) { $post_meta = $post->{$value}; if ($Contact_Data_Setting->is_upload_file_key($post, $value)) { // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理 if ($post_meta === '') { $post_meta = MWF_Functions::get_multimedia_id__fallback($post, $value); } $column = wp_get_attachment_url($post_meta); } else { $column = $post_meta ? $post_meta : ''; } } $columns[$key] = $column; } $rows[] = $columns; } wp_reset_postdata(); return $rows; }
echo wp_create_nonce(MWF_Config::NAME); ?> " /> <table border="0" cellpadding="0" cellspacing="0"> <?php $values = $Contact_Data_Setting->gets(); foreach ($values as $key => $value) { if (in_array($key, $Contact_Data_Setting->get_permit_keys())) { continue; } ?> <tr> <th> <?php if ($key === MWF_Config::TRACKINGNUMBER) { echo MWF_Functions::get_tracking_number_title($post_type); } else { echo esc_html($key); } ?> </th> <td> <?php if ($Contact_Data_Setting->is_upload_file_key($post, $key)) { // 過去バージョンでの不具合でメタデータが空になっていることがあるのでその場合は代替処理 if ($value === '') { $value = MWF_Functions::get_multimedia_id__fallback($post, $key); } echo MWF_Functions::get_multimedia_data($value); } else { echo nl2br(esc_html($value));