Changeset 47808 for trunk/src/wp-admin/includes/post.php
- Timestamp:
- 05/16/2020 06:40:52 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r47557 r47808 31 31 32 32 if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) { 33 if ( 'page' == $post_data['post_type'] ) {33 if ( 'page' === $post_data['post_type'] ) { 34 34 return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); 35 35 } else { … … 37 37 } 38 38 } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { 39 if ( 'page' == $post_data['post_type'] ) {39 if ( 'page' === $post_data['post_type'] ) { 40 40 return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); 41 41 } else { … … 76 76 77 77 if ( $update ) { 78 if ( 'page' == $post_data['post_type'] ) {78 if ( 'page' === $post_data['post_type'] ) { 79 79 return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) ); 80 80 } else { … … 82 82 } 83 83 } else { 84 if ( 'page' == $post_data['post_type'] ) {84 if ( 'page' === $post_data['post_type'] ) { 85 85 return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) ); 86 86 } else { … … 104 104 105 105 // What to do based on which button they pressed. 106 if ( isset( $post_data['saveasdraft'] ) && '' != $post_data['saveasdraft'] ) {106 if ( isset( $post_data['saveasdraft'] ) && '' !== $post_data['saveasdraft'] ) { 107 107 $post_data['post_status'] = 'draft'; 108 108 } 109 if ( isset( $post_data['saveasprivate'] ) && '' != $post_data['saveasprivate'] ) {109 if ( isset( $post_data['saveasprivate'] ) && '' !== $post_data['saveasprivate'] ) { 110 110 $post_data['post_status'] = 'private'; 111 111 } 112 if ( isset( $post_data['publish'] ) && ( '' != $post_data['publish'] ) && ( ! isset( $post_data['post_status'] ) || 'private' !== $post_data['post_status'] ) ) { 112 if ( isset( $post_data['publish'] ) && ( '' !== $post_data['publish'] ) 113 && ( ! isset( $post_data['post_status'] ) || 'private' !== $post_data['post_status'] ) 114 ) { 113 115 $post_data['post_status'] = 'publish'; 114 116 } 115 if ( isset( $post_data['advanced'] ) && '' != $post_data['advanced'] ) {117 if ( isset( $post_data['advanced'] ) && '' !== $post_data['advanced'] ) { 116 118 $post_data['post_status'] = 'draft'; 117 119 } 118 if ( isset( $post_data['pending'] ) && '' != $post_data['pending'] ) {120 if ( isset( $post_data['pending'] ) && '' !== $post_data['pending'] ) { 119 121 $post_data['post_status'] = 'pending'; 120 122 } … … 127 129 $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false; 128 130 129 if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) {131 if ( isset( $post_data['post_status'] ) && 'private' === $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) { 130 132 $post_data['post_status'] = $previous_status ? $previous_status : 'pending'; 131 133 } … … 248 250 $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); 249 251 250 if ( 'inherit' == $post_data['post_status'] ) {252 if ( 'inherit' === $post_data['post_status'] ) { 251 253 unset( $post_data['post_status'] ); 252 254 } … … 255 257 $ptype = get_post_type_object( $post_data['post_type'] ); 256 258 if ( ! current_user_can( 'edit_post', $post_ID ) ) { 257 if ( 'page' == $post_data['post_type'] ) {259 if ( 'page' === $post_data['post_type'] ) { 258 260 wp_die( __( 'Sorry, you are not allowed to edit this page.' ) ); 259 261 } else { … … 377 379 378 380 // Attachment stuff. 379 if ( 'attachment' == $post_data['post_type'] ) {381 if ( 'attachment' === $post_data['post_type'] ) { 380 382 if ( isset( $post_data['_wp_attachment_image_alt'] ) ) { 381 383 $image_alt = wp_unslash( $post_data['_wp_attachment_image_alt'] ); … … 468 470 469 471 if ( ! current_user_can( $ptype->cap->edit_posts ) ) { 470 if ( 'page' == $ptype->name ) {472 if ( 'page' === $ptype->name ) { 471 473 wp_die( __( 'Sorry, you are not allowed to edit pages.' ) ); 472 474 } else { … … 486 488 $post_data['post_status'] = sanitize_key( $post_data['post_status'] ); 487 489 488 if ( 'inherit' == $post_data['post_status'] ) {490 if ( 'inherit' === $post_data['post_status'] ) { 489 491 unset( $post_data['post_status'] ); 490 492 } … … 509 511 510 512 foreach ( $reset as $field ) { 511 if ( isset( $post_data[ $field ] ) && ( '' == $post_data[ $field ] || -1 == $post_data[ $field ] ) ) {513 if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || -1 == $post_data[ $field ] ) ) { 512 514 unset( $post_data[ $field ] ); 513 515 } … … 633 635 634 636 if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) { 635 if ( 'sticky' == $post_data['sticky'] ) {637 if ( 'sticky' === $post_data['sticky'] ) { 636 638 stick_post( $post_ID ); 637 639 } else { … … 814 816 815 817 if ( ! current_user_can( $ptype->cap->edit_posts ) ) { 816 if ( 'page' == $ptype->name ) {818 if ( 'page' === $ptype->name ) { 817 819 return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) ); 818 820 } else { … … 913 915 } 914 916 915 if ( ( ( '#NONE#' != $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) {917 if ( ( ( '#NONE#' !== $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) { 916 918 /* 917 919 * We have a key/value pair. If both the select and the input 918 920 * for the key have data, the input takes precedence. 919 921 */ 920 if ( '#NONE#' != $metakeyselect ) {922 if ( '#NONE#' !== $metakeyselect ) { 921 923 $metakey = $metakeyselect; 922 924 } … … 1144 1146 if ( isset( $q['order'] ) ) { 1145 1147 $order = $q['order']; 1146 } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) {1148 } elseif ( isset( $q['post_status'] ) && 'pending' === $q['post_status'] ) { 1147 1149 $order = 'ASC'; 1148 1150 } … … 1221 1223 } 1222 1224 1223 $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;1224 $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states;1225 $q['post_status'] = isset( $q['status'] ) && 'trash' === $q['status'] ? 'trash' : $states; 1226 $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' === $q['attachment-filter'] ? 'trash' : $states; 1225 1227 1226 1228 $media_per_page = (int) get_user_option( 'upload_per_page' ); … … 1244 1246 1245 1247 foreach ( array_keys( $post_mime_types ) as $type ) { 1246 if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) {1248 if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" === $q['attachment-filter'] ) { 1247 1249 $q['post_mime_type'] = $type; 1248 1250 break; … … 1250 1252 } 1251 1253 1252 if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) {1254 if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' === $q['attachment-filter'] ) ) { 1253 1255 $q['post_parent'] = 0; 1254 1256 } 1255 1257 1256 if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' == $q['attachment-filter'] ) ) {1258 if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' === $q['attachment-filter'] ) ) { 1257 1259 $q['author'] = get_current_user_id(); 1258 1260 } … … 1459 1461 1460 1462 // Encourage a pretty permalink setting. 1461 if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && ! ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $id ) ) { 1463 if ( ! get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) 1464 && ! ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $id ) 1465 ) { 1462 1466 $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __( 'Change Permalinks' ) . "</a></span>\n"; 1463 1467 } … … 1683 1687 $sendback = admin_url( 'edit.php' ); 1684 1688 1685 if ( 'post' != $post->post_type ) {1689 if ( 'post' !== $post->post_type ) { 1686 1690 $sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); 1687 1691 } … … 1701 1705 $query_args = array(); 1702 1706 if ( get_post_type_object( $post->post_type )->public ) { 1703 if ( 'publish' == $post->post_status || $user->ID != $post->post_author ) {1707 if ( 'publish' === $post->post_status || $user->ID != $post->post_author ) { 1704 1708 // Latest content is in autosave. 1705 1709 $nonce = wp_create_nonce( 'post_preview_' . $post->ID ); … … 1889 1893 $is_autosave = false; 1890 1894 1891 if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'draft' == $post->post_status || 'auto-draft' == $post->post_status ) ) { 1895 if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author 1896 && ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) 1897 ) { 1892 1898 $saved_post_id = edit_post(); 1893 1899 } else { 1894 1900 $is_autosave = true; 1895 1901 1896 if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) {1902 if ( isset( $_POST['post_status'] ) && 'auto-draft' === $_POST['post_status'] ) { 1897 1903 $_POST['post_status'] = 'draft'; 1898 1904 } … … 1954 1960 } 1955 1961 1956 if ( 'auto-draft' == $post->post_status ) {1962 if ( 'auto-draft' === $post->post_status ) { 1957 1963 $post_data['post_status'] = 'draft'; 1958 1964 } … … 1962 1968 } 1963 1969 1964 if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) { 1970 if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author 1971 && ( 'auto-draft' === $post->post_status || 'draft' === $post->post_status ) 1972 ) { 1965 1973 // Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked. 1966 1974 return edit_post( wp_slash( $post_data ) ); … … 1995 2003 } 1996 2004 } else { 1997 $message = 'draft' == $status ? 10 : 1;2005 $message = 'draft' === $status ? 10 : 1; 1998 2006 } 1999 2007
Note: See TracChangeset
for help on using the changeset viewer.