private function delete_form($inserted_posts) { $posts = History::post_ids_to_posts($inserted_posts); if (!$posts) { echo '<p>Posts were already deleted.</p>'; return; } $success = History::get_num_success($inserted_posts); $fail = History::get_num_fail($inserted_posts); echo '<p>'; if ($success === 1) { echo $success . ' post imported. '; } else { echo $success . ' posts imported. '; } if ($fail === 1) { echo $fail . ' post failed to import. '; } else { echo $fail . ' posts failed to import. '; } echo '</p>'; echo '<form method="post" action="' . esc_url(add_query_arg(array('step' => 3), $this->get_action())) . '">'; wp_nonce_field('acsv-import-delete'); echo '<table class="wp-list-table widefat fixed posts">'; echo '<thead><tr style="color: #dedede;">'; echo '<th scope="col" class="manage-column column-cb check-column"><input type="checkbox" id="cb-select-all-1" /></th><th scope="col">Title</th><th scope="col">Type</th><th scope="col">Status</th><th scope="col">Author</th><th scope="col">Date</th>'; echo '</tr></thead>'; foreach ($posts as $p) { printf('<tr><th scope="row" class="check-column"><input type="checkbox" name="acsv-import-id[]" value="%d" /></th><td class="post-title page-title column-title"><a href="post.php?post=%d&action=edit" target="_blank">%s</a></td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', intval($p['ID']), intval($p['ID']), esc_html($p['Title']), esc_html($p['Type']), esc_html($p['Status']), esc_html($p['Author']), esc_html($p['Date'])); } echo '</table>'; echo '<p style="text-align: right;"><input type="submit" name="submit" id="submit" class="button advanced-csv-importer" value="Move to Trash" /></p>'; echo '</form>'; }
/** * Display importing log. * * @param array $inserted_posts An array of the post ids * @return none */ private function get_imported_data($inserted_posts, $format = 'table') { $posts = History::post_ids_to_posts($inserted_posts); WP_CLI\Utils\format_items($format, $posts, array('ID', 'Title', 'Type', 'Status', 'Author', 'Date')); $fail = History::get_num_fail($inserted_posts); if ($fail) { WP_CLI::warning('Failed to import: ' . $fail); } }