当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_set_post_lock函数代码示例

本文整理汇总了PHP中wp_set_post_lock函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_set_post_lock函数的具体用法?PHP wp_set_post_lock怎么用?PHP wp_set_post_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_set_post_lock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: lock_post

 /**
  * @param $post_id
  */
 public function lock_post($post_id)
 {
     if (!function_exists('wp_set_post_lock')) {
         require_once ABSPATH . 'wp-admin/includes/post.php';
     }
     wp_set_post_lock($post_id);
 }
开发者ID:pojome,项目名称:elementor,代码行数:10,代码来源:editor.php

示例2: test_autosave_locked_post

 /**
  * Test autosaving a locked post
  * @return void
  */
 public function test_autosave_locked_post()
 {
     // Lock the post to another user
     $another_user_id = $this->factory->user->create(array('role' => 'editor'));
     wp_set_current_user($another_user_id);
     wp_set_post_lock($this->_post->ID);
     wp_set_current_user($this->user_id);
     // Ensure post is locked
     $this->assertEquals($another_user_id, wp_check_post_lock($this->_post->ID));
     // Set up the $_POST request
     $md5 = md5(uniqid());
     $_POST = array('action' => 'heartbeat', '_nonce' => wp_create_nonce('heartbeat-nonce'), 'data' => array('wp_autosave' => array('post_id' => $this->_post->ID, '_wpnonce' => wp_create_nonce('update-post_' . $this->_post->ID), 'post_content' => $this->_post->post_content . PHP_EOL . $md5, 'post_type' => 'post')));
     // Make the request
     try {
         $this->_handleAjax('heartbeat');
     } catch (WPAjaxDieContinueException $e) {
         unset($e);
     }
     $response = json_decode($this->_last_response, true);
     // Ensure everything is correct
     $this->assertNotEmpty($response['wp_autosave']);
     $this->assertTrue($response['wp_autosave']['success']);
     // Check that the original post was NOT edited
     $post = get_post($this->_post->ID);
     $this->assertFalse(strpos($post->post_content, $md5));
     // Check if the autosave post was created
     $autosave = wp_get_post_autosave($this->_post->ID, get_current_user_id());
     $this->assertNotEmpty($autosave);
     $this->assertGreaterThanOrEqual(0, strpos($autosave->post_content, $md5));
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:34,代码来源:Autosave.php

示例3: handle_locking

 protected function handle_locking($post_id)
 {
     $last_user = wp_check_post_lock($post_id);
     if ($last_user) {
         $message = __('Error: %s is currently editing this.', 'front-end-editor');
         $message = sprintf($message, esc_html(get_userdata($last_user)->display_name));
         throw new Exception($message);
     }
     wp_set_post_lock($post_id);
 }
开发者ID:robhadfield,项目名称:wp-front-end-editor,代码行数:10,代码来源:post.php

示例4: edit

 private function edit()
 {
     global $title, $post_ID, $p, $post, $post_referredby;
     $title = __('Edit Page');
     $page_ID = $post_ID = $p = (int) $_GET['post'];
     $post = $this->get_page($post_ID);
     if (current_user_can('edit_page', $page_ID)) {
         if ($last = wp_check_post_lock($post->ID)) {
             $last_user = get_userdata($last);
             $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
             $message = sprintf(__('Warning: %s is currently editing this page'), esc_html($last_user_name));
             $message = '<p><font color="red">' . $message . '</font></p>';
             add_action('admin_notices', create_function('', "echo '{$message}';"));
         } else {
             wp_set_post_lock($post->ID);
         }
     } else {
         $this->base->ks_die(__('You are not allowed to edit this page.'));
         // exit;
     }
     $post_referredby = $this->sendback;
     include dirname(__FILE__) . '/edit-page-form.php';
 }
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:23,代码来源:page.php

示例5: wp_set_post_lock

         if (is_wp_error($revision_id)) {
             $id = $revision_id;
         } else {
             $id = $post->ID;
         }
     }
     $data = $message;
 } else {
     if (!empty($_POST['auto_draft'])) {
         $id = 0;
     } else {
         $id = $post->ID;
     }
 }
 if ($do_lock && empty($_POST['auto_draft']) && $id && is_numeric($id)) {
     $lock_result = wp_set_post_lock($id);
     $supplemental['active-post-lock'] = implode(':', $lock_result);
 }
 if ($nonce_age == 2) {
     $supplemental['replace-autosavenonce'] = wp_create_nonce('autosave');
     $supplemental['replace-getpermalinknonce'] = wp_create_nonce('getpermalink');
     $supplemental['replace-samplepermalinknonce'] = wp_create_nonce('samplepermalink');
     $supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes');
     $supplemental['replace-_ajax_linking_nonce'] = wp_create_nonce('internal-linking');
     if ($id) {
         if ($_POST['post_type'] == 'post') {
             $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id);
         } elseif ($_POST['post_type'] == 'page') {
             $supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id);
         }
     }
