Changeset 4478
- Timestamp:
- 11/18/2006 06:09:48 AM (18 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r4418 r4478 3 3 function write_post() { 4 4 $result = wp_write_post(); 5 if( is_wp_error( $result) )5 if( is_wp_error( $result ) ) 6 6 wp_die( $result->get_error_message() ); 7 7 else … … 14 14 15 15 if ( 'page' == $_POST['post_type'] ) { 16 if ( !current_user_can( 'edit_pages') )17 return new WP_Error( 'edit_pages', __('You are not allowed to create pages on this blog.'));18 } else { 19 if ( !current_user_can( 'edit_posts') )20 return new WP_Error( 'edit_posts', __('You are not allowed to create posts or drafts on this blog.'));16 if ( !current_user_can( 'edit_pages' ) ) 17 return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) ); 18 } else { 19 if ( !current_user_can( 'edit_posts' ) ) 20 return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) ); 21 21 } 22 22 … … 27 27 $_POST['to_ping'] = $_POST['trackback_url']; 28 28 29 if (!empty ( $_POST['post_author_override'])) {29 if (!empty ( $_POST['post_author_override'] ) ) { 30 30 $_POST['post_author'] = (int) $_POST['post_author_override']; 31 31 } else { 32 if (!empty ( $_POST['post_author'])) {32 if (!empty ( $_POST['post_author'] ) ) { 33 33 $_POST['post_author'] = (int) $_POST['post_author']; 34 34 } else { … … 38 38 } 39 39 40 if ( $_POST['post_author'] != $_POST['user_ID']) {40 if ( $_POST['post_author'] != $_POST['user_ID'] ) { 41 41 if ( 'page' == $_POST['post_type'] ) { 42 if ( !current_user_can( 'edit_others_pages') )43 return new WP_Error( 'edit_others_pages', __('You cannot create pages as this user.'));42 if ( !current_user_can( 'edit_others_pages' ) ) 43 return new WP_Error( 'edit_others_pages', __( 'You cannot create pages as this user.' ) ); 44 44 } else { 45 if ( !current_user_can( 'edit_others_posts') )46 return new WP_Error( 'edit_others_posts', __('You cannot post as this user.'));45 if ( !current_user_can( 'edit_others_posts' ) ) 46 return new WP_Error( 'edit_others_posts', __( 'You cannot post as this user.' ) ); 47 47 48 48 } … … 50 50 51 51 // What to do based on which button they pressed 52 if ('' != $_POST['saveasdraft'] )52 if ('' != $_POST['saveasdraft'] ) 53 53 $_POST['post_status'] = 'draft'; 54 if ('' != $_POST['saveasprivate'] )54 if ('' != $_POST['saveasprivate'] ) 55 55 $_POST['post_status'] = 'private'; 56 if ('' != $_POST['publish'] )56 if ('' != $_POST['publish'] ) 57 57 $_POST['post_status'] = 'publish'; 58 if ('' != $_POST['advanced'] )58 if ('' != $_POST['advanced'] ) 59 59 $_POST['post_status'] = 'draft'; 60 60 61 61 if ( 'page' == $_POST['post_type'] ) { 62 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages'))62 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) ) 63 63 $_POST['post_status'] = 'draft'; 64 64 } else { 65 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts'))65 if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) ) 66 66 $_POST['post_status'] = 'draft'; 67 67 } 68 68 69 if (!isset ($_POST['comment_status']))69 if (!isset( $_POST['comment_status'] )) 70 70 $_POST['comment_status'] = 'closed'; 71 71 72 if (!isset ($_POST['ping_status']))72 if (!isset( $_POST['ping_status'] )) 73 73 $_POST['ping_status'] = 'closed'; 74 74 75 if (!empty ( $_POST['edit_date'])) {75 if (!empty ( $_POST['edit_date'] ) ) { 76 76 $aa = $_POST['aa']; 77 77 $mm = $_POST['mm']; … … 80 80 $mn = $_POST['mn']; 81 81 $ss = $_POST['ss']; 82 $jj = ($jj > 31 ) ? 31 : $jj;83 $hh = ($hh > 23 ) ? $hh -24 : $hh;84 $mn = ($mn > 59 ) ? $mn -60 : $mn;85 $ss = ($ss > 59 ) ? $ss -60 : $ss;86 $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);87 $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date']);82 $jj = ($jj > 31 ) ? 31 : $jj; 83 $hh = ($hh > 23 ) ? $hh -24 : $hh; 84 $mn = ($mn > 59 ) ? $mn -60 : $mn; 85 $ss = ($ss > 59 ) ? $ss -60 : $ss; 86 $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 87 $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] ); 88 88 } 89 89 90 90 // Create the post. 91 $post_ID = wp_insert_post( $_POST);92 add_meta( $post_ID);91 $post_ID = wp_insert_post( $_POST); 92 add_meta( $post_ID ); 93 93 94 94 // Reunite any orphaned attachments with their parent 95 95 if ( $_POST['temp_ID'] ) 96 relocate_children( $_POST['temp_ID'], $post_ID);96 relocate_children( $_POST['temp_ID'], $post_ID ); 97 97 98 98 // Now that we have an ID we can fix any attachment anchor hrefs 99 fix_attachment_links( $post_ID);99 fix_attachment_links( $post_ID ); 100 100 101 101 return $post_ID; … … 103 103 104 104 // Move child posts to a new parent 105 function relocate_children( $old_ID, $new_ID) {105 function relocate_children( $old_ID, $new_ID ) { 106 106 global $wpdb; 107 107 $old_ID = (int) $old_ID; 108 108 $new_ID = (int) $new_ID; 109 return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");109 return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); 110 110 } 111 111 112 112 // Replace hrefs of attachment anchors with up-to-date permalinks. 113 function fix_attachment_links( $post_ID) {113 function fix_attachment_links( $post_ID ) { 114 114 global $wp_rewrite; 115 115 116 $post = & get_post( $post_ID, ARRAY_A);117 118 $search = "#<a[^>]+rel=('|\" )[^'\"]*attachment[^>]*>#ie";116 $post = & get_post( $post_ID, ARRAY_A ); 117 118 $search = "#<a[^>]+rel=('|\" )[^'\"]*attachment[^>]*>#ie"; 119 119 120 120 // See if we have any rel="attachment" links 121 if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )121 if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) ) 122 122 return; 123 123 124 124 $i = 0; 125 $search = "#[\s]+rel=(\"|' )(.*?)wp-att-(\d+)\\1#i";125 $search = "#[\s]+rel=(\"|' )(.*? )wp-att-(\d+ )\\1#i"; 126 126 foreach ( $anchor_matches[0] as $anchor ) { 127 if ( 0 == preg_match( $search, $anchor, $id_matches) )127 if ( 0 == preg_match( $search, $anchor, $id_matches ) ) 128 128 continue; 129 129 … … 131 131 132 132 // While we have the attachment ID, let's adopt any orphans. 133 $attachment = & get_post( $id, ARRAY_A);134 if ( ! empty( $attachment) && ! is_object(get_post($attachment['post_parent'])) ) {133 $attachment = & get_post( $id, ARRAY_A ); 134 if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) { 135 135 $attachment['post_parent'] = $post_ID; 136 136 // Escape data pulled from DB. 137 $attachment = add_magic_quotes( $attachment);138 wp_update_post( $attachment);137 $attachment = add_magic_quotes( $attachment); 138 wp_update_post( $attachment); 139 139 } 140 140 141 141 $post_search[$i] = $anchor; 142 $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);142 $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor ); 143 143 ++$i; 144 144 } 145 145 146 $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content']);146 $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] ); 147 147 148 148 // Escape data pulled from DB. 149 $post = add_magic_quotes( $post);150 151 return wp_update_post( $post);149 $post = add_magic_quotes( $post); 150 151 return wp_update_post( $post); 152 152 } 153 153 … … 159 159 160 160 if ( 'page' == $_POST['post_type'] ) { 161 if ( !current_user_can( 'edit_page', $post_ID) )162 wp_die( __('You are not allowed to edit this page.'));163 } else { 164 if ( !current_user_can( 'edit_post', $post_ID) )165 wp_die( __('You are not allowed to edit this post.'));161 if ( !current_user_can( 'edit_page', $post_ID ) ) 162 wp_die( __('You are not allowed to edit this page.' )); 163 } else { 164 if ( !current_user_can( 'edit_post', $post_ID ) ) 165 wp_die( __('You are not allowed to edit this post.' )); 166 166 } 167 167 … … 173 173 $_POST['to_ping'] = $_POST['trackback_url']; 174 174 175 if (!empty ( $_POST['post_author_override'])) {175 if (!empty ( $_POST['post_author_override'] ) ) { 176 176 $_POST['post_author'] = (int) $_POST['post_author_override']; 177 177 } else 178 if (!empty ( $_POST['post_author'])) {178 if (!empty ( $_POST['post_author'] ) ) { 179 179 $_POST['post_author'] = (int) $_POST['post_author']; 180 180 } else { … … 182 182 } 183 183 184 if ( $_POST['post_author'] != $_POST['user_ID']) {184 if ( $_POST['post_author'] != $_POST['user_ID'] ) { 185 185 if ( 'page' == $_POST['post_type'] ) { 186 if ( !current_user_can( 'edit_others_pages') )187 wp_die( __('You cannot edit pages as this user.'));186 if ( !current_user_can( 'edit_others_pages' ) ) 187 wp_die( __('You cannot edit pages as this user.' )); 188 188 } else { 189 if ( !current_user_can( 'edit_others_posts') )190 wp_die( __('You cannot edit posts as this user.'));189 if ( !current_user_can( 'edit_others_posts' ) ) 190 wp_die( __('You cannot edit posts as this user.' )); 191 191 192 192 } … … 194 194 195 195 // What to do based on which button they pressed 196 if ('' != $_POST['saveasdraft'] )196 if ('' != $_POST['saveasdraft'] ) 197 197 $_POST['post_status'] = 'draft'; 198 if ('' != $_POST['saveasprivate'] )198 if ('' != $_POST['saveasprivate'] ) 199 199 $_POST['post_status'] = 'private'; 200 if ('' != $_POST['publish'] )200 if ('' != $_POST['publish'] ) 201 201 $_POST['post_status'] = 'publish'; 202 if ('' != $_POST['advanced'] )202 if ('' != $_POST['advanced'] ) 203 203 $_POST['post_status'] = 'draft'; 204 204 205 205 if ( 'page' == $_POST['post_type'] ) { 206 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages'))206 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' )) 207 207 $_POST['post_status'] = 'draft'; 208 208 } else { 209 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts'))209 if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' )) 210 210 $_POST['post_status'] = 'draft'; 211 211 } 212 212 213 if (!isset ($_POST['comment_status']))213 if (!isset( $_POST['comment_status'] )) 214 214 $_POST['comment_status'] = 'closed'; 215 215 216 if (!isset ($_POST['ping_status']))216 if (!isset( $_POST['ping_status'] )) 217 217 $_POST['ping_status'] = 'closed'; 218 218 219 if (!empty ( $_POST['edit_date'])) {219 if (!empty ( $_POST['edit_date'] ) ) { 220 220 $aa = $_POST['aa']; 221 221 $mm = $_POST['mm']; … … 224 224 $mn = $_POST['mn']; 225 225 $ss = $_POST['ss']; 226 $jj = ($jj > 31 ) ? 31 : $jj;227 $hh = ($hh > 23 ) ? $hh -24 : $hh;228 $mn = ($mn > 59 ) ? $mn -60 : $mn;229 $ss = ($ss > 59 ) ? $ss -60 : $ss;226 $jj = ($jj > 31 ) ? 31 : $jj; 227 $hh = ($hh > 23 ) ? $hh -24 : $hh; 228 $mn = ($mn > 59 ) ? $mn -60 : $mn; 229 $ss = ($ss > 59 ) ? $ss -60 : $ss; 230 230 $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 231 $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss");231 $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" ); 232 232 } 233 233 234 234 // Meta Stuff 235 if ( $_POST['meta']) {236 foreach ( $_POST['meta'] as $key => $value)237 update_meta( $key, $value['key'], $value['value']);238 } 239 240 if ( $_POST['deletemeta']) {241 foreach ( $_POST['deletemeta'] as $key => $value)242 delete_meta( $key);243 } 244 245 add_meta( $post_ID);246 247 wp_update_post( $_POST);235 if ( $_POST['meta'] ) { 236 foreach ( $_POST['meta'] as $key => $value ) 237 update_meta( $key, $value['key'], $value['value'] ); 238 } 239 240 if ( $_POST['deletemeta'] ) { 241 foreach ( $_POST['deletemeta'] as $key => $value ) 242 delete_meta( $key ); 243 } 244 245 add_meta( $post_ID ); 246 247 wp_update_post( $_POST); 248 248 249 249 // Now that we have an ID we can fix any attachment anchor hrefs 250 fix_attachment_links( $post_ID);250 fix_attachment_links( $post_ID ); 251 251 252 252 return $post_ID; … … 259 259 $comment_post_ID = (int) $_POST['comment_post_ID']; 260 260 261 if (!current_user_can( 'edit_post', $comment_post_ID))262 wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.'));261 if (!current_user_can( 'edit_post', $comment_post_ID )) 262 wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' )); 263 263 264 264 $_POST['comment_author'] = $_POST['newcomment_author']; … … 269 269 $_POST['comment_ID'] = (int) $_POST['comment_ID']; 270 270 271 if (!empty ( $_POST['edit_date'])) {271 if (!empty ( $_POST['edit_date'] ) ) { 272 272 $aa = $_POST['aa']; 273 273 $mm = $_POST['mm']; … … 276 276 $mn = $_POST['mn']; 277 277 $ss = $_POST['ss']; 278 $jj = ($jj > 31 ) ? 31 : $jj;279 $hh = ($hh > 23 ) ? $hh -24 : $hh;280 $mn = ($mn > 59 ) ? $mn -60 : $mn;281 $ss = ($ss > 59 ) ? $ss -60 : $ss;278 $jj = ($jj > 31 ) ? 31 : $jj; 279 $hh = ($hh > 23 ) ? $hh -24 : $hh; 280 $mn = ($mn > 59 ) ? $mn -60 : $mn; 281 $ss = ($ss > 59 ) ? $ss -60 : $ss; 282 282 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 283 283 } 284 284 285 wp_update_comment( $_POST);285 wp_update_comment( $_POST); 286 286 } 287 287 288 288 // Get an existing post and format it for editing. 289 function get_post_to_edit( $id) {290 291 $post = get_post( $id);292 293 $post->post_content = format_to_edit( $post->post_content, user_can_richedit());294 $post->post_content = apply_filters( 'content_edit_pre', $post->post_content);295 296 $post->post_excerpt = format_to_edit( $post->post_excerpt);297 $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt);298 299 $post->post_title = format_to_edit( $post->post_title);300 $post->post_title = apply_filters( 'title_edit_pre', $post->post_title);301 302 $post->post_password = format_to_edit( $post->post_password);303 304 if ( $post->post_type == 'page')305 $post->page_template = get_post_meta( $id, '_wp_page_template', true);289 function get_post_to_edit( $id ) { 290 291 $post = get_post( $id ); 292 293 $post->post_content = format_to_edit( $post->post_content, user_can_richedit() ); 294 $post->post_content = apply_filters( 'content_edit_pre', $post->post_content); 295 296 $post->post_excerpt = format_to_edit( $post->post_excerpt); 297 $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt); 298 299 $post->post_title = format_to_edit( $post->post_title ); 300 $post->post_title = apply_filters( 'title_edit_pre', $post->post_title ); 301 302 $post->post_password = format_to_edit( $post->post_password ); 303 304 if ( $post->post_type == 'page' ) 305 $post->page_template = get_post_meta( $id, '_wp_page_template', true ); 306 306 307 307 return $post; … … 310 310 // Default post information to use when populating the "Write Post" form. 311 311 function get_default_post_to_edit() { 312 if ( !empty( $_REQUEST['post_title']) )313 $post_title = wp_specialchars( stripslashes($_REQUEST['post_title']));314 else if ( !empty( $_REQUEST['popuptitle']) ) {315 $post_title = wp_specialchars( stripslashes($_REQUEST['popuptitle']));316 $post_title = funky_javascript_fix( $post_title);312 if ( !empty( $_REQUEST['post_title'] ) ) 313 $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] )); 314 else if ( !empty( $_REQUEST['popuptitle'] ) ) { 315 $post_title = wp_specialchars( stripslashes( $_REQUEST['popuptitle'] )); 316 $post_title = funky_javascript_fix( $post_title ); 317 317 } else { 318 318 $post_title = ''; 319 319 } 320 320 321 if ( !empty( $_REQUEST['content']) )322 $post_content = wp_specialchars( stripslashes($_REQUEST['content']));323 else if ( !empty( $post_title) ) {324 $text = wp_specialchars( stripslashes(urldecode($_REQUEST['text'])));325 $text = funky_javascript_fix( $text);326 $popupurl = wp_specialchars( $_REQUEST['popupurl']);321 if ( !empty( $_REQUEST['content'] ) ) 322 $post_content = wp_specialchars( stripslashes( $_REQUEST['content'] )); 323 else if ( !empty( $post_title ) ) { 324 $text = wp_specialchars( stripslashes( urldecode( $_REQUEST['text'] ) ) ); 325 $text = funky_javascript_fix( $text); 326 $popupurl = wp_specialchars( $_REQUEST['popupurl'] ); 327 327 $post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text"; 328 328 } 329 329 330 if ( !empty( $_REQUEST['excerpt']) )331 $post_excerpt = wp_specialchars( stripslashes($_REQUEST['excerpt']));330 if ( !empty( $_REQUEST['excerpt'] ) ) 331 $post_excerpt = wp_specialchars( stripslashes( $_REQUEST['excerpt'] )); 332 332 else 333 333 $post_excerpt = ''; 334 334 335 335 $post->post_status = 'draft'; 336 $post->comment_status = get_option( 'default_comment_status');337 $post->ping_status = get_option( 'default_ping_status');338 $post->post_pingback = get_option( 'default_pingback_flag');339 $post->post_category = get_option( 'default_category');340 $post->post_content = apply_filters( 'default_content', $post_content);341 $post->post_title = apply_filters( 'default_title', $post_title);342 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);336 $post->comment_status = get_option( 'default_comment_status' ); 337 $post->ping_status = get_option( 'default_ping_status' ); 338 $post->post_pingback = get_option( 'default_pingback_flag' ); 339 $post->post_category = get_option( 'default_category' ); 340 $post->post_content = apply_filters( 'default_content', $post_content); 341 $post->post_title = apply_filters( 'default_title', $post_title ); 342 $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt); 343 343 $post->page_template = 'default'; 344 344 $post->post_parent = 0; … … 348 348 } 349 349 350 function get_comment_to_edit( $id) {351 $comment = get_comment( $id);352 353 $comment->comment_content = format_to_edit( $comment->comment_content, user_can_richedit());354 $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);355 356 $comment->comment_author = format_to_edit( $comment->comment_author);357 $comment->comment_author_email = format_to_edit( $comment->comment_author_email);358 $comment->comment_author_url = format_to_edit( $comment->comment_author_url);350 function get_comment_to_edit( $id ) { 351 $comment = get_comment( $id ); 352 353 $comment->comment_content = format_to_edit( $comment->comment_content, user_can_richedit() ); 354 $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content); 355 356 $comment->comment_author = format_to_edit( $comment->comment_author ); 357 $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); 358 $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); 359 359 360 360 return $comment; 361 361 } 362 362 363 function get_category_to_edit( $id) {364 $category = get_category( $id);363 function get_category_to_edit( $id ) { 364 $category = get_category( $id ); 365 365 366 366 return $category; … … 370 370 global $wp_roles; 371 371 $r = ''; 372 foreach( $wp_roles->role_names as $role => $name)372 foreach( $wp_roles->role_names as $role => $name ) 373 373 if ( $default == $role ) // Make default first in list 374 374 $p = "\n\t<option selected='selected' value='$role'>$name</option>"; … … 379 379 380 380 381 function get_user_to_edit( $user_id) {382 $user = new WP_User( $user_id);383 $user->user_login = wp_specialchars( $user->user_login, 1);384 $user->user_email = wp_specialchars( $user->user_email, 1);385 $user->user_url = wp_specialchars( $user->user_url, 1);386 $user->first_name = wp_specialchars( $user->first_name, 1);387 $user->last_name = wp_specialchars( $user->last_name, 1);388 $user->display_name = wp_specialchars( $user->display_name, 1);389 $user->nickname = wp_specialchars( $user->nickname, 1);390 $user->aim = wp_specialchars( $user->aim, 1);391 $user->yim = wp_specialchars( $user->yim, 1);392 $user->jabber = wp_specialchars( $user->jabber, 1);393 $user->description = wp_specialchars( $user->description);381 function get_user_to_edit( $user_id ) { 382 $user = new WP_User( $user_id ); 383 $user->user_login = wp_specialchars( $user->user_login, 1 ); 384 $user->user_email = wp_specialchars( $user->user_email, 1 ); 385 $user->user_url = wp_specialchars( $user->user_url, 1 ); 386 $user->first_name = wp_specialchars( $user->first_name, 1 ); 387 $user->last_name = wp_specialchars( $user->last_name, 1 ); 388 $user->display_name = wp_specialchars( $user->display_name, 1 ); 389 $user->nickname = wp_specialchars( $user->nickname, 1 ); 390 $user->aim = wp_specialchars( $user->aim, 1 ); 391 $user->yim = wp_specialchars( $user->yim, 1 ); 392 $user->jabber = wp_specialchars( $user->jabber, 1 ); 393 $user->description = wp_specialchars( $user->description ); 394 394 395 395 return $user; … … 401 401 if ( func_num_args() ) { // The hackiest hack that ever did hack 402 402 global $current_user, $wp_roles; 403 $user_id = func_get_arg( 0);404 405 if ( isset ($_POST['role'])) {406 if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) {407 $user = new WP_User( $user_id);408 $user->set_role( $_POST['role']);403 $user_id = func_get_arg( 0 ); 404 405 if ( isset( $_POST['role'] ) ) { 406 if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ) ) { 407 $user = new WP_User( $user_id ); 408 $user->set_role( $_POST['role'] ); 409 409 } 410 410 } 411 411 } else { 412 add_action( 'user_register', 'add_user'); // See above412 add_action( 'user_register', 'add_user' ); // See above 413 413 return edit_user(); 414 414 } 415 415 } 416 416 417 function edit_user( $user_id = 0) {417 function edit_user( $user_id = 0 ) { 418 418 global $current_user, $wp_roles, $wpdb; 419 if ( $user_id != 0) {419 if ( $user_id != 0 ) { 420 420 $update = true; 421 421 $user->ID = $user_id; 422 $userdata = get_userdata( $user_id);423 $user->user_login = $wpdb->escape( $userdata->user_login);422 $userdata = get_userdata( $user_id ); 423 $user->user_login = $wpdb->escape( $userdata->user_login ); 424 424 } else { 425 425 $update = false; … … 427 427 } 428 428 429 if ( isset ($_POST['user_login']))430 $user->user_login = wp_specialchars( trim($_POST['user_login']));429 if ( isset( $_POST['user_login'] )) 430 $user->user_login = wp_specialchars( trim( $_POST['user_login'] )); 431 431 432 432 $pass1 = $pass2 = ''; 433 if ( isset ($_POST['pass1']))433 if ( isset( $_POST['pass1'] )) 434 434 $pass1 = $_POST['pass1']; 435 if ( isset ($_POST['pass2']))435 if ( isset( $_POST['pass2'] )) 436 436 $pass2 = $_POST['pass2']; 437 437 438 if ( isset ($_POST['role']) && current_user_can('edit_users')) {439 if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))438 if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) { 439 if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' )) 440 440 $user->role = $_POST['role']; 441 441 } 442 442 443 if ( isset ($_POST['email']))444 $user->user_email = wp_specialchars( trim($_POST['email']));445 if ( isset ($_POST['url'])) {446 $user->user_url = wp_specialchars( trim($_POST['url']));447 $user->user_url = preg_match( '/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;448 } 449 if ( isset ($_POST['first_name']))450 $user->first_name = wp_specialchars( trim($_POST['first_name']));451 if ( isset ($_POST['last_name']))452 $user->last_name = wp_specialchars( trim($_POST['last_name']));453 if ( isset ($_POST['nickname']))454 $user->nickname = wp_specialchars( trim($_POST['nickname']));455 if ( isset ($_POST['display_name']))456 $user->display_name = wp_specialchars( trim($_POST['display_name']));457 if ( isset ($_POST['description']))458 $user->description = trim( $_POST['description']);459 if ( isset ($_POST['jabber']))460 $user->jabber = wp_specialchars( trim($_POST['jabber']));461 if ( isset ($_POST['aim']))462 $user->aim = wp_specialchars( trim($_POST['aim']));463 if ( isset ($_POST['yim']))464 $user->yim = wp_specialchars( trim($_POST['yim']));443 if ( isset( $_POST['email'] )) 444 $user->user_email = wp_specialchars( trim( $_POST['email'] )); 445 if ( isset( $_POST['url'] ) ) { 446 $user->user_url = wp_specialchars( trim( $_POST['url'] )); 447 $user->user_url = preg_match( '/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url ) ? $user->user_url : 'http://'.$user->user_url; 448 } 449 if ( isset( $_POST['first_name'] )) 450 $user->first_name = wp_specialchars( trim( $_POST['first_name'] )); 451 if ( isset( $_POST['last_name'] )) 452 $user->last_name = wp_specialchars( trim( $_POST['last_name'] )); 453 if ( isset( $_POST['nickname'] )) 454 $user->nickname = wp_specialchars( trim( $_POST['nickname'] )); 455 if ( isset( $_POST['display_name'] )) 456 $user->display_name = wp_specialchars( trim( $_POST['display_name'] )); 457 if ( isset( $_POST['description'] )) 458 $user->description = trim( $_POST['description'] ); 459 if ( isset( $_POST['jabber'] )) 460 $user->jabber = wp_specialchars( trim( $_POST['jabber'] )); 461 if ( isset( $_POST['aim'] )) 462 $user->aim = wp_specialchars( trim( $_POST['aim'] )); 463 if ( isset( $_POST['yim'] )) 464 $user->yim = wp_specialchars( trim( $_POST['yim'] )); 465 465 466 466 $errors = new WP_Error(); 467 467 468 468 /* checking that username has been typed */ 469 if ( $user->user_login == '')470 $errors->add( 'user_login', __('<strong>ERROR</strong>: Please enter a username.'));469 if ( $user->user_login == '' ) 470 $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' )); 471 471 472 472 /* checking the password has been typed twice */ 473 do_action_ref_array( 'check_passwords', array ($user->user_login, & $pass1, & $pass2));474 475 if (!$update ) {476 if ( $pass1 == '' || $pass2 == '')477 $errors->add( 'pass', __('<strong>ERROR</strong>: Please enter your password twice.'));478 } else { 479 if ((empty ( $pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1)))480 $errors->add( 'pass', __("<strong>ERROR</strong>: you typed your new password only once."));473 do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 )); 474 475 if (!$update ) { 476 if ( $pass1 == '' || $pass2 == '' ) 477 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' )); 478 } else { 479 if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) ) 480 $errors->add( 'pass', __( "<strong>ERROR</strong>: you typed your new password only once." )); 481 481 } 482 482 483 483 /* Check for "\" in password */ 484 484 if( strpos( " ".$pass1, "\\" ) ) 485 $errors->add( 'pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'));485 $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' )); 486 486 487 487 /* checking the password has been typed twice the same */ 488 if ( $pass1 != $pass2)489 $errors->add( 'pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.'));490 491 if (!empty ( $pass1))488 if ( $pass1 != $pass2 ) 489 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please type the same password in the two password fields.' )); 490 491 if (!empty ( $pass1 )) 492 492 $user->user_pass = $pass1; 493 493 494 if ( !validate_username( $user->user_login) )495 $errors->add( 'user_login', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));496 497 if (!$update && username_exists( $user->user_login))498 $errors->add( 'user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));494 if ( !validate_username( $user->user_login ) ) 495 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 496 497 if (!$update && username_exists( $user->user_login )) 498 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' )); 499 499 500 500 /* checking e-mail address */ 501 if ( empty ($user->user_email)) {502 $errors->add( 'user_email', __("<strong>ERROR</strong>: please type an e-mail address"));501 if ( empty ( $user->user_email ) ) { 502 $errors->add( 'user_email', __( "<strong>ERROR</strong>: please type an e-mail address" )); 503 503 } else 504 if (!is_email( $user->user_email)) {505 $errors->add( 'user_email', __("<strong>ERROR</strong>: the email address isn't correct"));504 if (!is_email( $user->user_email ) ) { 505 $errors->add( 'user_email', __( "<strong>ERROR</strong>: the email address isn't correct" )); 506 506 } 507 507 … … 509 509 return $errors; 510 510 511 if ( $update) {512 $user_id = wp_update_user( get_object_vars($user));513 } else { 514 $user_id = wp_insert_user( get_object_vars($user));515 wp_new_user_notification( $user_id);511 if ( $update ) { 512 $user_id = wp_update_user( get_object_vars( $user )); 513 } else { 514 $user_id = wp_insert_user( get_object_vars( $user )); 515 wp_new_user_notification( $user_id ); 516 516 } 517 517 return $user_id; … … 519 519 520 520 521 function get_link_to_edit( $link_id) {522 $link = get_link( $link_id);523 524 $link->link_url = wp_specialchars( $link->link_url, 1);525 $link->link_name = wp_specialchars( $link->link_name, 1);526 $link->link_image = wp_specialchars( $link->link_image, 1);527 $link->link_description = wp_specialchars( $link->link_description, 1);528 $link->link_notes = wp_specialchars( $link->link_notes);529 $link->link_rss = wp_specialchars( $link->link_rss, 1);530 $link->link_rel = wp_specialchars( $link->link_rel, 1);521 function get_link_to_edit( $link_id ) { 522 $link = get_link( $link_id ); 523 524 $link->link_url = wp_specialchars( $link->link_url, 1 ); 525 $link->link_name = wp_specialchars( $link->link_name, 1 ); 526 $link->link_image = wp_specialchars( $link->link_image, 1 ); 527 $link->link_description = wp_specialchars( $link->link_description, 1 ); 528 $link->link_notes = wp_specialchars( $link->link_notes ); 529 $link->link_rss = wp_specialchars( $link->link_rss, 1 ); 530 $link->link_rel = wp_specialchars( $link->link_rel, 1 ); 531 531 $link->post_category = $link->link_category; 532 532 … … 535 535 536 536 function get_default_link_to_edit() { 537 if ( isset( $_GET['linkurl']) )538 $link->link_url = wp_specialchars( $_GET['linkurl'], 1);537 if ( isset( $_GET['linkurl'] ) ) 538 $link->link_url = wp_specialchars( $_GET['linkurl'], 1 ); 539 539 else 540 540 $link->link_url = ''; 541 541 542 if ( isset( $_GET['name']) )543 $link->link_name = wp_specialchars( $_GET['name'], 1);542 if ( isset( $_GET['name'] ) ) 543 $link->link_name = wp_specialchars( $_GET['name'], 1 ); 544 544 else 545 545 $link->link_name = ''; … … 554 554 } 555 555 556 function edit_link( $link_id = '') {557 if (!current_user_can( 'manage_links'))558 wp_die( __("Cheatin' uh ?"));559 560 $_POST['link_url'] = wp_specialchars( $_POST['link_url']);561 $_POST['link_url'] = preg_match( '/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url']) ? $_POST['link_url'] : 'http://' . $_POST['link_url'];562 $_POST['link_name'] = wp_specialchars( $_POST['link_name']);563 $_POST['link_image'] = wp_specialchars( $_POST['link_image']);564 $_POST['link_rss'] = wp_specialchars( $_POST['link_rss']);556 function edit_link( $link_id = '' ) { 557 if (!current_user_can( 'manage_links' )) 558 wp_die( __("Cheatin' uh ?" )); 559 560 $_POST['link_url'] = wp_specialchars( $_POST['link_url'] ); 561 $_POST['link_url'] = preg_match( '/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url'] ) ? $_POST['link_url'] : 'http://' . $_POST['link_url']; 562 $_POST['link_name'] = wp_specialchars( $_POST['link_name'] ); 563 $_POST['link_image'] = wp_specialchars( $_POST['link_image'] ); 564 $_POST['link_rss'] = wp_specialchars( $_POST['link_rss'] ); 565 565 $_POST['link_category'] = $_POST['post_category']; 566 566 567 if ( !empty( $link_id) ) {567 if ( !empty( $link_id ) ) { 568 568 $_POST['link_id'] = $link_id; 569 return wp_update_link( $_POST);570 } else { 571 return wp_insert_link( $_POST);572 } 573 } 574 575 function url_shorten( $url) {576 $short_url = str_replace( 'http://', '', stripslashes($url));577 $short_url = str_replace( 'www.', '', $short_url);578 if ('/' == substr( $short_url, -1))579 $short_url = substr( $short_url, 0, -1);580 if ( strlen($short_url) > 35)581 $short_url = substr( $short_url, 0, 32).'...';569 return wp_update_link( $_POST); 570 } else { 571 return wp_insert_link( $_POST); 572 } 573 } 574 575 function url_shorten( $url ) { 576 $short_url = str_replace( 'http://', '', stripslashes( $url )); 577 $short_url = str_replace( 'www.', '', $short_url ); 578 if ('/' == substr( $short_url, -1 )) 579 $short_url = substr( $short_url, 0, -1 ); 580 if ( strlen( $short_url ) > 35 ) 581 $short_url = substr( $short_url, 0, 32 ).'...'; 582 582 return $short_url; 583 583 } 584 584 585 function selected( $selected, $current) {586 if ( $selected == $current)585 function selected( $selected, $current) { 586 if ( $selected == $current) 587 587 echo ' selected="selected"'; 588 588 } 589 589 590 function checked( $checked, $current) {591 if ( $checked == $current)590 function checked( $checked, $current) { 591 if ( $checked == $current) 592 592 echo ' checked="checked"'; 593 593 } 594 594 595 function return_categories_list( $parent = 0) {595 function return_categories_list( $parent = 0 ) { 596 596 global $wpdb; 597 return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC");598 } 599 600 function sort_cats( $cat1, $cat2) {601 return strcasecmp( $cat1['cat_name'], $cat2['cat_name']);602 } 603 604 function get_nested_categories( $default = 0, $parent = 0) {597 return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC" ); 598 } 599 600 function sort_cats( $cat1, $cat2 ) { 601 return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] ); 602 } 603 604 function get_nested_categories( $default = 0, $parent = 0 ) { 605 605 global $post_ID, $link_id, $mode, $wpdb; 606 606 607 if ( $post_ID) {608 $checked_categories = $wpdb->get_col( "607 if ( $post_ID ) { 608 $checked_categories = $wpdb->get_col( " 609 609 SELECT category_id 610 610 FROM $wpdb->categories, $wpdb->post2cat 611 611 WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID' 612 " );613 614 if ( count($checked_categories) == 0) {612 " ); 613 614 if ( count( $checked_categories ) == 0 ) { 615 615 // No selected categories, strange 616 616 $checked_categories[] = $default; 617 617 } 618 } else if ( $link_id) {619 $checked_categories = $wpdb->get_col( "618 } else if ( $link_id ) { 619 $checked_categories = $wpdb->get_col( " 620 620 SELECT category_id 621 621 FROM $wpdb->categories, $wpdb->link2cat 622 622 WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id' 623 " );624 625 if ( count($checked_categories) == 0) {623 " ); 624 625 if ( count( $checked_categories ) == 0 ) { 626 626 // No selected categories, strange 627 627 $checked_categories[] = $default; … … 631 631 } 632 632 633 $cats = return_categories_list( $parent);633 $cats = return_categories_list( $parent); 634 634 $result = array (); 635 635 636 if ( is_array($cats)) {637 foreach ( $cats as $cat) {638 $result[$cat]['children'] = get_nested_categories( $default, $cat);636 if ( is_array( $cats ) ) { 637 foreach ( $cats as $cat) { 638 $result[$cat]['children'] = get_nested_categories( $default, $cat); 639 639 $result[$cat]['cat_ID'] = $cat; 640 $result[$cat]['checked'] = in_array( $cat, $checked_categories);641 $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);642 } 643 } 644 645 usort( $result, 'sort_cats');640 $result[$cat]['checked'] = in_array( $cat, $checked_categories ); 641 $result[$cat]['cat_name'] = get_the_category_by_ID( $cat); 642 } 643 } 644 645 usort( $result, 'sort_cats' ); 646 646 647 647 return $result; 648 648 } 649 649 650 function write_nested_categories( $categories) {651 foreach ( $categories as $category) {652 echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n";650 function write_nested_categories( $categories ) { 651 foreach ( $categories as $category ) { 652 echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( $category['cat_name'] ), "</label></li>\n"; 653 653 654 654 if ( $category['children'] ) { 655 655 echo "<ul>\n"; 656 write_nested_categories( $category['children']);656 write_nested_categories( $category['children'] ); 657 657 echo "</ul>\n"; 658 658 } … … 660 660 } 661 661 662 function dropdown_categories( $default = 0) {663 write_nested_categories( get_nested_categories($default));664 } 665 666 function return_link_categories_list( $parent = 0) {662 function dropdown_categories( $default = 0 ) { 663 write_nested_categories( get_nested_categories( $default) ); 664 } 665 666 function return_link_categories_list( $parent = 0 ) { 667 667 global $wpdb; 668 return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC");668 return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC" ); 669 669 } 670 670 … … 672 672 global $post_ID, $link_id, $mode, $wpdb; 673 673 674 if ( $link_id) {675 $checked_categories = $wpdb->get_col( "674 if ( $link_id ) { 675 $checked_categories = $wpdb->get_col( " 676 676 SELECT category_id 677 677 FROM $wpdb->categories, $wpdb->link2cat 678 678 WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id' 679 " );680 681 if ( count($checked_categories) == 0) {679 " ); 680 681 if ( count( $checked_categories ) == 0 ) { 682 682 // No selected categories, strange 683 683 $checked_categories[] = $default; … … 687 687 } 688 688 689 $cats = return_link_categories_list( $parent);689 $cats = return_link_categories_list( $parent); 690 690 $result = array (); 691 691 692 if ( is_array($cats)) {693 foreach ( $cats as $cat) {694 $result[$cat]['children'] = get_nested_link_categories( $default, $cat);692 if ( is_array( $cats ) ) { 693 foreach ( $cats as $cat) { 694 $result[$cat]['children'] = get_nested_link_categories( $default, $cat); 695 695 $result[$cat]['cat_ID'] = $cat; 696 $result[$cat]['checked'] = in_array( $cat, $checked_categories);697 $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);698 } 699 } 700 701 usort( $result, 'sort_cats');696 $result[$cat]['checked'] = in_array( $cat, $checked_categories ); 697 $result[$cat]['cat_name'] = get_the_category_by_ID( $cat); 698 } 699 } 700 701 usort( $result, 'sort_cats' ); 702 702 703 703 return $result; 704 704 } 705 705 706 function dropdown_link_categories( $default = 0) {707 write_nested_categories( get_nested_link_categories($default));706 function dropdown_link_categories( $default = 0 ) { 707 write_nested_categories( get_nested_link_categories( $default) ); 708 708 } 709 709 710 710 // Dandy new recursive multiple category stuff. 711 function cat_rows( $parent = 0, $level = 0, $categories = 0) {712 if (!$categories )713 $categories = get_categories( 'hide_empty=0');714 715 if ( $categories) {716 foreach ( $categories as $category) {717 if ( $category->category_parent == $parent) {711 function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { 712 if (!$categories ) 713 $categories = get_categories( 'hide_empty=0' ); 714 715 if ( $categories ) { 716 foreach ( $categories as $category ) { 717 if ( $category->category_parent == $parent) { 718 718 echo "\t" . _cat_row( $category, $level ); 719 cat_rows( $category->cat_ID, $level +1, $categories);719 cat_rows( $category->cat_ID, $level +1, $categories ); 720 720 } 721 721 } … … 728 728 global $class; 729 729 730 $pad = str_repeat( '— ', $level);731 if ( current_user_can( 'manage_categories') ) {732 $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__( 'Edit')."</a></td>";733 $default_cat_id = get_option( 'default_category');734 $default_link_cat_id = get_option( 'default_link_category');735 736 if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id) )737 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category "%s".\\nAll of its posts will go into the default category of "%s"\\nAll of its bookmarks will go into the default category of "%s".\\n"OK" to delete, "Cancel" to stop."), js_escape($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";730 $pad = str_repeat( '— ', $level ); 731 if ( current_user_can( 'manage_categories' ) ) { 732 $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__( 'Edit' )."</a></td>"; 733 $default_cat_id = get_option( 'default_category' ); 734 $default_link_cat_id = get_option( 'default_link_category' ); 735 736 if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) ) 737 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf( __("You are about to delete the category "%s".\\nAll of its posts will go into the default category of "%s"\\nAll of its bookmarks will go into the default category of "%s".\\n"OK" to delete, "Cancel" to stop." ), js_escape( $category->cat_name ), js_escape( get_catname( $default_cat_id )), js_escape( get_catname( $default_link_cat_id ) ) ) . "' );\" class='delete'>".__( 'Delete' )."</a>"; 738 738 else 739 $edit .= "<td style='text-align:center'>".__( "Default");739 $edit .= "<td style='text-align:center'>".__( "Default" ); 740 740 } else 741 741 $edit = ''; 742 742 743 $class = ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";743 $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; 744 744 745 745 $category->category_count = number_format( $category->category_count ); … … 754 754 } 755 755 756 function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true) {756 function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { 757 757 global $wpdb, $class, $post; 758 758 759 if (!$pages )760 $pages = get_pages( 'sort_column=menu_order');761 762 if (! $pages )759 if (!$pages ) 760 $pages = get_pages( 'sort_column=menu_order' ); 761 762 if (! $pages ) 763 763 return false; 764 764 765 foreach ( $pages as $post) {766 setup_postdata( $post);765 foreach ( $pages as $post) { 766 setup_postdata( $post); 767 767 if ( $hierarchy && ($post->post_parent != $parent) ) 768 768 continue; 769 769 770 $post->post_title = wp_specialchars( $post->post_title);771 $pad = str_repeat( '— ', $level);770 $post->post_title = wp_specialchars( $post->post_title ); 771 $pad = str_repeat( '— ', $level ); 772 772 $id = $post->ID; 773 $class = ('alternate' == $class ) ? '' : 'alternate';773 $class = ('alternate' == $class ) ? '' : 'alternate'; 774 774 ?> 775 775 <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'> … … 777 777 <td> 778 778 <?php echo $pad; ?><?php the_title() ?> 779 <?php if ('private' == $post->post_status ) _e(' - <strong>Private</strong>'); ?>779 <?php if ('private' == $post->post_status ) _e( ' - <strong>Private</strong>' ); ?> 780 780 </td> 781 781 <td><?php the_author() ?></td> 782 <td><?php echo mysql2date( 'Y-m-d g:i a', $post->post_modified); ?></td>783 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e( 'View'); ?></a></td>784 <td><?php if ( current_user_can( 'edit_page', $id) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>785 <td><?php if ( current_user_can( 'delete_page', $id) ) { echo "<a href='" . wp_nonce_url("page.php?action=delete&post=$id", 'delete-page_' . $id) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>782 <td><?php echo mysql2date( 'Y-m-d g:i a', $post->post_modified ); ?></td> 783 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e( 'View' ); ?></a></td> 784 <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td> 785 <td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&post=$id", 'delete-page_' . $id ) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf( __("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop." ), js_escape( get_the_title() ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td> 786 786 </tr> 787 787 788 788 <?php 789 if ( $hierarchy ) page_rows($id, $level + 1, $pages);789 if ( $hierarchy ) page_rows( $id, $level + 1, $pages ); 790 790 } 791 791 } 792 792 793 793 function user_row( $user_object, $style = '' ) { 794 if ( !(is_object( $user_object) && is_a($user_object, 'WP_User')) )794 if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 795 795 $user_object = new WP_User( (int) $user_object ); 796 796 $email = $user_object->user_email; 797 797 $url = $user_object->user_url; 798 $short_url = str_replace( 'http://', '', $url);799 $short_url = str_replace( 'www.', '', $short_url);800 if ('/' == substr( $short_url, -1))801 $short_url = substr( $short_url, 0, -1);802 if ( strlen($short_url) > 35)803 $short_url = substr( $short_url, 0, 32).'...';804 $numposts = get_usernumposts( $user_object->ID);798 $short_url = str_replace( 'http://', '', $url ); 799 $short_url = str_replace( 'www.', '', $short_url ); 800 if ('/' == substr( $short_url, -1 )) 801 $short_url = substr( $short_url, 0, -1 ); 802 if ( strlen( $short_url ) > 35 ) 803 $short_url = substr( $short_url, 0, 32 ).'...'; 804 $numposts = get_usernumposts( $user_object->ID ); 805 805 $r = "<tr id='user-$user_object->ID'$style> 806 806 <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td> 807 807 <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td> 808 808 <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td> 809 <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s'), $email) . "'>$email</a></td>809 <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td> 810 810 <td><a href='$url' title='website: $url'>$short_url</a></td>"; 811 811 $r .= "\n\t\t<td align='center'>"; 812 if ( $numposts > 0) {813 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author') . "' class='edit'>";814 $r .= sprintf( __('View %1$s %2$s'), $numposts, __ngettext('post', 'posts', $numposts));812 if ( $numposts > 0 ) { 813 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>"; 814 $r .= sprintf( __('View %1$s %2$s' ), $numposts, __ngettext( 'post', 'posts', $numposts )); 815 815 } 816 816 $r .= "</td>\n\t\t<td>"; 817 $edit_link = add_query_arg( 'wp_http_referer', wp_specialchars(urlencode(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id=$user_object->ID");818 if ( current_user_can( 'edit_user', $user_object->ID) )819 $r .= "<a href='$edit_link' class='edit'>".__( 'Edit')."</a>";817 $edit_link = add_query_arg( 'wp_http_referer', wp_specialchars( urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ); 818 if ( current_user_can( 'edit_user', $user_object->ID ) ) 819 $r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>"; 820 820 $r .= "</td>\n\t</tr>"; 821 821 return $r; 822 822 } 823 823 824 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {824 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { 825 825 global $wpdb; 826 if (!$categories )827 $categories = get_categories( 'hide_empty=0');828 829 if ( $categories) {830 foreach ( $categories as $category) {831 if ( $currentcat != $category->cat_ID && $parent == $category->category_parent) {832 $pad = str_repeat( '– ', $level);833 $category->cat_name = wp_specialchars( $category->cat_name);826 if (!$categories ) 827 $categories = get_categories( 'hide_empty=0' ); 828 829 if ( $categories ) { 830 foreach ( $categories as $category ) { 831 if ( $currentcat != $category->cat_ID && $parent == $category->category_parent) { 832 $pad = str_repeat( '– ', $level ); 833 $category->cat_name = wp_specialchars( $category->cat_name ); 834 834 echo "\n\t<option value='$category->cat_ID'"; 835 if ( $currentparent == $category->cat_ID)835 if ( $currentparent == $category->cat_ID ) 836 836 echo " selected='selected'"; 837 837 echo ">$pad$category->cat_name</option>"; 838 wp_dropdown_cats( $currentcat, $currentparent, $category->cat_ID, $level +1, $categories);838 wp_dropdown_cats( $currentcat, $currentparent, $category->cat_ID, $level +1, $categories ); 839 839 } 840 840 } … … 844 844 } 845 845 846 function wp_create_thumbnail( $file, $max_side, $effect = '') {846 function wp_create_thumbnail( $file, $max_side, $effect = '' ) { 847 847 848 848 // 1 = GIF, 2 = JPEG, 3 = PNG 849 849 850 if ( file_exists($file)) {851 $type = getimagesize( $file);850 if ( file_exists( $file ) ) { 851 $type = getimagesize( $file ); 852 852 853 853 // if the associated function doesn't exist - then it's not 854 854 // handle. duh. i hope. 855 855 856 if (!function_exists( 'imagegif') && $type[2] == 1) {857 $error = __( 'Filetype not supported. Thumbnail not created.');858 } 859 elseif (!function_exists( 'imagejpeg') && $type[2] == 2) {860 $error = __( 'Filetype not supported. Thumbnail not created.');861 } 862 elseif (!function_exists( 'imagepng') && $type[2] == 3) {863 $error = __( 'Filetype not supported. Thumbnail not created.');856 if (!function_exists( 'imagegif' ) && $type[2] == 1 ) { 857 $error = __( 'Filetype not supported. Thumbnail not created.' ); 858 } 859 elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) { 860 $error = __( 'Filetype not supported. Thumbnail not created.' ); 861 } 862 elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) { 863 $error = __( 'Filetype not supported. Thumbnail not created.' ); 864 864 } else { 865 865 866 866 // create the initial copy from the original file 867 if ( $type[2] == 1) {868 $image = imagecreatefromgif( $file);867 if ( $type[2] == 1 ) { 868 $image = imagecreatefromgif( $file ); 869 869 } 870 elseif ( $type[2] == 2) {871 $image = imagecreatefromjpeg( $file);870 elseif ( $type[2] == 2 ) { 871 $image = imagecreatefromjpeg( $file ); 872 872 } 873 elseif ( $type[2] == 3) {874 $image = imagecreatefrompng( $file);873 elseif ( $type[2] == 3 ) { 874 $image = imagecreatefrompng( $file ); 875 875 } 876 876 877 if ( function_exists('imageantialias'))878 imageantialias( $image, TRUE);879 880 $image_attr = getimagesize( $file);877 if ( function_exists( 'imageantialias' )) 878 imageantialias( $image, TRUE ); 879 880 $image_attr = getimagesize( $file ); 881 881 882 882 // figure out the longest side 883 883 884 if ( $image_attr[0] > $image_attr[1]) {884 if ( $image_attr[0] > $image_attr[1] ) { 885 885 $image_width = $image_attr[0]; 886 886 $image_height = $image_attr[1]; … … 900 900 } 901 901 902 $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);903 @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1]);902 $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height); 903 @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] ); 904 904 905 905 // If no filters change the filename, we'll do a default transformation. 906 if ( basename( $file) == $thumb = apply_filters('thumbnail_filename', basename($file)) )907 $thumb = preg_replace( '!(\.[^.]+)?$!', __('.thumbnail').'$1', basename($file), 1);908 909 $thumbpath = str_replace( basename($file), $thumb, $file);906 if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) ) 907 $thumb = preg_replace( '!(\.[^.]+)?$!', __( '.thumbnail' ).'$1', basename( $file ), 1 ); 908 909 $thumbpath = str_replace( basename( $file ), $thumb, $file ); 910 910 911 911 // move the thumbnail to it's final destination 912 if ( $type[2] == 1) {913 if (!imagegif( $thumbnail, $thumbpath)) {914 $error = __( "Thumbnail path invalid");912 if ( $type[2] == 1 ) { 913 if (!imagegif( $thumbnail, $thumbpath ) ) { 914 $error = __( "Thumbnail path invalid" ); 915 915 } 916 916 } 917 elseif ( $type[2] == 2) {918 if (!imagejpeg( $thumbnail, $thumbpath)) {919 $error = __( "Thumbnail path invalid");917 elseif ( $type[2] == 2 ) { 918 if (!imagejpeg( $thumbnail, $thumbpath ) ) { 919 $error = __( "Thumbnail path invalid" ); 920 920 } 921 921 } 922 elseif ( $type[2] == 3) {923 if (!imagepng( $thumbnail, $thumbpath)) {924 $error = __( "Thumbnail path invalid");922 elseif ( $type[2] == 3 ) { 923 if (!imagepng( $thumbnail, $thumbpath ) ) { 924 $error = __( "Thumbnail path invalid" ); 925 925 } 926 926 } … … 928 928 } 929 929 } else { 930 $error = __( 'File not found');931 } 932 933 if (!empty ( $error)) {930 $error = __( 'File not found' ); 931 } 932 933 if (!empty ( $error ) ) { 934 934 return $error; 935 935 } else { … … 940 940 941 941 // Some postmeta stuff 942 function has_meta( $postid) {942 function has_meta( $postid ) { 943 943 global $wpdb; 944 944 945 return $wpdb->get_results( "945 return $wpdb->get_results( " 946 946 SELECT meta_key, meta_value, meta_id, post_id 947 947 FROM $wpdb->postmeta 948 948 WHERE post_id = '$postid' 949 ORDER BY meta_key,meta_id", ARRAY_A );950 951 } 952 953 function list_meta( $meta) {949 ORDER BY meta_key,meta_id", ARRAY_A ); 950 951 } 952 953 function list_meta( $meta ) { 954 954 global $post_ID; 955 955 // Exit if no meta 956 if (!$meta ) {956 if (!$meta ) { 957 957 echo '<tbody id="the-list"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS 958 958 return; … … 962 962 <thead> 963 963 <tr> 964 <th><?php _e( 'Key') ?></th>965 <th><?php _e( 'Value') ?></th>966 <th colspan='2'><?php _e( 'Action') ?></th>964 <th><?php _e( 'Key' ) ?></th> 965 <th><?php _e( 'Value' ) ?></th> 966 <th colspan='2'><?php _e( 'Action' ) ?></th> 967 967 </tr> 968 968 </thead> 969 969 <?php 970 970 $r ="\n\t<tbody id='the-list'>"; 971 foreach ( $meta as $entry) {971 foreach ( $meta as $entry ) { 972 972 ++ $count; 973 if ( $count % 2)973 if ( $count % 2 ) 974 974 $style = 'alternate'; 975 975 else 976 976 $style = ''; 977 if ('_' == $entry['meta_key'] { 0 } )977 if ('_' == $entry['meta_key'] { 0 } ) 978 978 $style .= ' hidden'; 979 979 980 if ( is_serialized( $entry['meta_value']) ) {981 if ( is_serialized_string( $entry['meta_value']) ) {980 if ( is_serialized( $entry['meta_value'] ) ) { 981 if ( is_serialized_string( $entry['meta_value'] ) ) { 982 982 // this is a serialized string, so we should display it 983 $entry['meta_value'] = maybe_unserialize( $entry['meta_value']);983 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); 984 984 } else { 985 985 // this is a serialized array/object so we should NOT display it … … 989 989 } 990 990 991 $key_js = js_escape( $entry['meta_key']);991 $key_js = js_escape( $entry['meta_key'] ); 992 992 $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true ); 993 993 $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true ); … … 995 995 $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; 996 996 $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; 997 $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__( 'Update')."' /><br />";997 $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__( 'Update' )."' /><br />"; 998 998 $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '"; 999 $r .= sprintf( __("You are about to delete the "%s" custom field on this post.\\n"OK" to delete, "Cancel" to stop."), $key_js);1000 $r .= "' );\" class='deletemeta' tabindex='6' value='".__( 'Delete')."' /></td>";999 $r .= sprintf( __("You are about to delete the "%s" custom field on this post.\\n"OK" to delete, "Cancel" to stop." ), $key_js ); 1000 $r .= "' );\" class='deletemeta' tabindex='6' value='".__( 'Delete' )."' /></td>"; 1001 1001 $r .= "\n\t</tr>"; 1002 1002 } … … 1009 1009 global $wpdb; 1010 1010 1011 $keys = $wpdb->get_col( "1011 $keys = $wpdb->get_col( " 1012 1012 SELECT meta_key 1013 1013 FROM $wpdb->postmeta 1014 1014 GROUP BY meta_key 1015 ORDER BY meta_key" );1015 ORDER BY meta_key" ); 1016 1016 1017 1017 return $keys; … … 1020 1020 function meta_form() { 1021 1021 global $wpdb; 1022 $limit = (int) apply_filters( 'postmeta_form_limit', 30);1023 $keys = $wpdb->get_col( "1022 $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); 1023 $keys = $wpdb->get_col( " 1024 1024 SELECT meta_key 1025 1025 FROM $wpdb->postmeta 1026 1026 GROUP BY meta_key 1027 1027 ORDER BY meta_id DESC 1028 LIMIT $limit" );1029 natcasesort( $keys);1028 LIMIT $limit" ); 1029 natcasesort( $keys ); 1030 1030 ?> 1031 <h3><?php _e( 'Add a new custom field:') ?></h3>1031 <h3><?php _e( 'Add a new custom field:' ) ?></h3> 1032 1032 <table id="newmeta" cellspacing="3" cellpadding="3"> 1033 1033 <tr> 1034 <th colspan="2"><?php _e( 'Key') ?></th>1035 <th><?php _e( 'Value') ?></th>1034 <th colspan="2"><?php _e( 'Key' ) ?></th> 1035 <th><?php _e( 'Value' ) ?></th> 1036 1036 </tr> 1037 1037 <tr valign="top"> … … 1039 1039 <?php if ( $keys ) : ?> 1040 1040 <select id="metakeyselect" name="metakeyselect" tabindex="7"> 1041 <option value="#NONE#"><?php _e( '- Select -'); ?></option>1041 <option value="#NONE#"><?php _e( '- Select -' ); ?></option> 1042 1042 <?php 1043 1043 1044 1044 foreach ( $keys as $key ) { 1045 $key = wp_specialchars( $key, 1);1045 $key = wp_specialchars( $key, 1 ); 1046 1046 echo "\n\t<option value='$key'>$key</option>"; 1047 1047 } 1048 1048 ?> 1049 </select> <?php _e( 'or'); ?>1049 </select> <?php _e( 'or' ); ?> 1050 1050 <?php endif; ?> 1051 1051 </td> … … 1055 1055 1056 1056 </table> 1057 <p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field »') ?>" /></p>1057 <p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field »' ) ?>" /></p> 1058 1058 <?php 1059 1059 1060 1060 } 1061 1061 1062 function add_meta( $post_ID) {1062 function add_meta( $post_ID ) { 1063 1063 global $wpdb; 1064 1064 $post_ID = (int) $post_ID; 1065 1065 1066 $metakeyselect = $wpdb->escape( stripslashes(trim($_POST['metakeyselect'])));1067 $metakeyinput = $wpdb->escape( stripslashes(trim($_POST['metakeyinput'])));1068 $metavalue = maybe_serialize( stripslashes((trim($_POST['metavalue']))));1069 $metavalue = $wpdb->escape( $metavalue);1070 1071 if ( ('0' === $metavalue || !empty ( $metavalue)) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput)) ) {1066 $metakeyselect = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) ); 1067 $metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) ); 1068 $metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) )); 1069 $metavalue = $wpdb->escape( $metavalue ); 1070 1071 if ( ('0' === $metavalue || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) { 1072 1072 // We have a key/value pair. If both the select and the 1073 1073 // input for the key have data, the input takes precedence: … … 1076 1076 $metakey = $metakeyselect; 1077 1077 1078 if ( $metakeyinput)1078 if ( $metakeyinput) 1079 1079 $metakey = $metakeyinput; // default 1080 1080 1081 $result = $wpdb->query( "1081 $result = $wpdb->query( " 1082 1082 INSERT INTO $wpdb->postmeta 1083 (post_id,meta_key,meta_value )1084 VALUES ('$post_ID','$metakey','$metavalue' )1085 " );1083 (post_id,meta_key,meta_value ) 1084 VALUES ('$post_ID','$metakey','$metavalue' ) 1085 " ); 1086 1086 return $wpdb->insert_id; 1087 1087 } … … 1089 1089 } // add_meta 1090 1090 1091 function delete_meta( $mid) {1091 function delete_meta( $mid ) { 1092 1092 global $wpdb; 1093 1093 $mid = (int) $mid; 1094 1094 1095 return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");1096 } 1097 1098 function update_meta( $mid, $mkey, $mvalue) {1095 return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" ); 1096 } 1097 1098 function update_meta( $mid, $mkey, $mvalue ) { 1099 1099 global $wpdb; 1100 $mvalue = maybe_serialize( stripslashes($mvalue));1101 $mvalue = $wpdb->escape( $mvalue);1100 $mvalue = maybe_serialize( stripslashes( $mvalue )); 1101 $mvalue = $wpdb->escape( $mvalue ); 1102 1102 $mid = (int) $mid; 1103 return $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");1104 } 1105 1106 function get_post_meta_by_id( $mid) {1103 return $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'" ); 1104 } 1105 1106 function get_post_meta_by_id( $mid ) { 1107 1107 global $wpdb; 1108 1108 $mid = (int) $mid; 1109 1109 1110 $meta = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'");1111 if ( is_serialized_string( $meta->meta_value) )1112 $meta->meta_value = maybe_unserialize( $meta->meta_value);1110 $meta = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'" ); 1111 if ( is_serialized_string( $meta->meta_value ) ) 1112 $meta->meta_value = maybe_unserialize( $meta->meta_value ); 1113 1113 return $meta; 1114 1114 } 1115 1115 1116 function touch_time( $edit = 1, $for_post = 1) {1116 function touch_time( $edit = 1, $for_post = 1 ) { 1117 1117 global $wp_locale, $post, $comment; 1118 1118 1119 1119 if ( $for_post ) 1120 $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true;1120 $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true; 1121 1121 1122 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp').'</label></legend>';1123 1124 $time_adj = time() + (get_option( 'gmt_offset') * 3600);1122 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>'; 1123 1124 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); 1125 1125 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 1126 $jj = ($edit) ? mysql2date( 'd', $post_date) : gmdate('d', $time_adj);1127 $mm = ($edit) ? mysql2date( 'm', $post_date) : gmdate('m', $time_adj);1128 $aa = ($edit) ? mysql2date( 'Y', $post_date) : gmdate('Y', $time_adj);1129 $hh = ($edit) ? mysql2date( 'H', $post_date) : gmdate('H', $time_adj);1130 $mn = ($edit) ? mysql2date( 'i', $post_date) : gmdate('i', $time_adj);1131 $ss = ($edit) ? mysql2date( 's', $post_date) : gmdate('s', $time_adj);1126 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj ); 1127 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj ); 1128 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj ); 1129 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj ); 1130 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj ); 1131 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj ); 1132 1132 1133 1133 echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n"; 1134 for ( $i = 1; $i < 13; $i = $i +1) {1134 for ( $i = 1; $i < 13; $i = $i +1 ) { 1135 1135 echo "\t\t\t<option value=\"$i\""; 1136 if ( $i == $mm)1136 if ( $i == $mm ) 1137 1137 echo ' selected="selected"'; 1138 echo '>' . $wp_locale->get_month( $i) . "</option>\n";1138 echo '>' . $wp_locale->get_month( $i ) . "</option>\n"; 1139 1139 } 1140 1140 ?> … … 1147 1147 <?php 1148 1148 if ( $edit ) { 1149 _e( 'Existing timestamp');1150 //echo ': ' . $wp_locale->get_month( $mm) . "$jj, $aa @ $hh:$mn";1151 echo sprintf( __(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn);1149 _e( 'Existing timestamp' ); 1150 //echo ': ' . $wp_locale->get_month( $mm ) . "$jj, $aa @ $hh:$mn"; 1151 echo sprintf( __(': %1$s %2$s, %3$s @ %4$s:%5$s' ), $wp_locale->get_month( $mm ), $jj, $aa, $hh, $mn ); 1152 1152 } 1153 1153 ?> … … 1158 1158 1159 1159 // insert_with_markers: Owen Winkler, fixed by Eric Anderson 1160 // Inserts an array of strings into a file (.htaccess ), placing it between1160 // Inserts an array of strings into a file (.htaccess ), placing it between 1161 1161 // BEGIN and END markers. Replaces existing marked info. Retains surrounding 1162 1162 // data. Creates file if none exists. 1163 1163 // Returns true on write success, false on failure. 1164 function insert_with_markers( $filename, $marker, $insertion) {1165 if (!file_exists( $filename) || is_writeable($filename)) {1166 if (!file_exists( $filename)) {1164 function insert_with_markers( $filename, $marker, $insertion ) { 1165 if (!file_exists( $filename ) || is_writeable( $filename ) ) { 1166 if (!file_exists( $filename ) ) { 1167 1167 $markerdata = ''; 1168 1168 } else { 1169 $markerdata = explode( "\n", implode('', file($filename)));1170 } 1171 1172 $f = fopen( $filename, 'w');1169 $markerdata = explode( "\n", implode( '', file( $filename ) ) ); 1170 } 1171 1172 $f = fopen( $filename, 'w' ); 1173 1173 $foundit = false; 1174 if ( $markerdata) {1174 if ( $markerdata ) { 1175 1175 $state = true; 1176 foreach ( $markerdata as $n => $markerline) {1177 if ( strstr($markerline, "# BEGIN {$marker}"))1176 foreach ( $markerdata as $n => $markerline ) { 1177 if ( strstr( $markerline, "# BEGIN {$marker}" )) 1178 1178 $state = false; 1179 if ( $state) {1180 if ( $n + 1 < count( $markerdata) )1181 fwrite( $f, "{$markerline}\n");1179 if ( $state ) { 1180 if ( $n + 1 < count( $markerdata ) ) 1181 fwrite( $f, "{$markerline}\n" ); 1182 1182 else 1183 fwrite( $f, "{$markerline}");1183 fwrite( $f, "{$markerline}" ); 1184 1184 } 1185 if ( strstr($markerline, "# END {$marker}")) {1186 fwrite( $f, "# BEGIN {$marker}\n");1187 if ( is_array($insertion))1188 foreach ( $insertion as $insertline)1189 fwrite( $f, "{$insertline}\n");1190 fwrite( $f, "# END {$marker}\n");1185 if ( strstr( $markerline, "# END {$marker}" ) ) { 1186 fwrite( $f, "# BEGIN {$marker}\n" ); 1187 if ( is_array( $insertion )) 1188 foreach ( $insertion as $insertline ) 1189 fwrite( $f, "{$insertline}\n" ); 1190 fwrite( $f, "# END {$marker}\n" ); 1191 1191 $state = true; 1192 1192 $foundit = true; … … 1195 1195 } 1196 1196 if (!$foundit) { 1197 fwrite( $f, "# BEGIN {$marker}\n");1198 foreach ( $insertion as $insertline)1199 fwrite( $f, "{$insertline}\n");1200 fwrite( $f, "# END {$marker}\n");1201 } 1202 fclose( $f);1197 fwrite( $f, "# BEGIN {$marker}\n" ); 1198 foreach ( $insertion as $insertline ) 1199 fwrite( $f, "{$insertline}\n" ); 1200 fwrite( $f, "# END {$marker}\n" ); 1201 } 1202 fclose( $f ); 1203 1203 return true; 1204 1204 } else { … … 1208 1208 1209 1209 // extract_from_markers: Owen Winkler 1210 // Returns an array of strings from a file (.htaccess ) from between BEGIN1210 // Returns an array of strings from a file (.htaccess ) from between BEGIN 1211 1211 // and END markers. 1212 function extract_from_markers( $filename, $marker) {1212 function extract_from_markers( $filename, $marker ) { 1213 1213 $result = array (); 1214 1214 1215 if (!file_exists( $filename)) {1215 if (!file_exists( $filename ) ) { 1216 1216 return $result; 1217 1217 } 1218 1218 1219 if ( $markerdata = explode("\n", implode('', file($filename))));1219 if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) )); 1220 1220 { 1221 1221 $state = false; 1222 foreach ( $markerdata as $markerline) {1223 if ( strstr($markerline, "# END {$marker}"))1222 foreach ( $markerdata as $markerline ) { 1223 if ( strstr( $markerline, "# END {$marker}" )) 1224 1224 $state = false; 1225 if ( $state)1225 if ( $state ) 1226 1226 $result[] = $markerline; 1227 if ( strstr($markerline, "# BEGIN {$marker}"))1227 if ( strstr( $markerline, "# BEGIN {$marker}" )) 1228 1228 $state = true; 1229 1229 } … … 1240 1240 return false; 1241 1241 1242 if ( function_exists( 'apache_get_modules') ) {1243 if ( !in_array( 'mod_rewrite', apache_get_modules()) )1242 if ( function_exists( 'apache_get_modules' ) ) { 1243 if ( !in_array( 'mod_rewrite', apache_get_modules() ) ) 1244 1244 return false; 1245 1245 } … … 1252 1252 $home_path = get_home_path(); 1253 1253 1254 if (!$wp_rewrite->using_mod_rewrite_permalinks() )1254 if (!$wp_rewrite->using_mod_rewrite_permalinks() ) 1255 1255 return; 1256 1256 1257 if (!((!file_exists( $home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')))1257 if (!((!file_exists( $home_path.'.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path.'.htaccess' ) ) ) 1258 1258 return; 1259 1259 1260 if (! got_mod_rewrite() )1260 if (! got_mod_rewrite() ) 1261 1261 return; 1262 1262 1263 $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules());1264 insert_with_markers( $home_path.'.htaccess', 'WordPress', $rules);1263 $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() ); 1264 insert_with_markers( $home_path.'.htaccess', 'WordPress', $rules ); 1265 1265 } 1266 1266 … … 1278 1278 $page_templates = array (); 1279 1279 1280 if ( is_array($templates)) {1281 foreach ( $templates as $template) {1282 $template_data = implode( '', file(ABSPATH.$template));1283 preg_match( "|Template Name:(.*)|i", $template_data, $name);1284 preg_match( "|Description:(.*)|i", $template_data, $description);1280 if ( is_array( $templates ) ) { 1281 foreach ( $templates as $template ) { 1282 $template_data = implode( '', file( ABSPATH.$template )); 1283 preg_match( "|Template Name:(.* )|i", $template_data, $name ); 1284 preg_match( "|Description:(.* )|i", $template_data, $description ); 1285 1285 1286 1286 $name = $name[1]; 1287 1287 $description = $description[1]; 1288 1288 1289 if (!empty ( $name)) {1290 $page_templates[trim( $name)] = basename($template);1289 if (!empty ( $name ) ) { 1290 $page_templates[trim( $name )] = basename( $template ); 1291 1291 } 1292 1292 } … … 1296 1296 } 1297 1297 1298 function page_template_dropdown( $default = '') {1298 function page_template_dropdown( $default = '' ) { 1299 1299 $templates = get_page_templates(); 1300 foreach (array_keys( $templates) as $template)1301 : if ( $default == $templates[$template])1300 foreach (array_keys( $templates ) as $template ) 1301 : if ( $default == $templates[$template] ) 1302 1302 $selected = " selected='selected'"; 1303 1303 else … … 1307 1307 } 1308 1308 1309 function parent_dropdown( $default = 0, $parent = 0, $level = 0) {1309 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { 1310 1310 global $wpdb, $post_ID; 1311 $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");1312 1313 if ( $items) {1314 foreach ( $items as $item) {1311 $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" ); 1312 1313 if ( $items ) { 1314 foreach ( $items as $item ) { 1315 1315 // A page cannot be it's own parent. 1316 if (!empty ( $post_ID)) {1317 if ( $item->ID == $post_ID) {1316 if (!empty ( $post_ID ) ) { 1317 if ( $item->ID == $post_ID ) { 1318 1318 continue; 1319 1319 } 1320 1320 } 1321 $pad = str_repeat( ' ', $level * 3);1322 if ( $item->ID == $default)1321 $pad = str_repeat( ' ', $level * 3 ); 1322 if ( $item->ID == $default) 1323 1323 $current = ' selected="selected"'; 1324 1324 else … … 1326 1326 1327 1327 echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>"; 1328 parent_dropdown( $default, $item->ID, $level +1);1328 parent_dropdown( $default, $item->ID, $level +1 ); 1329 1329 } 1330 1330 } else { … … 1344 1344 /*echo "pa: $parent pn: $pagenow pp: $plugin_page<br/>"; 1345 1345 echo "<pre>"; 1346 print_r( $_wp_menu_nopriv);1347 print_r( $_wp_submenu_nopriv);1346 print_r( $_wp_menu_nopriv ); 1347 print_r( $_wp_submenu_nopriv ); 1348 1348 echo "</pre>";*/ 1349 if ( isset( $_wp_submenu_nopriv[$parent][$pagenow]) )1349 if ( isset( $_wp_submenu_nopriv[$parent][$pagenow] ) ) 1350 1350 return false; 1351 1351 1352 if ( isset( $plugin_page) && isset($_wp_submenu_nopriv[$parent][$plugin_page]) )1352 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) 1353 1353 return false; 1354 1354 1355 if ( empty( $parent) ) {1356 if ( isset( $_wp_menu_nopriv[$pagenow]) )1355 if ( empty( $parent) ) { 1356 if ( isset( $_wp_menu_nopriv[$pagenow] ) ) 1357 1357 return false; 1358 if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow]) )1358 if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) ) 1359 1359 return false; 1360 if ( isset( $plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) )1360 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) 1361 1361 return false; 1362 foreach (array_keys( $_wp_submenu_nopriv) as $key) {1363 if ( isset( $_wp_submenu_nopriv[$key][$pagenow]) )1362 foreach (array_keys( $_wp_submenu_nopriv ) as $key ) { 1363 if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) ) 1364 1364 return false; 1365 if ( isset( $plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page]) )1365 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) 1366 1366 return false; 1367 1367 } … … 1369 1369 } 1370 1370 1371 if ( isset ($submenu[$parent])) {1372 foreach ( $submenu[$parent] as $submenu_array) {1373 if ( $submenu_array[2] == $pagenow) {1374 if ( current_user_can($submenu_array[1]))1371 if ( isset( $submenu[$parent] ) ) { 1372 foreach ( $submenu[$parent] as $submenu_array ) { 1373 if ( $submenu_array[2] == $pagenow ) { 1374 if ( current_user_can( $submenu_array[1] )) 1375 1375 return true; 1376 1376 else … … 1380 1380 } 1381 1381 1382 foreach ( $menu as $menu_array) {1383 if ( $menu_array[2] == $parent) {1384 if ( current_user_can($menu_array[1]))1382 foreach ( $menu as $menu_array ) { 1383 if ( $menu_array[2] == $parent) { 1384 if ( current_user_can( $menu_array[1] )) 1385 1385 return true; 1386 1386 else … … 1399 1399 global $plugin_page; 1400 1400 1401 if ( isset ($title) && !empty ($title)) {1401 if ( isset( $title ) && !empty ( $title ) ) { 1402 1402 return $title; 1403 1403 } 1404 1404 1405 $hook = get_plugin_page_hook( $plugin_page, $pagenow);1405 $hook = get_plugin_page_hook( $plugin_page, $pagenow ); 1406 1406 1407 1407 $parent = $parent1 = get_admin_page_parent(); 1408 if ( empty ($parent)) {1409 foreach ( $menu as $menu_array) {1410 if ( isset ($menu_array[3])) {1411 if ( $menu_array[2] == $pagenow) {1408 if ( empty ( $parent) ) { 1409 foreach ( $menu as $menu_array ) { 1410 if ( isset( $menu_array[3] ) ) { 1411 if ( $menu_array[2] == $pagenow ) { 1412 1412 $title = $menu_array[3]; 1413 1413 return $menu_array[3]; 1414 1414 } else 1415 if ( isset ($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) {1415 if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) { 1416 1416 $title = $menu_array[3]; 1417 1417 return $menu_array[3]; 1418 1418 } 1419 } else { 1420 $title = $menu_array[0]; 1421 return $title; 1419 1422 } 1420 1423 } 1421 1424 } else { 1422 foreach (array_keys($submenu) as $parent) { 1423 foreach ($submenu[$parent] as $submenu_array) { 1424 if (isset ($submenu_array[3])) { 1425 if ($submenu_array[2] == $pagenow) { 1425 foreach (array_keys( $submenu ) as $parent) { 1426 foreach ( $submenu[$parent] as $submenu_array ) { 1427 if ( isset( $plugin_page ) && 1428 ($plugin_page == $submenu_array[2] ) && 1429 (($parent == $pagenow ) || ($parent == $plugin_page ) || ($plugin_page == $hook ) || (($pagenow == 'admin.php' ) && ($parent1 != $submenu_array[2] ) ) ) 1430 ) { 1426 1431 $title = $submenu_array[3]; 1427 1432 return $submenu_array[3]; 1428 } else 1429 if (isset ($plugin_page) && ($plugin_page == $submenu_array[2]) && (($parent == $pagenow) || ($parent == $plugin_page) || ($plugin_page == $hook) || (($pagenow == 'admin.php') && ($parent1 != $submenu_array[2])))) { 1430 $title = $submenu_array[3]; 1431 return $submenu_array[3]; 1432 } 1433 } 1434 1435 if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page 1436 continue; 1437 1438 if ( isset( $submenu_array[3] ) ) { 1439 $title = $submenu_array[3]; 1440 return $submenu_array[3]; 1441 } else { 1442 $title = $submenu_array[0]; 1443 return $title; 1433 1444 } 1434 1445 } … … 1436 1447 } 1437 1448 1438 return '';1449 return $title; 1439 1450 } 1440 1451 … … 1449 1460 global $_wp_submenu_nopriv; 1450 1461 1451 if ( !empty ( $parent_file) ) {1452 if ( isset( $_wp_real_parent_file[$parent_file]) )1462 if ( !empty ( $parent_file ) ) { 1463 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 1453 1464 $parent_file = $_wp_real_parent_file[$parent_file]; 1454 1465 … … 1456 1467 } 1457 1468 1458 if ( $pagenow == 'admin.php' && isset ($plugin_page)) {1459 foreach ( $menu as $parent_menu) {1460 if ( $parent_menu[2] == $plugin_page) {1469 if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { 1470 foreach ( $menu as $parent_menu ) { 1471 if ( $parent_menu[2] == $plugin_page ) { 1461 1472 $parent_file = $plugin_page; 1462 if ( isset( $_wp_real_parent_file[$parent_file]) )1473 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 1463 1474 $parent_file = $_wp_real_parent_file[$parent_file]; 1464 1475 return $parent_file; 1465 1476 } 1466 1477 } 1467 if ( isset( $_wp_menu_nopriv[$plugin_page]) ) {1478 if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) { 1468 1479 $parent_file = $plugin_page; 1469 if ( isset( $_wp_real_parent_file[$parent_file]) )1480 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 1470 1481 $parent_file = $_wp_real_parent_file[$parent_file]; 1471 1482 return $parent_file; … … 1473 1484 } 1474 1485 1475 if ( isset( $plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) ) {1486 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { 1476 1487 $parent_file = $pagenow; 1477 if ( isset( $_wp_real_parent_file[$parent_file]) )1488 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 1478 1489 $parent_file = $_wp_real_parent_file[$parent_file]; 1479 1490 return $parent_file; 1480 1491 } 1481 1492 1482 foreach (array_keys( $submenu) as $parent) {1483 foreach ( $submenu[$parent] as $submenu_array) {1484 if ( isset( $_wp_real_parent_file[$parent]) )1493 foreach (array_keys( $submenu ) as $parent) { 1494 foreach ( $submenu[$parent] as $submenu_array ) { 1495 if ( isset( $_wp_real_parent_file[$parent] ) ) 1485 1496 $parent = $_wp_real_parent_file[$parent]; 1486 if ( $submenu_array[2] == $pagenow) {1497 if ( $submenu_array[2] == $pagenow ) { 1487 1498 $parent_file = $parent; 1488 1499 return $parent; 1489 1500 } else 1490 if ( isset ($plugin_page) && ($plugin_page == $submenu_array[2])) {1501 if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) { 1491 1502 $parent_file = $parent; 1492 1503 return $parent; … … 1499 1510 } 1500 1511 1501 function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '') {1512 function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 1502 1513 global $menu, $admin_page_hooks; 1503 1514 1504 $file = plugin_basename( $file);1505 1506 $menu[] = array ( $menu_title, $access_level, $file, $page_title);1507 1508 $admin_page_hooks[$file] = sanitize_title( $menu_title);1509 1510 $hookname = get_plugin_page_hookname( $file, '');1511 if (!empty ( $function) && !empty ($hookname))1512 add_action( $hookname, $function);1515 $file = plugin_basename( $file ); 1516 1517 $menu[] = array ( $menu_title, $access_level, $file, $page_title ); 1518 1519 $admin_page_hooks[$file] = sanitize_title( $menu_title ); 1520 1521 $hookname = get_plugin_page_hookname( $file, '' ); 1522 if (!empty ( $function ) && !empty ( $hookname )) 1523 add_action( $hookname, $function ); 1513 1524 1514 1525 return $hookname; 1515 1526 } 1516 1527 1517 function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '') {1528 function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) { 1518 1529 global $submenu; 1519 1530 global $menu; … … 1522 1533 global $_wp_menu_nopriv; 1523 1534 1524 $file = plugin_basename( $file);1525 1526 $parent = plugin_basename( $parent);1527 if ( isset( $_wp_real_parent_file[$parent]) )1535 $file = plugin_basename( $file ); 1536 1537 $parent = plugin_basename( $parent); 1538 if ( isset( $_wp_real_parent_file[$parent] ) ) 1528 1539 $parent = $_wp_real_parent_file[$parent]; 1529 1540 1530 if ( !current_user_can( $access_level) ) {1541 if ( !current_user_can( $access_level ) ) { 1531 1542 $_wp_submenu_nopriv[$parent][$file] = true; 1532 1543 return false; … … 1537 1548 // parent file someone is trying to link back to the parent manually. In 1538 1549 // this case, don't automatically add a link back to avoid duplication. 1539 if (!isset ($submenu[$parent]) && $file != $parent ) {1540 foreach ( $menu as $parent_menu) {1541 if ( $parent_menu[2] == $parent && current_user_can( $parent_menu[1]) ) {1550 if (!isset( $submenu[$parent] ) && $file != $parent ) { 1551 foreach ( $menu as $parent_menu ) { 1552 if ( $parent_menu[2] == $parent && current_user_can( $parent_menu[1] ) ) { 1542 1553 $submenu[$parent][] = $parent_menu; 1543 1554 } … … 1545 1556 } 1546 1557 1547 $submenu[$parent][] = array ( $menu_title, $access_level, $file, $page_title);1548 1549 $hookname = get_plugin_page_hookname( $file, $parent);1550 if (!empty ( $function) && !empty ($hookname))1551 add_action( $hookname, $function);1558 $submenu[$parent][] = array ( $menu_title, $access_level, $file, $page_title ); 1559 1560 $hookname = get_plugin_page_hookname( $file, $parent); 1561 if (!empty ( $function ) && !empty ( $hookname )) 1562 add_action( $hookname, $function ); 1552 1563 1553 1564 return $hookname; 1554 1565 } 1555 1566 1556 function add_options_page( $page_title, $menu_title, $access_level, $file, $function = '') {1557 return add_submenu_page( 'options-general.php', $page_title, $menu_title, $access_level, $file, $function);1558 } 1559 1560 function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '') {1561 return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function);1562 } 1563 1564 function add_theme_page( $page_title, $menu_title, $access_level, $file, $function = '') {1565 return add_submenu_page( 'themes.php', $page_title, $menu_title, $access_level, $file, $function);1566 } 1567 1568 function validate_file( $file, $allowed_files = '') {1569 if ( false !== strpos($file, './'))1567 function add_options_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 1568 return add_submenu_page( 'options-general.php', $page_title, $menu_title, $access_level, $file, $function ); 1569 } 1570 1571 function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 1572 return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function ); 1573 } 1574 1575 function add_theme_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 1576 return add_submenu_page( 'themes.php', $page_title, $menu_title, $access_level, $file, $function ); 1577 } 1578 1579 function validate_file( $file, $allowed_files = '' ) { 1580 if ( false !== strpos( $file, './' )) 1570 1581 return 1; 1571 1582 1572 if (':' == substr( $file, 1, 1))1583 if (':' == substr( $file, 1, 1 )) 1573 1584 return 2; 1574 1585 1575 if (!empty ( $allowed_files) && (!in_array($file, $allowed_files)))1586 if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) ) 1576 1587 return 3; 1577 1588 … … 1579 1590 } 1580 1591 1581 function validate_file_to_edit( $file, $allowed_files = '') {1582 $file = stripslashes( $file);1583 1584 $code = validate_file( $file, $allowed_files);1585 1586 if (!$code )1592 function validate_file_to_edit( $file, $allowed_files = '' ) { 1593 $file = stripslashes( $file ); 1594 1595 $code = validate_file( $file, $allowed_files ); 1596 1597 if (!$code ) 1587 1598 return $file; 1588 1599 1589 switch ( $code) {1600 switch ( $code ) { 1590 1601 case 1 : 1591 wp_die( __('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));1602 wp_die( __('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.' )); 1592 1603 1593 1604 case 2 : 1594 wp_die( __('Sorry, can’t call files with their real path.'));1605 wp_die( __('Sorry, can’t call files with their real path.' )); 1595 1606 1596 1607 case 3 : 1597 wp_die( __('Sorry, that file cannot be edited.'));1608 wp_die( __('Sorry, that file cannot be edited.' )); 1598 1609 } 1599 1610 } 1600 1611 1601 1612 function get_home_path() { 1602 $home = get_option( 'home');1603 if ( $home != '' && $home != get_option('siteurl')) {1604 $home_path = parse_url( $home);1613 $home = get_option( 'home' ); 1614 if ( $home != '' && $home != get_option( 'siteurl' ) ) { 1615 $home_path = parse_url( $home ); 1605 1616 $home_path = $home_path['path']; 1606 $root = str_replace( $_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"]);1607 $home_path = trailingslashit( $root.$home_path);1617 $root = str_replace( $_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"] ); 1618 $home_path = trailingslashit( $root.$home_path ); 1608 1619 } else { 1609 1620 $home_path = ABSPATH; … … 1613 1624 } 1614 1625 1615 function get_real_file_to_edit( $file) {1616 if ('index.php' == $file || '.htaccess' == $file ) {1626 function get_real_file_to_edit( $file ) { 1627 if ('index.php' == $file || '.htaccess' == $file ) { 1617 1628 $real_file = get_home_path().$file; 1618 1629 } else { … … 1623 1634 } 1624 1635 1625 $wp_file_descriptions = array ('index.php' => __( 'Main Index Template'), 'style.css' => __('Stylesheet'), 'comments.php' => __('Comments'), 'comments-popup.php' => __('Popup Comments'), 'footer.php' => __('Footer'), 'header.php' => __('Header'), 'sidebar.php' => __('Sidebar'), 'archive.php' => __('Archives'), 'category.php' => __('Category Template'), 'page.php' => __('Page Template'), 'search.php' => __('Search Results'), 'single.php' => __('Single Post'), '404.php' => __('404 Template'), 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), '.htaccess' => __('.htaccess (for rewrite rules)'),1636 $wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ), 1626 1637 // Deprecated files 1627 'wp-layout.css' => __( 'Stylesheet'), 'wp-comments.php' => __('Comments Template'), 'wp-comments-popup.php' => __('Popup Comments Template'));1628 1629 function get_file_description( $file) {1638 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' )); 1639 1640 function get_file_description( $file ) { 1630 1641 global $wp_file_descriptions; 1631 1642 1632 if ( isset ($wp_file_descriptions[basename($file)])) {1633 return $wp_file_descriptions[basename( $file)];1643 if ( isset( $wp_file_descriptions[basename( $file )] ) ) { 1644 return $wp_file_descriptions[basename( $file )]; 1634 1645 } 1635 1646 elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) { 1636 $template_data = implode( '', file( ABSPATH . $file ));1637 if ( preg_match("|Template Name:(.*)|i", $template_data, $name))1647 $template_data = implode( '', file( ABSPATH . $file ) ); 1648 if ( preg_match( "|Template Name:(.* )|i", $template_data, $name )) 1638 1649 return $name[1]; 1639 1650 } 1640 1651 1641 return basename( $file);1642 } 1643 1644 function update_recently_edited( $file) {1645 $oldfiles = (array ) get_option('recently_edited');1646 if ( $oldfiles) {1647 $oldfiles = array_reverse( $oldfiles);1652 return basename( $file ); 1653 } 1654 1655 function update_recently_edited( $file ) { 1656 $oldfiles = (array ) get_option( 'recently_edited' ); 1657 if ( $oldfiles ) { 1658 $oldfiles = array_reverse( $oldfiles ); 1648 1659 $oldfiles[] = $file; 1649 $oldfiles = array_reverse( $oldfiles);1650 $oldfiles = array_unique( $oldfiles);1651 if ( 5 < count($oldfiles))1652 array_pop( $oldfiles);1660 $oldfiles = array_reverse( $oldfiles ); 1661 $oldfiles = array_unique( $oldfiles ); 1662 if ( 5 < count( $oldfiles )) 1663 array_pop( $oldfiles ); 1653 1664 } else { 1654 1665 $oldfiles[] = $file; 1655 1666 } 1656 update_option( 'recently_edited', $oldfiles);1657 } 1658 1659 function get_plugin_data( $plugin_file) {1660 $plugin_data = implode( '', file($plugin_file));1661 preg_match( "|Plugin Name:(.*)|i", $plugin_data, $plugin_name);1662 preg_match( "|Plugin URI:(.*)|i", $plugin_data, $plugin_uri);1663 preg_match( "|Description:(.*)|i", $plugin_data, $description);1664 preg_match( "|Author:(.*)|i", $plugin_data, $author_name);1665 preg_match( "|Author URI:(.*)|i", $plugin_data, $author_uri);1666 if ( preg_match("|Version:(.*)|i", $plugin_data, $version))1667 $version = trim( $version[1]);1667 update_option( 'recently_edited', $oldfiles ); 1668 } 1669 1670 function get_plugin_data( $plugin_file ) { 1671 $plugin_data = implode( '', file( $plugin_file )); 1672 preg_match( "|Plugin Name:(.*)|i", $plugin_data, $plugin_name ); 1673 preg_match( "|Plugin URI:(.*)|i", $plugin_data, $plugin_uri ); 1674 preg_match( "|Description:(.*)|i", $plugin_data, $description ); 1675 preg_match( "|Author:(.*)|i", $plugin_data, $author_name ); 1676 preg_match( "|Author URI:(.*)|i", $plugin_data, $author_uri ); 1677 if ( preg_match( "|Version:(.*)|i", $plugin_data, $version )) 1678 $version = trim( $version[1] ); 1668 1679 else 1669 1680 $version = ''; 1670 1681 1671 $description = wptexturize( trim($description[1]));1682 $description = wptexturize( trim( $description[1] )); 1672 1683 1673 1684 $name = $plugin_name[1]; 1674 $name = trim( $name);1685 $name = trim( $name ); 1675 1686 $plugin = $name; 1676 if ('' != $plugin_uri[1] && '' != $name ) {1677 $plugin = '<a href="' . trim( $plugin_uri[1]) . '" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';1678 } 1679 1680 if ('' == $author_uri[1] ) {1681 $author = trim( $author_name[1]);1682 } else { 1683 $author = '<a href="' . trim( $author_uri[1]) . '" title="'.__('Visit author homepage').'">' . trim($author_name[1]) . '</a>';1684 } 1685 1686 return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1] );1687 if ('' != $plugin_uri[1] && '' != $name ) { 1688 $plugin = '<a href="' . trim( $plugin_uri[1] ) . '" title="'.__( 'Visit plugin homepage' ).'">'.$plugin.'</a>'; 1689 } 1690 1691 if ('' == $author_uri[1] ) { 1692 $author = trim( $author_name[1] ); 1693 } else { 1694 $author = '<a href="' . trim( $author_uri[1] ) . '" title="'.__( 'Visit author homepage' ).'">' . trim( $author_name[1] ) . '</a>'; 1695 } 1696 1697 return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1] ); 1687 1698 } 1688 1699 … … 1690 1701 global $wp_plugins; 1691 1702 1692 if ( isset ($wp_plugins)) {1703 if ( isset( $wp_plugins ) ) { 1693 1704 return $wp_plugins; 1694 1705 } … … 1698 1709 1699 1710 // Files in wp-content/plugins directory 1700 $plugins_dir = @ dir( $plugin_root);1701 if ( $plugins_dir) {1702 while (($file = $plugins_dir->read() ) !== false) {1703 if ( preg_match('|^\.+$|', $file))1711 $plugins_dir = @ dir( $plugin_root); 1712 if ( $plugins_dir ) { 1713 while (($file = $plugins_dir->read() ) !== false ) { 1714 if ( preg_match( '|^\.+$|', $file )) 1704 1715 continue; 1705 if ( is_dir($plugin_root.'/'.$file)) {1706 $plugins_subdir = @ dir( $plugin_root.'/'.$file);1707 if ( $plugins_subdir) {1708 while (($subfile = $plugins_subdir->read() ) !== false) {1709 if ( preg_match('|^\.+$|', $subfile))1716 if ( is_dir( $plugin_root.'/'.$file ) ) { 1717 $plugins_subdir = @ dir( $plugin_root.'/'.$file ); 1718 if ( $plugins_subdir ) { 1719 while (($subfile = $plugins_subdir->read() ) !== false ) { 1720 if ( preg_match( '|^\.+$|', $subfile )) 1710 1721 continue; 1711 if ( preg_match('|\.php$|', $subfile))1722 if ( preg_match( '|\.php$|', $subfile )) 1712 1723 $plugin_files[] = "$file/$subfile"; 1713 1724 } 1714 1725 } 1715 1726 } else { 1716 if ( preg_match('|\.php$|', $file))1727 if ( preg_match( '|\.php$|', $file )) 1717 1728 $plugin_files[] = $file; 1718 1729 } … … 1724 1735 1725 1736 foreach ( $plugin_files as $plugin_file ) { 1726 if ( !is_readable( "$plugin_root/$plugin_file") )1737 if ( !is_readable( "$plugin_root/$plugin_file" ) ) 1727 1738 continue; 1728 1739 1729 $plugin_data = get_plugin_data( "$plugin_root/$plugin_file");1730 1731 if ( empty ( $plugin_data['Name']) )1740 $plugin_data = get_plugin_data( "$plugin_root/$plugin_file" ); 1741 1742 if ( empty ( $plugin_data['Name'] ) ) 1732 1743 continue; 1733 1744 1734 $wp_plugins[plugin_basename( $plugin_file)] = $plugin_data;1735 } 1736 1737 uasort( $wp_plugins, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));1745 $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; 1746 } 1747 1748 uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); 1738 1749 1739 1750 return $wp_plugins; 1740 1751 } 1741 1752 1742 function get_plugin_page_hookname( $plugin_page, $parent_page) {1753 function get_plugin_page_hookname( $plugin_page, $parent_page ) { 1743 1754 global $admin_page_hooks; 1744 1755 1745 1756 $parent = get_admin_page_parent(); 1746 1757 1747 if ( empty ($parent_page) || 'admin.php' == $parent_page) {1748 if ( isset ($admin_page_hooks[$plugin_page]))1758 if ( empty ( $parent_page ) || 'admin.php' == $parent_page ) { 1759 if ( isset( $admin_page_hooks[$plugin_page] )) 1749 1760 $page_type = 'toplevel'; 1750 1761 else 1751 if ( isset ($admin_page_hooks[$parent]))1762 if ( isset( $admin_page_hooks[$parent] )) 1752 1763 $page_type = $admin_page_hooks[$parent]; 1753 1764 } else 1754 if ( isset ($admin_page_hooks[$parent_page])) {1765 if ( isset( $admin_page_hooks[$parent_page] ) ) { 1755 1766 $page_type = $admin_page_hooks[$parent_page]; 1756 1767 } else { … … 1758 1769 } 1759 1770 1760 $plugin_name = preg_replace( '!\.php!', '', $plugin_page);1771 $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); 1761 1772 1762 1773 return $page_type.'_page_'.$plugin_name; 1763 1774 } 1764 1775 1765 function get_plugin_page_hook( $plugin_page, $parent_page) {1776 function get_plugin_page_hook( $plugin_page, $parent_page ) { 1766 1777 global $wp_filter; 1767 1778 1768 $hook = get_plugin_page_hookname( $plugin_page, $parent_page);1769 if ( isset ($wp_filter[$hook]))1779 $hook = get_plugin_page_hookname( $plugin_page, $parent_page ); 1780 if ( isset( $wp_filter[$hook] )) 1770 1781 return $hook; 1771 1782 else … … 1774 1785 1775 1786 function browse_happy() { 1776 $getit = __( 'WordPress recommends a better browser');1787 $getit = __( 'WordPress recommends a better browser' ); 1777 1788 echo ' 1778 1789 <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p> 1779 1790 '; 1780 1791 } 1781 if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))1782 add_action( 'admin_footer', 'browse_happy');1783 1784 function documentation_link( $for) {1792 if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' )) 1793 add_action( 'admin_footer', 'browse_happy' ); 1794 1795 function documentation_link( $for ) { 1785 1796 return; 1786 1797 } 1787 1798 1788 function register_importer( $id, $name, $description, $callback) {1799 function register_importer( $id, $name, $description, $callback ) { 1789 1800 global $wp_importers; 1790 1801 1791 $wp_importers[$id] = array ( $name, $description, $callback);1802 $wp_importers[$id] = array ( $name, $description, $callback ); 1792 1803 } 1793 1804 … … 1818 1829 // array wp_handle_upload ( array &file [, array overrides] ) 1819 1830 // file: reference to a single element of $_FILES. Call the function once for each uploaded file. 1820 // overrides: an associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE).1831 // overrides: an associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ). 1821 1832 // On success, returns an associative array of file attributes. 1822 // On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array('error'=>$message).1823 function wp_handle_upload( &$file, $overrides = false) {1833 // On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). 1834 function wp_handle_upload( &$file, $overrides = false ) { 1824 1835 // The default error handler. 1825 if (! function_exists( 'wp_handle_upload_error') ) {1826 function wp_handle_upload_error( &$file, $message) {1827 return array( 'error'=>$message);1836 if (! function_exists( 'wp_handle_upload_error' ) ) { 1837 function wp_handle_upload_error( &$file, $message ) { 1838 return array( 'error'=>$message ); 1828 1839 } 1829 1840 } … … 1836 1847 1837 1848 // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. 1838 $upload_error_strings = array( false,1839 __( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>."),1840 __( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form."),1841 __( "The uploaded file was only partially uploaded."),1842 __( "No file was uploaded."),1843 __( "Missing a temporary folder."),1844 __( "Failed to write file to disk."));1849 $upload_error_strings = array( false, 1850 __( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ), 1851 __( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ), 1852 __( "The uploaded file was only partially uploaded." ), 1853 __( "No file was uploaded." ), 1854 __( "Missing a temporary folder." ), 1855 __( "Failed to write file to disk." )); 1845 1856 1846 1857 // All tests are on by default. Most can be turned off by $override[{test_name}] = false; … … 1852 1863 1853 1864 // Install user overrides. Did we mention that this voids your warranty? 1854 if ( is_array( $overrides) )1855 extract( $overrides, EXTR_OVERWRITE);1865 if ( is_array( $overrides ) ) 1866 extract( $overrides, EXTR_OVERWRITE ); 1856 1867 1857 1868 // A correct form post will pass this test. 1858 if ( $test_form && (!isset( $_POST['action']) || ($_POST['action'] != $action)) )1859 return $upload_error_handler( $file, __('Invalid form submission.'));1869 if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) ) 1870 return $upload_error_handler( $file, __( 'Invalid form submission.' )); 1860 1871 1861 1872 // A successful upload will pass this test. It makes no sense to override this one. 1862 1873 if ( $file['error'] > 0 ) 1863 return $upload_error_handler( $file, $upload_error_strings[$file['error']]);1874 return $upload_error_handler( $file, $upload_error_strings[$file['error']] ); 1864 1875 1865 1876 // A non-empty file will pass this test. 1866 if ( $test_size && !($file['size'] > 0 ) )1867 return $upload_error_handler( $file, __('File is empty. Please upload something more substantial.'));1877 if ( $test_size && !($file['size'] > 0 ) ) 1878 return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial.' )); 1868 1879 1869 1880 // A properly uploaded file will pass this test. There should be no reason to override this one. 1870 if (! @ is_uploaded_file( $file['tmp_name']) )1871 return $upload_error_handler( $file, __('Specified file failed upload test.'));1881 if (! @ is_uploaded_file( $file['tmp_name'] ) ) 1882 return $upload_error_handler( $file, __( 'Specified file failed upload test.' )); 1872 1883 1873 1884 // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. 1874 1885 if ( $test_type ) { 1875 $wp_filetype = wp_check_filetype( $file['name'], $mimes);1876 1877 extract( $wp_filetype);1886 $wp_filetype = wp_check_filetype( $file['name'], $mimes ); 1887 1888 extract( $wp_filetype ); 1878 1889 1879 1890 if ( !$type || !$ext ) 1880 return $upload_error_handler( $file, __('File type does not meet security guidelines. Try another.'));1891 return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); 1881 1892 } 1882 1893 1883 1894 // A writable uploads dir will pass this test. Again, there's no point overriding this one. 1884 1895 if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) 1885 return $upload_error_handler( $file, $uploads['error']);1896 return $upload_error_handler( $file, $uploads['error'] ); 1886 1897 1887 1898 // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. 1888 if ( isset( $unique_filename_callback) && function_exists($unique_filename_callback) ) {1889 $filename = $unique_filename_callback( $uploads['path'], $file['name']);1899 if ( isset( $unique_filename_callback ) && function_exists( $unique_filename_callback ) ) { 1900 $filename = $unique_filename_callback( $uploads['path'], $file['name'] ); 1890 1901 } else { 1891 1902 $number = ''; 1892 $filename = str_replace( '#', '_', $file['name']);1893 $filename = str_replace( array('\\', "'"), '', $filename);1894 if ( empty( $ext) )1903 $filename = str_replace( '#', '_', $file['name'] ); 1904 $filename = str_replace( array( '\\', "'" ), '', $filename ); 1905 if ( empty( $ext) ) 1895 1906 $ext = ''; 1896 1907 else 1897 1908 $ext = ".$ext"; 1898 while ( file_exists( $uploads['path'] . "/$filename") ) {1909 while ( file_exists( $uploads['path'] . "/$filename" ) ) { 1899 1910 if ( '' == "$number$ext" ) 1900 1911 $filename = $filename . ++$number . $ext; 1901 1912 else 1902 $filename = str_replace( "$number$ext", ++$number . $ext, $filename);1903 } 1904 $filename = str_replace( $ext, '', $filename);1905 $filename = sanitize_title_with_dashes( $filename) . $ext;1913 $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); 1914 } 1915 $filename = str_replace( $ext, '', $filename ); 1916 $filename = sanitize_title_with_dashes( $filename ) . $ext; 1906 1917 } 1907 1918 1908 1919 // Move the file to the uploads dir 1909 1920 $new_file = $uploads['path'] . "/$filename"; 1910 if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file) )1911 wp_die( printf(__('The uploaded file could not be moved to %s.'), $uploads['path']));1921 if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) 1922 wp_die( printf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] )); 1912 1923 1913 1924 // Set correct file permissions 1914 $stat = stat( dirname($new_file));1925 $stat = stat( dirname( $new_file )); 1915 1926 $perms = $stat['mode'] & 0000666; 1916 @ chmod( $new_file, $perms);1927 @ chmod( $new_file, $perms ); 1917 1928 1918 1929 // Compute the URL 1919 1930 $url = $uploads['url'] . "/$filename"; 1920 1931 1921 $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type) );1932 $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) ); 1922 1933 1923 1934 return $return; 1924 1935 } 1925 1936 1926 function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96) {1937 function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) { 1927 1938 if ( $height <= $hmax && $width <= $wmax ) 1928 return array( $width, $height);1939 return array( $width, $height); 1929 1940 elseif ( $width / $height > $wmax / $hmax ) 1930 return array( $wmax, (int) ($height / $width * $wmax));1941 return array( $wmax, (int) ($height / $width * $wmax )); 1931 1942 else 1932 return array( (int) ($width / $height * $hmax), $hmax);1933 } 1934 1935 function wp_import_cleanup( $id) {1936 wp_delete_attachment( $id);1937 } 1938 1939 function wp_import_upload_form( $action) {1940 $size = strtolower( ini_get( 'upload_max_filesize') );1943 return array( (int) ($width / $height * $hmax ), $hmax ); 1944 } 1945 1946 function wp_import_cleanup( $id ) { 1947 wp_delete_attachment( $id ); 1948 } 1949 1950 function wp_import_upload_form( $action ) { 1951 $size = strtolower( ini_get( 'upload_max_filesize' ) ); 1941 1952 $bytes = 0; 1942 1953 if ( strstr( $size, 'k' ) ) … … 1949 1960 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo $action ?>"> 1950 1961 <p> 1951 <label for="upload"><?php _e( 'Choose a file from your computer:'); ?></label> (<?php printf( __('Maximum size: %s'), $size ); ?>)1962 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> ) 1952 1963 <input type="file" id="upload" name="import" size="25" /> 1953 1964 <input type="hidden" name="action" value="save" /> … … 1955 1966 </p> 1956 1967 <p class="submit"> 1957 <input type="submit" value="<?php _e( 'Upload file and import'); ?> »" />1968 <input type="submit" value="<?php _e( 'Upload file and import' ); ?> »" /> 1958 1969 </p> 1959 1970 </form> … … 1962 1973 1963 1974 function wp_import_handle_upload() { 1964 $overrides = array( 'test_form' => false, 'test_type' => false);1965 $file = wp_handle_upload( $_FILES['import'], $overrides);1966 1967 if ( isset( $file['error']) )1975 $overrides = array( 'test_form' => false, 'test_type' => false ); 1976 $file = wp_handle_upload( $_FILES['import'], $overrides ); 1977 1978 if ( isset( $file['error'] ) ) 1968 1979 return $file; 1969 1980 1970 1981 $url = $file['url']; 1971 1982 $file = addslashes( $file['file'] ); 1972 $filename = basename( $file);1983 $filename = basename( $file ); 1973 1984 1974 1985 // Construct the object array 1975 $object = array( 1976 'post_title' => $filename, 1986 $object = array( 'post_title' => $filename, 1977 1987 'post_content' => $url, 1978 1988 'post_mime_type' => 'import', … … 1981 1991 1982 1992 // Save the data 1983 $id = wp_insert_attachment( $object, $file);1984 1985 return array( 'file' => $file, 'id' => $id);1986 } 1987 1988 function the_attachment_links( $id = false) {1993 $id = wp_insert_attachment( $object, $file ); 1994 1995 return array( 'file' => $file, 'id' => $id ); 1996 } 1997 1998 function the_attachment_links( $id = false ) { 1989 1999 $id = (int) $id; 1990 $post = & get_post( $id);2000 $post = & get_post( $id ); 1991 2001 1992 2002 if ( $post->post_type != 'attachment' ) 1993 2003 return false; 1994 2004 1995 $icon = get_attachment_icon( $post->ID);2005 $icon = get_attachment_icon( $post->ID ); 1996 2006 $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true ); 1997 $thumb = isset( $attachment_data['thumb']);2007 $thumb = isset( $attachment_data['thumb'] ); 1998 2008 ?> 1999 2009 <form id="the-attachment-links"> … … 2002 2012 <col class="widefat" /> 2003 2013 <tr> 2004 <th scope="row"><?php _e( 'URL') ?></th>2014 <th scope="row"><?php _e( 'URL' ) ?></th> 2005 2015 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo $post->guid ?></textarea></td> 2006 2016 </tr> 2007 2017 <?php if ( $icon ) : ?> 2008 2018 <tr> 2009 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file') : _e('Image linked to file'); ?></th>2019 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th> 2010 2020 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid; ?>"><?php echo $icon ?></a></textarea></td> 2011 2021 </tr> 2012 2022 <tr> 2013 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page') : _e('Image linked to file'); ?></th>2014 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>2023 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to file' ); ?></th> 2024 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td> 2015 2025 </tr> 2016 2026 <?php else : ?> 2017 2027 <tr> 2018 <th scope="row"><?php _e( 'Link to file') ?></th>2019 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename( $post->guid); ?></a></textarea></td>2028 <th scope="row"><?php _e( 'Link to file' ) ?></th> 2029 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename( $post->guid ); ?></a></textarea></td> 2020 2030 </tr> 2021 2031 <tr> 2022 <th scope="row"><?php _e( 'Link to page') ?></th>2023 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>2032 <th scope="row"><?php _e( 'Link to page' ) ?></th> 2033 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td> 2024 2034 </tr> 2025 2035 <?php endif; ?> … … 2029 2039 } 2030 2040 2031 function get_udims( $width, $height) {2041 function get_udims( $width, $height) { 2032 2042 if ( $height <= 96 && $width <= 128 ) 2033 return array( $width, $height);2043 return array( $width, $height); 2034 2044 elseif ( $width / $height > 4 / 3 ) 2035 return array( 128, (int) ($height / $width * 128));2045 return array( 128, (int) ($height / $width * 128 )); 2036 2046 else 2037 return array( (int) ($width / $height * 96), 96);2038 } 2039 2040 function wp_reset_vars( $vars) {2041 for ( $i=0; $i<count($vars); $i += 1) {2047 return array( (int) ($width / $height * 96 ), 96 ); 2048 } 2049 2050 function wp_reset_vars( $vars ) { 2051 for ( $i=0; $i<count( $vars ); $i += 1 ) { 2042 2052 $var = $vars[$i]; 2043 2053 global $$var; 2044 2054 2045 if (!isset( $$var)) {2046 if ( empty($_POST["$var"])) {2047 if ( empty($_GET["$var"]))2055 if (!isset( $$var ) ) { 2056 if ( empty( $_POST["$var"] ) ) { 2057 if ( empty( $_GET["$var"] ) ) 2048 2058 $$var = ''; 2049 2059 else … … 2057 2067 2058 2068 // If siteurl or home changed, reset cookies and flush rewrite rules. 2059 function update_home_siteurl( $old_value, $value) {2069 function update_home_siteurl( $old_value, $value ) { 2060 2070 global $wp_rewrite, $user_login, $user_pass_md5; 2061 2071 2062 if ( defined( "WP_INSTALLING") )2072 if ( defined( "WP_INSTALLING" ) ) 2063 2073 return; 2064 2074 … … 2068 2078 wp_clearcookie(); 2069 2079 // Set cookies for new paths. 2070 wp_setcookie( $user_login, $user_pass_md5, true, get_option('home'), get_option('siteurl'));2071 } 2072 2073 add_action( 'update_option_home', 'update_home_siteurl', 10, 2);2074 add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2);2075 2076 function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false) {2077 if ( ctype_digit( $src_file) ) // Handle int as attachment ID2078 $src_file = get_attached_file( $src_file);2079 2080 $src = wp_load_image( $src_file);2081 2082 if ( !is_resource( $src))2080 wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); 2081 } 2082 2083 add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); 2084 add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); 2085 2086 function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { 2087 if ( ctype_digit( $src_file ) ) // Handle int as attachment ID 2088 $src_file = get_attached_file( $src_file ); 2089 2090 $src = wp_load_image( $src_file ); 2091 2092 if ( !is_resource( $src )) 2083 2093 return $src; 2084 2094 2085 $dst = imagecreatetruecolor( $dst_w, $dst_h);2095 $dst = imagecreatetruecolor( $dst_w, $dst_h ); 2086 2096 2087 2097 if ( $src_abs ) { … … 2090 2100 } 2091 2101 2092 imageantialias( $dst, true);2093 imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);2102 imageantialias( $dst, true ); 2103 imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); 2094 2104 2095 2105 if ( !$dst_file ) 2096 $dst_file = str_replace( basename($src_file), 'cropped-'.basename($src_file), $src_file);2097 2098 $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file);2099 2100 if ( imagejpeg( $dst, $dst_file) )2106 $dst_file = str_replace( basename( $src_file ), 'cropped-'.basename( $src_file ), $src_file ); 2107 2108 $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file ); 2109 2110 if ( imagejpeg( $dst, $dst_file ) ) 2101 2111 return $dst_file; 2102 2112 else … … 2104 2114 } 2105 2115 2106 function wp_load_image( $file) {2107 if ( ctype_digit( $file) )2108 $file = get_attached_file( $file);2109 2110 if ( !file_exists( $file) )2116 function wp_load_image( $file ) { 2117 if ( ctype_digit( $file ) ) 2118 $file = get_attached_file( $file ); 2119 2120 if ( !file_exists( $file ) ) 2111 2121 return "File '$file' doesn't exist?"; 2112 2122 2113 $contents = file_get_contents( $file);2114 2115 $image = imagecreatefromstring( $contents);2116 2117 if ( !is_resource( $image) )2123 $contents = file_get_contents( $file ); 2124 2125 $image = imagecreatefromstring( $contents ); 2126 2127 if ( !is_resource( $image ) ) 2118 2128 return "File '$file' is not image?"; 2119 2129 -
trunk/wp-admin/admin-header.php
r4218 r4478 17 17 <head> 18 18 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 19 <title><?php bloginfo('name') ?> › <?php echo $title; ?> — WordPress</title>19 <title><?php bloginfo('name') ?> › <?php echo wp_specialchars( strip_tags( $title ) ); ?> — WordPress</title> 20 20 <link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" /> 21 21 <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?> -
trunk/wp-admin/admin.php
r4349 r4478 83 83 include(ABSPATH . "wp-admin/import/$importer.php"); 84 84 85 $parent_file = 'edit.php';86 85 $submenu_file = 'import.php'; 87 $title = __('Import');88 86 89 87 if (! isset($_GET['noheader'])) -
trunk/wp-admin/categories.php
r4468 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Categories');5 $parent_file = 'edit.php';6 3 7 4 wp_reset_vars(array('action', 'cat')); -
trunk/wp-admin/comment.php
r4468 r4478 2 2 require_once('admin.php'); 3 3 4 $parent_file = 'edit.php';5 4 $submenu_file = 'edit-comments.php'; 6 5 -
trunk/wp-admin/edit-comments.php
r4474 r4478 2 2 require_once('admin.php'); 3 3 4 $title = __('Edit Comments');5 $parent_file = 'edit-comments.php';6 4 wp_enqueue_script( 'admin-comments' ); 7 5 -
trunk/wp-admin/edit-pages.php
r4258 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 $title = __('Pages');4 $parent_file = 'edit.php';5 3 wp_enqueue_script( 'listman' ); 6 4 require_once('admin-header.php'); -
trunk/wp-admin/edit.php
r4465 r4478 2 2 require_once('admin.php'); 3 3 4 $title = __('Posts');5 $parent_file = 'edit.php';6 4 wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' ); 7 5 require_once('admin-header.php'); -
trunk/wp-admin/export.php
r4477 r4478 1 1 <?php 2 2 require_once ('admin.php'); 3 $title = __('Export');4 $parent_file = 'edit.php';5 3 6 4 if ( isset( $_GET['download'] ) ) -
trunk/wp-admin/import.php
r3986 r4478 1 1 <?php 2 2 require_once ('admin.php'); 3 $title = __('Import');4 $parent_file = 'edit.php';5 3 require_once ('admin-header.php'); 6 4 ?> -
trunk/wp-admin/index.php
r4399 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 $title = __('Dashboard');4 $parent_file = 'index.php';5 3 require_once('admin-header.php'); 6 4 require_once (ABSPATH . WPINC . '/rss.php'); -
trunk/wp-admin/link-add.php
r4448 r4478 2 2 require_once('admin.php'); 3 3 4 $title = __('Add Bookmark');5 4 $this_file = 'link-manager.php'; 6 $parent_file = 'link-manager.php';7 8 5 9 6 wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', -
trunk/wp-admin/link-import.php
r4006 r4478 4 4 5 5 require_once('admin.php'); 6 $parent_file = 'link-manager.php';7 $title = __('Import Blogroll');8 6 $this_file = 'link-import.php'; 9 7 -
trunk/wp-admin/link-manager.php
r4258 r4478 7 7 require_once ('admin.php'); 8 8 9 $title = __('Manage Bookmarks');10 9 $this_file = $parent_file = 'link-manager.php'; 11 10 wp_enqueue_script( 'listman' ); -
trunk/wp-admin/menu-header.php
r4443 r4478 4 4 $self = preg_replace('|^.*/plugins/|i', '', $self); 5 5 6 get_admin_page_parent(); 6 foreach ( $submenu as $parent => $subpages ) { 7 foreach ( $subpages as $page ) { 8 // 0 menu title, 1 cap, 2 file or slug, 3 page title 9 if ( $self == $page[2] ) 10 $parent_file = $parent; 11 } 12 } 7 13 8 14 foreach ($menu as $item) { -
trunk/wp-admin/menu.php
r4474 r4478 5 5 // The minimum level the user needs to access the item: between 0 and 10 6 6 // The URL of the item's file 7 $menu[0] = array(__('Dashboard'), 'read', 'index.php'); 7 // Slug 8 $menu[0] = array(__('Dashboard'), 'read', 'index.php', 'home'); 8 9 10 // So when people switch between write and manage they go to the appropiate page/post mode they were on 9 11 if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php') ) 10 $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php' );12 $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php', 'write'); 11 13 else 12 $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php'); 14 $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php', 'write'); 15 13 16 if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php') ) 14 $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php' );17 $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php', 'manage'); 15 18 else 16 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php' );19 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php', 'manage'); 17 20 18 $menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); 19 $menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php'); 20 $menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php'); 21 $menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); 21 $menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php', 'comments'); 22 $menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php', 'blogroll'); 23 $menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php', 'themes'); 24 $menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php', 'plugins'); 25 22 26 if ( current_user_can('edit_users') ) 23 $menu[35] = array(__('Users'), 'edit_users', 'users.php' );27 $menu[35] = array(__('Users'), 'edit_users', 'users.php', 'users'); 24 28 else 25 $menu[35] = array(__('Profile'), 'read', 'profile.php'); 26 $menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); 29 $menu[35] = array(__('Profile'), 'read', 'profile.php', 'profile'); 30 31 $menu[40] = array(__('Options'), 'manage_options', 'options-general.php', 'options'); 27 32 28 33 … … 70 75 71 76 // Create list of page plugin hook names. 72 foreach ( $menu as $menu_page) {77 foreach ( $menu as $menu_page ) 73 78 $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]); 74 }75 79 76 80 $_wp_submenu_nopriv = array(); … … 129 133 } 130 134 131 unset( $id);135 unset( $id ); 132 136 133 uksort( $menu, "strnatcasecmp"); // make it all pretty137 uksort( $menu, 'strnatcasecmp' ); 134 138 135 if ( ! user_can_access_admin_page()) {139 if ( !user_can_access_admin_page() ) 136 140 wp_die( __('You do not have sufficient permissions to access this page.') ); 137 }138 141 139 142 ?> -
trunk/wp-admin/moderation.php
r4474 r4478 2 2 require_once('admin.php'); 3 3 4 $title = __('Moderate comments');5 $parent_file = 'edit-comments.php';6 4 wp_enqueue_script( 'admin-comments' ); 7 5 -
trunk/wp-admin/options-discussion.php
r4337 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Discussion Options');5 $parent_file = 'options-general.php';6 7 3 include('admin-header.php'); 8 4 ?> -
trunk/wp-admin/options-general.php
r4297 r4478 1 1 <?php 2 2 require_once('./admin.php'); 3 4 $title = __('General Options');5 $parent_file = 'options-general.php';6 7 3 include('./admin-header.php'); 8 4 ?> -
trunk/wp-admin/options-misc.php
r4196 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Miscellaneous Options');5 $parent_file = 'options-general.php';6 7 3 include('admin-header.php'); 8 4 -
trunk/wp-admin/options-permalink.php
r4197 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Permalink Options');5 $parent_file = 'options-general.php';6 7 3 function add_js() { 8 4 ?> -
trunk/wp-admin/options-privacy.php
r4424 r4478 1 1 <?php 2 2 require_once('./admin.php'); 3 4 $title = __('Privacy Options');5 $parent_file = 'options-general.php';6 7 3 include('./admin-header.php'); 8 4 ?> -
trunk/wp-admin/options-reading.php
r4457 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Reading Options');5 $parent_file = 'options-general.php';6 7 3 include('admin-header.php'); 8 4 ?> -
trunk/wp-admin/options-writing.php
r4327 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Writing Options');5 $parent_file = 'options-general.php';6 7 3 include('admin-header.php'); 8 4 ?> -
trunk/wp-admin/options.php
r4383 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Options');5 $this_file = 'options.php';6 $parent_file = 'options-general.php';7 3 8 4 wp_reset_vars(array('action')); -
trunk/wp-admin/page-new.php
r4338 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 $title = __('New Page');4 $parent_file = 'post-new.php';5 3 $editing = true; 6 4 wp_enqueue_script('prototype'); -
trunk/wp-admin/plugin-editor.php
r4202 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __("Edit Plugins");5 $parent_file = 'plugins.php';6 7 3 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); 8 4 -
trunk/wp-admin/plugins.php
r4453 r4478 30 30 } 31 31 32 $title = __('Manage Plugins');33 32 require_once('admin-header.php'); 34 33 -
trunk/wp-admin/post-new.php
r4429 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 $title = __('Create New Post');4 $parent_file = 'post-new.php';5 3 $editing = true; 6 4 wp_enqueue_script('prototype'); -
trunk/wp-admin/profile.php
r4447 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __('Profile');5 6 if ( current_user_can('edit_users') )7 $parent_file = 'users.php';8 else9 $parent_file = 'profile.php';10 3 include_once('admin-header.php'); 11 4 $profileuser = get_user_to_edit($user_ID); -
trunk/wp-admin/templates.php
r4415 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 $title = __('Template & File Editing');4 $parent_file = 'edit.php';5 6 3 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); 7 4 -
trunk/wp-admin/theme-editor.php
r4349 r4478 1 1 <?php 2 2 require_once('admin.php'); 3 4 $title = __("Edit Themes");5 $parent_file = 'themes.php';6 7 3 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme')); 8 4 -
trunk/wp-admin/themes.php
r3928 r4478 19 19 } 20 20 21 $title = __('Manage Themes');22 $parent_file = 'themes.php';23 21 require_once('admin-header.php'); 24 22 ?> -
trunk/wp-admin/user-edit.php
r4447 r4478 2 2 require_once('admin.php'); 3 3 4 $title = __('Edit User');5 if ( current_user_can('edit_users') )6 $parent_file = 'users.php';7 else8 $parent_file = 'profile.php';9 4 $submenu_file = 'users.php'; 10 5 -
trunk/wp-admin/users.php
r4468 r4478 2 2 require_once('admin.php'); 3 3 require_once( ABSPATH . WPINC . '/registration.php'); 4 5 $title = __('Users');6 if ( current_user_can('edit_users') )7 $parent_file = 'users.php';8 else9 $parent_file = 'profile.php';10 4 11 5 $action = $_REQUEST['action'];
Note: See TracChangeset
for help on using the changeset viewer.