23 if ( empty($post_data) ) |
23 if ( empty($post_data) ) |
24 $post_data = &$_POST; |
24 $post_data = &$_POST; |
25 |
25 |
26 if ( $update ) |
26 if ( $update ) |
27 $post_data['ID'] = (int) $post_data['post_ID']; |
27 $post_data['ID'] = (int) $post_data['post_ID']; |
|
28 |
|
29 $ptype = get_post_type_object( $post_data['post_type'] ); |
|
30 |
|
31 if ( $update && ! current_user_can( $ptype->cap->edit_post, $post_data['ID'] ) ) { |
|
32 if ( 'page' == $post_data['post_type'] ) |
|
33 return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) ); |
|
34 else |
|
35 return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) ); |
|
36 } elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) { |
|
37 if ( 'page' == $post_data['post_type'] ) |
|
38 return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
|
39 else |
|
40 return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
|
41 } |
28 |
42 |
29 if ( isset( $post_data['content'] ) ) |
43 if ( isset( $post_data['content'] ) ) |
30 $post_data['post_content'] = $post_data['content']; |
44 $post_data['post_content'] = $post_data['content']; |
31 |
45 |
32 if ( isset( $post_data['excerpt'] ) ) |
46 if ( isset( $post_data['excerpt'] ) ) |
49 } else { |
63 } else { |
50 $post_data['post_author'] = (int) $post_data['user_ID']; |
64 $post_data['post_author'] = (int) $post_data['user_ID']; |
51 } |
65 } |
52 } |
66 } |
53 |
67 |
54 $ptype = get_post_type_object( $post_data['post_type'] ); |
68 if ( ! $update && isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] ) |
55 if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) { |
69 && ! current_user_can( $ptype->cap->edit_others_posts ) ) { |
56 if ( !current_user_can( $ptype->cap->edit_others_posts ) ) { |
70 |
57 if ( 'page' == $post_data['post_type'] ) { |
71 if ( 'page' == $post_data['post_type'] ) |
58 return new WP_Error( 'edit_others_pages', $update ? |
72 return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) ); |
59 __( 'You are not allowed to edit pages as this user.' ) : |
73 else |
60 __( 'You are not allowed to create pages as this user.' ) |
74 return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) ); |
61 ); |
|
62 } else { |
|
63 return new WP_Error( 'edit_others_posts', $update ? |
|
64 __( 'You are not allowed to edit posts as this user.' ) : |
|
65 __( 'You are not allowed to post as this user.' ) |
|
66 ); |
|
67 } |
|
68 } |
|
69 } |
75 } |
70 |
76 |
71 // What to do based on which button they pressed |
77 // What to do based on which button they pressed |
72 if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
78 if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) |
73 $post_data['post_status'] = 'draft'; |
79 $post_data['post_status'] = 'draft'; |
121 $jj = ($jj <= 0 ) ? date('j') : $jj; |
127 $jj = ($jj <= 0 ) ? date('j') : $jj; |
122 $hh = ($hh > 23 ) ? $hh -24 : $hh; |
128 $hh = ($hh > 23 ) ? $hh -24 : $hh; |
123 $mn = ($mn > 59 ) ? $mn -60 : $mn; |
129 $mn = ($mn > 59 ) ? $mn -60 : $mn; |
124 $ss = ($ss > 59 ) ? $ss -60 : $ss; |
130 $ss = ($ss > 59 ) ? $ss -60 : $ss; |
125 $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); |
131 $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); |
|
132 $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); |
|
133 if ( !$valid_date ) { |
|
134 return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) ); |
|
135 } |
126 $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); |
136 $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); |
127 } |
137 } |
128 |
138 |
129 return $post_data; |
139 return $post_data; |
130 } |
140 } |
156 wp_die( __('You are not allowed to edit this page.' )); |
166 wp_die( __('You are not allowed to edit this page.' )); |
157 else |
167 else |
158 wp_die( __('You are not allowed to edit this post.' )); |
168 wp_die( __('You are not allowed to edit this post.' )); |
159 } |
169 } |
160 |
170 |
161 // Autosave shouldn't save too soon after a real save |
|
162 if ( 'autosave' == $post_data['action'] ) { |
|
163 $post =& get_post( $post_ID ); |
|
164 $now = time(); |
|
165 $then = strtotime($post->post_date_gmt . ' +0000'); |
|
166 $delta = AUTOSAVE_INTERVAL / 2; |
|
167 if ( ($now - $then) < $delta ) |
|
168 return $post_ID; |
|
169 } |
|
170 |
|
171 $post_data = _wp_translate_postdata( true, $post_data ); |
171 $post_data = _wp_translate_postdata( true, $post_data ); |
172 if ( is_wp_error($post_data) ) |
172 if ( is_wp_error($post_data) ) |
173 wp_die( $post_data->get_error_message() ); |
173 wp_die( $post_data->get_error_message() ); |
174 if ( 'autosave' != $post_data['action'] && 'auto-draft' == $post_data['post_status'] ) |
174 if ( ( empty( $post_data['action'] ) || 'autosave' != $post_data['action'] ) && 'auto-draft' == $post_data['post_status'] ) { |
175 $post_data['post_status'] = 'draft'; |
175 $post_data['post_status'] = 'draft'; |
|
176 } |
176 |
177 |
177 if ( isset($post_data['visibility']) ) { |
178 if ( isset($post_data['visibility']) ) { |
178 switch ( $post_data['visibility'] ) { |
179 switch ( $post_data['visibility'] ) { |
179 case 'public' : |
180 case 'public' : |
180 $post_data['post_password'] = ''; |
181 $post_data['post_password'] = ''; |
221 continue; |
222 continue; |
222 delete_meta( $key ); |
223 delete_meta( $key ); |
223 } |
224 } |
224 } |
225 } |
225 |
226 |
|
227 // Attachment stuff |
|
228 if ( 'attachment' == $post_data['post_type'] ) { |
|
229 if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) { |
|
230 $image_alt = get_post_meta( $post_ID, '_wp_attachment_image_alt', true ); |
|
231 if ( $image_alt != stripslashes( $post_data['_wp_attachment_image_alt'] ) ) { |
|
232 $image_alt = wp_strip_all_tags( stripslashes( $post_data['_wp_attachment_image_alt'] ), true ); |
|
233 // update_meta expects slashed |
|
234 update_post_meta( $post_ID, '_wp_attachment_image_alt', addslashes( $image_alt ) ); |
|
235 } |
|
236 } |
|
237 |
|
238 $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array(); |
|
239 $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data ); |
|
240 } |
|
241 |
226 add_meta( $post_ID ); |
242 add_meta( $post_ID ); |
227 |
243 |
228 update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); |
244 update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); |
229 |
245 |
230 wp_update_post( $post_data ); |
246 wp_update_post( $post_data ); |
437 $post->post_pingback = get_option( 'default_pingback_flag' ); |
453 $post->post_pingback = get_option( 'default_pingback_flag' ); |
438 $post->post_category = get_option( 'default_category' ); |
454 $post->post_category = get_option( 'default_category' ); |
439 $post->page_template = 'default'; |
455 $post->page_template = 'default'; |
440 $post->post_parent = 0; |
456 $post->post_parent = 0; |
441 $post->menu_order = 0; |
457 $post->menu_order = 0; |
|
458 $post = new WP_Post( $post ); |
442 } |
459 } |
443 |
460 |
444 $post->post_content = apply_filters( 'default_content', $post_content, $post ); |
461 $post->post_content = apply_filters( 'default_content', $post_content, $post ); |
445 $post->post_title = apply_filters( 'default_title', $post_title, $post ); |
462 $post->post_title = apply_filters( 'default_title', $post_title, $post ); |
446 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); |
463 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post ); |
448 |
465 |
449 return $post; |
466 return $post; |
450 } |
467 } |
451 |
468 |
452 /** |
469 /** |
453 * Get the default page information to use. |
|
454 * |
|
455 * @since 2.5.0 |
|
456 * |
|
457 * @return object stdClass object containing all the default post data as attributes |
|
458 */ |
|
459 function get_default_page_to_edit() { |
|
460 $page = get_default_post_to_edit(); |
|
461 $page->post_type = 'page'; |
|
462 return $page; |
|
463 } |
|
464 |
|
465 /** |
|
466 * Get an existing post and format it for editing. |
|
467 * |
|
468 * @since 2.0.0 |
|
469 * |
|
470 * @param unknown_type $id |
|
471 * @return unknown |
|
472 */ |
|
473 function get_post_to_edit( $id ) { |
|
474 |
|
475 $post = get_post( $id, OBJECT, 'edit' ); |
|
476 |
|
477 if ( $post->post_type == 'page' ) |
|
478 $post->page_template = get_post_meta( $id, '_wp_page_template', true ); |
|
479 |
|
480 return $post; |
|
481 } |
|
482 |
|
483 /** |
|
484 * Determine if a post exists based on title, content, and date |
470 * Determine if a post exists based on title, content, and date |
485 * |
471 * |
486 * @since 2.0.0 |
472 * @since 2.0.0 |
487 * |
473 * |
488 * @param string $title Post title |
474 * @param string $title Post title |
743 * |
729 * |
744 * @param unknown_type $post_ID |
730 * @param unknown_type $post_ID |
745 * @return unknown |
731 * @return unknown |
746 */ |
732 */ |
747 function _fix_attachment_links( $post_ID ) { |
733 function _fix_attachment_links( $post_ID ) { |
748 $post = & get_post( $post_ID, ARRAY_A ); |
734 $post = get_post( $post_ID, ARRAY_A ); |
749 $content = $post['post_content']; |
735 $content = $post['post_content']; |
750 |
736 |
751 // quick sanity check, don't run if no pretty permalinks or post is not published |
737 // quick sanity check, don't run if no pretty permalinks or post is not published |
752 if ( !get_option('permalink_structure') || $post['post_status'] != 'publish' ) |
738 if ( !get_option('permalink_structure') || $post['post_status'] != 'publish' ) |
753 return; |
739 return; |
891 |
877 |
892 return $avail_post_stati; |
878 return $avail_post_stati; |
893 } |
879 } |
894 |
880 |
895 /** |
881 /** |
896 * Get default post mime types |
|
897 * |
|
898 * @since 2.9.0 |
|
899 * |
|
900 * @return array |
|
901 */ |
|
902 function get_post_mime_types() { |
|
903 $post_mime_types = array( // array( adj, noun ) |
|
904 'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')), |
|
905 'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')), |
|
906 'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')), |
|
907 ); |
|
908 |
|
909 return apply_filters('post_mime_types', $post_mime_types); |
|
910 } |
|
911 |
|
912 /** |
|
913 * {@internal Missing Short Description}} |
882 * {@internal Missing Short Description}} |
914 * |
883 * |
915 * @since 2.5.0 |
884 * @since 2.5.0 |
916 * |
885 * |
917 * @param unknown_type $type |
886 * @param unknown_type $type |
923 $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); |
892 $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); |
924 return $types; |
893 return $types; |
925 } |
894 } |
926 |
895 |
927 /** |
896 /** |
928 * {@internal Missing Short Description}} |
897 * Executes a query for attachments. An array of WP_Query arguments |
|
898 * can be passed in, which will override the arguments set by this function. |
929 * |
899 * |
930 * @since 2.5.0 |
900 * @since 2.5.0 |
931 * |
901 * @uses apply_filters() Calls 'upload_per_page' on posts_per_page argument |
932 * @param unknown_type $q |
902 * |
933 * @return unknown |
903 * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal. |
|
904 * @return array |
934 */ |
905 */ |
935 function wp_edit_attachments_query( $q = false ) { |
906 function wp_edit_attachments_query( $q = false ) { |
936 if ( false === $q ) |
907 if ( false === $q ) |
937 $q = $_GET; |
908 $q = $_GET; |
938 |
909 |
1008 * @param string $title (optional) Title |
979 * @param string $title (optional) Title |
1009 * @param string $name (optional) Name |
980 * @param string $name (optional) Name |
1010 * @return array With two entries of type string |
981 * @return array With two entries of type string |
1011 */ |
982 */ |
1012 function get_sample_permalink($id, $title = null, $name = null) { |
983 function get_sample_permalink($id, $title = null, $name = null) { |
1013 $post = &get_post($id); |
984 $post = get_post($id); |
1014 if ( !$post->ID ) |
985 if ( !$post->ID ) |
1015 return array('', ''); |
986 return array('', ''); |
1016 |
987 |
1017 $ptype = get_post_type_object($post->post_type); |
988 $ptype = get_post_type_object($post->post_type); |
1018 |
989 |
1061 |
1032 |
1062 return $permalink; |
1033 return $permalink; |
1063 } |
1034 } |
1064 |
1035 |
1065 /** |
1036 /** |
1066 * sample permalink html |
1037 * Returns the HTML of the sample permalink slug editor. |
1067 * |
|
1068 * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. |
|
1069 * |
1038 * |
1070 * @since 2.5.0 |
1039 * @since 2.5.0 |
1071 * |
1040 * |
1072 * @param int|object $id Post ID or post object. |
1041 * @param int|object $id Post ID or post object. |
1073 * @param string $new_title (optional) New title |
1042 * @param string $new_title Optional. New title. |
1074 * @param string $new_slug (optional) New slug |
1043 * @param string $new_slug Optional. New slug. |
1075 * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. |
1044 * @return string The HTML of the sample permalink slug editor. |
1076 */ |
1045 */ |
1077 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
1046 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { |
1078 global $wpdb; |
1047 global $wpdb; |
1079 $post = &get_post($id); |
1048 $post = get_post($id); |
1080 |
1049 |
1081 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
1050 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); |
1082 |
1051 |
1083 if ( 'publish' == $post->post_status ) { |
1052 if ( 'publish' == get_post_status( $post ) ) { |
1084 $ptype = get_post_type_object($post->post_type); |
1053 $ptype = get_post_type_object($post->post_type); |
1085 $view_post = $ptype->labels->view_item; |
1054 $view_post = $ptype->labels->view_item; |
1086 $title = __('Click to edit this part of the permalink'); |
1055 $title = __('Click to edit this part of the permalink'); |
1087 } else { |
1056 } else { |
1088 $title = __('Temporary permalink. Click to edit this part.'); |
1057 $title = __('Temporary permalink. Click to edit this part.'); |
1089 } |
1058 } |
1090 |
1059 |
1091 if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { |
1060 if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { |
1092 $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n"; |
1061 $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n"; |
1093 if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) |
1062 if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) |
1094 $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; |
1063 $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; |
1095 if ( isset($view_post) ) |
1064 if ( isset( $view_post ) ) |
1096 $return .= "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n"; |
1065 $return .= "<span id='view-post-btn'><a href='$permalink' class='button button-small'>$view_post</a></span>\n"; |
1097 |
1066 |
1098 $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); |
1067 $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); |
1099 |
1068 |
1100 return $return; |
1069 return $return; |
1101 } |
1070 } |
1116 |
1085 |
1117 $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>'; |
1086 $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>'; |
1118 $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); |
1087 $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); |
1119 $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); |
1088 $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); |
1120 $return = '<strong>' . __('Permalink:') . "</strong>\n"; |
1089 $return = '<strong>' . __('Permalink:') . "</strong>\n"; |
1121 $return .= '<span id="sample-permalink">' . $display_link . "</span>\n"; |
1090 $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n"; |
1122 $return .= '‎'; // Fix bi-directional text display defect in RTL languages. |
1091 $return .= '‎'; // Fix bi-directional text display defect in RTL languages. |
1123 $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n"; |
1092 $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n"; |
1124 $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; |
1093 $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; |
1125 if ( isset($view_post) ) |
1094 if ( isset($view_post) ) |
1126 $return .= "<span id='view-post-btn'><a href='$view_link' class='button' target='_blank'>$view_post</a></span>\n"; |
1095 $return .= "<span id='view-post-btn'><a href='$view_link' class='button button-small'>$view_post</a></span>\n"; |
1127 |
1096 |
1128 $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); |
1097 $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); |
1129 |
1098 |
1130 return $return; |
1099 return $return; |
1131 } |
1100 } |
1134 * Output HTML for the post thumbnail meta-box. |
1103 * Output HTML for the post thumbnail meta-box. |
1135 * |
1104 * |
1136 * @since 2.9.0 |
1105 * @since 2.9.0 |
1137 * |
1106 * |
1138 * @param int $thumbnail_id ID of the attachment used for thumbnail |
1107 * @param int $thumbnail_id ID of the attachment used for thumbnail |
1139 * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID |
1108 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. |
1140 * @return string html |
1109 * @return string html |
1141 */ |
1110 */ |
1142 function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) { |
1111 function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { |
1143 global $content_width, $_wp_additional_image_sizes, $post_ID; |
1112 global $content_width, $_wp_additional_image_sizes; |
1144 |
1113 |
1145 if ( empty( $post_id ) ) |
1114 $post = get_post( $post ); |
1146 $post_id = $post_ID; |
1115 |
1147 |
1116 $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) ); |
1148 $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post_id) ); |
|
1149 $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>'; |
1117 $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>'; |
1150 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) ); |
1118 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) ); |
1151 |
1119 |
1152 if ( $thumbnail_id && get_post( $thumbnail_id ) ) { |
1120 if ( $thumbnail_id && get_post( $thumbnail_id ) ) { |
1153 $old_content_width = $content_width; |
1121 $old_content_width = $content_width; |
1155 if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) |
1123 if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) |
1156 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) ); |
1124 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) ); |
1157 else |
1125 else |
1158 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); |
1126 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); |
1159 if ( !empty( $thumbnail_html ) ) { |
1127 if ( !empty( $thumbnail_html ) ) { |
1160 $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" ); |
1128 $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); |
1161 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html ); |
1129 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html ); |
1162 $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>'; |
1130 $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>'; |
1163 } |
1131 } |
1164 $content_width = $old_content_width; |
1132 $content_width = $old_content_width; |
1165 } |
1133 } |
1166 |
1134 |
1167 return apply_filters( 'admin_post_thumbnail_html', $content ); |
1135 return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID ); |
1168 } |
1136 } |
1169 |
1137 |
1170 /** |
1138 /** |
1171 * Check to see if the post is currently being edited by another user. |
1139 * Check to see if the post is currently being edited by another user. |
1172 * |
1140 * |
1220 * |
1188 * |
1221 * @since 2.8.5 |
1189 * @since 2.8.5 |
1222 * @return none |
1190 * @return none |
1223 */ |
1191 */ |
1224 function _admin_notice_post_locked() { |
1192 function _admin_notice_post_locked() { |
1225 global $post; |
1193 $post = get_post(); |
1226 |
|
1227 $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); |
1194 $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); |
1228 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); |
1195 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); |
1229 $last_user = get_userdata( $user ); |
1196 $last_user = get_userdata( $user ); |
1230 $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); |
1197 $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); |
1231 |
1198 |