开发者ID:vivekkodira1,项目名称:wordpress,代码行数:31,代码来源:admin-ajax.php

示例6: front_end_editor_shortcodes

 public function front_end_editor_shortcodes($attr)
 {
     global $wp, $current_screen, $wp_meta_boxes, $post;
     $is_bac = $this->is_bac();
     $output = '';
     /**
      * Start Checking the Conditional needed to render editor
      * Define Variable needed for use in whole function
      *  
      *
      */
     if (!is_user_logged_in()) {
         if ($is_bac === true) {
             wp_safe_redirect(bon_accounts()->my_account_url());
         } else {
             if (is_woocommerce_activated()) {
                 wp_safe_redirect(get_permalink(wc_get_page_id('myaccount')));
             }
         }
     } else {
         if (!$this->is_edit()) {
             return;
         }
         $object_id = $this->get_post_to_edit();
         if (!$object_id) {
             bon_error_notice()->add('invalid_post', __('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'), 'error');
             return;
         }
         $post_object = get_post($this->get_post_to_edit());
         setup_postdata($GLOBALS['post'] =& $post_object);
         $current_post_type = get_post_type($object_id);
         if (!$post_object) {
             bon_error_notice()->add('invalid_post', __('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'), 'error');
             return;
         }
         if (!current_user_can('edit_post', $object_id)) {
             bon_error_notice()->add('permission_denied', __('You are not allowed to edit this item.'), 'error');
             return;
         }
         if (!post_type_supports($post_object->post_type, 'front-end-editor')) {
             bon_error_notice()->add('unsupported_posttype', __('The post type assigned is not supporting front end post', 'bon'), 'error');
         }
         $form_extra = '';
         $notice = false;
         if ($post_object->post_status === 'auto-draft') {
             $post_object->post_title = '';
             $post_object->comment_status = get_option('default_comment_status');
             $post_object->ping_status = get_option('default_ping_status');
             $autosave = false;
             $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
         } else {
             $autosave = wp_get_post_autosave($object_id);
         }
         $form_action = 'editpost';
         $nonce_action = 'update-post_' . $object_id;
         $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($object_id) . "' />";
         $content_css = array(trailingslashit(get_stylesheet_directory_uri()) . 'assets/css/editor-styles.css', trailingslashit(includes_url()) . 'css/dashicons.min.css', trailingslashit(includes_url()) . 'js/mediaelement/mediaelementplayer.min.css', trailingslashit(includes_url()) . 'js/mediaelement/wp-mediaelement.css', trailingslashit(includes_url()) . 'js/tinymce/skins/wordpress/wp-content.css', trailingslashit(includes_url()) . 'css/editor.min.css');
         $content_css = join(',', array_map('esc_url', array_unique($content_css)));
         $args = array('post_ID' => $object_id, 'post_type' => $current_post_type, 'user_ID' => get_current_user_id(), 'post' => $post_object, 'post_type_object' => get_post_type_object($current_post_type), 'autosave' => $autosave, 'form_extra' => $form_extra, 'form_action' => $form_action, 'nonce_action' => $nonce_action, 'editor_settings' => array('dfw' => true, 'drag_drop_upload' => true, 'tabfocus_elements' => 'insert-media-button, save-post', 'editor_height' => 360, 'tinymce' => array('resize' => false, 'add_unload_trigger' => false, 'content_css' => $content_css)));
         ob_start();
         bon_get_template('posts/editor.php', $args);
         $args['editor'] = ob_get_clean();
         unset($args['editor_settings']);
         set_current_screen($current_post_type);
         $current_screen->set_parentage('edit.php?post_type=' . $current_post_type);
         if (!wp_check_post_lock($object_id)) {
             $args['active_post_lock'] = wp_set_post_lock($object_id);
         }
         $messages = $this->get_wp_messages($post_object);
         $message = false;
         if (isset($_GET['message'])) {
             $_GET['message'] = absint($_GET['message']);
             if (isset($messages[$current_post_type][$_GET['message']])) {
                 $message = $messages[$current_post_type][$_GET['message']];
             } elseif (!isset($messages[$current_post_type]) && isset($messages['post'][$_GET['message']])) {
                 $message = $messages['post'][$_GET['message']];
             }
         }
         // Detect if there exists an autosave newer than the post and if that autosave is different than the post
         if ($autosave && mysql2date('U', $autosave->post_modified_gmt, false) > mysql2date('U', $post_object->post_modified_gmt, false)) {
             foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
                 if (normalize_whitespace($autosave->{$autosave_field}) != normalize_whitespace($post_object->{$autosave_field})) {
                     bon_error_notice()->add('autosave_exists', sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>'), get_edit_post_link($autosave->ID)), 'notice');
                     break;
                 }
             }
             // If this autosave isn't different from the current post, begone.
             if (!$notice) {
                 wp_delete_post_revision($autosave->ID);
             }
             unset($autosave_field, $_autosave_field);
         }
         bon_get_template('posts/post.php', $args);
         unset($GLOBALS['current_screen']);
         wp_reset_postdata();
     }
 }
