Better AJAX feedback messages and markup fixes. Props mdawaffe. fixes #3208
git-svn-id: http://svn.automattic.com/wordpress/trunk@4583 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -147,7 +147,7 @@ case 'add-cat' : // From Manage->Categories
|
||||
'what' => 'cat',
|
||||
'id' => $cat->cat_ID,
|
||||
'data' => _cat_row( $cat, $level, $cat_full_name ),
|
||||
'supplemental' => array('name' => $cat_full_name)
|
||||
'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->cat_ID", $cat_full_name))
|
||||
) );
|
||||
$x->send();
|
||||
break;
|
||||
@@ -211,10 +211,12 @@ case 'add-user' :
|
||||
echo "<p>$message<p>";
|
||||
exit;
|
||||
}
|
||||
$user_object = new WP_User( $user_id );
|
||||
$x = new WP_Ajax_Response( array(
|
||||
'what' => 'user',
|
||||
'id' => $user_id,
|
||||
'data' => user_row( $user_id )
|
||||
'data' => user_row( $user_object ),
|
||||
'supplemental' => array('show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login))
|
||||
) );
|
||||
$x->send();
|
||||
break;
|
||||
|
||||
@@ -814,11 +814,13 @@ function user_row( $user_object, $style = '' ) {
|
||||
if ( $numposts > 0 ) {
|
||||
$r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
|
||||
$r .= sprintf( __('View %1$s %2$s' ), $numposts, __ngettext( 'post', 'posts', $numposts ));
|
||||
$r .= '</a>';
|
||||
}
|
||||
$r .= "</td>\n\t\t<td>";
|
||||
$edit_link = add_query_arg( 'wp_http_referer', wp_specialchars( urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" );
|
||||
if ( current_user_can( 'edit_user', $user_object->ID ) )
|
||||
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
|
||||
$edit_link = wp_specialchars( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
|
||||
$r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>";
|
||||
}
|
||||
$r .= "</td>\n\t</tr>";
|
||||
return $r;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ if ( ! empty($cat_ID) ) {
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php echo $heading ?></h2>
|
||||
<div id="ajax-response"></div>
|
||||
<?php echo $form ?>
|
||||
<input type="hidden" name="action" value="<?php echo $action ?>" />
|
||||
<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" />
|
||||
@@ -41,7 +42,6 @@ if ( ! empty($cat_ID) ) {
|
||||
</tr>
|
||||
</table>
|
||||
<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
|
||||
<div id="ajax-response"></div>
|
||||
<?php do_action('edit_category_form', $category); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@ addLoadEvent(function() {
|
||||
theListEls = document.getElementsByTagName('tbody');
|
||||
theUserLists = new Array();
|
||||
for ( var l = 0; l < theListEls.length; l++ ) {
|
||||
theUserLists[theListEls[l].id] = new listMan(theListEls[l].id);
|
||||
if ( theListEls[l].id )
|
||||
theUserLists[theListEls[l].id] = new listMan(theListEls[l].id);
|
||||
}
|
||||
addUserInputs = document.getElementById('adduser').getElementsByTagName('input');
|
||||
for ( var i = 0; i < addUserInputs.length; i++ ) {
|
||||
|
||||
+15
-12
@@ -376,7 +376,7 @@ default:
|
||||
foreach($roleclasses as $role => $roleclass) {
|
||||
uksort($roleclass, "strnatcasecmp");
|
||||
?>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<?php if ( !empty($role) ) : ?>
|
||||
<th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
|
||||
@@ -392,7 +392,7 @@ foreach($roleclasses as $role => $roleclass) {
|
||||
<th><?php _e('Website') ?></th>
|
||||
<th colspan="2" style="text-align: center"><?php _e('Actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
<tbody id="role-<?php echo $role; ?>"><?php
|
||||
$style = '';
|
||||
foreach ( (array) $roleclass as $user_object ) {
|
||||
@@ -437,7 +437,19 @@ foreach ( (array) $roleclass as $user_object ) {
|
||||
|
||||
<div class="wrap">
|
||||
<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
|
||||
|
||||
<?php if ( is_wp_error( $add_user_errors ) ) : ?>
|
||||
<div class="error">
|
||||
<?php
|
||||
foreach ( $add_user_errors->get_error_messages() as $message )
|
||||
echo "<p>$message</p>";
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="ajax-response"></div>
|
||||
|
||||
<div class="narrow">
|
||||
|
||||
<?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php').'</p>'; ?>
|
||||
<form action="#add-new-user" method="post" name="adduser" id="adduser">
|
||||
<?php wp_nonce_field('add-user') ?>
|
||||
@@ -488,18 +500,9 @@ foreach ( (array) $roleclass as $user_object ) {
|
||||
<?php echo $referer; ?>
|
||||
<input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User »') ?>" />
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php if ( is_wp_error( $add_user_errors ) ) : ?>
|
||||
<div class="error">
|
||||
<?php
|
||||
foreach ( $add_user_errors->get_error_messages() as $message )
|
||||
echo "<p>$message</p>";
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="ajax-response"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user