本文整理汇总了PHP中get_preview_post_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_preview_post_link函数的具体用法?PHP get_preview_post_link怎么用?PHP get_preview_post_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_preview_post_link函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: post_preview
/**
* Save draft or manually autosave for showing preview.
*
* @package WordPress
* @since 2.7.0
*
* @return str URL to redirect to show the preview
*/
function post_preview()
{
$post_ID = (int) $_POST['post_ID'];
$_POST['ID'] = $post_ID;
if (!($post = get_post($post_ID))) {
wp_die(__('Sorry, you are not allowed to edit this post.'));
}
if (!current_user_can('edit_post', $post->ID)) {
wp_die(__('Sorry, you are not allowed to edit this post.'));
}
$is_autosave = false;
if (!wp_check_post_lock($post->ID) && get_current_user_id() == $post->post_author && ('draft' == $post->post_status || 'auto-draft' == $post->post_status)) {
$saved_post_id = edit_post();
} else {
$is_autosave = true;
if (isset($_POST['post_status']) && 'auto-draft' == $_POST['post_status']) {
$_POST['post_status'] = 'draft';
}
$saved_post_id = wp_create_post_autosave($post->ID);
}
if (is_wp_error($saved_post_id)) {
wp_die($saved_post_id->get_error_message());
}
$query_args = array();
if ($is_autosave && $saved_post_id) {
$query_args['preview_id'] = $post->ID;
$query_args['preview_nonce'] = wp_create_nonce('post_preview_' . $post->ID);
if (isset($_POST['post_format'])) {
$query_args['post_format'] = empty($_POST['post_format']) ? 'standard' : sanitize_key($_POST['post_format']);
}
if (isset($_POST['_thumbnail_id'])) {
$query_args['_thumbnail_id'] = intval($_POST['_thumbnail_id']) <= 0 ? '-1' : intval($_POST['_thumbnail_id']);
}
}
return get_preview_post_link($post, $query_args);
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:44,代码来源:post.php
示例2: wpnt_add_new_tab_link
function wpnt_add_new_tab_link($actions, $page_object)
{
global $post;
if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
$unpublished_link = set_url_scheme(get_permalink($post));
$preview_link = get_preview_post_link($post, array(), $unpublished_link);
$actions['view_new_tab'] = '<a href="' . esc_url($preview_link) . '" rel="permalink" target="_blank">' . __('Preview In New Tab') . '</a>';
} elseif ('trash' != $post->post_status) {
$actions['view_new_tab'] = '<a href="' . get_permalink($post->ID) . '" rel="permalink" target="_blank">' . __('View In New Tab') . '</a>';
}
return $actions;
}
开发者ID:josephfusco,项目名称:wp-new-tab,代码行数:12,代码来源:wp-new-tab.php
示例3: wp_ajax_get_permalink
/**
* Ajax handler to retrieve a permalink.
*
* @since 3.1.0
*/
function wp_ajax_get_permalink()
{
check_ajax_referer('getpermalink', 'getpermalinknonce');
$post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
wp_die(get_preview_post_link($post_id));
}
开发者ID:hughnet,项目名称:WordPress,代码行数:11,代码来源:ajax-actions.php
示例4: _wp_link_page
/**
* Helper function for wp_link_pages().
*
* @since 3.1.0
* @access private
*
* @global WP_Rewrite $wp_rewrite
*
* @param int $i Page number.
* @return string Link.
*/
function _wp_link_page($i)
{
global $wp_rewrite;
$post = get_post();
$query_args = array();
if (1 == $i) {
$url = get_permalink();
} else {
if ('' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending'))) {
$url = add_query_arg('page', $i, get_permalink());
} elseif ('page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID) {
$url = trailingslashit(get_permalink()) . user_trailingslashit("{$wp_rewrite->pagination_base}/" . $i, 'single_paged');
} else {
$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
}
}
if (is_preview()) {
if ('draft' !== $post->post_status && isset($_GET['preview_id'], $_GET['preview_nonce'])) {
$query_args['preview_id'] = wp_unslash($_GET['preview_id']);
$query_args['preview_nonce'] = wp_unslash($_GET['preview_nonce']);
}
$url = get_preview_post_link($post, $query_args, $url);
}
return '<a href="' . esc_url($url) . '">';
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:36,代码来源:post-template.php
示例5: handle_row_actions
/**
* Generates and displays row action links.
*
* @since 4.3.0
* @access protected
*
* @param object $post Post being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for posts.
*/
protected function handle_row_actions($post, $column_name, $primary)
{
if ($primary !== $column_name) {
return '';
}
$post_type_object = get_post_type_object($post->post_type);
$can_edit_post = current_user_can('edit_post', $post->ID);
$actions = array();
$title = _draft_or_post_title();
if ($can_edit_post && 'trash' != $post->post_status) {
$actions['edit'] = sprintf('<a href="%s" aria-label="%s">%s</a>', get_edit_post_link($post->ID), esc_attr(sprintf(__('Edit “%s”'), $title)), __('Edit'));
$actions['inline hide-if-no-js'] = sprintf('<a href="#" class="editinline" aria-label="%s">%s</a>', esc_attr(sprintf(__('Quick edit “%s” inline'), $title)), __('Quick Edit'));
}
if (current_user_can('delete_post', $post->ID)) {
if ('trash' === $post->post_status) {
$actions['untrash'] = sprintf('<a href="%s" aria-label="%s">%s</a>', wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID)), 'untrash-post_' . $post->ID), esc_attr(sprintf(__('Restore “%s” from the Trash'), $title)), __('Restore'));
} elseif (EMPTY_TRASH_DAYS) {
$actions['trash'] = sprintf('<a href="%s" class="submitdelete" aria-label="%s">%s</a>', get_delete_post_link($post->ID), esc_attr(sprintf(__('Move “%s” to the Trash'), $title)), _x('Trash', 'verb'));
}
if ('trash' === $post->post_status || !EMPTY_TRASH_DAYS) {
$actions['delete'] = sprintf('<a href="%s" class="submitdelete" aria-label="%s">%s</a>', get_delete_post_link($post->ID, '', true), esc_attr(sprintf(__('Delete “%s” permanently'), $title)), __('Delete Permanently'));
}
}
if (is_post_type_viewable($post_type_object)) {
if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
if ($can_edit_post) {
$unpublished_link = set_url_scheme(get_permalink($post));
$preview_link = get_preview_post_link($post, array(), $unpublished_link);
$actions['view'] = sprintf('<a href="%s" rel="permalink" aria-label="%s">%s</a>', esc_url($preview_link), esc_attr(sprintf(__('Preview “%s”'), $title)), __('Preview'));
}
} elseif ('trash' != $post->post_status) {
$actions['view'] = sprintf('<a href="%s" rel="permalink" aria-label="%s">%s</a>', get_permalink($post->ID), esc_attr(sprintf(__('View “%s”'), $title)), __('View'));
}
}
if (is_post_type_hierarchical($post->post_type)) {
/**
* Filter the array of row action links on the Pages list table.
*
* The filter is evaluated only for hierarchical post types.
*
* @since 2.8.0
*
* @param array $actions An array of row action links. Defaults are
* 'Edit', 'Quick Edit', 'Restore, 'Trash',
* 'Delete Permanently', 'Preview', and 'View'.
* @param WP_Post $post The post object.
*/
$actions = apply_filters('page_row_actions', $actions, $post);
} else {
/**
* Filter the array of row action links on the Posts list table.
*
* The filter is evaluated only for non-hierarchical post types.
*
* @since 2.8.0
*
* @param array $actions An array of row action links. Defaults are
* 'Edit', 'Quick Edit', 'Restore, 'Trash',
* 'Delete Permanently', 'Preview', and 'View'.
* @param WP_Post $post The post object.
*/
$actions = apply_filters('post_row_actions', $actions, $post);
}
return $this->row_actions($actions);
}
开发者ID:dd32,项目名称:wordpress.develop,代码行数:76,代码来源:class-wp-posts-list-table.php
示例6: post_submit_meta_box
/**
* Displays post submit form fields.
*
* @since 2.7.0
*
* @global string $action
*
* @param WP_Post $post Current post object.
* @param array $args {
* Array of arguments for building the post submit meta box.
*
* @type string $id Meta box ID.
* @type string $title Meta box title.
* @type callable $callback Meta box display callback.
* @type array $args Extra meta box arguments.
* }
*/
function post_submit_meta_box($post, $args = array())
{
global $action;
$post_type = $post->post_type;
$post_type_object = get_post_type_object($post_type);
$can_publish = current_user_can($post_type_object->cap->publish_posts);
?>
<div class="submitbox" id="submitpost">
<div id="minor-publishing">
<?php
// Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key
?>
<div style="display:none;">
<?php
submit_button(__('Save'), 'button', 'save');
?>
</div>
<div id="minor-publishing-actions">
<div id="save-action">
<?php
if ('publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status) {
?>
<input <?php
if ('private' == $post->post_status) {
?>
style="display:none"<?php
}
?>
type="submit" name="save" id="save-post" value="<?php
esc_attr_e('Save Draft');
?>
" class="button" />
<span class="spinner"></span>
<?php
} elseif ('pending' == $post->post_status && $can_publish) {
?>
<input type="submit" name="save" id="save-post" value="<?php
esc_attr_e('Save as Pending');
?>
" class="button" />
<span class="spinner"></span>
<?php
}
?>
</div>
<?php
if (is_post_type_viewable($post_type_object)) {
?>
<div id="preview-action">
<?php
$preview_link = esc_url(get_preview_post_link($post));
if ('publish' == $post->post_status) {
$preview_button = __('Preview Changes');
} else {
$preview_button = __('Preview');
}
?>
<a class="preview button" href="<?php
echo $preview_link;
?>
" target="wp-preview-<?php
echo (int) $post->ID;
?>
" id="post-preview"><?php
echo $preview_button;
?>
</a>
<input type="hidden" name="wp-preview" id="wp-preview" value="" />
</div>
<?php
}
// public post type
/**
* Fires before the post time/date setting in the Publish meta box.
*
* @since 4.4.0
*
* @param WP_Post $post WP_Post object for the current post.
*/
do_action('post_submitbox_minor_actions', $post);
//.........这里部分代码省略.........
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:101,代码来源:meta-boxes.php
示例7: add_thickbox
add_thickbox();
wp_enqueue_media(array('post' => $post_ID));
}
// Add the local autosave notice HTML
add_action('admin_footer', '_local_storage_notice');
/*
* @todo Document the $messages array(s).
*/
$permalink = get_permalink($post_ID);
if (!$permalink) {
$permalink = '';
}
$messages = array();
$preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = '';
$preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = '';
$preview_url = get_preview_post_link($post);
$viewable = is_post_type_viewable($post_type_object);
if ($viewable) {
// Preview post link.
$preview_post_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($preview_url), __('Preview post'));
// Scheduled post preview link.
$scheduled_post_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($permalink), __('Preview post'));
// View post link.
$view_post_link_html = sprintf(' <a href="%1$s">%2$s</a>', esc_url($permalink), __('View post'));
// Preview page link.
$preview_page_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($preview_url), __('Preview page'));
// Scheduled page preview link.
$scheduled_page_link_html = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($permalink), __('Preview page'));
// View page link.
$view_page_link_html = sprintf(' <a href="%1$s">%2$s</a>', esc_url($permalink), __('View page'));
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:31,代码来源:edit-form-advanced.php
示例8: wp_admin_bar_edit_menu
/**
* Provide an edit link for posts and terms.
*
* @since 3.1.0
*
* @global WP_Term $tag
* @global WP_Query $wp_the_query
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function wp_admin_bar_edit_menu($wp_admin_bar)
{
global $tag, $wp_the_query;
if (is_admin()) {
$current_screen = get_current_screen();
$post = get_post();
if ('post' == $current_screen->base && 'add' != $current_screen->action && ($post_type_object = get_post_type_object($post->post_type)) && current_user_can('read_post', $post->ID) && $post_type_object->public && $post_type_object->show_in_admin_bar) {
if ('draft' == $post->post_status) {
$preview_link = get_preview_post_link($post);
$wp_admin_bar->add_menu(array('id' => 'preview', 'title' => $post_type_object->labels->view_item, 'href' => esc_url($preview_link), 'meta' => array('target' => 'wp-preview-' . $post->ID)));
} else {
$wp_admin_bar->add_menu(array('id' => 'view', 'title' => $post_type_object->labels->view_item, 'href' => get_permalink($post->ID)));
}
} elseif ('term' == $current_screen->base && isset($tag) && is_object($tag) && !is_wp_error($tag) && ($tax = get_taxonomy($tag->taxonomy)) && $tax->public) {
$wp_admin_bar->add_menu(array('id' => 'view', 'title' => $tax->labels->view_item, 'href' => get_term_link($tag)));
}
} else {
$current_object = $wp_the_query->get_queried_object();
if (empty($current_object)) {
return;
}
if (!empty($current_object->post_type) && ($post_type_object = get_post_type_object($current_object->post_type)) && current_user_can('edit_post', $current_object->ID) && $post_type_object->show_in_admin_bar && ($edit_post_link = get_edit_post_link($current_object->ID))) {
$wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $post_type_object->labels->edit_item, 'href' => $edit_post_link));
} elseif (!empty($current_object->taxonomy) && ($tax = get_taxonomy($current_object->taxonomy)) && current_user_can($tax->cap->edit_terms) && ($edit_term_link = get_edit_term_link($current_object->term_id, $current_object->taxonomy))) {
$wp_admin_bar->add_menu(array('id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => $edit_term_link));
}
}
}
开发者ID:Garth619,项目名称:Femi9,代码行数:38,代码来源:admin-bar.php
示例9: ccp_post_updated_messages
/**
* Adds custom post updated messages on the edit post screen.
*
* @since 1.0.0
* @access public
* @param array $messages
* @global object $post
* @global int $post_ID
* @return array
*/
function ccp_post_updated_messages($messages)
{
global $post, $post_ID;
$project_type = ccp_get_project_post_type();
if ($project_type !== $post->post_type) {
return $messages;
}
// Get permalink and preview URLs.
$permalink = get_permalink($post_ID);
$preview_url = function_exists('get_preview_post_link') ? get_preview_post_link($post) : apply_filters('preview_post_link', add_query_arg(array('preview' => true), $permalink), $post);
// Translators: Scheduled project date format. See http://php.net/date
$scheduled_date = date_i18n(__('M j, Y @ H:i', 'custom-content-portfolio'), strtotime($post->post_date));
// Set up view links.
$preview_link = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($preview_url), esc_html__('Preview project', 'custom-content-portfolio'));
$scheduled_link = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($permalink), esc_html__('Preview project', 'custom-content-portfolio'));
$view_link = sprintf(' <a href="%1$s">%2$s</a>', esc_url($permalink), esc_html__('View project', 'custom-content-portfolio'));
// Post updated messages.
$messages[$project_type] = array(1 => esc_html__('Project updated.', 'custom-content-portfolio') . $view_link, 4 => esc_html__('Project updated.', 'custom-content-portfolio'), 5 => isset($_GET['revision']) ? sprintf(esc_html__('Project restored to revision from %s.', 'custom-content-portfolio'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => esc_html__('Project published.', 'custom-content-portfolio') . $view_link, 7 => esc_html__('Project saved.', 'custom-content-portfolio'), 8 => esc_html__('Project submitted.', 'custom-content-portfolio') . $preview_link, 9 => sprintf(esc_html__('Project scheduled for: %s.', 'custom-content-portfolio'), "<strong>{$scheduled_date}</strong>") . $scheduled_link, 10 => esc_html__('Project draft updated.', 'custom-content-portfolio') . $preview_link);
return $messages;
}
开发者ID:kraftner,项目名称:custom-content-portfolio,代码行数:30,代码来源:functions-post-types.php
示例10: test_get_sample_permalink_html_should_use_preview_links_for_draft_and_pending_posts_with_no_post_name
/**
* @ticket 30910
* @ticket 18306
*/
public function test_get_sample_permalink_html_should_use_preview_links_for_draft_and_pending_posts_with_no_post_name()
{
$this->set_permalink_structure('/%postname%/');
wp_set_current_user(self::$admin_id);
$future_date = date('Y-m-d H:i:s', time() + 100);
$p = self::factory()->post->create(array('post_status' => 'pending', 'post_name' => '', 'post_date' => $future_date));
$found = get_sample_permalink_html($p);
$post = get_post($p);
$this->assertContains('href="' . esc_url(get_preview_post_link($post)), $found);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:14,代码来源:includesPost.php
示例11: test_get_preview_post_link_should_return_empty_string_for_non_viewable_post_type
public function test_get_preview_post_link_should_return_empty_string_for_non_viewable_post_type()
{
$post_type = register_post_type(rand_str(12), array('public' => false));
$post = self::factory()->post->create(array('post_type' => $post_type->name));
$this->assertSame('', get_preview_post_link($post));
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:6,代码来源:getPreviewPostLink.php
示例12: thds_post_updated_messages
/**
* Adds custom post updated messages on the edit post screen.
*
* @since 1.0.0
* @access public
* @param array $messages
* @global object $post
* @global int $post_ID
* @return array
*/
function thds_post_updated_messages($messages)
{
global $post, $post_ID;
$theme_type = thds_get_theme_post_type();
if ($theme_type !== $post->post_type) {
return $messages;
}
// Get permalink and preview URLs.
$permalink = get_permalink($post_ID);
$preview_url = get_preview_post_link($post);
// Translators: Scheduled theme date format. See http://php.net/date
$scheduled_date = date_i18n(__('M j, Y @ H:i', 'theme-designer'), strtotime($post->post_date));
// Set up view links.
$preview_link = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($preview_url), esc_html__('Preview theme', 'theme-designer'));
$scheduled_link = sprintf(' <a target="_blank" href="%1$s">%2$s</a>', esc_url($permalink), esc_html__('Preview theme', 'theme-designer'));
$view_link = sprintf(' <a href="%1$s">%2$s</a>', esc_url($permalink), esc_html__('View theme', 'theme-designer'));
// Post updated messages.
$messages[$theme_type] = array(1 => esc_html__('Theme updated.', 'theme-designer') . $view_link, 4 => esc_html__('Theme updated.', 'theme-designer'), 5 => isset($_GET['revision']) ? sprintf(esc_html__('Theme restored to revision from %s.', 'theme-designer'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => esc_html__('Theme published.', 'theme-designer') . $view_link, 7 => esc_html__('Theme saved.', 'theme-designer'), 8 => esc_html__('Theme submitted.', 'theme-designer') . $preview_link, 9 => sprintf(esc_html__('Theme scheduled for: %s.', 'theme-designer'), "<strong>{$scheduled_date}</strong>") . $scheduled_link, 10 => esc_html__('Theme draft updated.', 'theme-designer') . $preview_link);
return $messages;
}
开发者ID:grvrulz,项目名称:theme-designer,代码行数:30,代码来源:post-types.php
示例13: col_connection
/**
* Output column data for a Posts 2 Posts connection.
*
* @param string $connection The ID of the connection type
* @param array $args Optional. Array of arguments for a given connection type
*/
public function col_connection($connection, array $args = array())
{
global $post, $wp_query;
if (!function_exists('p2p_type')) {
return;
}
if (!$this->p2p_connection_exists($connection)) {
echo esc_html(sprintf(__('Invalid connection type: %s', 'extended-cpts'), $connection));
return;
}
$_post = $post;
$meta = $out = array();
$field = 'connected_' . $connection;
if (isset($args['field']) && isset($args['value'])) {
$meta = array('connected_meta' => array($args['field'] => $args['value']));
$field .= sanitize_title('_' . $args['field'] . '_' . $args['value']);
}
if (!isset($_post->{$field})) {
if ($type = p2p_type($connection)) {
$type->each_connected($wp_query, $meta, $field);
} else {
echo esc_html(sprintf(__('Invalid connection type: %s', 'extended-cpts'), $connection));
return;
}
}
foreach ($_post->{$field} as $post) {
setup_postdata($post);
$pto = get_post_type_object($post->post_type);
$pso = get_post_status_object($post->post_status);
if ($pso->protected && !current_user_can('edit_post', $post->ID)) {
continue;
}
if ('trash' == $post->post_status) {
continue;
}
if ($args['link']) {
switch ($args['link']) {
case 'view':
if ($pto->public) {
if ($pso->protected) {
$out[] = sprintf('<a href="%1$s">%2$s</a>', esc_url(get_preview_post_link()), esc_html(get_the_title()));
} else {
$out[] = sprintf('<a href="%1$s">%2$s</a>', esc_url(get_permalink()), esc_html(get_the_title()));
}
} else {
$out[] = esc_html(get_the_title());
}
break;
case 'edit':
if (current_user_can('edit_post', $post->ID)) {
$out[] = sprintf('<a href="%1$s">%2$s</a>', esc_url(get_edit_post_link()), esc_html(get_the_title()));
} else {
$out[] = esc_html(get_the_title());
}
break;
case 'list':
$link = add_query_arg(array_merge(array('post_type' => $_post->post_type, 'connected_type' => $connection, 'connected_items' => $post->ID), $meta), admin_url('edit.php'));
$out[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($link), esc_html(get_the_title()));
break;
}
} else {
$out[] = esc_html(get_the_title());
}
}
$post = $_post;
// WPCS: override ok.
echo implode(', ', $out);
// WPCS: XSS ok.
}
开发者ID:avclark,项目名称:extended-cpts,代码行数:75,代码来源:extended-cpts.php
注:本文中的get_preview_post_link函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论