开发者ID:VadimSid,项目名称:thinkgreek,代码行数:97,代码来源:class-bon-front-end-editor.php

示例7: wp_refresh_post_lock

/**
 * Check lock status on the New/Edit Post screen and refresh the lock
 *
 * @since 3.6.0
 *
 * @param array  $response  The Heartbeat response.
 * @param array  $data      The $_POST data sent.
 * @param string $screen_id The screen id.
 * @return array The Heartbeat response.
 */
function wp_refresh_post_lock($response, $data, $screen_id)
{
    if (array_key_exists('wp-refresh-post-lock', $data)) {
        $received = $data['wp-refresh-post-lock'];
        $send = array();
        if (!($post_id = absint($received['post_id']))) {
            return $response;
        }
        if (!current_user_can('edit_post', $post_id)) {
            return $response;
        }
        if (($user_id = wp_check_post_lock($post_id)) && ($user = get_userdata($user_id))) {
            $error = array('text' => sprintf(__('%s has taken over and is currently editing.'), $user->display_name));
            if ($avatar = get_avatar($user->ID, 64)) {
                if (preg_match("|src='([^']+)'|", $avatar, $matches)) {
                    $error['avatar_src'] = $matches[1];
                }
            }
            $send['lock_error'] = $error;
        } else {
            if ($new_lock = wp_set_post_lock($post_id)) {
                $send['new_lock'] = implode(':', $new_lock);
            }
        }
        $response['wp-refresh-post-lock'] = $send;
    }
    return $response;
}
开发者ID:akalipetis,项目名称:WordPress,代码行数:38,代码来源:misc.php

示例8: wp_write_post

/**
 * Creates a new post from the "Write Post" form using $_POST information.
 *
 * @since 2.1.0
 *
 * @global WP_User $current_user
 *
 * @return int|WP_Error
 */
function wp_write_post()
{
    if (isset($_POST['post_type'])) {
        $ptype = get_post_type_object($_POST['post_type']);
    } else {
        $ptype = get_post_type_object('post');
    }
    if (!current_user_can($ptype->cap->edit_posts)) {
        if ('page' == $ptype->name) {
            return new WP_Error('edit_pages', __('Sorry, you are not allowed to create pages on this site.'));
        } else {
            return new WP_Error('edit_posts', __('Sorry, you are not allowed to create posts or drafts on this site.'));
        }
    }
    $_POST['post_mime_type'] = '';
    // Clear out any data in internal vars.
    unset($_POST['filter']);
    // Edit don't write if we have a post id.
    if (isset($_POST['post_ID'])) {
        return edit_post();
    }
    if (isset($_POST['visibility'])) {
        switch ($_POST['visibility']) {
            case 'public':
                $_POST['post_password'] = '';
                break;
            case 'password':
                unset($_POST['sticky']);
                break;
            case 'private':
                $_POST['post_status'] = 'private';
                $_POST['post_password'] = '';
                unset($_POST['sticky']);
                break;
        }
    }
    $translated = _wp_translate_postdata(false);
    if (is_wp_error($translated)) {
        return $translated;
    }
    // Create the post.
    $post_ID = wp_insert_post($_POST);
    if (is_wp_error($post_ID)) {
        return $post_ID;
    }
    if (empty($post_ID)) {
        return 0;
    }
    add_meta($post_ID);
    add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID);
    // Now that we have an ID we can fix any attachment anchor hrefs
    _fix_attachment_links($post_ID);
    wp_set_post_lock($post_ID);
    return $post_ID;
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:64,代码来源:post.php

