/** * Construct function. */ function __construct($parent_post, $child_post_type, $data) { WPCF_Loader::loadModel('relationship'); $this->parent = $parent_post; $this->parent_post_type = $parent_post->post_type; $this->child_post_type = $child_post_type; $this->data = $data; // Clean data if (empty($this->data['fields_setting'])) { $this->data['fields_setting'] = 'all_cf'; } $this->cf = new WPCF_Field(); $this->cf->context = 'relationship'; $this->children = WPCF_Relationship_Model::getChildrenByPostType($this->parent, $this->child_post_type, $this->data, $_GET); // If no children - use dummy post if (empty($this->children)) { $_dummy_post = get_default_post_to_edit($this->child_post_type, false); $this->children = array($_dummy_post); $this->_dummy_post = true; } $this->child_post_type_object = get_post_type_object($this->child_post_type); // Collect params from request foreach ($this->__params as $__param) { if (isset($_GET[$__param])) { $this->__urlParams[$__param] = $_GET[$__param]; } } $post_types = get_option('wpcf-custom-types', array()); if (array_key_exists($child_post_type, $post_types) && array_key_exists('supports', $post_types[$child_post_type])) { foreach ($post_types[$child_post_type]['supports'] as $key => $value) { $this->child_supports[$key] = (bool) $value; } } unset($post_types); }
function save() { $post = get_default_post_to_edit('sp_template', true); $post_ID = $post->ID; global $current_user; $content = ''; switch ($_POST['starter']) { case 'blank': $content = ''; break; default: $content = 'Default HTML'; break; } /* $my_post['ID'] = $_POST['post_ID']; $my_post['post_content'] = $_POST['content']; $my_post['post_title'] = $_POST['post_title']; */ $post->post_title = $_POST['post_title']; $post->post_status = 'sp-custom'; $post->post_content = $content; // Update the post into the database wp_update_post($post); //SendPress_Email::set_default_style( $my_post['ID'] ); //clear the cached file. SendPress_Admin::redirect('Emails_Tempedit', array('templateID' => $post->ID)); //$this->save_redirect( $_POST ); }
public function init($args = array()) { if (is_object($args)) { $args = (array) $args; } $this->attachment_id = array(); $this->tags = array(); $this->medias = array(); $this->metas = array(); $this->fields = array(); $this->media_count = 0; if (is_numeric($args)) { $post = get_post(intval($args)); if ($post && isset($post->ID) && !is_wp_error($post)) { $this->post_id = $post->ID; $this->post = $post; return true; } else { return false; } } else { $this->post = get_default_post_to_edit(); $this->post->post_category = null; if (is_array($args) && count($args) > 0) { return $this->set($args); } else { return true; } } }
public function import_media() { $post = get_default_post_to_edit('attachment'); $post->post_category = array(); $done = array(); foreach ($this->_get_media() as $block => $media) { foreach ($media as $m) { if (isset($done[$m])) { $this->_media_pool[$block][] = $done[$m]; continue; } $upload = circleflip_importer_fetch_local_file($m); if (is_wp_error($upload)) { continue; } if ($info = wp_check_filetype($upload['file'])) { $post->post_mime_type = $info['type']; } else { continue; } $post->guid = $upload['url']; $post_id = wp_insert_attachment($post, $upload['file']); // wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); $this->_media_pool[$block][] = $post_id; $done[$m] = $post_id; } } }
/** * Construct function. */ function __construct($parent_post, $child_post_type, $data) { WPCF_Loader::loadModel('relationship'); $this->parent = $parent_post; $this->parent_post_type = $parent_post->post_type; $this->child_post_type = $child_post_type; $this->data = $data; // Clean data if (empty($this->data['fields_setting'])) { $this->data['fields_setting'] = 'all_cf'; } $this->cf = new WPCF_Field(); $this->cf->context = 'relationship'; $this->children = WPCF_Relationship_Model::getChildrenByPostType($this->parent, $this->child_post_type, $this->data, $_GET); // If no children - use dummy post if (empty($this->children)) { $_dummy_post = get_default_post_to_edit($this->child_post_type, false); $this->children = array($_dummy_post); $this->_dummy_post = true; } $this->child_post_type_object = get_post_type_object($this->child_post_type); // Collect params from request foreach ($this->__params as $__param) { if (isset($_GET[$__param])) { $this->__urlParams[$__param] = $_GET[$__param]; } } }
function frontier_clone_post($fpost_sc_parms = array()) { //extract($fpost_sc_parms); //echo "CLONE POST<br>"; $frontier_permalink = get_permalink(); $concat = get_option("permalink_structure") ? "?" : "&"; if (isset($_POST['task'])) { $post_task = $_POST['task']; } else { if (isset($_GET['task'])) { $post_task = $_GET['task']; } else { $post_task = "notaskset"; } } $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown"; if ($post_task == "clone" && $_REQUEST['postid']) { $old_post = get_post($_REQUEST['postid']); $old_post_id = $old_post->ID; //double check current user can add a post with this post type if (frontier_can_add($old_post->post_type)) { require_once ABSPATH . '/wp-admin/includes/post.php'; global $current_user; //Get permalink from old post $old_permalink = get_permalink($old_post_id); // lets clone it $thispost = get_default_post_to_edit($fpost_sc_parms['frontier_add_post_type'], true); $new_post_id = $thispost->ID; $tmp_post = array('ID' => $new_post_id, 'post_type' => $old_post->post_type, 'post_title' => __("CLONED from", "frontier-post") . ': <a href="' . $old_permalink . '">' . $old_post->post_title . '</a>', 'post_content' => __("CLONED from", "frontier-post") . ': <a href="' . $old_permalink . '">' . $old_post->post_title . '</a><br>' . $old_post->post_content, 'post_status' => "draft", 'post_author' => $current_user->ID); //**************************************************************************************************** // Apply filter before update of post // filter: frontier_post_clone // $tmp_post Array that holds the updated fields // $old_post The post being cloed (Object) //**************************************************************************************************** $tmp_post = apply_filters('frontier_post_clone', $tmp_post, $old_post); // save post wp_update_post($tmp_post); //Get the updated post $new_post = get_post($new_post_id); //get all current post terms ad set them to the new post draft $taxonomies = get_object_taxonomies($old_post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag"); foreach ($taxonomies as $taxonomy) { $post_terms = wp_get_object_terms($old_post_id, $taxonomy, array('fields' => 'slugs')); wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false); } // Set featured image: $post_thumbnail_id = get_post_thumbnail_id($old_post_id); if (intval($post_thumbnail_id) > 0) { set_post_thumbnail($new_post_id, $post_thumbnail_id); } // Add/Update message frontier_post_set_msg(__("Post Cloned and ready edit", "frontier-post") . ": " . $new_post->post_title); frontier_post_set_msg(__("Post status set to Draft", "frontier-post")); frontier_user_post_list($fpost_sc_parms); } } }
function ajax_new() { check_ajax_referer('fee-new', 'nonce'); require_once ABSPATH . '/wp-admin/includes/post.php'; $post = get_default_post_to_edit(isset($_POST['post_type']) ? $_POST['post_type'] : 'post', true); wp_set_post_categories($post->ID, array(get_option('default_category'))); wp_send_json_success($this->edit_link($post->ID)); }
/** * Create a default track for use in the tracklist repeater. * * @since 1.0.0 */ function audiotheme_ajax_get_default_track() { $is_valid_nonce = !empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'get-default-track_' . $_POST['record']); if (empty($_POST['record']) || !$is_valid_nonce) { wp_send_json_error(); } $data['track'] = get_default_post_to_edit('audiotheme_track', true); $data['nonce'] = wp_create_nonce('get-default-track_' . $_POST['record']); wp_send_json($data); }
/** * Press It form handler. * * @package WordPress * @subpackage Press_This * @since 2.6.0 * * @return int Post ID */ function press_it() { $post = get_default_post_to_edit(); $post = get_object_vars($post); $post_ID = $post['ID'] = (int) $_POST['post_id']; if ( !current_user_can('edit_post', $post_ID) ) wp_die(__('You are not allowed to edit this post.')); $post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : ''; $post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : ''; $post['post_title'] = isset($_POST['title']) ? $_POST['title'] : ''; $content = isset($_POST['content']) ? $_POST['content'] : ''; $upload = false; if ( !empty($_POST['photo_src']) && current_user_can('upload_files') ) { foreach( (array) $_POST['photo_src'] as $key => $image) { // see if files exist in content - we don't want to upload non-used selected files. if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) { $desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : ''; $upload = media_sideload_image($image, $post_ID, $desc); // Replace the POSTED content <img> with correct uploaded ones. Regex contains fix for Magic Quotes if ( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content); } } } // set the post_content and status $post['post_content'] = $content; if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) ) $post['post_status'] = 'publish'; elseif ( isset( $_POST['review'] ) ) $post['post_status'] = 'pending'; else $post['post_status'] = 'draft'; // error handling for media_sideload if ( is_wp_error($upload) ) { wp_delete_post($post_ID); wp_die($upload); } else { // Post formats if ( isset( $_POST['post_format'] ) ) { if ( current_theme_supports( 'post-formats', $_POST['post_format'] ) ) set_post_format( $post_ID, $_POST['post_format'] ); elseif ( '0' == $_POST['post_format'] ) set_post_format( $post_ID, false ); } $post_ID = wp_update_post($post); } return $post_ID; }
/** * create a new post so that the ID can be used * Generally used for the Payments page for creating an Invoice ID * * @param: str $type Required: The type of post to create * * @return The post ID */ function mdjm_create_post() { $transaction = get_default_post_to_edit($_POST['mdjm_post_type'], true); if (empty($transaction)) { return $result['type'] = 'error'; } $response['type'] = 'success'; $response['id'] = $transaction->ID; echo json_encode($response); die; }
/** * @param string $post_type The type of the post (Default: 'post') * @param bool $replace_first Wether to replace the first post in the loop or not (Default: true) */ function fee_inject_dummy_post($post_type = 'post', $replace_first = true) { global $wp_query; require_once ABSPATH . '/wp-admin/includes/post.php'; $post = get_default_post_to_edit($post_type, true); if ($replace_first) { $wp_query->posts[0] = $post; } else { array_unshift($wp_query->posts, $post); } }
/** * Construct function. */ function __construct($parent_post, $child_post_type, $data) { WPCF_Loader::loadModel('relationship'); $this->parent = $parent_post; $this->parent_post_type = $parent_post->post_type; $this->child_post_type = $child_post_type; $this->data = $data; // Clean data if (empty($this->data['fields_setting'])) { $this->data['fields_setting'] = 'all_cf'; } $this->cf = new WPCF_Field(); $this->cf->context = 'relationship'; $this->children = WPCF_Relationship_Model::getChildrenByPostType($this->parent, $this->child_post_type, $this->data, $_GET); // If no children - use dummy post if (empty($this->children)) { $_dummy_post = get_default_post_to_edit($this->child_post_type, false); $this->children = array($_dummy_post); $this->_dummy_post = true; } $this->child_post_type_object = get_post_type_object($this->child_post_type); if (!isset($this->child_post_type_object->slug) && isset($this->child_post_type_object->name)) { $this->child_post_type_object->slug = $this->child_post_type_object->name; } // Collect params from request foreach ($this->__params as $__param) { if (isset($_GET[$__param])) { $this->__urlParams[$__param] = $_GET[$__param]; } } /** * build-in types */ if (in_array($child_post_type, array('page', 'post', 'attachment', 'revision', 'nav_menu_item'))) { foreach (array_keys($this->child_supports) as $key) { $this->child_supports[$key] = post_type_supports($child_post_type, $key); } return; } /** * post types */ $post_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array()); if (array_key_exists($child_post_type, $post_types) && array_key_exists('supports', $post_types[$child_post_type])) { foreach ($post_types[$child_post_type]['supports'] as $key => $value) { $this->child_supports[$key] = (bool) $value; } } unset($post_types); /** * wp_enqueue_media allways */ add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_media'), PHP_INT_MAX); }
echo ', '; $draft->post_title = stripslashes($draft->post_title); if ( empty($draft->post_title) ) $draft->post_title = sprintf(__('Post # %s'), $draft->ID); echo "<a href='post.php?action=edit&post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>"; } ?> <?php if ( 15 < count($drafts) ) { ?> , <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> »</a> <?php } ?> .</p> </div> <?php } $post = get_default_post_to_edit(); include('edit-form-advanced.php'); ?> <div id="wp-bookmarklet" class="wrap"> <?php echo '<h3>'.__('WordPress bookmarklet').'</h3> <p>'.__('Right click on the following link and choose "Add to favorites" to create a posting shortcut.').'</p>'; ?> <p> <?php if ($is_NS4 || $is_gecko) { ?> <a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_settings('siteurl') ?>/wp-admin/post.php?text='+encodeURIComponent(Q)+'&popupurl='+encodeURIComponent(location.href)+'&popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), wp_specialchars(get_settings('blogname'))); ?></a> <?php } else if ($is_winIE) { ?>
function wp_dashboard_quick_press() { global $post_ID; $drafts = false; if ('post' === strtolower($_SERVER['REQUEST_METHOD']) && isset($_POST['action']) && 0 === strpos($_POST['action'], 'post-quickpress') && (int) $_POST['post_ID']) { $view = get_permalink($_POST['post_ID']); $edit = esc_url(get_edit_post_link($_POST['post_ID'])); if ('post-quickpress-publish' == $_POST['action']) { if (current_user_can('publish_posts')) { printf('<div class="updated"><p>' . __('Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>') . '</p></div>', esc_url($view), $edit); } else { printf('<div class="updated"><p>' . __('Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>') . '</p></div>', esc_url(add_query_arg('preview', 1, $view)), $edit); } } else { printf('<div class="updated"><p>' . __('Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>') . '</p></div>', esc_url(add_query_arg('preview', 1, $view)), $edit); $drafts_query = new WP_Query(array('post_type' => 'post', 'post_status' => 'draft', 'author' => $GLOBALS['current_user']->ID, 'posts_per_page' => 1, 'orderby' => 'modified', 'order' => 'DESC')); if ($drafts_query->posts) { $drafts =& $drafts_query->posts; } } printf('<p class="easy-blogging">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url(admin_url('tools.php')) . '">' . __('Press This') . '</a>'); $_REQUEST = array(); // hack for get_default_post_to_edit() } /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ $last_post_id = (int) get_user_option('dashboard_quick_press_last_post_id'); // Get the last post_ID if ($last_post_id) { $post = get_post($last_post_id); if (empty($post) || $post->post_status != 'auto-draft') { // auto-draft doesn't exists anymore $post = get_default_post_to_edit('post', true); update_user_option(get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID } else { $post->post_title = ''; // Remove the auto draft title } } else { $post = get_default_post_to_edit('post', true); $user_id = get_current_user_id(); // Don't create an option if this is a super admin who does not belong to this site. if (!(is_super_admin($user_id) && !in_array(get_current_blog_id(), array_keys(get_blogs_of_user($user_id))))) { update_user_option($user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID); } // Save post_ID } $post_ID = (int) $post->ID; $media_settings = array('id' => $post->ID, 'nonce' => wp_create_nonce('update-post_' . $post->ID)); if (current_theme_supports('post-thumbnails', $post->post_type) && post_type_supports($post->post_type, 'thumbnail')) { $featured_image_id = get_post_meta($post->ID, '_thumbnail_id', true); $media_settings['featuredImageId'] = $featured_image_id ? $featured_image_id : -1; } ?> <form name="post" action="<?php echo esc_url(admin_url('post.php')); ?> " method="post" id="quick-press"> <div class="input-text-wrap" id="title-wrap"> <label class="screen-reader-text prompt" for="title" id="title-prompt-text"><?php _e('Enter title here'); ?> </label> <input type="text" name="post_title" id="title" autocomplete="off" value="<?php echo esc_attr($post->post_title); ?> " /> </div> <?php if (current_user_can('upload_files')) { ?> <div id="wp-content-wrap" class="wp-editor-wrap hide-if-no-js wp-media-buttons"> <?php do_action('media_buttons', 'content'); ?> </div> <?php } ?> <div class="textarea-wrap"> <label class="screen-reader-text" for="content"><?php _e('Content'); ?> </label> <textarea name="content" id="content" class="mceEditor" rows="3" cols="15"><?php echo esc_textarea($post->post_content); ?> </textarea> </div> <script type="text/javascript"> edCanvas = document.getElementById('content'); edInsertContent = null; <?php if ($_POST) { ?> wp.media.editor.remove('content'); wp.media.view.settings.post = <?php echo json_encode($media_settings); // big juicy hack. ?> ; wp.media.editor.add('content'); <?php } ?> </script> <div class="input-text-wrap" id="tags-input-wrap"> <label class="screen-reader-text prompt" for="tags-input" id="tags-input-prompt-text"><?php _e('Tags (separate with commas)'); ?> </label> <input type="text" name="tags_input" id="tags-input" value="<?php echo get_tags_to_edit($post->ID); ?> " /> </div> <p class="submit"> <span id="publishing-action"> <input type="submit" name="publish" id="publish" accesskey="p" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?> " /> <span class="spinner"></span> </span> <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" /> <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?> " /> <input type="hidden" name="post_type" value="post" /> <?php wp_nonce_field('add-post'); ?> <?php submit_button(__('Save Draft'), 'button', 'save', false, array('id' => 'save-post')); ?> <input type="reset" value="<?php esc_attr_e('Reset'); ?> " class="button" /> <br class="clear" /> </p> </form> <?php if ($drafts) { wp_dashboard_recent_drafts($drafts); } }
/** * Add meta boxes. * * @param type $post_type * @param type $post * @return boolean */ function wpcf_add_meta_boxes($post_type, $post) { // Do not add metaboxes if (in_array($post_type, array('view', 'view-template', 'cred-form'))) { return false; } // Fix for empty $post (tabify) if (empty($post->ID)) { $post = get_default_post_to_edit($post_type, false); } // Get groups $groups = wpcf_admin_post_get_post_groups_fields($post); foreach ($groups as $group) { $only_preview = ''; //If Access plugin activated if (function_exists('wpcf_access_register_caps')) { //If user can't view own profile fields if (!current_user_can('view_fields_in_edit_page_' . $group['slug'])) { continue; } //If user can modify current group in own profile if (!current_user_can('modify_fields_in_edit_page_' . $group['slug'])) { $only_preview = 1; } } // Process fields if (!empty($group['fields']) && empty($only_preview)) { if (defined('WPTOOLSET_FORMS_VERSION')) { $errors = get_post_meta($post->ID, '__wpcf-invalid-fields', true); $group['html'] = array(); foreach ($group['fields'] as $field) { wpcf_admin_post_add_to_editor($field); $meta = get_post_meta($post->ID, $field['meta_key']); $config = wptoolset_form_filter_types_field($field, $post->ID); if ($errors) { $config['validate'] = true; } if ($field['type'] == 'wysiwyg') { $group['html'][] = array('config' => $config, 'meta' => $meta); } else { $group['html'][] = wptoolset_form_field('post', $config, $meta); } } // OLD delete_post_meta($post->ID, 'wpcf-invalid-fields'); delete_post_meta($post->ID, '__wpcf-invalid-fields'); } else { // Process fields $group['fields'] = wpcf_admin_post_process_fields($post, $group['fields'], true); } } // Check if hidden if (!isset($group['__show_meta_box']) || $group['__show_meta_box'] != false) { // Add meta boxes if (empty($only_preview)) { add_meta_box("wpcf-group-{$group['slug']}", wpcf_translate('group ' . $group['id'] . ' name', $group['name']), 'wpcf_admin_post_meta_box', $post_type, $group['meta_box_context'], 'high', $group); } else { add_meta_box("wpcf-group-{$group['slug']}", wpcf_translate('group ' . $group['id'] . ' name', $group['name']), 'wpcf_admin_post_meta_box_preview', $post_type, $group['meta_box_context'], 'high', $group); } } } }
/** * {@internal Missing Short Description}} * * @since unknown * * @return unknown */ function get_default_page_to_edit() { $page = get_default_post_to_edit(); $page->post_type = 'page'; return $page; }
/** * Utility to create an auto-draft post, to be used on front-end forms. * * @param string $post_type * @return object */ function appthemes_get_draft_post($post_type) { $key = 'draft_' . $post_type . '_id'; $draft_post_id = (int) get_user_option($key); if ($draft_post_id) { $draft = get_post($draft_post_id); if (!empty($draft) && $draft->post_status == 'auto-draft') { return $draft; } } require ABSPATH . '/wp-admin/includes/post.php'; $draft = get_default_post_to_edit($post_type, true); update_user_option(get_current_user_id(), $key, $draft->ID); return $draft; }
public static function wpematico_add_to_quick_edit_custom_box($column_name, $post_type) { $post = get_default_post_to_edit($post_type); $post_type_object = get_post_type_object('post'); $taxonomy_names = get_object_taxonomies('post'); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ($taxonomy_names as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); if (!$taxonomy->show_ui) { continue; } if ($taxonomy->hierarchical) { $hierarchical_taxonomies[] = $taxonomy; } else { $flat_taxonomies[] = $taxonomy; } } switch ($post_type) { case 'wpematico': switch ($column_name) { case 'status': static $printNonce = TRUE; if ($printNonce) { $printNonce = FALSE; wp_nonce_field(plugin_basename(__FILE__), 'wpematico_edit_nonce'); } ?> <fieldset class="" id="optionscampaign" style="display:none;"> <div class="inline-edit-col"> <h4><?php _e('Campaign Options', WPeMatico::TEXTDOMAIN); ?> </h4> <div class="inline-edit-group"> <label class="alignleft"> <span class="field-title"><?php _e('Max items to create on each fetch:', WPeMatico::TEXTDOMAIN); ?> </span> <span class="input-text"> <input type="number" min="0" size="3" name="campaign_max" class="campaign_max small-text" value=""> </span> </label> <label class="alignleft"> <input type="checkbox" name="campaign_feeddate" value="1"> <span class="checkbox-title"><?php _e('Use feed date', WPeMatico::TEXTDOMAIN); ?> </span> </label> </div> <div class="inline-edit-group"> <label class="alignleft inline-edit-col"> <span class="authortitle"><?php _e('Author:', WPeMatico::TEXTDOMAIN); ?> </span> <span class="input-text"> <?php wp_dropdown_users(array('name' => 'campaign_author')); ?> </span> </label> <label class="alignleft inline-edit-col"> <span class="commenttitle"><?php _e('Discussion options:', WPeMatico::TEXTDOMAIN); ?> </span> <span class="input-text"> <select class="campaign_commentstatus" name="campaign_commentstatus"> <?php $options = array('open' => __('Open', WPeMatico::TEXTDOMAIN), 'closed' => __('Closed', WPeMatico::TEXTDOMAIN), 'registered_only' => __('Registered only', WPeMatico::TEXTDOMAIN)); foreach ($options as $key => $value) { echo '<option value="' . esc_attr($key) . '">' . $value . '</option>'; } ?> </select> </span> </label> </div> <div class="inline-edit-group"> <label class="alignleft"> <input type="checkbox" name="campaign_allowpings" value="1"> <span class="checkbox-title"><?php _e('Allow pings?', WPeMatico::TEXTDOMAIN); ?> </span> </label> <label class="alignleft"> <input type="checkbox" name="campaign_linktosource" value="1"> <span class="checkbox-title"><?php _e('Post title links to source?', WPeMatico::TEXTDOMAIN); ?> </span> </label> <label class="alignleft"> <input type="checkbox" name="campaign_strip_links" value="1"> <span class="checkbox-title"><?php _e('Strip links from content', WPeMatico::TEXTDOMAIN); ?> </span> </label> <br class="clear" /> </div> </div> </fieldset> <?php if (count($hierarchical_taxonomies)) { ?> <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <?php foreach ($hierarchical_taxonomies as $taxonomy) { ?> <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name); ?> </span> <input type="hidden" name="<?php echo $taxonomy->name == 'category' ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?> " value="0" /> <ul class="cat-checklist <?php echo esc_attr($taxonomy->name); ?> -checklist"> <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)); ?> </ul> <?php } //$hierarchical_taxonomies as $taxonomy ?> </div> </fieldset> <?php } // count( $hierarchical_taxonomies ) && !$bulk ?> <?php if (count($flat_taxonomies)) { ?> <fieldset class="inline-edit-col-right"> <div class="inline-edit-col"> <?php foreach ($flat_taxonomies as $taxonomy) { ?> <?php if (current_user_can($taxonomy->cap->assign_terms)) { ?> <label class="inline-edit-tags"> <span class="title"><?php echo esc_html($taxonomy->labels->name); ?> </span> <textarea cols="22" rows="1" name="campaign_tags" class="tax_input_<?php echo esc_attr($taxonomy->name); ?> "></textarea> </label> <?php } ?> <?php } //$flat_taxonomies as $taxonomy ?> <?php } // count( $flat_taxonomies ) && !$bulk ?> <div class="inline-edit-radiosbox"> <label> <span class="title"><?php _e('Post type', WPeMatico::TEXTDOMAIN); ?> </span> <br/> <span class="input-text"> <?php $args = array('public' => true); $output = 'names'; // names or objects, note names is the default $operator = 'and'; // 'and' or 'or' $post_types = get_post_types($args, $output, $operator); foreach ($post_types as $posttype) { if ($posttype == 'wpematico') { continue; } echo '<label><input type="radio" name="campaign_customposttype" value="' . $posttype . '" id="customtype_' . $posttype . '" /> ' . $posttype . '</label>'; } ?> </span> </label> </div> <div class="inline-edit-radiosbox"> <label> <span class="title"><?php _e('Status', WPeMatico::TEXTDOMAIN); ?> </span> <br/> <span class="input-text"> <label><input type="radio" name="campaign_posttype" value="publish" /> <?php _e('Published'); ?> </label> <label><input type="radio" name="campaign_posttype" value="private" /> <?php _e('Private'); ?> </label> <label><input type="radio" name="campaign_posttype" value="pending" /> <?php _e('Pending'); ?> </label> <label><input type="radio" name="campaign_posttype" value="draft" /> <?php _e('Draft'); ?> </label> </span> </label> </div> <?php if (current_theme_supports('post-formats')) { $post_formats = get_theme_support('post-formats'); ?> <div class="inline-edit-radiosbox qedscroll"> <label> <span class="title" style="width: 100%;"><?php _e('Post Format', WPeMatico::TEXTDOMAIN); ?> </span> <br/> <span class="input-text"> <?php if (is_array($post_formats[0])) { global $post, $campaign_data; $campaign_post_format = @(!$campaign_post_format) ? '0' : $campaign_data['campaign_post_format']; ?> <div id="post-formats-select"> <label><input type="radio" name="campaign_post_format" class="post-format" id="post-format-0" value="0" /> <?php echo get_post_format_string('standard'); ?> </label> <?php foreach ($post_formats[0] as $format) { ?> <label><input type="radio" name="campaign_post_format" class="post-format" id="post-format-<?php echo esc_attr($format); ?> " value="<?php echo esc_attr($format); ?> " /> <?php echo esc_html(get_post_format_string($format)); ?> </label> <?php } ?> </div> <?php } ?> </span> </label> </div> <?php } ?> </div> </fieldset><?php break; case 'title': // No entra en title break; case 'others': /* ?><fieldset class="inline-edit-col-right"> <div class="inline-edit-col"> <label> <span class="title">Release Date</span> <input type="text" name="next" value="" /> </label> </div> </fieldset><?php */ break; } break; // case 'wpematico' } }
/** * Outputs the hidden row displayed when inline editing * * @since 3.1.0 * * @global string $mode */ public function inline_edit() { global $mode; $screen = $this->screen; $post = get_default_post_to_edit($screen->post_type); $post_type_object = get_post_type_object($screen->post_type); $taxonomy_names = get_object_taxonomies($screen->post_type); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ($taxonomy_names as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); $show_in_quick_edit = $taxonomy->show_in_quick_edit; /** * Filter whether the current taxonomy should be shown in the Quick Edit panel. * * @since 4.2.0 * * @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. * @param string $taxonomy_name Taxonomy name. * @param string $post_type Post type of current Quick Edit post. */ if (!apply_filters('quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type)) { continue; } if ($taxonomy->hierarchical) { $hierarchical_taxonomies[] = $taxonomy; } else { $flat_taxonomies[] = $taxonomy; } } $m = isset($mode) && 'excerpt' == $mode ? 'excerpt' : 'list'; $can_publish = current_user_can($post_type_object->cap->publish_posts); $core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true); ?> <form method="get"><table style="display: none"><tbody id="inlineedit"> <?php $hclass = count($hierarchical_taxonomies) ? 'post' : 'page'; $bulk = 0; while ($bulk < 2) { ?> <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?> " class="inline-edit-row inline-edit-row-<?php echo "{$hclass} inline-edit-" . $screen->post_type; echo $bulk ? " bulk-edit-row bulk-edit-row-{$hclass} bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-{$hclass} inline-edit-{$screen->post_type}"; ?> " style="display: none"><td colspan="<?php echo $this->get_column_count(); ?> " class="colspanchange"> <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> <h4><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?> </h4> <?php if (post_type_supports($screen->post_type, 'title')) { if ($bulk) { ?> <div id="bulk-title-div"> <div id="bulk-titles"></div> </div> <?php } else { // $bulk ?> <label> <span class="title"><?php _e('Title'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> </label> <label> <span class="title"><?php _e('Slug'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> </label> <?php } // $bulk } // post_type_supports title ?> <?php if (!$bulk) { ?> <fieldset class="inline-edit-date"> <legend><span class="title"><?php _e('Date'); ?> </span></legend> <?php touch_time(1, 1, 0, 1); ?> </fieldset> <br class="clear" /> <?php } // $bulk if (post_type_supports($screen->post_type, 'author')) { $authors_dropdown = ''; if (is_super_admin() || current_user_can($post_type_object->cap->edit_others_posts)) { $users_opt = array('hide_if_only_one_author' => false, 'who' => 'authors', 'name' => 'post_author', 'class' => 'authors', 'multi' => 1, 'echo' => 0); if ($bulk) { $users_opt['show_option_none'] = __('— No Change —'); } if ($authors = wp_dropdown_users($users_opt)) { $authors_dropdown = '<label class="inline-edit-author">'; $authors_dropdown .= '<span class="title">' . __('Author') . '</span>'; $authors_dropdown .= $authors; $authors_dropdown .= '</label>'; } } // authors ?> <?php if (!$bulk) { echo $authors_dropdown; } } // post_type_supports author if (!$bulk && $can_publish) { ?> <div class="inline-edit-group"> <label class="alignleft"> <span class="title"><?php _e('Password'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> </label> <em class="alignleft inline-edit-or"> <?php /* translators: Between password field and private checkbox on post quick edit interface */ _e('–OR–'); ?> </em> <label class="alignleft inline-edit-private"> <input type="checkbox" name="keep_private" value="private" /> <span class="checkbox-title"><?php _e('Private'); ?> </span> </label> </div> <?php } ?> </div></fieldset> <?php if (count($hierarchical_taxonomies) && !$bulk) { ?> <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <?php foreach ($hierarchical_taxonomies as $taxonomy) { ?> <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name); ?> </span> <input type="hidden" name="<?php echo $taxonomy->name == 'category' ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?> " value="0" /> <ul class="cat-checklist <?php echo esc_attr($taxonomy->name); ?> -checklist"> <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)); ?> </ul> <?php } //$hierarchical_taxonomies as $taxonomy ?> </div></fieldset> <?php } // count( $hierarchical_taxonomies ) && !$bulk ?> <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> <?php if (post_type_supports($screen->post_type, 'author') && $bulk) { echo $authors_dropdown; } if (post_type_supports($screen->post_type, 'page-attributes')) { if ($post_type_object->hierarchical) { ?> <label> <span class="title"><?php _e('Parent'); ?> </span> <?php $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column' => 'menu_order, post_title'); if ($bulk) { $dropdown_args['show_option_no_change'] = __('— No Change —'); } /** * Filter the arguments used to generate the Quick Edit page-parent drop-down. * * @since 2.7.0 * * @see wp_dropdown_pages() * * @param array $dropdown_args An array of arguments. */ $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); wp_dropdown_pages($dropdown_args); ?> </label> <?php } // hierarchical if (!$bulk) { ?> <label> <span class="title"><?php _e('Order'); ?> </span> <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?> " /></span> </label> <?php } // !$bulk if ('page' == $screen->post_type) { ?> <label> <span class="title"><?php _e('Template'); ?> </span> <select name="page_template"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <?php /** This filter is documented in wp-admin/includes/meta-boxes.php */ $default_title = apply_filters('default_page_template_title', __('Default Template'), 'quick-edit'); ?> <option value="default"><?php echo esc_html($default_title); ?> </option> <?php page_template_dropdown(); ?> </select> </label> <?php } // page post_type } // page-attributes ?> <?php if (count($flat_taxonomies) && !$bulk) { ?> <?php foreach ($flat_taxonomies as $taxonomy) { ?> <?php if (current_user_can($taxonomy->cap->assign_terms)) { ?> <label class="inline-edit-tags"> <span class="title"><?php echo esc_html($taxonomy->labels->name); ?> </span> <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name); ?> ]" class="tax_input_<?php echo esc_attr($taxonomy->name); ?> "></textarea> </label> <?php } ?> <?php } //$flat_taxonomies as $taxonomy ?> <?php } // count( $flat_taxonomies ) && !$bulk ?> <?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) { if ($bulk) { ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <span class="title"><?php _e('Comments'); ?> </span> <select name="comment_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignright"> <span class="title"><?php _e('Pings'); ?> </span> <select name="ping_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } ?> </div> <?php } else { // $bulk ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <input type="checkbox" name="comment_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Comments'); ?> </span> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignleft"> <input type="checkbox" name="ping_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Pings'); ?> </span> </label> <?php } ?> </div> <?php } // $bulk } // post_type_supports comments or pings ?> <div class="inline-edit-group"> <label class="inline-edit-status alignleft"> <span class="title"><?php _e('Status'); ?> </span> <select name="_status"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <?php if ($can_publish) { // Contributors only get "Unpublished" and "Pending Review" ?> <option value="publish"><?php _e('Published'); ?> </option> <option value="future"><?php _e('Scheduled'); ?> </option> <?php if ($bulk) { ?> <option value="private"><?php _e('Private'); ?> </option> <?php } // $bulk ?> <?php } ?> <option value="pending"><?php _e('Pending Review'); ?> </option> <option value="draft"><?php _e('Draft'); ?> </option> </select> </label> <?php if ('post' == $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) { ?> <?php if ($bulk) { ?> <label class="alignright"> <span class="title"><?php _e('Sticky'); ?> </span> <select name="sticky"> <option value="-1"><?php _e('— No Change —'); ?> </option> <option value="sticky"><?php _e('Sticky'); ?> </option> <option value="unsticky"><?php _e('Not Sticky'); ?> </option> </select> </label> <?php } else { // $bulk ?> <label class="alignleft"> <input type="checkbox" name="sticky" value="sticky" /> <span class="checkbox-title"><?php _e('Make this post sticky'); ?> </span> </label> <?php } // $bulk ?> <?php } // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?> </div> <?php if ($bulk && current_theme_supports('post-formats') && post_type_supports($screen->post_type, 'post-formats')) { $post_formats = get_theme_support('post-formats'); ?> <label class="alignleft"> <span class="title"><?php _ex('Format', 'post format'); ?> </span> <select name="post_format"> <option value="-1"><?php _e('— No Change —'); ?> </option> <option value="0"><?php echo get_post_format_string('standard'); ?> </option> <?php if (is_array($post_formats[0])) { foreach ($post_formats[0] as $format) { ?> <option value="<?php echo esc_attr($format); ?> "><?php echo esc_html(get_post_format_string($format)); ?> </option> <?php } } ?> </select></label> <?php } ?> </div></fieldset> <?php list($columns) = $this->get_column_info(); foreach ($columns as $column_name => $column_display_name) { if (isset($core_columns[$column_name])) { continue; } if ($bulk) { /** * Fires once for each column in Bulk Edit mode. * * @since 2.7.0 * * @param string $column_name Name of the column to edit. * @param WP_Post $post_type The post type slug. */ do_action('bulk_edit_custom_box', $column_name, $screen->post_type); } else { /** * Fires once for each column in Quick Edit mode. * * @since 2.7.0 * * @param string $column_name Name of the column to edit. * @param string $post_type The post type slug. */ do_action('quick_edit_custom_box', $column_name, $screen->post_type); } } ?> <p class="submit inline-edit-save"> <button type="button" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?> </button> <?php if (!$bulk) { wp_nonce_field('inlineeditnonce', '_inline_edit', false); ?> <button type="button" class="button-primary save alignright"><?php _e('Update'); ?> </button> <span class="spinner"></span> <?php } else { submit_button(__('Update'), 'button-primary alignright', 'bulk_edit', false); } ?> <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?> " /> <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?> " /> <?php if (!$bulk && !post_type_supports($screen->post_type, 'author')) { ?> <input type="hidden" name="post_author" value="<?php echo esc_attr($post->post_author); ?> " /> <?php } ?> <span class="error" style="display:none"></span> <br class="clear" /> </p> </td></tr> <?php $bulk++; } ?> </tbody></table></form> <?php }
/** * Serves the app's base HTML, which in turns calls the load script. * * @since 4.2.0 * @access public * * @global WP_Locale $wp_locale * @global string $wp_version * @global bool $is_IE */ public function html() { global $wp_locale, $wp_version; // Get data, new (POST) and old (GET). $data = $this->merge_or_fetch_data(); $post_title = $this->get_suggested_title($data); $post_content = $this->get_suggested_content($data); // Get site settings array/data. $site_settings = $this->site_settings(); // Pass the images and embeds $images = $this->get_images($data); $embeds = $this->get_embeds($data); $site_data = array('v' => !empty($data['v']) ? $data['v'] : '', 'u' => !empty($data['u']) ? $data['u'] : '', 'hasData' => !empty($data)); if (!empty($images)) { $site_data['_images'] = $images; } if (!empty($embeds)) { $site_data['_embeds'] = $embeds; } // Add press-this-editor.css and remove theme's editor-style.css, if any. remove_editor_styles(); add_filter('mce_css', array($this, 'add_editor_style')); if (!empty($GLOBALS['is_IE'])) { @header('X-UA-Compatible: IE=edge'); } @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); ?> <!DOCTYPE html> <!--[if IE 7]> <html class="lt-ie9 lt-ie8" <?php language_attributes(); ?> > <![endif]--> <!--[if IE 8]> <html class="lt-ie9" <?php language_attributes(); ?> > <![endif]--> <!--[if gt IE 8]><!--> <html <?php language_attributes(); ?> > <!--<![endif]--> <head> <meta http-equiv="Content-Type" content="<?php echo esc_attr(get_bloginfo('html_type')); ?> ; charset=<?php echo esc_attr(get_option('blog_charset')); ?> " /> <meta name="viewport" content="width=device-width"> <title><?php esc_html_e('Press This!'); ?> </title> <script> window.wpPressThisData = <?php echo wp_json_encode($site_data); ?> ; window.wpPressThisConfig = <?php echo wp_json_encode($site_settings); ?> ; </script> <script type="text/javascript"> var ajaxurl = '<?php echo esc_js(admin_url('admin-ajax.php', 'relative')); ?> ', pagenow = 'press-this', typenow = 'post', adminpage = 'press-this-php', thousandsSeparator = '<?php echo addslashes($wp_locale->number_format['thousands_sep']); ?> ', decimalPoint = '<?php echo addslashes($wp_locale->number_format['decimal_point']); ?> ', isRtl = <?php echo (int) is_rtl(); ?> ; </script> <?php /* * $post->ID is needed for the embed shortcode so we can show oEmbed previews in the editor. * Maybe find a way without it. */ $post = get_default_post_to_edit('post', true); $post_ID = (int) $post->ID; wp_enqueue_media(array('post' => $post_ID)); wp_enqueue_style('press-this'); wp_enqueue_script('press-this'); wp_enqueue_script('json2'); wp_enqueue_script('editor'); $supports_formats = false; $post_format = 0; if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) { $supports_formats = true; if (!($post_format = get_post_format($post_ID))) { $post_format = 0; } } /** This action is documented in wp-admin/admin-header.php */ do_action('admin_enqueue_scripts', 'press-this.php'); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_print_styles-press-this.php'); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_print_styles'); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_print_scripts-press-this.php'); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_print_scripts'); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_head-press-this.php'); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_head'); ?> </head> <?php $admin_body_class = 'press-this'; $admin_body_class .= is_rtl() ? ' rtl' : ''; $admin_body_class .= ' branch-' . str_replace(array('.', ','), '-', floatval($wp_version)); $admin_body_class .= ' version-' . str_replace('.', '-', preg_replace('/^([.0-9]+).*/', '$1', $wp_version)); $admin_body_class .= ' admin-color-' . sanitize_html_class(get_user_option('admin_color'), 'fresh'); $admin_body_class .= ' locale-' . sanitize_html_class(strtolower(str_replace('_', '-', get_locale()))); /** This filter is documented in wp-admin/admin-header.php */ $admin_body_classes = apply_filters('admin_body_class', ''); ?> <body class="wp-admin wp-core-ui <?php echo $admin_body_classes . ' ' . $admin_body_class; ?> "> <div id="adminbar" class="adminbar"> <h1 id="current-site" class="current-site"> <a class="current-site-link" href="<?php echo esc_url(home_url('/')); ?> " target="_blank" rel="home"> <span class="dashicons dashicons-wordpress"></span> <span class="current-site-name"><?php bloginfo('name'); ?> </span> </a> </h1> <button type="button" class="options button-subtle closed"> <span class="dashicons dashicons-tag on-closed"></span> <span class="screen-reader-text on-closed"><?php _e('Show post options'); ?> </span> <span aria-hidden="true" class="on-open"><?php _e('Done'); ?> </span> <span class="screen-reader-text on-open"><?php _e('Hide post options'); ?> </span> </button> </div> <div id="scanbar" class="scan"> <form method="GET"> <label for="url-scan" class="screen-reader-text"><?php _e('Scan site for content'); ?> </label> <input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php esc_attr_e('Enter a URL to scan'); ?> " /> <input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php esc_attr_e('Scan'); ?> " /> </form> </div> <form id="pressthis-form" method="post" action="post.php" autocomplete="off"> <input type="hidden" name="post_ID" id="post_ID" value="<?php echo $post_ID; ?> " /> <input type="hidden" name="action" value="press-this-save-post" /> <input type="hidden" name="post_status" id="post_status" value="draft" /> <input type="hidden" name="wp-preview" id="wp-preview" value="" /> <input type="hidden" name="post_title" id="post_title" value="" /> <?php wp_nonce_field('update-post_' . $post_ID, '_wpnonce', false); wp_nonce_field('add-category', '_ajax_nonce-add-category', false); ?> <div class="wrapper"> <div class="editor-wrapper"> <div class="alerts" role="alert" aria-live="assertive" aria-relevant="all" aria-atomic="true"> <?php if (isset($data['v']) && $this->version > $data['v']) { ?> <p class="alert is-notice"> <?php printf(__('You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!'), admin_url('tools.php')); ?> </p> <?php } ?> </div> <div id="app-container" class="editor"> <span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e('Post title'); ?> </span> <h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php esc_attr_e('Post title'); ?> " tabindex="0"><?php echo esc_html($post_title); ?> </h2> <div class="media-list-container"> <div class="media-list-inner-container"> <h2 class="screen-reader-text"><?php _e('Suggested media'); ?> </h2> <ul class="media-list"></ul> </div> </div> <?php wp_editor($post_content, 'pressthis', array('drag_drop_upload' => true, 'editor_height' => 600, 'media_buttons' => false, 'textarea_name' => 'post_content', 'teeny' => true, 'tinymce' => array('resize' => false, 'wordpress_adv_hidden' => false, 'add_unload_trigger' => false, 'statusbar' => false, 'autoresize_min_height' => 600, 'wp_autoresize_on' => true, 'plugins' => 'lists,media,paste,tabfocus,fullscreen,wordpress,wpautoresize,wpeditimage,wpgallery,wplink,wpview', 'toolbar1' => 'bold,italic,bullist,numlist,blockquote,link,unlink', 'toolbar2' => 'undo,redo'), 'quicktags' => false)); ?> </div> </div> <div class="options-panel-back is-hidden" tabindex="-1"></div> <div class="options-panel is-off-screen is-hidden" tabindex="-1"> <div class="post-options"> <?php if ($supports_formats) { ?> <button type="button" class="button-reset post-option"> <span class="dashicons dashicons-admin-post"></span> <span class="post-option-title"><?php _ex('Format', 'post format'); ?> </span> <span class="post-option-contents" id="post-option-post-format"><?php echo esc_html(get_post_format_string($post_format)); ?> </span> <span class="dashicons post-option-forward"></span> </button> <?php } ?> <button type="button" class="button-reset post-option"> <span class="dashicons dashicons-category"></span> <span class="post-option-title"><?php _e('Categories'); ?> </span> <span class="dashicons post-option-forward"></span> </button> <button type="button" class="button-reset post-option"> <span class="dashicons dashicons-tag"></span> <span class="post-option-title"><?php _e('Tags'); ?> </span> <span class="dashicons post-option-forward"></span> </button> </div> <?php if ($supports_formats) { ?> <div class="setting-modal is-off-screen is-hidden"> <button type="button" class="button-reset modal-close"> <span class="dashicons post-option-back"></span> <span class="setting-title" aria-hidden="true"><?php _ex('Format', 'post format'); ?> </span> <span class="screen-reader-text"><?php _e('Back to post options'); ?> </span> </button> <?php $this->post_formats_html($post); ?> </div> <?php } ?> <div class="setting-modal is-off-screen is-hidden"> <button type="button" class="button-reset modal-close"> <span class="dashicons post-option-back"></span> <span class="setting-title" aria-hidden="true"><?php _e('Categories'); ?> </span> <span class="screen-reader-text"><?php _e('Back to post options'); ?> </span> </button> <?php $this->categories_html($post); ?> </div> <div class="setting-modal tags is-off-screen is-hidden"> <button type="button" class="button-reset modal-close"> <span class="dashicons post-option-back"></span> <span class="setting-title" aria-hidden="true"><?php _e('Tags'); ?> </span> <span class="screen-reader-text"><?php _e('Back to post options'); ?> </span> </button> <?php $this->tags_html($post); ?> </div> </div><!-- .options-panel --> </div><!-- .wrapper --> <div class="press-this-actions"> <div class="pressthis-media-buttons"> <button type="button" class="insert-media button-subtle" data-editor="pressthis"> <span class="dashicons dashicons-admin-media"></span> <span class="screen-reader-text"><?php _e('Add Media'); ?> </span> </button> </div> <div class="post-actions"> <span class="spinner"> </span> <div class="split-button"> <div class="split-button-head"> <button type="button" class="publish-button split-button-primary"><?php echo current_user_can('publish_posts') ? __('Publish') : __('Submit for Review'); ?> </button><button type="button" class="split-button-toggle" aria-haspopup="true" aria-expanded="false"> <i class="dashicons dashicons-arrow-down-alt2"></i> <span class="screen-reader-text"><?php _e('More actions'); ?> </span> </button> </div> <ul class="split-button-body"> <li><button type="button" class="button-subtle draft-button split-button-option" aria-live="polite"><?php _e('Save Draft'); ?> </button></li> <li><a href="<?php echo esc_url(get_edit_post_link($post_ID)); ?> " class="edit-post-link split-button-option" target="_blank"><?php _e('Standard Editor'); ?> </a></li> <li><button type="button" class="button-subtle preview-button split-button-option"><?php _e('Preview'); ?> </button></li> </ul> </div> </div> </div> </form> <?php /** This action is documented in wp-admin/admin-footer.php */ do_action('admin_footer'); /** This action is documented in wp-admin/admin-footer.php */ do_action('admin_print_footer_scripts'); /** This action is documented in wp-admin/admin-footer.php */ do_action('admin_footer-press-this.php'); ?> </body> </html> <?php die; }
/** * Outputs the hidden row displayed when inline editing * * @since 3.1.0 */ function inline_edit() { global $mode; $screen = get_current_screen(); $post = get_default_post_to_edit($screen->post_type); $post_type_object = get_post_type_object($screen->post_type); $taxonomy_names = get_object_taxonomies($screen->post_type); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ($taxonomy_names as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); if (!$taxonomy->show_ui) { continue; } if ($taxonomy->hierarchical) { $hierarchical_taxonomies[] = $taxonomy; } else { $flat_taxonomies[] = $taxonomy; } } $m = isset($mode) && 'excerpt' == $mode ? 'excerpt' : 'list'; $can_publish = current_user_can($post_type_object->cap->publish_posts); $core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true); ?> <form method="get" action=""><table style="display: none"><tbody id="inlineedit"> <?php $hclass = count($hierarchical_taxonomies) ? 'post' : 'page'; $bulk = 0; while ($bulk < 2) { ?> <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?> " class="inline-edit-row inline-edit-row-<?php echo "{$hclass} inline-edit-{$screen->post_type} "; echo $bulk ? "bulk-edit-row bulk-edit-row-{$hclass} bulk-edit-{$screen->post_type}" : "quick-edit-row quick-edit-row-{$hclass} inline-edit-{$screen->post_type}"; ?> " style="display: none"><td colspan="<?php echo $this->get_column_count(); ?> " class="colspanchange"> <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> <h4><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?> </h4> <?php if (post_type_supports($screen->post_type, 'title')) { if ($bulk) { ?> <div id="bulk-title-div"> <div id="bulk-titles"></div> </div> <?php } else { // $bulk ?> <label> <span class="title"><?php _e('Title'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> </label> <label> <span class="title"><?php _e('Slug'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> </label> <?php } // $bulk } // post_type_supports title ?> <?php if (!$bulk) { ?> <label><span class="title"><?php _e('Date'); ?> </span></label> <div class="inline-edit-date"> <?php touch_time(1, 1, 4, 1); ?> </div> <br class="clear" /> <?php } // $bulk if (post_type_supports($screen->post_type, 'author')) { $authors_dropdown = ''; if (is_super_admin() || current_user_can($post_type_object->cap->edit_others_posts)) { $users_opt = array('hide_if_only_one_author' => false, 'who' => 'authors', 'name' => 'post_author', 'class' => 'authors', 'multi' => 1, 'echo' => 0); if ($bulk) { $users_opt['show_option_none'] = __('— No Change —'); } if ($authors = wp_dropdown_users($users_opt)) { $authors_dropdown = '<label class="inline-edit-author">'; $authors_dropdown .= '<span class="title">' . __('Author') . '</span>'; $authors_dropdown .= $authors; $authors_dropdown .= '</label>'; } } // authors ?> <?php if (!$bulk) { echo $authors_dropdown; } } // post_type_supports author if (!$bulk) { ?> <div class="inline-edit-group"> <label class="alignleft"> <span class="title"><?php _e('Password'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> </label> <em style="margin:5px 10px 0 0" class="alignleft"> <?php /* translators: Between password field and private checkbox on post quick edit interface */ echo __('–OR–'); ?> </em> <label class="alignleft inline-edit-private"> <input type="checkbox" name="keep_private" value="private" /> <span class="checkbox-title"><?php echo __('Private'); ?> </span> </label> </div> <?php } ?> </div></fieldset> <?php if (count($hierarchical_taxonomies) && !$bulk) { ?> <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <?php foreach ($hierarchical_taxonomies as $taxonomy) { ?> <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name); ?> <span class="catshow"><?php _e('[more]'); ?> </span> <span class="cathide" style="display:none;"><?php _e('[less]'); ?> </span> </span> <input type="hidden" name="<?php echo $taxonomy->name == 'category' ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?> " value="0" /> <ul class="cat-checklist <?php echo esc_attr($taxonomy->name); ?> -checklist"> <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)); ?> </ul> <?php } //$hierarchical_taxonomies as $taxonomy ?> </div></fieldset> <?php } // count( $hierarchical_taxonomies ) && !$bulk ?> <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> <?php if (post_type_supports($screen->post_type, 'author') && $bulk) { echo $authors_dropdown; } if (post_type_supports($screen->post_type, 'page-attributes')) { if ($post_type_object->hierarchical) { ?> <label> <span class="title"><?php _e('Parent'); ?> </span> <?php $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column' => 'menu_order, post_title'); if ($bulk) { $dropdown_args['show_option_no_change'] = __('— No Change —'); } $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); wp_dropdown_pages($dropdown_args); ?> </label> <?php } // hierarchical if (!$bulk) { ?> <label> <span class="title"><?php _e('Order'); ?> </span> <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?> " /></span> </label> <?php } // !$bulk if ('page' == $screen->post_type) { ?> <label> <span class="title"><?php _e('Template'); ?> </span> <select name="page_template"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <option value="default"><?php _e('Default Template'); ?> </option> <?php page_template_dropdown(); ?> </select> </label> <?php } // page post_type } // page-attributes ?> <?php if (count($flat_taxonomies) && !$bulk) { ?> <?php foreach ($flat_taxonomies as $taxonomy) { ?> <?php if (current_user_can($taxonomy->cap->assign_terms)) { ?> <label class="inline-edit-tags"> <span class="title"><?php echo esc_html($taxonomy->labels->name); ?> </span> <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name); ?> ]" class="tax_input_<?php echo esc_attr($taxonomy->name); ?> "></textarea> </label> <?php } ?> <?php } //$flat_taxonomies as $taxonomy ?> <?php } // count( $flat_taxonomies ) && !$bulk ?> <?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) { if ($bulk) { ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <span class="title"><?php _e('Comments'); ?> </span> <select name="comment_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignright"> <span class="title"><?php _e('Pings'); ?> </span> <select name="ping_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } ?> </div> <?php } else { // $bulk ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <input type="checkbox" name="comment_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Comments'); ?> </span> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignleft"> <input type="checkbox" name="ping_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Pings'); ?> </span> </label> <?php } ?> </div> <?php } // $bulk } // post_type_supports comments or pings ?> <div class="inline-edit-group"> <label class="inline-edit-status alignleft"> <span class="title"><?php _e('Status'); ?> </span> <select name="_status"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <?php if ($can_publish) { // Contributors only get "Unpublished" and "Pending Review" ?> <option value="publish"><?php _e('Published'); ?> </option> <option value="future"><?php _e('Scheduled'); ?> </option> <?php if ($bulk) { ?> <option value="private"><?php _e('Private'); ?> </option> <?php } // $bulk ?> <?php } ?> <option value="pending"><?php _e('Pending Review'); ?> </option> <option value="draft"><?php _e('Draft'); ?> </option> </select> </label> <?php if ('post' == $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) { ?> <?php if ($bulk) { ?> <label class="alignright"> <span class="title"><?php _e('Sticky'); ?> </span> <select name="sticky"> <option value="-1"><?php _e('— No Change —'); ?> </option> <option value="sticky"><?php _e('Sticky'); ?> </option> <option value="unsticky"><?php _e('Not Sticky'); ?> </option> </select> </label> <?php } else { // $bulk ?> <label class="alignleft"> <input type="checkbox" name="sticky" value="sticky" /> <span class="checkbox-title"><?php _e('Make this post sticky'); ?> </span> </label> <?php } // $bulk ?> <?php } // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?> </div> <?php if (post_type_supports($screen->post_type, 'post-formats') && current_theme_supports('post-formats')) { $post_formats = get_theme_support('post-formats'); if (isset($post_formats[0]) && is_array($post_formats[0])) { $all_post_formats = get_post_format_strings(); ?> <div class="inline-edit-group"> <label class="alignleft" for="post_format"> <span class="title"><?php _e('Post Format'); ?> </span> <select name="post_format"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } ?> <option value="0"><?php _ex('Standard', 'Post format'); ?> </option> <?php foreach ($all_post_formats as $slug => $format) { if ($slug != 'standard') { ?> <option value="<?php echo esc_attr($slug); ?> "<?php if (!in_array($slug, $post_formats[0])) { echo ' class="unsupported"'; } ?> ><?php echo esc_html($format); ?> </option> <?php } } ?> </select></label> </div> <?php } ?> <?php } // post-formats ?> </div></fieldset> <?php list($columns) = $this->get_column_info(); foreach ($columns as $column_name => $column_display_name) { if (isset($core_columns[$column_name])) { continue; } do_action($bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type); } ?> <p class="submit inline-edit-save"> <a accesskey="c" href="#inline-edit" title="<?php esc_attr_e('Cancel'); ?> " class="button-secondary cancel alignleft"><?php _e('Cancel'); ?> </a> <?php if (!$bulk) { wp_nonce_field('inlineeditnonce', '_inline_edit', false); $update_text = __('Update'); ?> <a accesskey="s" href="#inline-edit" title="<?php esc_attr_e('Update'); ?> " class="button-primary save alignright"><?php echo esc_attr($update_text); ?> </a> <img class="waiting" style="display:none;" src="<?php echo esc_url(admin_url('images/wpspin_light.gif')); ?> " alt="" /> <?php } else { submit_button(__('Update'), 'button-primary alignright', 'bulk_edit', false, array('accesskey' => 's')); } ?> <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?> " /> <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?> " /> <span class="error" style="display:none"></span> <br class="clear" /> </p> </td></tr> <?php $bulk++; } ?> </tbody></table></form> <?php }
function wp_dashboard_quick_press() { global $post_ID; $drafts = false; if ('post' === strtolower($_SERVER['REQUEST_METHOD']) && isset($_POST['action']) && 0 === strpos($_POST['action'], 'post-quickpress') && (int) $_POST['post_ID']) { $view = get_permalink($_POST['post_ID']); $edit = esc_url(get_edit_post_link($_POST['post_ID'])); if ('post-quickpress-publish' == $_POST['action']) { if (current_user_can('publish_posts')) { printf('<div class="updated"><p>' . __('Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>') . '</p></div>', esc_url($view), $edit); } else { printf('<div class="updated"><p>' . __('Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>') . '</p></div>', esc_url(add_query_arg('preview', 1, $view)), $edit); } } else { printf('<div class="updated"><p>' . __('Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>') . '</p></div>', esc_url(add_query_arg('preview', 1, $view)), $edit); $drafts_query = new WP_Query(array('post_type' => 'post', 'post_status' => 'draft', 'author' => $GLOBALS['current_user']->ID, 'posts_per_page' => 1, 'orderby' => 'modified', 'order' => 'DESC')); if ($drafts_query->posts) { $drafts =& $drafts_query->posts; } } printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url(admin_url('tools.php')) . '">' . __('Press This') . '</a>'); $_REQUEST = array(); // hack for get_default_post_to_edit() } /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ $last_post_id = (int) get_user_option('dashboard_quick_press_last_post_id'); // Get the last post_ID if ($last_post_id) { $post = get_post($last_post_id); if (empty($post) || $post->post_status != 'auto-draft') { // auto-draft doesn't exists anymore $post = get_default_post_to_edit('post', true); update_user_option((int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID } else { $post->post_title = ''; // Remove the auto draft title } } else { $post = get_default_post_to_edit('post', true); update_user_option((int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID } $post_ID = (int) $post->ID; ?> <form name="post" action="<?php echo esc_url(admin_url('post.php')); ?> " method="post" id="quick-press"> <h4 id="quick-post-title"><label for="title"><?php _e('Title'); ?> </label></h4> <div class="input-text-wrap"> <input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr($post->post_title); ?> " /> </div> <?php if (current_user_can('upload_files')) { ?> <div id="media-buttons" class="hide-if-no-js"> <?php do_action('media_buttons'); ?> </div> <?php } ?> <h4 id="content-label"><label for="content"><?php _e('Content'); ?> </label></h4> <div class="textarea-wrap"> <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo esc_textarea($post->post_content); ?> </textarea> </div> <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script> <h4><label for="tags-input"><?php _e('Tags'); ?> </label></h4> <div class="input-text-wrap"> <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit($post->ID); ?> " /> </div> <p class="submit"> <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" /> <input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?> " /> <input type="hidden" name="post_type" value="post" /> <?php wp_nonce_field('add-post'); ?> <?php submit_button(__('Save Draft'), 'button', 'save', false, array('id' => 'save-post', 'tabindex' => 4)); ?> <input type="reset" value="<?php esc_attr_e('Reset'); ?> " class="button" /> <span id="publishing-action"> <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?> " /> <img class="waiting" src="<?php echo esc_url(admin_url('images/wpspin_light.gif')); ?> " alt="" /> </span> <br class="clear" /> </p> </form> <?php if ($drafts) { wp_dashboard_recent_drafts($drafts); } }
/** * The Quick Draft widget display and creation of drafts. * * @since 3.8.0 * * @global int $post_ID * * @param string $error_msg Optional. Error message. Default false. */ function wp_dashboard_quick_press($error_msg = false) { global $post_ID; if (!current_user_can('edit_posts')) { return; } /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ $last_post_id = (int) get_user_option('dashboard_quick_press_last_post_id'); // Get the last post_ID if ($last_post_id) { $post = get_post($last_post_id); if (empty($post) || $post->post_status != 'auto-draft') { // auto-draft doesn't exists anymore $post = get_default_post_to_edit('post', true); update_user_option(get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID } else { $post->post_title = ''; // Remove the auto draft title } } else { $post = get_default_post_to_edit('post', true); $user_id = get_current_user_id(); // Don't create an option if this is a super admin who does not belong to this site. if (!(is_super_admin($user_id) && !in_array(get_current_blog_id(), array_keys(get_blogs_of_user($user_id))))) { update_user_option($user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID); } // Save post_ID } $post_ID = (int) $post->ID; ?> <form name="post" action="<?php echo esc_url(admin_url('post.php')); ?> " method="post" id="quick-press" class="initial-form hide-if-no-js"> <?php if ($error_msg) { ?> <div class="error"><?php echo $error_msg; ?> </div> <?php } ?> <div class="input-text-wrap" id="title-wrap"> <label class="screen-reader-text prompt" for="title" id="title-prompt-text"> <?php /** This filter is documented in wp-admin/edit-form-advanced.php */ echo apply_filters('enter_title_here', __('Title'), $post); ?> </label> <input type="text" name="post_title" id="title" autocomplete="off" /> </div> <div class="textarea-wrap" id="description-wrap"> <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e('What’s on your mind?'); ?> </label> <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea> </div> <p class="submit"> <input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" /> <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?> " /> <input type="hidden" name="post_type" value="post" /> <?php wp_nonce_field('add-post'); ?> <?php submit_button(__('Save Draft'), 'primary', 'save', false, array('id' => 'save-post')); ?> <br class="clear" /> </p> </form> <?php wp_dashboard_recent_drafts(); }
/** * {@internal Missing Short Description}} * * Outputs the quick edit and bulk edit table rows for posts and pages * * @since 2.7 * * @param string $type 'post' or 'page' */ function inline_edit_row( $type ) { global $current_user, $mode; $is_page = 'page' == $type; if ( $is_page ) { $screen = 'edit-pages'; $post = get_default_page_to_edit(); } else { $screen = 'edit'; $post = get_default_post_to_edit(); } $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns(); $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) ); $col_count = count($columns) - count($hidden); $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; $can_publish = current_user_can("publish_{$type}s"); $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); ?> <form method="get" action=""><table style="display: none"><tbody id="inlineedit"> <?php $bulk = 0; while ( $bulk < 2 ) { ?> <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type "; echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type"; ?>" style="display: none"><td colspan="<?php echo $col_count; ?>"> <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4> <?php if ( $bulk ) : ?> <div id="bulk-title-div"> <div id="bulk-titles"></div> </div> <?php else : // $bulk ?> <label> <span class="title"><?php _e( 'Title' ); ?></span> <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> </label> <?php endif; // $bulk ?> <?php if ( !$bulk ) : ?> <label> <span class="title"><?php _e( 'Slug' ); ?></span> <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> </label> <label><span class="title"><?php _e( 'Date' ); ?></span></label> <div class="inline-edit-date"> <?php touch_time(1, 1, 4, 1); ?> </div> <br class="clear" /> <?php endif; // $bulk ob_start(); $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM if ( $authors && count( $authors ) > 1 ) : $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1); if ( $bulk ) $users_opt['show_option_none'] = __('- No Change -'); ?> <label> <span class="title"><?php _e( 'Author' ); ?></span> <?php wp_dropdown_users( $users_opt ); ?> </label> <?php endif; // authors $authors_dropdown = ob_get_clean(); ?> <?php if ( !$bulk ) : echo $authors_dropdown; ?> <div class="inline-edit-group"> <label class="alignleft"> <span class="title"><?php _e( 'Password' ); ?></span> <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> </label> <em style="margin:5px 10px 0 0" class="alignleft"><?php echo _c( '–OR–|Between password field and private checkbox on post quick edit interface' ); ?></em> <label class="alignleft inline-edit-private"> <input type="checkbox" name="keep_private" value="private" /> <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span> </label> </div> <?php endif; ?> </div></fieldset> <?php if ( !$is_page && !$bulk ) : ?> <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?> <span class="catshow"><?php _e('[more]'); ?></span> <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span> </span> <ul class="cat-checklist"> <?php wp_category_checklist(); ?> </ul> </div></fieldset> <?php endif; // !$is_page && !$bulk ?> <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> <?php if ( $bulk ) echo $authors_dropdown; ?> <?php if ( $is_page ) : ?> <label> <span class="title"><?php _e( 'Parent' ); ?></span> <?php $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title'); if ( $bulk ) $dropdown_args['show_option_no_change'] = __('- No Change -'); $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); wp_dropdown_pages($dropdown_args); ?> </label> <?php if ( !$bulk ) : ?> <label> <span class="title"><?php _e( 'Order' ); ?></span> <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span> </label> <?php endif; // !$bulk ?> <label> <span class="title"><?php _e( 'Template' ); ?></span> <select name="page_template"> <?php if ( $bulk ) : ?> <option value="-1"><?php _e('- No Change -'); ?></option> <?php endif; // $bulk ?> <option value="default"><?php _e( 'Default Template' ); ?></option> <?php page_template_dropdown() ?> </select> </label> <?php elseif ( !$bulk ) : // $is_page ?> <label class="inline-edit-tags"> <span class="title"><?php _e( 'Tags' ); ?></span> <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea> </label> <?php endif; // $is_page ?> <?php if ( $bulk ) : ?> <div class="inline-edit-group"> <label class="alignleft"> <span class="title"><?php _e( 'Comments' ); ?></span> <select name="comment_status"> <option value=""><?php _e('- No Change -'); ?></option> <option value="open"><?php _e('Allow'); ?></option> <option value="closed"><?php _e('Do not allow'); ?></option> </select> </label> <label class="alignright"> <span class="title"><?php _e( 'Pings' ); ?></span> <select name="ping_status"> <option value=""><?php _e('- No Change -'); ?></option> <option value="open"><?php _e('Allow'); ?></option> <option value="closed"><?php _e('Do not allow'); ?></option> </select> </label> </div> <?php else : // $bulk ?> <div class="inline-edit-group"> <label class="alignleft"> <input type="checkbox" name="comment_status" value="open" /> <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> </label> <label class="alignleft"> <input type="checkbox" name="ping_status" value="open" /> <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> </label> </div> <?php endif; // $bulk ?> <div class="inline-edit-group"> <label class="inline-edit-status alignleft"> <span class="title"><?php _e( 'Status' ); ?></span> <select name="_status"> <?php if ( $bulk ) : ?> <option value="-1"><?php _e('- No Change -'); ?></option> <?php endif; // $bulk ?> <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?> <option value="publish"><?php _e( 'Published' ); ?></option> <option value="future"><?php _e( 'Scheduled' ); ?></option> <?php if ( $bulk ) : ?> <option value="private"><?php _e('Private') ?></option> <?php endif; // $bulk ?> <?php endif; ?> <option value="pending"><?php _e( 'Pending Review' ); ?></option> <option value="draft"><?php _e( 'Unpublished' ); ?></option> </select> </label> <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?> <?php if ( $bulk ) : ?> <label class="alignright"> <span class="title"><?php _e( 'Sticky' ); ?></span> <select name="sticky"> <option value="-1"><?php _e( '- No Change -' ); ?></option> <option value="sticky"><?php _e( 'Sticky' ); ?></option> <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> </select> </label> <?php else : // $bulk ?> <label class="alignleft"> <input type="checkbox" name="sticky" value="sticky" /> <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> </label> <?php endif; // $bulk ?> <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?> </div> </div></fieldset> <?php foreach ( $columns as $column_name => $column_display_name ) { if ( isset( $core_columns[$column_name] ) ) continue; do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type); } ?> <p class="submit inline-edit-save"> <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a> <?php if ( ! $bulk ) { wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' ); ?> <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo attribute_escape( $update_text ); ?></a> <img class="waiting" style="display:none;" src="images/loading.gif" alt="" /> <?php } else { $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' ); ?> <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo attribute_escape( $update_text ); ?>" /> <?php } ?> <input type="hidden" name="post_view" value="<?php echo $m; ?>" /> <br class="clear" /> </p> </td></tr> <?php $bulk++; } ?> </tbody></table></form> <?php }
$submenu_file = "post-new.php?post_type={$post_type}"; } else { $parent_file = 'edit.php'; $submenu_file = 'post-new.php'; } $post_type_object = get_post_type_object($post_type); $title = $post_type_object->labels->add_new_item; $editing = true; if ('post' == $post_type && !current_user_can('edit_posts')) { include './admin-header.php'; ?> <div class="wrap"> <p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br /> You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br /> When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_option('admin_email')); ?> </p> </div> <?php include './admin-footer.php'; exit; } wp_enqueue_script('autosave'); // Show post form. if (current_user_can($post_type_object->cap->edit_posts)) { $post = get_default_post_to_edit($post_type, true); $post_ID = $post->ID; include 'edit-form-advanced.php'; } include './admin-footer.php';
/** * Serves the app's base HTML, which in turns calls the load.js * * @since 4.2 */ public function serve_app_html() { global $wp_locale; // Get data, new (POST) and old (GET) $data = $this->merge_or_fetch_data(); // Get site settings array/data $site_settings = $this->site_settings(); // Set the passed data $data['_version'] = $site_settings['version']; $data['_runtime_url'] = $site_settings['runtime_url']; $data['_ajax_url'] = $site_settings['ajax_url']; // Plugin only wp_register_script('press-this-app', plugin_dir_url(__FILE__) . 'js/app.js', array('jquery'), false, true); wp_localize_script('press-this-app', 'pressThisL10n', $this->i18n()); wp_register_style('press-this-css', plugin_dir_url(__FILE__) . 'css/press-this.css'); // TEMP: for tags handling –– @TODO: evaluate wp_register_script('tag-box', plugin_dir_url(__FILE__) . 'js/tag-box.js', array('suggest'), false, true); // Add press-this-editor.css and remove theme's editor-style.css, if any. remove_editor_styles(); add_filter('mce_css', array($this, 'editor_styles_override')); $hook_suffix = 'press-this.php'; /** * @TODO: this is a temp fix to an arcane issue while we're a plugin. * See https://github.com/MichaelArestad/Press-This/issues/51 * Will become irrelevant when/if we merge into core. */ if (function_exists('set_current_screen')) { set_current_screen($hook_suffix); } if (!empty($GLOBALS['is_IE'])) { @header('X-UA-Compatible: IE=edge'); } @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); ?> <!DOCTYPE html> <!--[if IE 7]> <html class="lt-ie9 lt-ie8" <?php language_attributes(); ?> > <![endif]--> <!--[if IE 8]> <html class="lt-ie9" <?php language_attributes(); ?> > <![endif]--> <!--[if gt IE 8]><!--> <html <?php language_attributes(); ?> > <!--<![endif]--> <head> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?> ; charset=<?php echo get_option('blog_charset'); ?> " /> <meta name="viewport" content="width=device-width"> <title><?php echo esc_html(__('Press This!')); ?> </title> <script> window.wpPressThisData = <?php echo json_encode($data); ?> ; window.wpPressThisConfig = <?php echo json_encode($site_settings); ?> ; </script> <script type="text/javascript"> var ajaxurl = '<?php echo admin_url('admin-ajax.php', 'relative'); ?> ', pagenow = 'press-this', typenow = 'post', adminpage = 'press-this-php', thousandsSeparator = '<?php echo addslashes($wp_locale->number_format['thousands_sep']); ?> ', decimalPoint = '<?php echo addslashes($wp_locale->number_format['decimal_point']); ?> ', isRtl = <?php echo (int) is_rtl(); ?> ; </script> <?php // $post->ID is needed for the embed shortcode so we can show oEmbed previews in the editor. Maybe find a way without it. $post = get_default_post_to_edit('post', true); $post_ID = (int) $post->ID; wp_enqueue_style('press-this-css'); wp_enqueue_script('press-this-app'); wp_enqueue_script('json2'); wp_enqueue_media(array('post' => $post->ID)); wp_enqueue_script('editor'); // TEMP: for tags handling –– @TODO: evaluate wp_enqueue_script('tag-box'); $supports_formats = false; $post_format = 0; if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats')) { $supports_formats = true; if (!($post_format = get_post_format($post->ID))) { $post_format = 0; } } /** This action is documented in wp-admin/admin-header.php */ do_action('admin_enqueue_scripts', $hook_suffix); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_print_styles'); /** This action is documented in wp-admin/admin-header.php */ do_action('admin_print_scripts'); ?> </head> <body> <div id="adminbar" class="adminbar"> <h1 id="current-site" class="current-site"> <span class="dashicons dashicons-wordpress"></span> <span><?php bloginfo('name'); ?> </span> </h1> <button type="button" class="options-open button-subtle"><span class="dashicons dashicons-tag"></span><span class="screen-reader-text"><?php _e('Show post options'); ?> </span></button> <button type="button" class="options-close button-subtle is-hidden"><?php _e('Done'); ?> </button> </div> <div id="scanbar" class="scan"> <form method="GET"> <input type="url" name="u" id="url-scan" class="scan-url" value="" placeholder="<?php echo esc_attr(__('Enter a URL to scan')); ?> " /> <input type="submit" name="url-scan-submit" id="url-scan-submit" class="scan-submit" value="<?php echo esc_attr(__('Scan')); ?> " /> </form> </div> <form id="pressthis-form" name="pressthis-form" method="POST" autocomplete="off"> <input type="hidden" name="post_ID" id="post_ID" value="<?php echo $post_ID; ?> " /> <?php wp_nonce_field('press-this', 'pressthis-nonce', false); ?> <?php wp_nonce_field('add-category', '_ajax_nonce-add-category', false); ?> <input type="hidden" name="title" id="title-field" value="" /> <div class="wrapper"> <div class="editor-wrapper"> <div class="alerts"> <p class="alert is-notice is-hidden should-upgrade-bookmarklet"> <?php printf(__('You should upgrade <a href="%s" target="_blank">your bookmarklet</a> to the latest version!'), admin_url('tools.php?page=press_this_options')); ?> </p> </div> <div id='app-container' class="editor"> <span id="title-container-label" class="post-title-placeholder" aria-hidden="true"><?php _e('Post title'); ?> </span> <h2 id="title-container" class="post-title" contenteditable="true" spellcheck="true" aria-label="<?php _e('Post title'); ?> " tabindex="0"></h2> <div id='featured-media-container' class="featured-container no-media"> <div id='all-media-widget' class="all-media"> <div id='all-media-container'></div> </div> </div> <?php wp_editor('', 'pressthis', array('drag_drop_upload' => true, 'editor_height' => 600, 'media_buttons' => false, 'teeny' => true, 'tinymce' => array('resize' => false, 'wordpress_adv_hidden' => false, 'add_unload_trigger' => false, 'statusbar' => false, 'autoresize_min_height' => 600, 'wp_autoresize_on' => true, 'plugins' => 'lists,media,paste,tabfocus,fullscreen,wordpress,wpautoresize,wpeditimage,wpgallery,wplink,wpview', 'toolbar1' => 'bold,italic,bullist,numlist,blockquote,link,unlink', 'toolbar2' => 'undo,redo'), 'quicktags' => false)); ?> </div> </div> <div class="options-panel is-off-screen is-hidden"> <div class="post-options"> <?php if ($supports_formats) { ?> <button type="button" class="button-reset post-option"> <span class="dashicons dashicons-admin-post"></span> <span class="post-option-title"><?php _e('Format'); ?> </span> <span class="post-option-contents" id="post-option-post-format"><?php echo esc_html(get_post_format_string($post_format)); ?> </span> <span class="dashicons dashicons-arrow-right-alt2"></span> </button> <?php } ?> <button type="button" class="button-reset post-option"> <span class="dashicons dashicons-category"></span> <span class="post-option-title"><?php _e('Categories'); ?> </span> <span class="post-option-contents" id="post-option-category"></span> <span class="dashicons dashicons-arrow-right-alt2"></span> </button> <button type="button" class="button-reset post-option"> <span class="dashicons dashicons-tag"></span> <span class="post-option-title"><?php _e('Tags'); ?> </span> <span class="post-option-contents" id="post-option-tags"></span> <span class="dashicons dashicons-arrow-right-alt2"></span> </button> </div> <?php if ($supports_formats) { ?> <div class="setting-modal is-off-screen is-hidden"> <button type="button" class="button-reset modal-close"><span class="dashicons dashicons-arrow-left-alt2"></span><span class="setting-title"><?php _e('Post format'); ?> </span></button> <?php $this->post_formats_html($post); ?> </div> <?php } ?> <div class="setting-modal is-off-screen is-hidden"> <button type="button" class="button-reset modal-close"><span class="dashicons dashicons-arrow-left-alt2"></span><span class="setting-title"><?php _e('Categories'); ?> </span></button> <?php $this->categories_html($post); ?> </div> <div class="setting-modal tags is-off-screen is-hidden"> <button type="button" class="button-reset modal-close"><span class="dashicons dashicons-arrow-left-alt2"></span><span class="setting-title"><?php _e('Tags'); ?> </span></button> <?php $this->tags_html($post); ?> </div> </div><!-- .options-panel --> </div><!-- .wrapper --> <div class="press-this-actions"> <div class="pressthis-media-buttons"> <button type="button" class="insert-media button-subtle" data-editor="pressthis"> <span class="dashicons dashicons-admin-media"></span> <span class="screen-reader-text"><?php _e('Add Media'); ?> </span> </button> </div> <div class="post-actions"> <button type="button" class="button-subtle" id="draft-field"><?php _e('Save Draft'); ?> </button> <button type="button" class="button-primary" id="publish-field"><?php _e('Publish'); ?> </button> </div> </div> </form> <?php // TODO: consider running "special" press-this hooks here? // Maybe better so we don't output stuff accidentaly added by plugins. Would probably prevent some errors. do_action('admin_footer', ''); do_action('admin_print_footer_scripts'); ?> </body> </html> <?php die; }
/** * Create a new post. * * The 'content_struct' argument must contain: * - title * - description * - mt_excerpt * - mt_text_more * - mt_keywords * - mt_tb_ping_urls * - categories * * Also, it can optionally contain: * - wp_slug * - wp_password * - wp_page_parent_id * - wp_page_order * - wp_author_id * - post_status | page_status - can be 'draft', 'private', 'publish', or 'pending' * - mt_allow_comments - can be 'open' or 'closed' * - mt_allow_pings - can be 'open' or 'closed' * - date_created_gmt * - dateCreated * - wp_post_thumbnail * * @since 1.5.0 * * @param array $args Method parameters. Contains: * - blog_id (unused) * - username * - password * - content_struct * - publish * @return int|IXR_Error */ public function mw_newPost($args) { $this->escape($args); $username = $args[1]; $password = $args[2]; $content_struct = $args[3]; $publish = isset($args[4]) ? $args[4] : 0; if (!($user = $this->login($username, $password))) { return $this->error; } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action('xmlrpc_call', 'metaWeblog.newPost'); $page_template = ''; if (!empty($content_struct['post_type'])) { if ($content_struct['post_type'] == 'page') { if ($publish) { $cap = 'publish_pages'; } elseif (isset($content_struct['page_status']) && 'publish' == $content_struct['page_status']) { $cap = 'publish_pages'; } else { $cap = 'edit_pages'; } $error_message = __('Sorry, you are not allowed to publish pages on this site.'); $post_type = 'page'; if (!empty($content_struct['wp_page_template'])) { $page_template = $content_struct['wp_page_template']; } } elseif ($content_struct['post_type'] == 'post') { if ($publish) { $cap = 'publish_posts'; } elseif (isset($content_struct['post_status']) && 'publish' == $content_struct['post_status']) { $cap = 'publish_posts'; } else { $cap = 'edit_posts'; } $error_message = __('Sorry, you are not allowed to publish posts on this site.'); $post_type = 'post'; } else { // No other post_type values are allowed here return new IXR_Error(401, __('Invalid post type')); } } else { if ($publish) { $cap = 'publish_posts'; } elseif (isset($content_struct['post_status']) && 'publish' == $content_struct['post_status']) { $cap = 'publish_posts'; } else { $cap = 'edit_posts'; } $error_message = __('Sorry, you are not allowed to publish posts on this site.'); $post_type = 'post'; } if (!current_user_can(get_post_type_object($post_type)->cap->create_posts)) { return new IXR_Error(401, __('Sorry, you are not allowed to publish posts on this site.')); } if (!current_user_can($cap)) { return new IXR_Error(401, $error_message); } // Check for a valid post format if one was given if (isset($content_struct['wp_post_format'])) { $content_struct['wp_post_format'] = sanitize_key($content_struct['wp_post_format']); if (!array_key_exists($content_struct['wp_post_format'], get_post_format_strings())) { return new IXR_Error(404, __('Invalid post format')); } } // Let WordPress generate the post_name (slug) unless // one has been provided. $post_name = ""; if (isset($content_struct['wp_slug'])) { $post_name = $content_struct['wp_slug']; } // Only use a password if one was given. if (isset($content_struct['wp_password'])) { $post_password = $content_struct['wp_password']; } // Only set a post parent if one was provided. if (isset($content_struct['wp_page_parent_id'])) { $post_parent = $content_struct['wp_page_parent_id']; } // Only set the menu_order if it was provided. if (isset($content_struct['wp_page_order'])) { $menu_order = $content_struct['wp_page_order']; } $post_author = $user->ID; // If an author id was provided then use it instead. if (isset($content_struct['wp_author_id']) && $user->ID != $content_struct['wp_author_id']) { switch ($post_type) { case "post": if (!current_user_can('edit_others_posts')) { return new IXR_Error(401, __('You are not allowed to create posts as this user.')); } break; case "page": if (!current_user_can('edit_others_pages')) { return new IXR_Error(401, __('You are not allowed to create pages as this user.')); } break; default: return new IXR_Error(401, __('Invalid post type')); break; } $author = get_userdata($content_struct['wp_author_id']); if (!$author) { return new IXR_Error(404, __('Invalid author ID.')); } $post_author = $content_struct['wp_author_id']; } $post_title = isset($content_struct['title']) ? $content_struct['title'] : null; $post_content = isset($content_struct['description']) ? $content_struct['description'] : null; $post_status = $publish ? 'publish' : 'draft'; if (isset($content_struct["{$post_type}_status"])) { switch ($content_struct["{$post_type}_status"]) { case 'draft': case 'pending': case 'private': case 'publish': $post_status = $content_struct["{$post_type}_status"]; break; default: $post_status = $publish ? 'publish' : 'draft'; break; } } $post_excerpt = isset($content_struct['mt_excerpt']) ? $content_struct['mt_excerpt'] : null; $post_more = isset($content_struct['mt_text_more']) ? $content_struct['mt_text_more'] : null; $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null; if (isset($content_struct['mt_allow_comments'])) { if (!is_numeric($content_struct['mt_allow_comments'])) { switch ($content_struct['mt_allow_comments']) { case 'closed': $comment_status = 'closed'; break; case 'open': $comment_status = 'open'; break; default: $comment_status = get_option('default_comment_status'); break; } } else { switch ((int) $content_struct['mt_allow_comments']) { case 0: case 2: $comment_status = 'closed'; break; case 1: $comment_status = 'open'; break; default: $comment_status = get_option('default_comment_status'); break; } } } else { $comment_status = get_option('default_comment_status'); } if (isset($content_struct['mt_allow_pings'])) { if (!is_numeric($content_struct['mt_allow_pings'])) { switch ($content_struct['mt_allow_pings']) { case 'closed': $ping_status = 'closed'; break; case 'open': $ping_status = 'open'; break; default: $ping_status = get_option('default_ping_status'); break; } } else { switch ((int) $content_struct['mt_allow_pings']) { case 0: $ping_status = 'closed'; break; case 1: $ping_status = 'open'; break; default: $ping_status = get_option('default_ping_status'); break; } } } else { $ping_status = get_option('default_ping_status'); } if ($post_more) { $post_content = $post_content . '<!--more-->' . $post_more; } $to_ping = null; if (isset($content_struct['mt_tb_ping_urls'])) { $to_ping = $content_struct['mt_tb_ping_urls']; if (is_array($to_ping)) { $to_ping = implode(' ', $to_ping); } } // Do some timestamp voodoo if (!empty($content_struct['date_created_gmt'])) { // We know this is supposed to be GMT, so we're going to slap that Z on there by force $dateCreated = rtrim($content_struct['date_created_gmt']->getIso(), 'Z') . 'Z'; } elseif (!empty($content_struct['dateCreated'])) { $dateCreated = $content_struct['dateCreated']->getIso(); } if (!empty($dateCreated)) { $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT'); } else { $post_date = current_time('mysql'); $post_date_gmt = current_time('mysql', 1); } $post_category = array(); if (isset($content_struct['categories'])) { $catnames = $content_struct['categories']; if (is_array($catnames)) { foreach ($catnames as $cat) { $post_category[] = get_cat_ID($cat); } } } $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template'); $post_ID = $postdata['ID'] = get_default_post_to_edit($post_type, true)->ID; // Only posts can be sticky if ($post_type == 'post' && isset($content_struct['sticky'])) { if ($content_struct['sticky'] == true) { stick_post($post_ID); } elseif ($content_struct['sticky'] == false) { unstick_post($post_ID); } } if (isset($content_struct['custom_fields'])) { $this->set_custom_fields($post_ID, $content_struct['custom_fields']); } if (isset($content_struct['wp_post_thumbnail'])) { if (set_post_thumbnail($post_ID, $content_struct['wp_post_thumbnail']) === false) { return new IXR_Error(404, __('Invalid attachment ID.')); } unset($content_struct['wp_post_thumbnail']); } // Handle enclosures $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null; $this->add_enclosure_if_new($post_ID, $thisEnclosure); $this->attach_uploads($post_ID, $post_content); // Handle post formats if assigned, value is validated earlier // in this function if (isset($content_struct['wp_post_format'])) { set_post_format($post_ID, $content_struct['wp_post_format']); } $post_ID = wp_insert_post($postdata, true); if (is_wp_error($post_ID)) { return new IXR_Error(500, $post_ID->get_error_message()); } if (!$post_ID) { return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); } /** * Fires after a new post has been successfully created via the XML-RPC MovableType API. * * @since 3.4.0 * * @param int $post_ID ID of the new post. * @param array $args An array of arguments to create the new post. */ do_action('xmlrpc_call_success_mw_newPost', $post_ID, $args); return strval($post_ID); }
function wp_dashboard_quick_press() { $drafts = false; if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) { $view = get_permalink( $_POST['post_ID'] ); $edit = clean_url( get_edit_post_link( $_POST['post_ID'] ) ); if ( 'post-quickpress-publish' == $_POST['action'] ) { if ( current_user_can('publish_posts') ) printf( '<div class="message"><p>' . __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( $view ), $edit ); else printf( '<div class="message"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit ); } else { printf( '<div class="message"><p>' . __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', clean_url( add_query_arg( 'preview', 1, $view ) ), $edit ); $drafts_query = new WP_Query( array( 'post_type' => 'post', 'what_to_show' => 'posts', 'post_status' => 'draft', 'author' => $GLOBALS['current_user']->ID, 'posts_per_page' => 1, 'orderby' => 'modified', 'order' => 'DESC' ) ); if ( $drafts_query->posts ) $drafts =& $drafts_query->posts; } printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="tools.php">' . __('Press This') . '</a>' ); $_REQUEST = array(); // hack for get_default_post_to_edit() } $post = get_default_post_to_edit(); ?> <form name="post" action="<?php echo clean_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press"> <h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4> <div class="input-text-wrap"> <input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo attribute_escape( $post->post_title ); ?>" /> </div> <?php if ( current_user_can( 'upload_files' ) ) : ?> <div id="media-buttons" class="hide-if-no-js"> <?php do_action( 'media_buttons' ); ?> </div> <?php endif; ?> <h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4> <div class="textarea-wrap"> <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo $post->post_content; ?></textarea> </div> <script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script> <h4><label for="tags-input"><?php _e('Tags') ?></label></h4> <div class="input-text-wrap"> <input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /> </div> <p class="submit"> <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" /> <input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" /> <?php wp_nonce_field('add-post'); ?> <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php _e('Save Draft'); ?>" /> <input type="reset" value="<?php _e( 'Cancel' ); ?>" class="cancel" /> <?php if ( current_user_can('publish_posts') ) { ?> <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php _e('Publish'); ?>" /> <?php } else { ?> <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php _e('Submit for Review'); ?>" /> <?php } ?> <br class="clear" /> </p> </form> <?php if ( $drafts ) wp_dashboard_recent_drafts( $drafts ); }
/** * Get the default page information to use. * * @since 2.5.0 * @deprecated 3.5.0 * @deprecated Use get_default_post_to_edit() * * @return WP_Post Post object containing all the default post data as attributes */ function get_default_page_to_edit() { _deprecated_function(__FUNCTION__, '3.5', "get_default_post_to_edit( 'page' )"); $page = get_default_post_to_edit(); $page->post_type = 'page'; return $page; }
/** * Loads the correct fields for the selected actions under Profile > Actions. * * @since 1.0.0 * @param $data str. The type of action being requested. * @return html. The fields. */ function bbconnect_get_post_to_edit() { if (!wp_verify_nonce($_POST['bbconnect_admin_nonce'], 'bbconnect-admin-nonce')) { die(__('Terribly sorry.', 'bbconnect')); } if (isset($_POST['data'])) { $cid = $_POST['cid']; $type = $_POST['type']; $post_val = array(); global $post; // WE'RE EDITING AN EXISTING FILE if (false !== strpos($_POST['data'], 'edit-')) { $post_id = (int) substr($_POST['data'], 5); $post = get_post($post_id); $post_author = $post->post_author; $post_type = $post->post_type; $action = 'edit'; if ($post_type == 'bb_note') { $note_types = wp_get_post_terms($post_id, 'bb_note_type'); foreach ($note_types as $note_type) { if ($note_type->parent == 0) { $parent_term = $note_type; } else { $child_term = $note_type; } } } } else { if ('user' == $type) { $bbconnect_actions = bbconnect_get_user_actions(); $post_type = 'bb_note'; if (empty($_POST['data'])) { echo ''; die; } } else { $bbconnect_actions = bbconnect_get_post_actions(); $post_type = false; $post_type = $_POST['data']; if (false == $post_type) { echo ''; die; } } $post = get_default_post_to_edit($post_type, true); $post_author = $_POST['uid']; $action = $_POST['actung']; } // SET THE NONCE if ('user' == $type) { bbconnect_user_actions_nonce_field(); } else { bbconnect_post_actions_nonce_field(); } $post_fields = array(array('meta' => array('source' => 'wpr', 'meta_key' => 'post_title', 'name' => __('Title', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'text', 'req' => true, 'public' => false, 'choices' => false))), array('meta' => array('source' => 'wpr', 'meta_key' => 'post_date', 'name' => __('Date', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'date', 'req' => true, 'public' => false, 'choices' => false)))); if ('user' == $type) { if (!empty($parent_term)) { // Editing existing note $post_fields[] = array('post_val' => $parent_term->slug, 'meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type_parent', 'name' => __('Type', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => true, 'public' => true, 'choices' => array($parent_term->slug => $parent_term->name)))); $post_fields[] = array('post_val' => $child_term->slug, 'meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type', 'name' => __('', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => false, 'public' => true, 'choices' => array($child_term->slug => $child_term->name)))); } else { // New note $parent_term = get_term_by('slug', $_POST['data'], 'bb_note_type'); $terms = get_terms('bb_note_type', array('hide_empty' => false, 'parent' => $parent_term->term_id)); $choices = array(); foreach ($terms as $term) { $choices[$term->slug] = $term->name; } $post_fields[] = array('meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type', 'name' => __('Type', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => true, 'public' => false, 'choices' => $choices))); $post_fields[] = array('meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type_parent', 'name' => __('', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'hidden', 'req' => false, 'public' => false, 'choices' => $parent_term->slug))); } } foreach ($post_fields as $field) { $meta_key = $field['meta']['meta_key']; $field['type'] = 'post'; $field['action'] = $action; $field['id'] = $post->ID; $field['swap_name'] = $meta_key; if (isset($post->{$meta_key})) { $field['post_val'] = $post->{$meta_key}; } echo '<p><ul style="display: block; float: none;">'; bbconnect_get_field($field); echo '</ul></p>'; } if ('bulk-edit' == $action) { echo '<ul><li class="meta-item"><span class="bbconnect-label">'; echo '<a class="rui off" title="' . $cid . 'bulk-edit">Enable Text</a>'; echo '</span><span class="bbconnect-field">'; } echo '<div style="width: 90%;padding: .3em;margin: .2em 0;"> </div>'; //echo '<p>'. __( 'Title', 'bbconnect' ) .'<br /><input type="text" name="post_title" class="regular-text" value="'.$post->post_title.'" /></p>'; //echo '<p>'. __( 'Date', 'bbconnect' ) .'<br /><input type="text" class="bbconnect-date" name="post_date" class="regular-text" value="'.$post->post_date.'" /></p>'; if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) { wp_editor(stripslashes($post->post_content), $cid, array('tinymce' => false, 'textarea_name' => 'post_content', 'teeny' => true, 'quicktags' => true)); } else { wp_editor(stripslashes($post->post_content), $cid, array('tinymce' => true, 'textarea_name' => 'post_content', 'teeny' => false, 'quicktags' => true)); } if ('bulk-edit' == $action) { echo '</span></li></ul>'; } // SET THE META if ('user' == $type) { bbconnect_user_actions_meta_fields(array('post_id' => $post->ID, 'fields' => bbconnect_get_user_actions_meta(), 'action' => $action, 'post_val' => $post_val)); } else { bbconnect_post_actions_meta_fields(array('post_id' => $post->ID, 'fields' => bbconnect_get_post_actions_meta(), 'action' => $action, 'post_val' => $post_val)); } ?> <input type="hidden" name="post_ID" value="<?php echo $post->ID; ?> " /> <input type="hidden" name="post_status" value="publish" /> <input type="hidden" name="post_author" value="<?php echo $post_author; ?> " /> <input type="hidden" name="post_type" value="<?php echo $post_type; ?> " /> <?php $inline_button = apply_filters('bbconnect_inline_do_action_button', array('<input type="submit" class="bbconnect-actions-save button-primary ' . $type . '" name="save" value="' . __('Save', 'bbconnect') . '" />'), $post_type, $type, $action); echo '<div class="tright">'; echo implode(' ', $inline_button); echo '</div>'; } else { echo 'error'; } if ('3.9' <= get_bloginfo('version')) { _WP_Editors::enqueue_scripts(); //print_footer_scripts(); _WP_Editors::editor_js(); echo '<script src="' . admin_url('js/editor.js') . '" />'; } die; }