output(); /* ================================================== * KtaiAdmin_Post_Form class ================================================== */ class KtaiAdmin_Post_Form { private $base; private $admin; private $orig_referer; private $message; private $messages; private $notices; public function __construct($base) { $this->base = $base; $this->admin = $base->admin; $this->orig_referer = wp_get_original_referer(); if ( isset($_GET['message']) ) { $this->message = intval( $_GET['message'] ); if ($this->message == 1 && ! $this->orig_referer) { $this->message = 4; } } $this->messages[1] = sprintf(__('Post updated. Continue editing below or go back.' , 'ktai_style'), esc_attr($this->orig_referer)); $this->messages[2] = __('Custom field updated.', 'ktai_style'); $this->messages[3] = __('Custom field deleted.', 'ktai_style'); $this->messages[4] = __('Post updated.', 'ktai_style'); $this->messages[6] = __('Post published.', 'ktai_style'); $this->messages[7] = __('Post saved.', 'ktai_style'); $this->messages[8] = __('Post submitted.', 'ktai_style'); if ( isset($_GET['revision']) ) { $messages[5] = sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ); } $this->notices[1] = __( 'There is an autosave of this page that is more recent than the version below. View the autosave.' ); global $post_ID; $post_ID = isset($post_ID) ? intval($post_ID) : 0; } // ================================================== public function output() { global $action, $post_ID, $temp_ID, $post, $post_referredby, $checked_cats; $notice = false; if ( 0 == $post_ID ) { $temp_ID = -1 * time(); // don't change this formula without looking at wp_write_post() $form_action = 'post'; $nonce_action = 'add-post'; $slug_optional = ' ' . __('(Optional)', 'ktai_style'); $form_extra = ''; if (! isset($checked_cats)) { $checked_cats = array(get_option('default_category')); } } else { $form_action = 'editpost'; $nonce_action = 'update-post_' . $post_ID; $slug_optional = ''; $form_extra = ''; if (! isset($checked_cats)) { $checked_cats = wp_get_post_categories($post_ID); } } $cat_names = array(); if (count($checked_cats)) { foreach ($checked_cats as $c) { $cat_names[] = esc_html(apply_filters('the_category', get_the_category_by_ID($c))); } } if (empty($post->post_status)) { $post->post_status = 'draft'; } $can_publish = current_user_can('publish_posts'); include dirname(__FILE__) . '/admin-header.php'; if ( $notice ) : ?>
message)) : ?>messages[$this->message]; ?>