示例9: elseif

     $post_new_file = "post-new.php";
 } elseif ('attachment' == $post_type) {
     $parent_file = 'upload.php';
     $submenu_file = 'upload.php';
     $post_new_file = 'media-new.php';
 } else {
     if (isset($post_type_object) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true) {
         $parent_file = $post_type_object->show_in_menu;
     } else {
         $parent_file = "edit.php?post_type={$post_type}";
     }
     $submenu_file = "edit.php?post_type={$post_type}";
     $post_new_file = "post-new.php?post_type={$post_type}";
 }
 if (!wp_check_post_lock($post->ID)) {
     $active_post_lock = wp_set_post_lock($post->ID);
     if ('attachment' !== $post_type) {
         wp_enqueue_script('autosave');
     }
 }
 if (is_multisite()) {
     add_action('admin_footer', '_admin_notice_post_locked');
 } else {
     $check_users = get_users(array('fields' => 'ID', 'number' => 2));
     if (count($check_users) > 1) {
         add_action('admin_footer', '_admin_notice_post_locked');
     }
     unset($check_users);
 }
 $title = $post_type_object->labels->edit_item;
 $post = get_post($post_id, OBJECT, 'edit');
开发者ID:pbearne,项目名称:contrib2core,代码行数:31,代码来源:post.php

示例10: display

 /**
  * Loads the display template
  *
  * @since 1.0-beta
  *
  * @param int $group_id ID of the current group. Available only in BP 2.2+.
  */
 function display($group_id = null)
 {
     global $bp;
     // Docs are stored on the root blog
     if (!bp_is_root_blog()) {
         switch_to_blog(BP_ROOT_BLOG);
     }
     switch ($bp->bp_docs->current_view) {
         case 'create':
             // Todo: Make sure the user has permission to create
             /**
              * Load the template tags for the edit screen
              */
             if (!function_exists('wp_tiny_mce')) {
                 bp_docs_define_tiny_mce();
             }
             require_once BP_DOCS_INCLUDES_PATH . 'templatetags-edit.php';
             $template = 'edit-doc.php';
             break;
         case 'list':
             $template = 'docs-loop.php';
             break;
         case 'category':
             // Check to make sure the category exists
             // If not, redirect back to list view with error
             // Otherwise, get args based on category ID
             // Then load the loop template
             break;
         case 'single':
         case 'edit':
         case 'delete':
         case 'history':
             // If this is the edit screen, we won't really be able to use a
             // regular have_posts() loop in the template, so we'll stash the
             // post in the $bp global for the edit-specific template tags
             if ($bp->bp_docs->current_view == 'edit') {
                 if (bp_docs_has_docs()) {
                     while (bp_docs_has_docs()) {
                         bp_docs_the_doc();
                         $bp->bp_docs->current_post = $post;
                         // Set an edit lock
                         wp_set_post_lock($post->ID);
                     }
                 }
                 /**
                  * Load the template tags for the edit screen
                  */
                 require_once BP_DOCS_INCLUDES_PATH . 'templatetags-edit.php';
             }
             switch ($bp->bp_docs->current_view) {
                 case 'single':
                     $template = 'single/index.php';
                     break;
                 case 'edit':
                     $template = 'single/edit.php';
                     break;
                 case 'history':
                     $template = 'single/history.php';
                     break;
             }
             // Todo: Maybe some sort of error if there is no edit permission?
             break;
     }
     // Only register on the root blog
     if (!bp_is_root_blog()) {
         restore_current_blog();
     }
     $template_path = bp_docs_locate_template($template);
     if (!empty($template)) {
         include apply_filters('bp_docs_template', $template_path, $this);
     }
 }
