Changeset 9029

Show
Ignore:
Timestamp:
09/29/08 12:03:30 (3 months ago)
Author:
azaozz
Message:

Fix "select all" checkboxes and upload.php

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/edit-comments.php

    r9028 r9029  
    1515wp_enqueue_script( 'jquery-table-hotkeys' ); 
    1616 
    17 if ( isset( $_POST['delete_all_spam'] ) ) { 
     17if ( isset( $_POST['delete_all_spam'] ) || isset( $_POST['delete_all_spam2'] ) ) { 
    1818    check_admin_referer('bulk-spam-delete'); 
    1919 
  • trunk/wp-admin/js/forms.js

    r8857 r9029  
    2121        return true; 
    2222    } ); 
    23     $( 'thead :checkbox' ).click( function() { 
     23    $( 'thead :checkbox, tfoot :checkbox' ).click( function() { 
    2424        checkAll( $(this).parents( 'form:first' ) ); 
    2525    } ); 
  • trunk/wp-admin/upload.php

    r9028 r9029  
    99/** WordPress Administration Bootstrap */ 
    1010require_once('admin.php'); 
    11 //add_thickbox(); 
    12 wp_enqueue_script( 'media-upload' ); 
    1311wp_enqueue_script( 'wp-ajax-response' ); 
    1412wp_enqueue_script( 'jquery-ui-draggable' ); 
     
    5755        $attach = implode(',', $attach); 
    5856        $attached = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ($attach)", $parent_id) ); 
    59  
    60         $message = sprintf( __ngettext('Added %1$s attachment to <strong>%2$s</strong>', 'Added %1$s attachments to <strong>%2$s</strong>', $attached, apply_filters( "the_title", $parent->post_title ) ) , $attached, apply_filters( "the_title", $parent->post_title ) ); 
    61     } 
    62  
    63     $_GET['detached'] = 1; 
    64  
    65 } elseif ( isset($_GET['action']) && isset($_GET['media']) && isset($_GET['doaction']) ) { 
    66     check_admin_referer('bulk-media'); 
    67     if ( $_GET['action'] == 'delete' ) { 
    68         foreach( (array) $_GET['media'] as $post_id_del ) { 
    69             $post_del = & get_post($post_id_del); 
    70  
    71             if ( !current_user_can('delete_post', $post_id_del) ) 
    72                 wp_die( __('You are not allowed to delete this post.') ); 
    73  
    74             if ( $post_del->post_type == 'attachment' ) 
    75                 if ( ! wp_delete_attachment($post_id_del) ) 
    76                     wp_die( __('Error in deleting...') ); 
    77         } 
    78  
     57    } 
     58 
     59    if ( isset($attached) ) { 
    7960        $location = 'upload.php'; 
    8061        if ( $referer = wp_get_referer() ) { 
     
    8263                $location = $referer; 
    8364        } 
     65     
     66        $location = add_query_arg( array( 'detached' => 1, 'attached' => $attached ) , $location ); 
     67        wp_redirect($location); 
     68        exit; 
     69    } 
     70 
     71} elseif ( isset($_GET['action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) { 
     72    check_admin_referer('bulk-media'); 
     73    $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; 
     74 
     75    if ( 'delete' == $doaction ) { 
     76        foreach( (array) $_GET['media'] as $post_id_del ) { 
     77            $post_del = & get_post($post_id_del); 
     78 
     79            if ( !current_user_can('delete_post', $post_id_del) ) 
     80                wp_die( __('You are not allowed to delete this post.') ); 
     81 
     82            if ( $post_del->post_type == 'attachment' ) 
     83                if ( ! wp_delete_attachment($post_id_del) ) 
     84                    wp_die( __('Error in deleting...') ); 
     85        } 
     86 
     87        $location = 'upload.php'; 
     88        if ( $referer = wp_get_referer() ) { 
     89            if ( false !== strpos($referer, 'upload.php') ) 
     90                $location = $referer; 
     91        } 
    8492 
    8593        $location = add_query_arg('message', 2, $location); 
     
    8896        exit; 
    8997    } 
    90 } elseif ( !empty($_GET['_wp_http_referer']) ) { 
    91     wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); 
    92     exit; 
     98} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 
     99    wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 
     100    exit; 
    93101} 
    94102 
     
    155163    $_GET['message'] = '1'; 
    156164    $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); 
     165} 
     166 
     167if ( isset($_GET['attached']) && (int) $_GET['attached'] ) { 
     168    $attached = (int) $_GET['attached']; 
     169    $message = sprintf( __ngettext('Reattached %d attachment', 'Reattached %d attachments', $attached), $attached ); 
     170    $_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']); 
    157171} 
    158172 
     
    294308 
    295309<div class="alignleft"> 
    296 <select name="action" id="select-action"> 
    297 <option value="" selected><?php _e('Actions'); ?></option> 
     310<select name="action" class="select-action"> 
     311<option value="-1" selected="selected"><?php _e('Actions'); ?></option> 
    298312<option value="delete"><?php _e('Delete'); ?></option> 
    299313<?php if ( isset($orphans) ) { ?> 
     
    301315<?php } ?> 
    302316</select> 
    303 <input type="submit" id="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 
     317<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 
    304318<?php wp_nonce_field('bulk-media'); ?> 
    305319 
     
    325339</tr> 
    326340</thead> 
     341 
     342<tfoot> 
     343<tr> 
     344    <th scope="col" class="check-column"><input type="checkbox" /></th> 
     345    <th scope="col"></th> 
     346    <th scope="col"><?php echo _c('Media|media column header'); ?></th> 
     347    <th scope="col"><?php echo _c('Date Added|media column header'); ?></th> 
     348</tr> 
     349</tfoot> 
    327350 
    328351<tbody id="the-list" class="list:post"> 
     
    384407</tbody> 
    385408</table> 
    386 <script type="text/javascript"> 
    387     (function($){ 
    388         $('#submit').click(function(e) { 
    389             if ( 'attach' == $('#select-action').val() ) { 
    390                 e.preventDefault(); 
    391                 findPosts.open(); 
    392             } 
    393         }); 
    394     })(jQuery); 
    395 </script> 
     409 
    396410<?php find_posts_div(); 
    397411 
     
    410424 
    411425<div class="alignleft"> 
    412 <select name="action2" id="select-action"> 
    413 <option value="" selected><?php _e('Actions'); ?></option> 
     426<select name="action2" class="select-action"> 
     427<option value="-1" selected="selected"><?php _e('Actions'); ?></option> 
    414428<option value="delete"><?php _e('Delete'); ?></option> 
    415429<?php if ( isset($orphans) ) { ?> 
     
    417431<?php } ?> 
    418432</select> 
    419 <input type="submit" id="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 
     433<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 
    420434</div> 
    421435 
     
    464478</div> 
    465479 
     480<script type="text/javascript"> 
     481    jQuery(function($) { 
     482        $('#doaction').click(function(e) { 
     483            if ( 'attach' == $('#posts-filter select[name="action"]').val() ) { 
     484                e.preventDefault(); 
     485                findPosts.open(); 
     486            } 
     487        }); 
     488        $('#doaction2').click(function(e) { 
     489            if ( 'attach' == $('#posts-filter select[name="action2"]').val() ) { 
     490                e.preventDefault(); 
     491                findPosts.open(); 
     492            } 
     493        }); 
     494    }); 
     495</script> 
    466496<?php 
    467497