Skip to content

Commit

Permalink
Upgrade post as draft checkbox to a dropdown allowing status to be se…
Browse files Browse the repository at this point in the history
…lected
  • Loading branch information
ShawnDrew committed Jul 3, 2013
1 parent 1adaacd commit e4049f8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
20 changes: 7 additions & 13 deletions classes/aktt_account.php
Expand Up @@ -37,18 +37,18 @@ public static function set_default_settings() {
'value' => 0,
'type' => 'is_cat',
),
'post_status' => array( // Set blog post status
'label' => __('Post Status', 'twitter-tools'),
'label_first' => true,
'value' => 'publish',
'type' => 'str',
),
'post_tags' => array( // tags to add to posts created from this acct
'label' => __('Post Tags', 'twitter-tools'),
'label_first' => true,
'value' => '',
'type' => 'tags',
),
'post_as_draft' => array( // Set blog post as draft
'label' => __('Set blog posts as draft', 'twitter-tools'),
'label_first' => false,
'value' => 0,
'type' => 'int',
),
'exclude_reply_tweets' => array( // Exclude tweets that are a reply from creating their own blog posts?
'label' => __('Exclude reply tweets from post creation', 'twitter-tools'),
'label_first' => false,
Expand Down Expand Up @@ -167,18 +167,12 @@ function save_tweets($tweets) {
AND post_type = '".AKTT::$post_type."'
");

// Check for draft post setting
$post_status = 'publish';
if ($this->option('post_as_draft')) {
$post_status = 'draft';
}

// Set the args for any blog posts created
$post_tweet_args = array(
'post_author' => $this->option('post_author'),
'post_category' => $this->option('post_category'),
'post_tags' => $this->option('post_tags'),
'post_status' => $post_status,
'post_status' => $this->option('post_status'),
'title_prefix' => $this->option('blog_post_title'),
);

Expand Down
21 changes: 15 additions & 6 deletions views/admin-account.php
Expand Up @@ -48,14 +48,23 @@
?>
</p>
<p>
<label class="left" for="<?php echo esc_attr(sprintf($name, 'post_tags')); ?>"><?php _e('Tags', 'twitter-tools'); ?></label>
<input type="text" class="type-ahead" data-tax="post_tag" name="<?php echo esc_attr(sprintf($name, 'post_tags')); ?>" id="<?php echo esc_attr(sprintf($name, 'post_tags')); ?>" value="<?php echo esc_attr($account->option('post_tags')); ?>" /> <span class="help"><?php _e('(comma separated)', 'twitter-tools'); ?></span>
<label class="left" for="<?php echo esc_attr(sprintf($name, 'post_status')); ?>"><?php _e('Status', 'twitter-tools'); ?></label>
<select name="<?php echo esc_attr(sprintf($name, 'post_status')); ?>" id="<?php echo esc_attr(sprintf($name, 'post_status')); ?>">
<?php
$post_statuses = get_post_stati(array('show_in_admin_status_list' => true), 'objects');
foreach ($post_statuses as $post_status_key => $post_status) {
$is_selected = '';
if ($account->option('post_status') === $post_status->name) {
$is_selected = ' selected="selected"';
}
echo '<option class="level-0" value="', $post_status->name, '"', $is_selected,'>', $post_status->label,'</option>';
}
?>
</select>
</p>
<p>
<label class="right" for="<?php echo esc_attr(sprintf($name, 'post_as_draft')); ?>">
<input type="checkbox" name="<?php echo esc_attr(sprintf($name, 'post_as_draft')); ?>" id="<?php echo esc_attr(sprintf($name, 'post_as_draft')); ?>" value="1" <?php checked('1', $account->option('post_as_draft')); ?> />
<?php _e('Set blog posts as draft', 'twitter-tools'); ?>
</label>
<label class="left" for="<?php echo esc_attr(sprintf($name, 'post_tags')); ?>"><?php _e('Tags', 'twitter-tools'); ?></label>
<input type="text" class="type-ahead" data-tax="post_tag" name="<?php echo esc_attr(sprintf($name, 'post_tags')); ?>" id="<?php echo esc_attr(sprintf($name, 'post_tags')); ?>" value="<?php echo esc_attr($account->option('post_tags')); ?>" /> <span class="help"><?php _e('(comma separated)', 'twitter-tools'); ?></span>
</p>
<p>
<label class="right" for="<?php echo esc_attr(sprintf($name, 'exclude_reply_tweets')); ?>">
Expand Down

0 comments on commit e4049f8

Please sign in to comment.