开发者ID:projectestac,项目名称:wordpress-buddypress-docs,代码行数:79,代码来源:integration-groups.php

示例11: meta_modal

 public function meta_modal()
 {
     global $post, $post_type, $post_type_object, $current_screen, $wp_meta_modal_sections;
     $post_ID = $post->ID;
     set_current_screen($post_type);
     if (!wp_check_post_lock($post->ID)) {
         $active_post_lock = wp_set_post_lock($post->ID);
     }
     $messages = array();
     $messages['post'] = array(0 => '', 1 => sprintf(__('Post updated. <a href="%s">View post</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Post updated.'), 5 => isset($_GET['revision']) ? sprintf(__('Post restored to revision from %s', 'wplms-front-end'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Post published. <a href="%s">View post</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 7 => __('Post saved.'), 8 => sprintf(__('Post submitted. <a target="_blank" href="%s">Preview post</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('Post scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview post</a>', 'wplms-front-end'), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('Post draft updated. <a target="_blank" href="%s">Preview post</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))));
     $messages['page'] = array(0 => '', 1 => sprintf(__('Page updated. <a href="%s">View page</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('Page updated.'), 5 => isset($_GET['revision']) ? sprintf(__('Page restored to revision from %s'), 'wplms-front-end', wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Page published. <a href="%s">View page</a>', 'wplms-front-end'), esc_url(get_permalink($post_ID))), 7 => __('Page saved.'), 8 => sprintf(__('Page submitted. <a target="_blank" href="%s">Preview page</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>', 'wplms-front-end'), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('Page draft updated. <a target="_blank" href="%s">Preview page</a>', 'wplms-front-end'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))));
     $messages['attachment'] = array_fill(1, 10, __('Media attachment updated.', 'wplms-front-end'));
     // Hack, for now.
     $messages = apply_filters('post_updated_messages', $messages);
     $message = false;
     if (isset($_GET['message'])) {
         $_GET['message'] = absint($_GET['message']);
         if (isset($messages[$post_type][$_GET['message']])) {
             $message = $messages[$post_type][$_GET['message']];
         } elseif (!isset($messages[$post_type]) && isset($messages['post'][$_GET['message']])) {
             $message = $messages['post'][$_GET['message']];
         }
     }
     $notice = false;
     $form_extra = '';
     if ('auto-draft' == $post->post_status) {
         if ('edit' == $action) {
             $post->post_title = '';
         }
         $autosave = false;
         $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
     } else {
         $autosave = wp_get_post_autosave($post_ID);
     }
     $form_action = 'editpost';
     $nonce_action = 'update-post_' . $post_ID;
     // Detect if there exists an autosave newer than the post and if that autosave is different than the post
     if ($autosave && mysql2date('U', $autosave->post_modified_gmt, false) > mysql2date('U', $post->post_modified_gmt, false)) {
         foreach (_wp_post_revision_fields() as $autosave_field => $_autosave_field) {
             if (normalize_whitespace($autosave->{$autosave_field}) != normalize_whitespace($post->{$autosave_field})) {
                 $notice = sprintf(__('There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>', 'wplms-front-end'), get_edit_post_link($autosave->ID));
                 break;
             }
         }
         // If this autosave isn't different from the current post, begone.
         if (!$notice) {
             wp_delete_post_revision($autosave->ID);
         }
         unset($autosave_field, $_autosave_field);
     }
     $post_type_object = get_post_type_object($post_type);
     $this->add_meta_modal_section('submitdiv', __('Publish'), array($this, 'meta_section_publish'), 10, 10);
     if (post_type_supports($post_type, 'revisions') && 'auto-draft' !== $post->post_status) {
         $revisions = wp_get_post_revisions($post->ID);
         $count = count($revisions);
         if ($count > 1) {
             $this->add_meta_modal_section('revisionsdiv', __('Revisions', 'wplms-front-end') . ' (' . $count . ')', 'post_revisions_meta_box', 30, 50);
         }
     }
     if (current_theme_supports('post-formats') && post_type_supports($post_type, 'post-formats')) {
         $this->add_meta_modal_section('formatdiv', _x('Format', 'post format', 'wplms-front-end'), 'post_format_meta_box', 20, 10);
     }
     foreach (get_object_taxonomies($post) as $tax_name) {
         $taxonomy = get_taxonomy($tax_name);
         if (!$taxonomy->show_ui || false === $taxonomy->meta_box_cb) {
             continue;
         }
         $label = $taxonomy->labels->name;
         if (!is_taxonomy_hierarchical($tax_name)) {
             $tax_meta_box_id = 'tagsdiv-' . $tax_name;
         } else {
             $tax_meta_box_id = $tax_name . 'div';
         }
         $this->add_meta_modal_section($tax_meta_box_id, $label, $taxonomy->meta_box_cb, 20, 20, array('taxonomy' => $tax_name));
     }
     if (post_type_supports($post_type, 'page-attributes')) {
         $this->add_meta_modal_section('pageparentdiv', 'page' == $post_type ? __('Page Attributes', 'wplms-front-end') : __('Attributes', 'wplms-front-end'), 'page_attributes_meta_box', 10, 10);
     }
     if (post_type_supports($post_type, 'excerpt')) {
         $this->add_meta_modal_section('postexcerpt', __('Excerpt', 'wplms-front-end'), 'post_excerpt_meta_box', 30, 10);
     }
     if (post_type_supports($post_type, 'trackbacks')) {
         $this->add_meta_modal_section('trackbacksdiv', __('Send Trackbacks', 'wplms-front-end'), 'post_trackback_meta_box', 30, 20);
     }
     if (post_type_supports($post_type, 'custom-fields')) {
         $this->add_meta_modal_section('postcustom', __('Custom Fields', 'wplms-front-end'), 'post_custom_meta_box', 30, 30);
     }
     if (post_type_supports($post_type, 'comments')) {
         $this->add_meta_modal_section('commentstatusdiv', __('Discussion', 'wplms-front-end'), 'post_comment_status_meta_box', 30, 40);
     }
     require_once 'meta-modal-template.php';
     unset($GLOBALS['current_screen']);
 }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:93,代码来源:class-wp-front-end-editor.php

示例12: etwp_write_post

function etwp_write_post()
{
    global $user_ID;
    /*     if ( isset($_POST['post_type']) )
            $ptype = get_post_type_object($_POST['post_type']);
        else
            $ptype = get_post_type_object('post');
    
        if ( !current_user_can( $ptype->cap->edit_posts ) ) {
            if ( 'page' == $ptype->name )
                return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
            else
                return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
        }
    */
    $_POST['post_mime_type'] = '';
    // Clear out any data in internal vars.
    unset($_POST['filter']);
    /*    // Edit don't write if we have a post id.
        if ( isset( $_POST['post_ID'] ) )
            return edit_post();
    */
    if (!isset($_POST['publish'])) {
        $_POST['publish'] = 'publish';
    }
    if (!isset($_POST['visibility'])) {
        $_POST['visibility'] = 'public';
    }
    if (empty($_POST['post_status'])) {
        $_POST['post_status'] = 'publish';
    }
    if (!isset($_POST['comment_status'])) {
        $_POST['comment_status'] = 'open';
    }
    if (isset($_POST['visibility'])) {
        switch ($_POST['visibility']) {
            case 'public':
                $_POST['post_password'] = '';
                break;
            case 'password':
                unset($_POST['sticky']);
                break;
            case 'private':
                $_POST['post_status'] = 'private';
                $_POST['post_password'] = '';
                unset($_POST['sticky']);
                break;
        }
    }
    $translated = et_wp_translate_postdata(false);
    if (is_wp_error($translated)) {
        return $translated;
    }
    // Create the post.
    $post_ID = etwp_insert_post($_POST);
    if (is_wp_error($post_ID)) {
        return $post_ID;
    }
    if (empty($post_ID)) {
        return 0;
    }
    //add_meta( $post_ID );
    //zzcity add
    if (isset($_POST['meta']) && $_POST['meta']) {
        foreach ($_POST['meta'] as $key => $value) {
            add_post_meta($post_ID, $value['key'], $value['value']);
        }
    }
    add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID);
    // Now that we have an ID we can fix any attachment anchor hrefs
    _fix_attachment_links($post_ID);
    wp_set_post_lock($post_ID);
    return $post_ID;
}
开发者ID:richhu,项目名称:stuqtest,代码行数:74,代码来源:etpost.php

