Skip to content

Commit

Permalink
add option to default post status to published
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewklimek committed Aug 4, 2020
1 parent fd79453 commit 0c9caa8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rs-csv-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ function greet() {
<label>
<input type="radio" name="replace-by-title" value="1" /><?php _e( 'Enable', 'really-simple-csv-importer' ); ?>
</label>
<p>
<label>
<input type=checkbox name=default-to-published><?php _e( 'Default to Published (if post_status is empty)', 'really-simple-csv-importer' ); ?>
</label>
</div>
<?php
wp_import_upload_form( add_query_arg('step', 1) );
Expand Down Expand Up @@ -180,8 +184,6 @@ function process_posts() {
$delimiter = ",";
$h->parse_columns( $this, $csv );
}

$post_statuses = get_post_stati();

echo '<ol>';

Expand Down Expand Up @@ -298,9 +300,11 @@ function process_posts() {
// (string) post status
$post_status = $h->get_data($this,$data,'post_status');
if ($post_status) {
if (in_array($post_status, $post_statuses)) {
if ( in_array( $post_status, get_post_stati() ) ) {
$post['post_status'] = $post_status;
}
} elseif ( !empty( $_POST['default-to-published'] ) ) {
$post['post_status'] = "publish";
}

// (string) post password
Expand Down

0 comments on commit 0c9caa8

Please sign in to comment.