Changeset 34170
- Timestamp:
- 09/15/2015 04:14:23 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/edit-form-advanced.php
r34016 r34170 82 82 83 83 $messages = array(); 84 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 85 $post_preview_url = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $permalink ), $post ); 84 $post_preview_url = get_preview_post_link( $post ); 86 85 87 86 $preview_link_html = $scheduled_link_html = $view_post_html = ''; … … 126 125 ); 127 126 128 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 129 $page_preview_url = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $permalink ), $post ); 127 $page_preview_url = get_preview_post_link( $post ); 130 128 131 129 $messages['page'] = array( -
trunk/src/wp-admin/includes/ajax-actions.php
r34163 r34170 1528 1528 check_ajax_referer( 'getpermalink', 'getpermalinknonce' ); 1529 1529 $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; 1530 wp_die( add_query_arg( array( 'preview' => 'true' ), get_permalink( $post_id )) );1530 wp_die( get_preview_post_link( $post_id ) ); 1531 1531 } 1532 1532 -
trunk/src/wp-admin/includes/class-wp-posts-list-table.php
r34084 r34170 1158 1158 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { 1159 1159 if ( $can_edit_post ) { 1160 $ preview_link = set_url_scheme( get_permalink( $post->ID) );1160 $unpublished_link = set_url_scheme( get_permalink( $post ) ); 1161 1161 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 1162 $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post);1162 $preview_link = get_preview_post_link( $post, array(), $unpublished_link ); 1163 1163 $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>'; 1164 1164 } -
trunk/src/wp-admin/includes/meta-boxes.php
r34069 r34170 41 41 <div id="preview-action"> 42 42 <?php 43 $preview_link = esc_url( get_preview_post_link( $post ) ); 43 44 if ( 'publish' == $post->post_status ) { 44 $preview_link = esc_url( get_permalink( $post->ID ) );45 45 $preview_button = __( 'Preview Changes' ); 46 46 } else { 47 $preview_link = set_url_scheme( get_permalink( $post->ID ) );48 49 /**50 * Filter the URI of a post preview in the post submit box.51 *52 * @since 2.0.553 * @since 4.0.0 $post parameter was added.54 *55 * @param string $preview_link URI the user will be directed to for a post preview.56 * @param WP_Post $post Post object.57 */58 $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ) );59 47 $preview_button = __( 'Preview' ); 60 48 } -
trunk/src/wp-admin/includes/post.php
r34020 r34170 1319 1319 if ( isset( $view_post ) ) { 1320 1320 if ( 'draft' == $post->post_status ) { 1321 $ preview_link = set_url_scheme( get_permalink( $post->ID ) );1321 $draft_link = set_url_scheme( get_permalink( $post->ID ) ); 1322 1322 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 1323 $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post);1323 $preview_link = get_preview_post_link( $post, array(), $draft_link ); 1324 1324 $return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n"; 1325 1325 } else { … … 1512 1512 1513 1513 if ( $locked ) { 1514 $query_args = array(); 1514 1515 if ( get_post_type_object( $post->post_type )->public ) { 1515 $preview_link = set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) );1516 1517 1516 if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) { 1518 1517 // Latest content is in autosave 1519 1518 $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); 1520 $preview_link = add_query_arg( array( 'preview_id' => $post->ID, 'preview_nonce' => $nonce ), $preview_link ); 1519 $query_args['preview_id'] = $post->ID; 1520 $query_args['preview_nonce'] = $nonce; 1521 1521 } 1522 } else { 1523 $preview_link = ''; 1524 } 1525 1526 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 1527 $preview_link = apply_filters( 'preview_post_link', $preview_link, $post ); 1522 } 1523 1524 $preview_link = get_preview_post_link( $post->ID, $query_args ); 1528 1525 1529 1526 /** … … 1711 1708 wp_die( $saved_post_id->get_error_message() ); 1712 1709 1713 $query_args = array( 'preview' => 'true');1710 $query_args = array(); 1714 1711 1715 1712 if ( $is_autosave && $saved_post_id ) { … … 1721 1718 } 1722 1719 1723 $url = add_query_arg( $query_args, get_permalink( $post->ID ) ); 1724 1725 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 1726 return apply_filters( 'preview_post_link', $url, $post ); 1720 return get_preview_post_link( $post, $query_args ); 1727 1721 } 1728 1722 -
trunk/src/wp-includes/admin-bar.php
r34122 r34170 551 551 { 552 552 if ( 'draft' == $post->post_status ) { 553 $preview_link = set_url_scheme( get_permalink( $post->ID ) ); 554 /** This filter is documented in wp-admin/includes/meta-boxes.php */ 555 $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ); 553 $draft_link = set_url_scheme( get_permalink( $post->ID ) ); 554 $preview_link = get_preview_post_link( $post, array(), $draft_link ); 556 555 $wp_admin_bar->add_menu( array( 557 556 'id' => 'preview', -
trunk/src/wp-includes/link-template.php
r34160 r34170 1160 1160 1161 1161 /** 1162 * Retrieve preview post link. 1163 * 1164 * Get the preview post URL. Allow any number of query args to be appended. 1165 * 1166 * @since 4.4.0 1167 * 1168 * @param int $post Optional. Post ID or WP_Post object. Defaults to global post. 1169 * @param array $query_args Optional. If preview query arg should be added. Or array of query args to be added. 1170 * @param string $preview_link Optional. If a link other than the permalink should be used. Used by _wp_link_page. 1171 * @return string 1172 */ 1173 function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) { 1174 $post = get_post( $post ); 1175 if ( ! $post ) { 1176 return; 1177 } 1178 1179 $post_type_object = get_post_type_object( $post->post_type ); 1180 if ( is_post_type_viewable( $post_type_object ) ) { 1181 if ( ! $preview_link ) { 1182 $preview_link = get_permalink( $post ); 1183 } 1184 1185 $query_args['preview'] = true; 1186 $preview_link = add_query_arg( $query_args, $preview_link ); 1187 } 1188 1189 /** 1190 * Filter the URI of a post preview in the post submit box. 1191 * 1192 * @since 2.0.5 1193 * @since 4.4.0 $post parameter was added. 1194 * 1195 * @param string $preview_link URI the user will be directed to for a post preview. 1196 * @param WP_Post $post Post object. 1197 */ 1198 return apply_filters( 'preview_post_link', $preview_link, $post ); 1199 } 1200 1201 /** 1162 1202 * Retrieve edit posts link for post. 1163 1203 * -
trunk/src/wp-includes/post-template.php
r34109 r34170 900 900 global $wp_rewrite; 901 901 $post = get_post(); 902 $query_args = array(); 902 903 903 904 if ( 1 == $i ) { … … 913 914 914 915 if ( is_preview() ) { 915 $url = add_query_arg( array(916 'preview' => 'true'917 ), $url );918 916 919 917 if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) { 920 $ url = add_query_arg( array(921 'preview_id' => wp_unslash( $_GET['preview_id'] ),922 'preview_nonce' => wp_unslash( $_GET['preview_nonce'] )923 ), $url ); 924 }918 $query_args['preview_id'] = wp_unslash( $_GET['preview_id'] ); 919 $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] ); 920 } 921 922 $url = get_preview_post_link( $post, $query_args, $url ); 925 923 } 926 924
Note: See TracChangeset
for help on using the changeset viewer.