示例13: _edit_cpt_item

 /**
  * default method for the 'edit' route for cpt admin pages
  *
  * For reference on what to put in here, refer to wp-admin/post.php
  *
  * @access protected
  * @return string   template for edit cpt form
  */
 protected function _edit_cpt_item()
 {
     global $post, $title, $is_IE;
     $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL;
     $post = !empty($post_id) ? get_post($post_id, OBJECT, 'edit') : NULL;
     if (empty($post)) {
         wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'));
     }
     if (!empty($_GET['get-post-lock'])) {
         $test = wp_set_post_lock($post_id);
         wp_redirect(get_edit_post_link($post_id, 'url'));
         exit;
     }
     $this->_template_args['editing'] = TRUE;
     $this->_template_args['post_ID'] = $post_id;
     $this->_template_args['post'] = $post;
     $this->_template_args['post_type'] = $this->_cpt_routes[$this->_req_action];
     $this->_template_args['post_type_object'] = $this->_cpt_object;
     $this->_template_args['is_IE'] = $is_IE;
     if ($last = wp_check_post_lock($post->ID)) {
         add_action('admin_notices', '_admin_notice_post_locked');
     } else {
         $this->_template_args['active_post_lock'] = wp_set_post_lock($post->ID);
         wp_enqueue_script('autosave');
     }
     $title = $this->_cpt_object->labels->edit_item;
     if (isset($this->_cpt_routes[$this->_req_data['action']]) && !isset($this->_labels['hide_add_button_on_cpt_route']['edit_attendee'])) {
         $this->_template_args['post_new_file'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'create_new', 'page' => $this->page_slug), 'admin.php');
     }
     if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
         wp_enqueue_script('admin-comments');
         enqueue_comment_hotkeys_js();
     }
     add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
     $template = WP_ADMIN_PATH . 'edit-form-advanced.php';
     EEH_Template::display_template($template, $this->_template_args);
 }
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:45,代码来源:EE_Admin_Page_CPT.core.php

