@@ -1376,7 +1376,7 @@ function postbox_classes( $box_id, $screen_id ) {
13761376 *
13771377 * @since 2.5.0
13781378 *
1379- * @param int|WP_Post $id Post ID or post object.
1379+ * @param int|WP_Post $post Post ID or post object.
13801380 * @param string|null $title Optional. Title to override the post's current title
13811381 * when generating the post name. Default null.
13821382 * @param string|null $name Optional. Name to override the post name. Default null.
@@ -1387,8 +1387,9 @@ function postbox_classes( $box_id, $screen_id ) {
13871387 * @type string $1 The post name.
13881388 * }
13891389 */
1390- function get_sample_permalink ( $ id , $ title = null , $ name = null ) {
1391- $ post = get_post ( $ id );
1390+ function get_sample_permalink ( $ post , $ title = null , $ name = null ) {
1391+ $ post = get_post ( $ post );
1392+
13921393 if ( ! $ post ) {
13931394 return array ( '' , '' );
13941395 }
@@ -1468,13 +1469,14 @@ function get_sample_permalink( $id, $title = null, $name = null ) {
14681469 *
14691470 * @since 2.5.0
14701471 *
1471- * @param int|WP_Post $id Post ID or post object.
1472+ * @param int|WP_Post $post Post ID or post object.
14721473 * @param string|null $new_title Optional. New title. Default null.
14731474 * @param string|null $new_slug Optional. New slug. Default null.
14741475 * @return string The HTML of the sample permalink slug editor.
14751476 */
1476- function get_sample_permalink_html ( $ id , $ new_title = null , $ new_slug = null ) {
1477- $ post = get_post ( $ id );
1477+ function get_sample_permalink_html ( $ post , $ new_title = null , $ new_slug = null ) {
1478+ $ post = get_post ( $ post );
1479+
14781480 if ( ! $ post ) {
14791481 return '' ;
14801482 }
@@ -1511,7 +1513,7 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
15111513
15121514 // Encourage a pretty permalink setting.
15131515 if ( ! get_option ( 'permalink_structure ' ) && current_user_can ( 'manage_options ' )
1514- && ! ( 'page ' === get_option ( 'show_on_front ' ) && get_option ( 'page_on_front ' ) == $ id )
1516+ && ! ( 'page ' === get_option ( 'show_on_front ' ) && get_option ( 'page_on_front ' ) == $ post -> ID )
15151517 ) {
15161518 $ return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small"> ' . __ ( 'Change Permalink Structure ' ) . "</a></span> \n" ;
15171519 }
@@ -1628,17 +1630,19 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
16281630 *
16291631 * @since 2.5.0
16301632 *
1631- * @param int|WP_Post $post_id ID or object of the post to check for editing.
1633+ * @param int|WP_Post $post ID or object of the post to check for editing.
16321634 * @return int|false ID of the user with lock. False if the post does not exist, post is not locked,
16331635 * the user with lock does not exist, or the post is locked by current user.
16341636 */
1635- function wp_check_post_lock ( $ post_id ) {
1636- $ post = get_post ( $ post_id );
1637+ function wp_check_post_lock ( $ post ) {
1638+ $ post = get_post ( $ post );
1639+
16371640 if ( ! $ post ) {
16381641 return false ;
16391642 }
16401643
16411644 $ lock = get_post_meta ( $ post ->ID , '_edit_lock ' , true );
1645+
16421646 if ( ! $ lock ) {
16431647 return false ;
16441648 }
@@ -1666,7 +1670,7 @@ function wp_check_post_lock( $post_id ) {
16661670 *
16671671 * @since 2.5.0
16681672 *
1669- * @param int|WP_Post $post_id ID or object of the post being edited.
1673+ * @param int|WP_Post $post ID or object of the post being edited.
16701674 * @return array|false {
16711675 * Array of the lock time and user ID. False if the post does not exist, or there
16721676 * is no current user.
@@ -1675,13 +1679,15 @@ function wp_check_post_lock( $post_id ) {
16751679 * @type int $1 The ID of the current user.
16761680 * }
16771681 */
1678- function wp_set_post_lock ( $ post_id ) {
1679- $ post = get_post ( $ post_id );
1682+ function wp_set_post_lock ( $ post ) {
1683+ $ post = get_post ( $ post );
1684+
16801685 if ( ! $ post ) {
16811686 return false ;
16821687 }
16831688
16841689 $ user_id = get_current_user_id ();
1690+
16851691 if ( 0 == $ user_id ) {
16861692 return false ;
16871693 }
@@ -1701,12 +1707,14 @@ function wp_set_post_lock( $post_id ) {
17011707 */
17021708function _admin_notice_post_locked () {
17031709 $ post = get_post ();
1710+
17041711 if ( ! $ post ) {
17051712 return ;
17061713 }
17071714
17081715 $ user = null ;
17091716 $ user_id = wp_check_post_lock ( $ post ->ID );
1717+
17101718 if ( $ user_id ) {
17111719 $ user = get_userdata ( $ user_id );
17121720 }
@@ -1936,6 +1944,7 @@ function post_preview() {
19361944 $ _POST ['ID ' ] = $ post_ID ;
19371945
19381946 $ post = get_post ( $ post_ID );
1947+
19391948 if ( ! $ post ) {
19401949 wp_die ( __ ( 'Sorry, you are not allowed to edit this post. ' ) );
19411950 }
0 commit comments