In edit-form-advanced.php
:
* `get_permalink( $post_ID )` can return `false`, set it to a variable and check it * Using the variable allows us to replace 11 separate calls to `get_permalink( $post_ID )` in the file * These notices were triggered by the potential for `false` to be passed to `esc_url()` See #30799. git-svn-id: https://develop.svn.wordpress.org/trunk@31131 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d4c4205f31
commit
358b309da9
@ -65,35 +65,40 @@ add_action( 'admin_footer', '_local_storage_notice' );
|
||||
/*
|
||||
* @todo Document the $messages array(s).
|
||||
*/
|
||||
$permalink = get_permalink( $post_ID );
|
||||
if ( ! $permalink ) {
|
||||
$permalink = '';
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
$messages['post'] = array(
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
1 => sprintf( __('Post updated. <a href="%s">View post</a>'), esc_url( get_permalink($post_ID) ) ),
|
||||
1 => sprintf( __('Post updated. <a href="%s">View post</a>'), esc_url( $permalink ) ),
|
||||
2 => __('Custom field updated.'),
|
||||
3 => __('Custom field deleted.'),
|
||||
4 => __('Post updated.'),
|
||||
/* translators: %s: date and time of the revision */
|
||||
5 => isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => sprintf( __('Post published. <a href="%s">View post</a>'), esc_url( get_permalink($post_ID) ) ),
|
||||
6 => sprintf( __('Post published. <a href="%s">View post</a>'), esc_url( $permalink ) ),
|
||||
7 => __('Post saved.'),
|
||||
8 => sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
|
||||
8 => sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
|
||||
9 => sprintf( __('Post scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview post</a>'),
|
||||
/* translators: Publish box date format, see http://php.net/date */
|
||||
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>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
|
||||
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ),
|
||||
10 => sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
|
||||
);
|
||||
$messages['page'] = array(
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
1 => sprintf( __('Page updated. <a href="%s">View page</a>'), esc_url( get_permalink($post_ID) ) ),
|
||||
1 => sprintf( __('Page updated. <a href="%s">View page</a>'), esc_url( $permalink ) ),
|
||||
2 => __('Custom field updated.'),
|
||||
3 => __('Custom field deleted.'),
|
||||
4 => __('Page updated.'),
|
||||
5 => isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => sprintf( __('Page published. <a href="%s">View page</a>'), esc_url( get_permalink($post_ID) ) ),
|
||||
6 => sprintf( __('Page published. <a href="%s">View page</a>'), esc_url( $permalink ) ),
|
||||
7 => __('Page saved.'),
|
||||
8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), 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>'), 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>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
|
||||
8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
|
||||
9 => sprintf( __('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ),
|
||||
10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
|
||||
);
|
||||
$messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated.' ) ); // Hack, for now.
|
||||
|
||||
@ -485,7 +490,7 @@ do_action( 'edit_form_before_permalink', $post );
|
||||
<?php
|
||||
$sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
|
||||
$shortlink = wp_get_shortlink($post->ID, 'post');
|
||||
$permalink = get_permalink( $post->ID );
|
||||
|
||||
if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) )
|
||||
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user