示例14: test_locked_post

 /**
  * Test with a locked post
  * @return void
  */
 public function test_locked_post()
 {
     // Become an administrator
     $this->_setRole('administrator');
     // Lock the post
     wp_set_post_lock($this->_post->ID);
     // Become a different administrator
     $this->_setRole('administrator');
     // Set up the $_POST request
     $_POST = array('post_ID' => $this->_post->ID, 'autosavenonce' => wp_create_nonce('autosave'), 'autosave' => 1);
     // Make the request
     try {
         $this->_handleAjax('autosave');
     } catch (WPAjaxDieContinueException $e) {
         unset($e);
     }
     // Get the response
     $xml = simplexml_load_string($this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA);
     // Ensure everything is correct
     $this->assertEquals($this->_post->ID, (int) $xml->response[0]->autosave['id']);
     $this->assertEquals('autosave_' . $this->_post->ID, (string) $xml->response['action']);
     $this->assertEquals('disable', (string) $xml->response[0]->autosave[0]->supplemental[0]->disable_autosave);
 }
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:27,代码来源:Autosave.php

示例15: wp_create_post_autosave

         } else {
             // Non drafts are not overwritten.  The autosave is stored in a special post revision.
             $revision_id = wp_create_post_autosave($post->ID);
             if (is_wp_error($revision_id)) {
                 $id = $revision_id;
             } else {
                 $id = $post->ID;
             }
         }
         $data = $message;
     } else {
         $id = $post->ID;
     }
 }
 if ($do_lock && $id && is_numeric($id)) {
     wp_set_post_lock($id);
 }
 if ($nonce_age == 2) {
     $supplemental['replace-autosavenonce'] = wp_create_nonce('autosave');
     $supplemental['replace-getpermalinknonce'] = wp_create_nonce('getpermalink');
     $supplemental['replace-samplepermalinknonce'] = wp_create_nonce('samplepermalink');
     $supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes');
     if ($id) {
         if ($_POST['post_type'] == 'post') {
             $supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id);
         } elseif ($_POST['post_type'] == 'page') {
             $supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id);
         }
     }
 }
 $x = new WP_Ajax_Response(array('what' => 'autosave', 'id' => $id, 'data' => $id ? $data : '', 'supplemental' => $supplemental));
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php


注:本文中的wp_set_post_lock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。