本文整理汇总了PHP中get_post_to_edit函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_to_edit函数的具体用法?PHP get_post_to_edit怎么用?PHP get_post_to_edit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_to_edit函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: checkConversion
/**
* Check POST date for convert object on an another custom type.
*
* @return void
* @author Amaury Balmer
*/
function checkConversion()
{
if (isset($_POST['custom-type-convert']) && $_POST['custom-type-convert'] == '1') {
check_admin_referer('convert-post_type');
foreach ((array) $_POST['objects'] as $object_id => $new_post_type) {
// Change the post type
$object = get_post_to_edit($object_id);
$object->post_type = $new_post_type;
wp_update_post((array) $object);
// Clean object cache
clean_post_cache($object_id);
}
return true;
}
return false;
}
开发者ID:newinsites,项目名称:Wordpress-Starter,代码行数:22,代码来源:class.admin.conversion.php
示例2: listenConversion
/**
* Listen POST datas for make bulk posts conversion to new post type
*/
function listenConversion()
{
global $pagenow, $wpdb;
if ($pagenow != 'edit.php') {
return false;
}
// Default values for CPT
$typenow = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : 'post';
if (isset($_REQUEST['action']) && substr($_REQUEST['action'], 0, strlen('convert_cpt')) == 'convert_cpt') {
check_admin_referer('bulk-posts');
// Source CPT
$source_cpt = get_post_type_object($typenow);
if (!current_user_can($source_cpt->cap->edit_posts)) {
wp_die(__('Cheatin’ uh?'));
}
// Destination CPT
$destination_cpt = get_post_type_object(substr($_REQUEST['action'], strlen('convert_cpt') + 1));
if (!current_user_can($destination_cpt->cap->edit_posts)) {
wp_die(__('Cheatin’ uh?'));
}
// Loop on posts
foreach ((array) $_REQUEST['post'] as $post_id) {
// Change the post type
$object = get_post_to_edit($post_id);
$object->post_type = $destination_cpt->name;
wp_update_post((array) $object);
// Clean object cache
clean_post_cache($post_id);
}
$location = 'edit.php?post_type=' . $typenow;
if ($referer = wp_get_referer()) {
if (false !== strpos($referer, 'edit.php')) {
$location = $referer;
}
}
$location = add_query_arg('message', 991, $location);
wp_redirect($location);
exit;
}
}
开发者ID:nico1989,项目名称:amillion,代码行数:43,代码来源:class.admin.conversion.php
示例3: __
wp_redirect($location);
exit();
break;
case 'edit':
$title = __('Edit');
require_once('admin-header.php');
$post_ID = $p = (int) $_GET['post'];
if ( !current_user_can('edit_post', $post_ID) )
die ( __('You are not allowed to edit this post.') );
$post = get_post_to_edit($post_ID);
if ($post->post_status == 'static')
include('edit-page-form.php');
else
include('edit-form-advanced.php');
?>
<div id='preview' class='wrap'>
<h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit ↑'); ?></a></small></h2>
<iframe src="<?php echo attribute_escape(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
</div>
<?php
break;
case 'editattachment':
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:30,代码来源:post.php
示例4: wp_upload_form
function wp_upload_form() {
$id = get_the_ID();
global $post_id, $tab, $style;
$enctype = $id ? '' : ' enctype="multipart/form-data"';
$post_id = (int) $post_id;
?>
<form<?php echo $enctype; ?> id="upload-file" method="post" action="<?php echo get_option('siteurl') . '/wp-admin/upload.php?style=' . attribute_escape($style . '&tab=upload&post_id=' . $post_id); ?>">
<?php
if ( $id ) :
$attachment = get_post_to_edit( $id );
$attachment_data = wp_get_attachment_metadata( $id );
?>
<div id="file-title">
<h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
the_title();
if ( !isset($attachment_data['width']) && 'inline' != $style )
echo '</a>';
?></h2>
<span><?php
echo '[ ';
echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
echo ' | ';
echo '<a href="' . clean_url(add_query_arg('action', 'view')) . '">' . __('links') . '</a>';
echo ' | ';
echo '<a href="' . clean_url(remove_query_arg(array('action','ID'))) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
echo ' ]'; ?></span>
</div>
<div id="upload-file-view" class="alignleft">
<?php if ( isset($attachment_data['width']) && 'inline' != $style )
echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
echo wp_upload_display( array(171, 128) );
if ( isset($attachment_data['width']) && 'inline' != $style )
echo '</a>'; ?>
</div>
<?php endif; ?>
<table><col /><col class="widefat" />
<?php if ( $id ): ?>
<tr>
<th scope="row"><label for="url"><?php _e('URL'); ?></label></th>
<td><input type="text" id="url" class="readonly" value="<?php echo wp_get_attachment_url(); ?>" readonly="readonly" /></td>
</tr>
<?php else : ?>
<tr>
<th scope="row"><label for="upload"><?php _e('File'); ?></label></th>
<td><input type="file" id="upload" name="image" /></td>
</tr>
<?php endif; ?>
<tr>
<th scope="row"><label for="post_title"><?php _e('Title'); ?></label></th>
<td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="post_content"><?php _e('Description'); ?></label></th>
<td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
</tr>
<tr id="buttons" class="submit">
<td colspan='2'>
<?php if ( $id ) : ?>
<input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" />
<?php endif; ?>
<input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
<input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
<?php if ( $post_id ) : ?>
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
<?php endif; if ( $id ) : ?>
<input type="hidden" name="ID" value="<?php echo $id; ?>" />
<?php endif; ?>
<?php wp_nonce_field( 'inlineuploading' ); ?>
<div class="submit">
<input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?> »" />
</div>
</td>
</tr>
</table>
</form>
<?php
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:79,代码来源:upload-functions.php
示例5: add_action
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 ($last = wp_check_post_lock($post->ID)) {
add_action('admin_notices', '_admin_notice_post_locked');
} else {
wp_set_post_lock($post->ID);
wp_enqueue_script('autosave');
}
$title = $post_type_object->labels->edit_item;
$post = get_post_to_edit($post_id);
if (post_type_supports($post_type, 'comments')) {
wp_enqueue_script('admin-comments');
enqueue_comment_hotkeys_js();
}
include './edit-form-advanced.php';
break;
case 'editattachment':
check_admin_referer('update-attachment_' . $post_id);
// Don't let these be changed
unset($_POST['guid']);
$_POST['post_type'] = 'attachment';
// Update the thumbnail filename
$newmeta = wp_get_attachment_metadata($post_id, true);
$newmeta['thumb'] = $_POST['thumb'];
wp_update_attachment_metadata($post_id, $newmeta);
开发者ID:fka2004,项目名称:webkit,代码行数:31,代码来源:post.php
示例6: get_post
private function get_post($post_ID)
{
$post = get_post_to_edit($post_ID);
if (empty($post->ID)) {
$this->base->ks_die(__("You attempted to edit a post that doesn't exist. Perhaps it was deleted?"));
}
if ('post' != $post->post_type) {
$this->admin->redirect(get_edit_post_link($post->ID, 'url'));
exit;
}
return $post;
}
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:12,代码来源:post.php
示例7: edit_products_copy_action
function edit_products_copy_action()
{
$action = 'copy-product';
if (isset($_GET['action']) && $_GET['action'] == "copy-product") {
$sendback_href = remove_query_arg(array('_wpnonce', 'mp-action', 'post', 'trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer());
if (isset($_GET['post'])) {
$product_id = intval($_GET['post']);
} else {
wp_redirect($sendback_href);
}
if (isset($_GET['post_type'])) {
$post_type = esc_attr($_GET['post_type']);
} else {
wp_redirect($sendback_href);
}
if (!isset($_GET['_wpnonce']) || !wp_verify_nonce($_GET['_wpnonce'], "{$action}-{$post_type}_{$product_id}")) {
wp_redirect($sendback_href);
}
$product = (array) get_post_to_edit($product_id);
$product['ID'] = 0;
// Zero out the Product ID to force insert of new item
$product['post_status'] = 'draft';
$product['post_author'] = get_current_user_id();
$new_product_id = wp_insert_post($product);
if ($new_product_id && !is_wp_error(${$new_product_id})) {
//If we have the a valid new product ID we copy the product meta...
$product_meta_keys = get_post_custom_keys($product_id);
if (!empty($product_meta_keys)) {
foreach ($product_meta_keys as $meta_key) {
$meta_values = get_post_custom_values($meta_key, $product_id);
foreach ($meta_values as $meta_value) {
$meta_value = maybe_unserialize($meta_value);
add_post_meta($new_product_id, $meta_key, $meta_value);
}
}
}
// ... thne we copy the product taxonomy terms
$product_taxonomies = get_object_taxonomies($post_type);
if (!empty($product_taxonomies)) {
foreach ($product_taxonomies as $product_taxonomy) {
$product_terms = wp_get_object_terms($product_id, $product_taxonomy, array('orderby' => 'term_order'));
if ($product_terms && count($product_terms)) {
$terms = array();
foreach ($product_terms as $product_term) {
$terms[] = $product_term->slug;
}
}
wp_set_object_terms($new_product_id, $terms, $product_taxonomy);
}
}
}
}
wp_redirect($sendback_href);
die;
}
开发者ID:vilmark,项目名称:vilmark_main,代码行数:55,代码来源:marketpress.php
注:本文中的get_post_to_edit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论