Changeset 1139 for trunk/wp-admin/includes
- Timestamp:
- 10/30/07 16:49:38 (10 months ago)
- Files:
-
- trunk/wp-admin/includes/plugin.php (modified) (1 diff)
- trunk/wp-admin/includes/post.php (modified) (4 diffs)
- trunk/wp-admin/includes/schema.php (modified) (2 diffs)
- trunk/wp-admin/includes/template.php (modified) (8 diffs)
- trunk/wp-admin/includes/upgrade.php (modified) (1 diff)
- trunk/wp-admin/includes/user.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/includes/plugin.php
r1125 r1139 87 87 } 88 88 89 function activate_plugin($plugin) {90 $current = get_option('active_plugins');91 $plugin = trim($plugin);92 93 if ( validate_file($plugin) )94 return new WP_Error('plugin_invalid', __('Invalid plugin.'));95 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )96 return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));97 98 if (!in_array($plugin, $current)) {99 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error100 ob_start();101 @include(ABSPATH . PLUGINDIR . '/' . $plugin);102 $current[] = $plugin;103 sort($current);104 update_option('active_plugins', $current);105 do_action('activate_' . $plugin);106 ob_end_clean();107 }108 109 return null;110 }111 112 function deactivate_plugins($plugins) {113 $current = get_option('active_plugins');114 115 if(!is_array($plugins))116 $plugins = array($plugins);117 118 foreach($plugins as $plugin) {119 array_splice($current, array_search( $plugin, $current), 1 ); // Array-fu!120 do_action('deactivate_' . trim( $plugin ));121 }122 123 update_option('active_plugins', $current);124 }125 126 function deactivate_all_plugins() {127 $current = get_option('active_plugins');128 deactivate_plugins($current);129 }130 131 89 // 132 90 // Menu trunk/wp-admin/includes/post.php
r1130 r1139 349 349 return false; 350 350 351 wp_cache_delete($post_ID, 'post_meta');352 353 351 $result = $wpdb->query( " 354 352 INSERT INTO $wpdb->postmeta … … 365 363 $mid = (int) $mid; 366 364 367 $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'");368 wp_cache_delete($post_id, 'post_meta');369 370 365 return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" ); 371 366 } … … 413 408 if ( in_array($mkey, $protected) ) 414 409 return false; 415 416 $post_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = '$mid'");417 wp_cache_delete($post_id, 'post_meta');418 410 419 411 $mvalue = maybe_serialize( stripslashes( $mvalue )); … … 477 469 } 478 470 479 function wp_edit_posts_query( $q = false ) {480 global $wpdb;481 if ( false === $q )482 $q = $_GET;483 $q['m'] = (int) $q['m'];484 $q['cat'] = (int) $q['cat'];485 $post_stati = array( // array( adj, noun )486 'draft' => array(__('Draft'), _c('Drafts|manage posts header')),487 'future' => array(__('Scheduled'), __('Scheduled posts')),488 'pending' => array(__('Pending Review'), __('Pending posts')),489 'private' => array(__('Private'), __('Private posts')),490 'publish' => array(__('Published'), __('Published posts'))491 );492 493 $avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'");494 495 $post_status_q = '';496 $post_status_label = _c('Posts|manage posts header');497 if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) {498 $post_status_label = $post_stati[$q['post_status']][1];499 $post_status_q = '&post_status=' . $q['post_status'];500 }501 502 if ( 'pending' === $q['post_status'] ) {503 $order = 'ASC';504 $orderby = 'modified';505 } elseif ( 'draft' === $q['post_status'] ) {506 $order = 'DESC';507 $orderby = 'modified';508 } else {509 $order = 'DESC';510 $orderby = 'date';511 }512 513 wp("what_to_show=posts$post_status_q&posts_per_page=20&order=$order&orderby=$orderby");514 515 return array($post_stati, $avail_post_stati);516 }517 518 471 ?> trunk/wp-admin/includes/schema.php
r1125 r1139 5 5 $charset_collate = ''; 6 6 7 if ( $wpdb->supports_collation() ) {7 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { 8 8 if ( ! empty($wpdb->charset) ) 9 9 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; … … 335 335 336 336 // Add roles 337 add_role('administrator', _ c('Administrator|User role'));338 add_role('editor', _ c('Editor|User role'));339 add_role('author', _ c('Author|User role'));340 add_role('contributor', _ c('Contributor|User role'));341 add_role('subscriber', _ c('Subscriber|User role'));337 add_role('administrator', __('Administrator')); 338 add_role('editor', __('Editor')); 339 add_role('author', __('Author')); 340 add_role('contributor', __('Contributor')); 341 add_role('subscriber', __('Subscriber')); 342 342 343 343 // Add caps for Administrator role trunk/wp-admin/includes/template.php
r1125 r1139 42 42 43 43 if ( $category->term_id != $default_cat_id ) 44 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id ) . "' class='delete:the-list:cat-$category->term_iddelete'>".__( 'Delete' )."</a>";44 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>"; 45 45 else 46 46 $edit .= "<td style='text-align:center'>".__( "Default" ); … … 165 165 } 166 166 167 // define the columns to display, the syntax is 'internal name' => 'display name'168 function wp_manage_posts_columns() {169 $posts_columns = array();170 $posts_columns['id'] = '<div style="text-align: center">' . __('ID') . '</div>';171 if ( 'draft' === $_GET['post_status'] )172 $posts_columns['modified'] = __('Modified');173 elseif ( 'pending' === $_GET['post_status'] )174 $posts_columns['modified'] = __('Submitted');175 else176 $posts_columns['date'] = __('When');177 $posts_columns['title'] = __('Title');178 $posts_columns['categories'] = __('Categories');179 if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )180 $posts_columns['comments'] = '<div style="text-align: center">' . __('Comments') . '</div>';181 $posts_columns['author'] = __('Author');182 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);183 184 // you can not edit these at the moment185 $posts_columns['control_view'] = '';186 $posts_columns['control_edit'] = '';187 $posts_columns['control_delete'] = '';188 189 return $posts_columns;190 }191 192 167 function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { 193 168 global $wpdb, $class, $post; … … 216 191 <td><?php the_author() ?></td> 217 192 <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?></td> 218 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td>193 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td> 219 194 <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td> 220 <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 :the-list:page-$id delete'>" . __( 'Delete' ) . "</a>"; } ?></td>195 <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 . ", '" . js_escape(sprintf( __("You are about to delete the '%s' page.\n'OK' to delete, 'Cancel' to stop." ), get_the_title() ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td> 221 196 </tr> 222 197 … … 290 265 function _wp_comment_list_item( $id, $alt = 0 ) { 291 266 global $authordata, $comment, $wpdb; 267 $id = (int) $id; 292 268 $comment =& get_comment( $id ); 293 $id = (int) $comment->comment_ID;294 269 $class = ''; 295 270 $post = get_post($comment->comment_post_ID); 296 271 $authordata = get_userdata($post->post_author); 297 $comment_status = wp_get_comment_status($ id);272 $comment_status = wp_get_comment_status($comment->comment_ID); 298 273 if ( 'unapproved' == $comment_status ) 299 274 $class .= ' unapproved'; 300 275 if ( $alt % 2 ) 301 276 $class .= ' alternate'; 302 echo "<li id='comment-$ id' class='$class'>";303 ?> 304 <p><strong class="comment-author"><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>277 echo "<li id='comment-$comment->comment_ID' class='$class'>"; 278 ?> 279 <p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 305 280 306 281 <?php comment_text() ?> … … 309 284 <?php 310 285 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 311 echo " <a href='comment.php?action=editcomment&c=$id'>" . __('Edit') . '</a>'; 312 $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$id", "delete-comment_$id" ) ); 313 echo " | <a href='$url' class='delete:the-comment-list:comment-$id'>" . __('Delete') . '</a> '; 286 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 287 echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; 314 288 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 315 $url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$id", "unapprove-comment_$id" ) ); 316 echo "<span class='unapprove'> | <a href='$url' class='dim:the-comment-list:comment-$id:unapproved:FF3333'>" . __('Unapprove') . '</a> </span>'; 317 $url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$id", "approve-comment_$id" ) ); 318 echo "<span class='approve'> | <a href='$url' class='dim:the-comment-list:comment-$id:unapproved:FFFF33:FFFF33'>" . __('Approve') . '</a> </span>'; 319 } 320 $url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$id", "delete-comment_$id" ) ); 321 echo " | <a href='$url' class='delete:the-comment-list:comment-$id::spam=1'>" . __('Spam') . '</a> '; 322 } 323 if ( !is_single() ) { 324 $post = get_post($comment->comment_post_ID, OBJECT, 'display'); 325 $post_title = wp_specialchars( $post->post_title, 'double' ); 326 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 327 ?> 328 ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a> 329 <?php } ?> 330 </p> 289 echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; 290 echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 291 } 292 echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; 293 } 294 $post = get_post($comment->comment_post_ID, OBJECT, 'display'); 295 $post_title = wp_specialchars( $post->post_title, 'double' ); 296 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 297 ?> 298 ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> 331 299 </li> 332 300 <?php … … 359 327 // Exit if no meta 360 328 if (!$meta ) { 361 echo '<tbody id="the-list" class="list:meta"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS329 echo '<tbody id="the-list"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS 362 330 return; 363 331 } … … 371 339 </tr> 372 340 </thead> 373 <tbody id='the-list' class='list:meta'> 374 <?php 375 foreach ( $meta as $entry ) 376 echo _list_meta_row( $entry, $count ); 341 <?php 342 $r ="\n\t<tbody id='the-list'>"; 343 foreach ( $meta as $entry ) { 344 ++ $count; 345 if ( $count % 2 ) 346 $style = 'alternate'; 347 else 348 $style = ''; 349 if ('_' == $entry['meta_key'] { 0 } ) 350 $style .= ' hidden'; 351 352 if ( is_serialized( $entry['meta_value'] ) ) { 353 if ( is_serialized_string( $entry['meta_value'] ) ) { 354 // this is a serialized string, so we should display it 355 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); 356 } else { 357 // this is a serialized array/object so we should NOT display it 358 --$count; 359 continue; 360 } 361 } 362 363 $key_js = js_escape( $entry['meta_key'] ); 364 $entry['meta_key'] = attribute_escape($entry['meta_key']); 365 $entry['meta_value'] = attribute_escape($entry['meta_value']); 366 $entry['meta_id'] = (int) $entry['meta_id']; 367 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; 368 $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>"; 369 $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; 370 $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".attribute_escape(__( 'Update' ))."' /><br />"; 371 $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '"; 372 $r .= js_escape(sprintf( __("You are about to delete the '%s' custom field on this post.\n'OK' to delete, 'Cancel' to stop." ), $key_js ) ); 373 $r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' /></td>"; 374 $r .= "\n\t</tr>"; 375 } 376 echo $r; 377 377 echo "\n\t</tbody>"; 378 }379 380 function _list_meta_row( $entry, &$count ) {381 $r = '';382 ++ $count;383 if ( $count % 2 )384 $style = 'alternate';385 else386 $style = '';387 if ('_' == $entry['meta_key'] { 0 } )388 $style .= ' hidden';389 390 if ( is_serialized( $entry['meta_value'] ) ) {391 if ( is_serialized_string( $entry['meta_value'] ) ) {392 // this is a serialized string, so we should display it393 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );394 } else {395 // this is a serialized array/object so we should NOT display it396 --$count;397 return;398 }399 }400 401 $key_js = js_escape( $entry['meta_key'] );402 $entry['meta_key'] = attribute_escape($entry['meta_key']);403 $entry['meta_value'] = attribute_escape($entry['meta_value']);404 $entry['meta_id'] = (int) $entry['meta_id'];405 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";406 $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>";407 $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";408 $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']} updatemeta' /><br />";409 $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' ";410 $r .= "class='delete:the-list:meta-{$entry['meta_id']} deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />";411 $r .= "<input type='hidden' name='_ajax_nonce' value='$nonce' />";412 $r .= "</td>\n\t</tr>";413 return $r;414 378 } 415 379 … … 452 416 </tr> 453 417 454 <tr class="submit"><td colspan="3">455 <?php wp_nonce_field( 'change_meta', '_ajax_nonce', false ); ?>456 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field »' ) ?>" />457 </td></tr>458 418 </table> 419 <p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field »' ) ?>" /></p> 459 420 <?php 460 421 trunk/wp-admin/includes/upgrade.php
r1125 r1139 1254 1254 1255 1255 function wp_check_mysql_version() { 1256 global $wpdb; 1257 $result = $wpdb->check_database_version(); 1258 if ( is_wp_error( $result ) ) 1259 die( $result->get_error_message() ); 1256 global $wp_version; 1257 1258 // Make sure the server has MySQL 4.0 1259 $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info()); 1260 if ( version_compare($mysql_version, '4.0.0', '<') ) 1261 die(sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version)); 1260 1262 } 1261 1263 trunk/wp-admin/includes/user.php
r1125 r1139 88 88 } else { 89 89 if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) ) 90 $errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.'));90 $errors->add( 'pass', __( "<strong>ERROR</strong>: you typed your new password only once." )); 91 91 } 92 92 … … 97 97 /* checking the password has been typed twice the same */ 98 98 if ( $pass1 != $pass2 ) 99 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enterthe same password in the two password fields.' ));99 $errors->add( 'pass', __( '<strong>ERROR</strong>: Please type the same password in the two password fields.' )); 100 100 101 101 if (!empty ( $pass1 )) … … 103 103 104 104 if ( !$update && !validate_username( $user->user_login ) ) 105 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' ));105 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' )); 106 106 107 107 if (!$update && username_exists( $user->user_login )) 108 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered . Please choose another one.' ));108 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' )); 109 109 110 110 /* checking e-mail address */ 111 111 if ( empty ( $user->user_email ) ) { 112 $errors->add( 'user_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.'));112 $errors->add( 'user_email', __( "<strong>ERROR</strong>: please type an e-mail address" )); 113 113 } else 114 114 if (!is_email( $user->user_email ) ) { 115 $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ));115 $errors->add( 'user_email', __( "<strong>ERROR</strong>: the email address isn't correct" )); 116 116 } 117 117
