• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_check_post_lock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_autosave_locked_post

 /**
  * Test autosaving a locked post
  * @return void
  */
 public function test_autosave_locked_post()
 {
     // Lock the post to another user
     wp_set_current_user(self::$editor_id);
     wp_set_post_lock(self::$post_id);
     wp_set_current_user(self::$admin_id);
     // Ensure post is locked
     $this->assertEquals(self::$editor_id, wp_check_post_lock(self::$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' => self::$post_id, '_wpnonce' => wp_create_nonce('update-post_' . self::$post_id), 'post_content' => self::$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(self::$post_id);
     $this->assertFalse(strpos($post->post_content, $md5));
     // Check if the autosave post was created
     $autosave = wp_get_post_autosave(self::$post_id, get_current_user_id());
     $this->assertNotEmpty($autosave);
     $this->assertGreaterThanOrEqual(0, strpos($autosave->post_content, $md5));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:33,代码来源:Autosave.php


示例2: 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


示例3: test_postLock

 public function test_postLock()
 {
     $this->user_own_post = $this->factory->user->create(['role' => 'administrator']);
     $this->user_editor = $this->factory->user->create(['role' => 'administrator']);
     wp_set_current_user($this->user_own_post);
     $post = $this->factory->post->create_and_get();
     $data = ['elementor_post_lock' => ['post_ID' => $post->ID]];
     $response = apply_filters('heartbeat_received', [], $data, '');
     // Switch to other user
     wp_set_current_user($this->user_editor);
     $this->assertEquals($this->user_own_post, wp_check_post_lock($post->ID));
     $response = apply_filters('heartbeat_received', [], $data, '');
     $this->assertArrayHasKey('locked_user', $response);
 }
开发者ID:pojome,项目名称:elementor,代码行数:14,代码来源:test-heartbeat.php


示例4: init

 /**
  * Initializes the builder interface.
  *
  * @since 1.0
  * @return void
  */
 public static function init()
 {
     // Enable editing if the builder is active.
     if (FLBuilderModel::is_builder_active() && !defined('DOING_AJAX')) {
         // Tell W3TC not to minify while the builder is active.
         define('DONOTMINIFY', true);
         // Tell Autoptimize not to minify while the builder is active.
         add_filter('autoptimize_filter_noptimize', '__return_true');
         // Remove 3rd party editor buttons.
         remove_all_actions('media_buttons', 999999);
         remove_all_actions('media_buttons_context', 999999);
         // Get the post.
         require_once ABSPATH . 'wp-admin/includes/post.php';
         $post_id = FLBuilderModel::get_post_id();
         // Check to see if the post is locked.
         if (wp_check_post_lock($post_id) !== false) {
             header('Location: ' . admin_url('/post.php?post=' . $post_id . '&action=edit'));
         } else {
             FLBuilderModel::enable_editing();
         }
     }
 }
开发者ID:Nirajjcu,项目名称:minime3d,代码行数:28,代码来源:class-fl-builder.php


示例5: 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


示例6: callback

 function callback($path = '', $blog_id = 0, $post_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     $args = $this->query_args();
     $input = $this->input(false);
     if (!is_array($input) || !$input) {
         return new WP_Error('invalid_input', 'Invalid request input', 400);
     }
     $post = get_post($post_id);
     if (!$post || is_wp_error($post)) {
         return new WP_Error('unknown_post', 'Unknown post', 404);
     }
     if (!current_user_can('edit_post', $post->ID)) {
         return new WP_Error('unauthorized', 'User cannot edit post', 403);
     }
     $post_data = array('post_ID' => $post_id, 'post_title' => $input['title'], 'post_content' => $input['content'], 'post_excerpt' => $input['excerpt']);
     $preview_url = add_query_arg('preview', 'true', get_permalink($post->ID));
     if (!wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('auto-draft' == $post->post_status || 'draft' == $post->post_status)) {
         // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
         $auto_ID = edit_post(wp_slash($post_data));
     } else {
         // Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user.
         $auto_ID = wp_create_post_autosave(wp_slash($post_data));
         $nonce = wp_create_nonce('post_preview_' . $post->ID);
         $preview_url = add_query_arg(array('preview_id' => $auto_ID, 'preview_nonce' => $nonce), $preview_url);
     }
     $updated_post = get_post($auto_ID);
     if ($updated_post && $updated_post->ID && $updated_post->post_modified) {
         return array('ID' => $auto_ID, 'post_ID' => $post->ID, 'modified' => $this->format_date($updated_post->post_modified), 'preview_URL' => $preview_url);
     } else {
         return new WP_Error('autosave_error', __('Autosave encountered an unexpected error', 'jetpack'), 500);
     }
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:36,代码来源:class.wpcom-json-api-autosave-post-v1-1-endpoint.php


示例7: redirect_post

     }
     redirect_post($post_id);
     // Send user on their way while we keep working
     exit;
 case 'trash':
     check_admin_referer('trash-post_' . $post_id);
     if (!$post) {
         wp_die(__('The item you are trying to move to the Trash no longer exists.'));
     }
     if (!$post_type_object) {
         wp_die(__('Unknown post type.'));
     }
     if (!current_user_can('delete_post', $post_id)) {
         wp_die(__('You are not allowed to move this item to the Trash.'));
     }
     if ($user_id = wp_check_post_lock($post_id)) {
         $user = get_userdata($user_id);
         wp_die(sprintf(__('You cannot move this item to the Trash. %s is currently editing.'), $user->display_name));
     }
     if (!wp_trash_post($post_id)) {
         wp_die(__('Error in moving to Trash.'));
     }
     wp_redirect(add_query_arg(array('trashed' => 1, 'ids' => $post_id), $sendback));
     exit;
 case 'untrash':
     check_admin_referer('untrash-post_' . $post_id);
     if (!$post) {
         wp_die(__('The item you are trying to restore from the Trash no longer exists.'));
     }
     if (!$post_type_object) {
         wp_die(__('Unknown post type.'));
开发者ID:pbearne,项目名称:contrib2core,代码行数:31,代码来源:post.php


示例8: bulk_edit_posts

/**
 * Process the post data for the bulk editing of posts.
 *
 * Updates all bulk edited posts/pages, adding (but not removing) tags and
 * categories. Skips pages when they would be their own parent or child.
 *
 * @since 2.7.0
 *
 * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal.
 * @return array
 */
function bulk_edit_posts($post_data = null)
{
    global $wpdb;
    if (empty($post_data)) {
        $post_data =& $_POST;
    }
    if (isset($post_data['post_type'])) {
        $ptype = get_post_type_object($post_data['post_type']);
    } else {
        $ptype = get_post_type_object('post');
    }
    if (!current_user_can($ptype->cap->edit_posts)) {
        if ('page' == $ptype->name) {
            wp_die(__('You are not allowed to edit pages.'));
        } else {
            wp_die(__('You are not allowed to edit posts.'));
        }
    }
    if (-1 == $post_data['_status']) {
        $post_data['post_status'] = null;
        unset($post_data['post_status']);
    } else {
        $post_data['post_status'] = $post_data['_status'];
    }
    unset($post_data['_status']);
    $post_IDs = array_map('intval', (array) $post_data['post']);
    $reset = array('post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky');
    foreach ($reset as $field) {
        if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field])) {
            unset($post_data[$field]);
        }
    }
    if (isset($post_data['post_category'])) {
        if (is_array($post_data['post_category']) && !empty($post_data['post_category'])) {
            $new_cats = array_map('absint', $post_data['post_category']);
        } else {
            unset($post_data['post_category']);
        }
    }
    $tax_input = array();
    if (isset($post_data['tax_input'])) {
        foreach ($post_data['tax_input'] as $tax_name => $terms) {
            if (empty($terms)) {
                continue;
            }
            if (is_taxonomy_hierarchical($tax_name)) {
                $tax_input[$tax_name] = array_map('absint', $terms);
            } else {
                $comma = _x(',', 'tag delimiter');
                if (',' !== $comma) {
                    $terms = str_replace($comma, ',', $terms);
                }
                $tax_input[$tax_name] = explode(',', trim($terms, " \n\t\r\v,"));
            }
        }
    }
    if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) {
        $pages = $wpdb->get_results("SELECT ID, post_parent FROM {$wpdb->posts} WHERE post_type = 'page'");
        $children = array();
        for ($i = 0; $i < 50 && $parent > 0; $i++) {
            $children[] = $parent;
            foreach ($pages as $page) {
                if ($page->ID == $parent) {
                    $parent = $page->post_parent;
                    break;
                }
            }
        }
    }
    if (isset($post_data['post_format'])) {
        if ('0' == $post_data['post_format']) {
            $post_data['post_format'] = false;
        } elseif (!current_theme_supports('post-formats', $post_data['post_format'])) {
            unset($post_data['post_format']);
        }
    }
    $updated = $skipped = $locked = array();
    foreach ($post_IDs as $post_ID) {
        $post_type_object = get_post_type_object(get_post_type($post_ID));
        if (!isset($post_type_object) || isset($children) && in_array($post_ID, $children) || !current_user_can($post_type_object->cap->edit_post, $post_ID)) {
            $skipped[] = $post_ID;
            continue;
        }
        if (wp_check_post_lock($post_ID)) {
            $locked[] = $post_ID;
            continue;
        }
        $post = get_post($post_ID);
        $tax_names = get_object_taxonomies($post);
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:post.php


示例9: wp_print_revision_templates

/**
 * Print JavaScript templates required for the revisions experience.
 *
 * @since 4.1.0
 *
 * @global WP_Post $post The global `$post` object.
 */
function wp_print_revision_templates()
{
    global $post;
    ?>
<script id="tmpl-revisions-frame" type="text/html">
		<div class="revisions-control-frame"></div>
		<div class="revisions-diff-frame"></div>
	</script>

	<script id="tmpl-revisions-buttons" type="text/html">
		<div class="revisions-previous">
			<input class="button" type="button" value="<?php 
    echo esc_attr_x('Previous', 'Button label for a previous revision');
    ?>
" />
		</div>

		<div class="revisions-next">
			<input class="button" type="button" value="<?php 
    echo esc_attr_x('Next', 'Button label for a next revision');
    ?>
" />
		</div>
	</script>

	<script id="tmpl-revisions-checkbox" type="text/html">
		<div class="revision-toggle-compare-mode">
			<label>
				<input type="checkbox" class="compare-two-revisions"
				<#
				if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) {
					#> checked="checked"<#
				}
				#>
				/>
				<?php 
    esc_attr_e('Compare any two revisions');
    ?>
			</label>
		</div>
	</script>

	<script id="tmpl-revisions-meta" type="text/html">
		<# if ( ! _.isUndefined( data.attributes ) ) { #>
			<div class="diff-title">
				<# if ( 'from' === data.type ) { #>
					<strong><?php 
    _ex('From:', 'Followed by post revision info');
    ?>
</strong>
				<# } else if ( 'to' === data.type ) { #>
					<strong><?php 
    _ex('To:', 'Followed by post revision info');
    ?>
</strong>
				<# } #>
				<div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
					{{{ data.attributes.author.avatar }}}
					<div class="author-info">
					<# if ( data.attributes.autosave ) { #>
						<span class="byline"><?php 
    printf(__('Autosave by %s'), '<span class="author-name">{{ data.attributes.author.name }}</span>');
    ?>
</span>
					<# } else if ( data.attributes.current ) { #>
						<span class="byline"><?php 
    printf(__('Current Revision by %s'), '<span class="author-name">{{ data.attributes.author.name }}</span>');
    ?>
</span>
					<# } else { #>
						<span class="byline"><?php 
    printf(__('Revision by %s'), '<span class="author-name">{{ data.attributes.author.name }}</span>');
    ?>
</span>
					<# } #>
						<span class="time-ago">{{ data.attributes.timeAgo }}</span>
						<span class="date">({{ data.attributes.dateShort }})</span>
					</div>
				<# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
					<input  <?php 
    if (wp_check_post_lock($post->ID)) {
        ?>
						disabled="disabled"
					<?php 
    } else {
        ?>
						<# if ( data.attributes.current ) { #>
							disabled="disabled"
						<# } #>
					<?php 
    }
    ?>
					<# if ( data.attributes.autosave ) { #>
//.........这里部分代码省略.........
开发者ID:psycle,项目名称:wordpress,代码行数:101,代码来源:revision.php


示例10: bulk_edit_posts

/**
 * {@internal Missing Short Description}}
 *
 * Updates all bulk edited posts/pages, adding (but not removing) tags and
 * categories. Skips pages when they would be their own parent or child.
 *
 * @since unknown
 *
 * @return array
 */
function bulk_edit_posts($post_data = null)
{
    global $wpdb;
    if (empty($post_data)) {
        $post_data =& $_POST;
    }
    if (isset($post_data['post_type']) && 'page' == $post_data['post_type']) {
        if (!current_user_can('edit_pages')) {
            wp_die(__('You are not allowed to edit pages.'));
        }
    } else {
        if (!current_user_can('edit_posts')) {
            wp_die(__('You are not allowed to edit posts.'));
        }
    }
    $post_IDs = array_map('intval', (array) $post_data['post']);
    $reset = array('post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tags_input', 'post_category', 'sticky');
    foreach ($reset as $field) {
        if (isset($post_data[$field]) && ('' == $post_data[$field] || -1 == $post_data[$field])) {
            unset($post_data[$field]);
        }
    }
    if (isset($post_data['post_category'])) {
        if (is_array($post_data['post_category']) && !empty($post_data['post_category'])) {
            $new_cats = array_map(absint, $post_data['post_category']);
        } else {
            unset($post_data['post_category']);
        }
    }
    if (isset($post_data['tags_input'])) {
        $new_tags = preg_replace('/\\s*,\\s*/', ',', rtrim(trim($post_data['tags_input']), ' ,'));
        $new_tags = explode(',', $new_tags);
    }
    if (isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent'])) {
        $pages = $wpdb->get_results("SELECT ID, post_parent FROM {$wpdb->posts} WHERE post_type = 'page'");
        $children = array();
        for ($i = 0; $i < 50 && $parent > 0; $i++) {
            $children[] = $parent;
            foreach ($pages as $page) {
                if ($page->ID == $parent) {
                    $parent = $page->post_parent;
                    break;
                }
            }
        }
    }
    $updated = $skipped = $locked = array();
    foreach ($post_IDs as $post_ID) {
        if (isset($children) && in_array($post_ID, $children)) {
            $skipped[] = $post_ID;
            continue;
        }
        if (wp_check_post_lock($post_ID)) {
            $locked[] = $post_ID;
            continue;
        }
        if (isset($new_cats)) {
            $cats = (array) wp_get_post_categories($post_ID);
            $post_data['post_category'] = array_unique(array_merge($cats, $new_cats));
        }
        if (isset($new_tags)) {
            $tags = wp_get_post_tags($post_ID, array('fields' => 'names'));
            $post_data['tags_input'] = array_unique(array_merge($tags, $new_tags));
        }
        $post_data['ID'] = $post_ID;
        $updated[] = wp_update_post($post_data);
        if (current_user_can('edit_others_posts') && isset($post_data['sticky'])) {
            if ('sticky' == $post_data['sticky']) {
                stick_post($post_ID);
            } else {
                unstick_post($post_ID);
            }
        }
    }
    return array('updated' => $updated, 'skipped' => $skipped, 'locked' => $locked);
}
开发者ID:schr,项目名称:wordpress,代码行数:86,代码来源:post.php


示例11: single_row

    function single_row($post, $level = 0)
    {
        global $mode;
        static $alternate;
        $global_post = get_post();
        $GLOBALS['post'] = $post;
        setup_postdata($post);
        $edit_link = get_edit_post_link($post->ID);
        $title = _draft_or_post_title();
        $post_type_object = get_post_type_object($post->post_type);
        $can_edit_post = current_user_can('edit_post', $post->ID);
        $alternate = 'alternate' == $alternate ? '' : 'alternate';
        $classes = $alternate . ' iedit author-' . (get_current_user_id() == $post->post_author ? 'self' : 'other');
        $lock_holder = wp_check_post_lock($post->ID);
        if ($lock_holder) {
            $classes .= ' wp-locked';
            $lock_holder = get_userdata($lock_holder);
        }
        if ($post->post_parent) {
            $count = count(get_post_ancestors($post->ID));
            $classes .= ' level-' . $count;
        } else {
            $classes .= ' level-0';
        }
        ?>
		<tr id="post-<?php 
        echo $post->ID;
        ?>
" class="<?php 
        echo implode(' ', get_post_class($classes, $post->ID));
        ?>
">
	<?php 
        list($columns, $hidden) = $this->get_column_info();
        foreach ($columns as $column_name => $column_display_name) {
            $class = "class=\"{$column_name} column-{$column_name}\"";
            $style = '';
            if (in_array($column_name, $hidden)) {
                $style = ' style="display:none;"';
            }
            $attributes = "{$class}{$style}";
            switch ($column_name) {
                case 'cb':
                    ?>
			<th scope="row" class="check-column">
				<label class="screen-reader-text" for="cb-select-<?php 
                    the_ID();
                    ?>
"><?php 
                    printf(__('Select %s'), $title);
                    ?>
</label>
				<input id="cb-select-<?php 
                    the_ID();
                    ?>
" type="checkbox" name="select_posts[]" value="<?php 
                    the_ID();
                    ?>
" data-post_id="<?php 
                    the_ID();
                    ?>
" data-post_type="<?php 
                    echo $post->post_type;
                    ?>
" />
				<?php 
                    if ($can_edit_post) {
                        ?>
				<div class="locked-indicator"></div>
				<?php 
                    }
                    ?>
			</th>
			<?php 
                    break;
                case 'title':
                    $attributes = 'class="post-title page-title column-title"' . $style;
                    if ($this->hierarchical_display) {
                        if (0 == $level && (int) $post->post_parent > 0) {
                            //sent level 0 by accident, by default, or because we don't know the actual level
                            $find_main_page = (int) $post->post_parent;
                            while ($find_main_page > 0) {
                                $parent = get_post($find_main_page);
                                if (is_null($parent)) {
                                    break;
                                }
                                $level++;
                                $find_main_page = (int) $parent->post_parent;
                                if (!isset($parent_name)) {
                                    /** This filter is documented in wp-includes/post-template.php */
                                    $parent_name = apply_filters('the_title', $parent->post_title, $parent->ID);
                                }
                            }
                        }
                    }
                    $pad = str_repeat('&#8212; ', $level);
                    echo "<td {$attributes}><strong>";
                    // post format filtering
                    if ($format = get_post_format($post->ID)) {
                        $label = get_post_format_string($format);
//.........这里部分代码省略.........
开发者ID:vrxm,项目名称:htdocs,代码行数:101,代码来源:class-fa-posts-list-table.php


示例12: wp_die

 if (empty($post->ID)) {
     wp_die(__("You attempted to edit a page that doesn't exist. Perhaps it was deleted?"));
 }
 if ('page' != $post->post_type) {
     wp_redirect(get_edit_post_link($post_ID, 'url'));
     exit;
 }
 wp_enqueue_script('page');
 if (user_can_richedit()) {
     wp_enqueue_script('editor');
 }
 add_thickbox();
 wp_enqueue_script('media-upload');
 wp_enqueue_script('word-count');
 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'), wp_specialchars($last_user_name));
         $message = str_replace("'", "\\'", "<div class='error'><p>{$message}</p></div>");
         add_action('admin_notices', create_function('', "echo '{$message}';"));
     } else {
         wp_set_post_lock($post->ID);
         wp_enqueue_script('autosave');
     }
 }
 require_once 'admin-header.php';
 if (!current_user_can('edit_page', $page_ID)) {
     die(__('You are not allowed to edit this page.'));
 }
 include 'edit-page-form.php';
开发者ID:alx,项目名称:blogsfera,代码行数:31,代码来源:page.php


示例13: 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


示例14: explode

     $post_ids = explode(',', $_REQUEST['ids']);
 } elseif (!empty($_REQUEST['post'])) {
     $post_ids = array_map('intval', $_REQUEST['post']);
 }
 if (!isset($post_ids)) {
     wp_redirect($sendback);
     exit;
 }
 switch ($doaction) {
     case 'trash':
         $trashed = $locked = 0;
         foreach ((array) $post_ids as $post_id) {
             if (!current_user_can('delete_post', $post_id)) {
                 wp_die(__('You are not allowed to move this item to the Trash.'));
             }
             if (wp_check_post_lock($post_id)) {
                 $locked++;
                 continue;
             }
             if (!wp_trash_post($post_id)) {
                 wp_die(__('Error in moving to Trash.'));
             }
             $trashed++;
         }
         $sendback = add_query_arg(array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked), $sendback);
         break;
     case 'untrash':
         $untrashed = 0;
         foreach ((array) $post_ids as $post_id) {
             if (!current_user_can('delete_post', $post_id)) {
                 wp_die(__('You are not allowed to restore this item from the Trash.'));
开发者ID:valryb,项目名称:accelerate,代码行数:31,代码来源:edit.php


示例15: body_class

 function body_class($classes)
 {
     global $post;
     $classes[] = 'fee fee-off';
     require_once ABSPATH . '/wp-admin/includes/post.php';
     if (wp_check_post_lock($post->ID)) {
         $classes[] = 'fee-locked';
     }
     return $classes;
 }
开发者ID:foxpcteam,项目名称:wp-front-end-editor,代码行数:10,代码来源:class-fee.php


示例16: catch_page_load

 /**
  * Catches page loads, determines what to do, and sends users on their merry way
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  */
 function catch_page_load()
 {
     global $bp;
     if (!empty($_POST['doc-edit-submit'])) {
         $this_doc = new BP_Docs_Query();
         $this_doc->save();
     }
     if (!empty($_POST['docs-filter-submit'])) {
         $this->handle_filters();
     }
     // If this is the edit screen, ensure that the user can edit the
     // doc before querying, and redirect if necessary
     if (!empty($bp->bp_docs->current_view) && 'edit' == $bp->bp_docs->current_view) {
         if (bp_docs_current_user_can('edit')) {
             $doc = bp_docs_get_current_doc();
             // The user can edit, so we check for edit locks
             // Because we're not using WP autosave at the moment, ensure that
             // the lock interval always returns as in process
             add_filter('wp_check_post_lock_window', create_function(false, 'return time();'));
             $lock = wp_check_post_lock($doc->ID);
             if ($lock) {
                 bp_core_add_message(sprintf(__('This doc is currently being edited by %s. To prevent overwrites, you cannot edit until that user has finished. Please try again in a few minutes.', 'bp-docs'), bp_core_get_user_displayname($lock)), 'error');
                 $group_permalink = bp_get_group_permalink($bp->groups->current_group);
                 $doc_slug = $bp->bp_docs->doc_slug;
                 // Redirect back to the non-edit view of this document
                 bp_core_redirect($group_permalink . $bp->bp_docs->slug . '/' . $doc_slug);
             }
         } else {
             // The user does not have edit permission. Redirect.
             bp_core_add_message(__('You do not have permission to edit the doc.', 'bp-docs'), 'error');
             $group_permalink = bp_get_group_permalink($bp->groups->current_group);
             $doc_slug = $bp->bp_docs->doc_slug;
             // Redirect back to the non-edit view of this document
             bp_core_redirect($group_permalink . $bp->bp_docs->slug . '/' . $doc_slug);
         }
     }
     if (!empty($bp->bp_docs->current_view) && 'create' == $bp->bp_docs->current_view) {
         if (!bp_docs_current_user_can('create')) {
             // The user does not have edit permission. Redirect.
             bp_core_add_message(__('You do not have permission to create a Doc in this group.', 'bp-docs'), 'error');
             $group_permalink = bp_get_group_permalink($bp->groups->current_group);
             // Redirect back to the Doc list view
             bp_core_redirect($group_permalink . $bp->bp_docs->slug . '/');
         }
     }
     if (!empty($bp->bp_docs->current_view) && 'history' == $bp->bp_docs->current_view) {
         if (!bp_docs_current_user_can('view_history')) {
             // The user does not have edit permission. Redirect.
             bp_core_add_message(__('You do not have permission to view this Doc\'s history.', 'bp-docs'), 'error');
             $doc = bp_docs_get_current_doc();
             $redirect = bp_docs_get_doc_link($doc->ID);
             // Redirect back to the Doc list view
             bp_core_redirect($redirect);
         }
     }
     // Cancel edit lock
     if (!empty($_GET['bpd_action']) && $_GET['bpd_action'] == 'cancel_edit_lock') {
         // Check the nonce
         check_admin_referer('bp_docs_cancel_edit_lock');
         // Todo: make this part of the perms system
         if (is_super_admin() || bp_group_is_admin()) {
             $doc = bp_docs_get_current_doc();
             // Todo: get this into a proper method as well, blech
             delete_post_meta($doc->ID, '_edit_lock');
             bp_core_add_message(__('Lock successfully removed', 'bp-docs'));
             bp_core_redirect(bp_docs_get_doc_link($doc->ID));
         }
     }
     // Cancel edit
     // Have to have a catcher for this so the edit lock can be removed
     if (!empty($_GET['bpd_action']) && $_GET['bpd_action'] == 'cancel_edit') {
         $doc = bp_docs_get_current_doc();
         // Todo: get this into a proper method as well, blech
         delete_post_meta($doc->ID, '_edit_lock');
         bp_core_redirect(bp_docs_get_doc_link($doc->ID));
     }
     // Todo: get this into a proper method
     if ($bp->bp_docs->current_view == 'delete') {
         check_admin_referer('bp_docs_delete');
         if (bp_docs_current_user_can('manage')) {
             $the_doc_args = array('name' => $bp->action_variables[0], 'post_type' => $bp->bp_docs->post_type_name);
             $the_docs = get_posts($the_doc_args);
             $doc_id = $the_docs[0]->ID;
             do_action('bp_docs_before_doc_delete', $doc_id);
             $delete_args = array('ID' => $doc_id, 'post_status' => 'trash');
             wp_update_post($delete_args);
             do_action('bp_docs_doc_deleted', $delete_args);
             bp_core_add_message(__('Doc successfully deleted!', 'bp-docs'));
         } else {
             bp_core_add_message(__('You do not have permission to delete that doc.', 'bp-docs'), 'error');
         }
         // todo: abstract this out so I don't have to call group permalink here
         $redirect_url = bp_get_group_permalink($bp->groups->current_group) . $bp->bp_docs->slug . '/';
         bp_core_redirect($redirect_url);
//.........这里部分代码省略.........
开发者ID:Nightgunner5,项目名称:Pubcomp-CMS,代码行数:101,代码来源:integration-bp.php


示例17: get_the_id

			<a href="#" class="np-btn clone-post" data-id="<?php 
    echo get_the_id();
    ?>
" data-parentname="<?php 
    echo $this->post->title;
    ?>
"><?php 
    _e('Clone', 'nestedpages');
    ?>
</a>
			<?php 
}
?>

			<?php 
if (!($user = wp_check_post_lock($this->post->id) || !$this->integrations->plugins->editorial_access_manager->hasAccess($this->post->id))) {
    ?>
			<a href="#" 
				class="np-btn np-quick-edit" 
				data-id="<?php 
    echo $this->post->id;
    ?>
" 
				data-template="<?php 
    echo $this->post->template;
    ?>
" 
				data-title="<?php 
    echo $this->post->title;
    ?>
" 
开发者ID:dtwist,项目名称:wp-nested-pages,代码行数:31,代码来源:row.php


示例18: _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_type, $post_type_object;
     $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'])) {
         wp_set_post_lock($post_id);
         wp_redirect(get_edit_post_link($post_id, 'url'));
         exit;
     }
     $editing = TRUE;
     $post_ID = $post_id;
     $post = $post;
     $post_type = $this->_cpt_routes[$this->_req_action];
     $post_type_object = $this->_cpt_object;
     $is_IE = $is_IE;
     if (!wp_check_post_lock($post->ID)) {
         $active_post_lock = wp_set_post_lock($post->ID);
         //wp_enqueue_script('autosave');
     }
     $title = $this->_cpt_object->labels->edit_item;
     add_action('admin_footer', '_admin_notice_post_locked');
     if (isset($this->_cpt_routes[$this->_req_data['action']]) && !isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])) {
         $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this);
         $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array('action' => $create_new_action, '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'));
     //modify the default editor title field with default title.
     add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
     include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
 }
开发者ID:kaffiemetsuker,项目名称:event-espresso-core,代码行数:46,代码来源:EE_Admin_Page_CPT.core.php


示例19: start_el

 function start_el(&$output, $page, $depth, $args)
 {
     if ($depth) {
         $indent = str_repeat("\t", $depth);
     } else {
         $indent = '';
     }
     extract($args, EXTR_SKIP);
     // Post States
     $page_states = array();
     if ($user_id = wp_check_post_lock($page->ID)) {
         $user = get_userdata($user_id);
         $page_states['post-lock'] = sprintf(__('! %s is editing this page. Page order might be overwritten.', 'cms-page-order'), $user->display_name);
     }
     // Password protected?
     if (!empty($page->post_password)) {
         $page_states['password'] = __('Password protected', 'cms-page-order');
     }
     // Check post status, but skip published pages.
     if ($page->post_status !== 'publish') {
         $page_states[$page->post_status] = $page->post_status;
     }
     // Text for the labels
     foreach ($page_states as $state => $state_name) {
         // Don't list private pages if user is not allowed read them
         if ($state == 'private') {
             if (!current_user_can('read_private_pages')) {
                 return;
             }
         }
         if (in_array($state, array('private', 'draft', 'pending'))) {
             $page_states[$state] = __(ucfirst($state));
         } elseif ($state == 'future') {
             $page_states[$state] = __('Scheduled', 'cms-page-order');
         } elseif ($state !== 'password' && empty($state_name)) {
              

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_checkdate函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_check_password函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap