Ticket #4099: bulk-edit-blogroll-cats-2.diff

File bulk-edit-blogroll-cats-2.diff, 4.5 KB (added by technosailor, 5 years ago)

submit button labellin, some element changes, general cleanup.

  • Users/aaron/Sites/trunk/wp-admin/link-manager.php

     
    116116<form id="links" method="post" action="link.php"> 
    117117<?php wp_nonce_field('bulk-bookmarks') ?> 
    118118<input type="hidden" name="link_id" value="" /> 
    119 <input type="hidden" name="action" value="" /> 
     119<input type="hidden" id="action" name="action" value="bulkmodbookmarks" /> 
    120120<input type="hidden" name="order_by" value="<?php echo attribute_escape($order_by); ?>" /> 
    121121<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 
    122122<table class="widefat"> 
     
    194194</table> 
    195195 
    196196<div id="ajax-response"></div> 
     197<h3><?php _e('Update Selected'); ?></h3> 
     198        <ul style="list-style:none;"> 
     199                <li><input type="radio" name="rbulkeditblogroll" id="dbookmarks" value="deletebookmarks" onclick="change_submit_button();" /> <label for="dbookmarks"><?php _e('Delete checked Bookmarks.'); ?></label></li> 
     200                <li> 
     201                        <input type="radio" name="rbulkeditblogroll" id="ebookmarks" value="editbookmarks" onclick="change_submit_button();" checked="checked" /> <label for="ebookmarks"><?php _e('Set the new category for checked Blogroll items:'); ?></label> 
     202                         
     203                        <select name="bookmarks_newcat" onfocus="getElementById('ebookmarks').checked = 'true';getElementById('submiteditbookmarks').value = 'Update Checked Links';"> 
     204                        <?php 
     205                        $linkcats = get_categories("hide_empty=0"); 
     206                        foreach($linkcats as $bulklinkcat) 
     207                                echo'<option value="' . $bulklinkcat->cat_ID . '">' . $bulklinkcat->cat_name .'</option>'; 
     208                        ?> 
     209                        </select> 
     210                        <script type="text/javascript" charset="utf-8"> 
     211                        function change_submit_button () 
     212                        { 
     213                                if( document.getElementById('ebookmarks').checked == true) 
     214                                { 
     215                                        document.getElementById('action').value = 'bulkmodbookmarks'; 
     216                                } 
     217                                else 
     218                                { 
     219                                        document.getElementById('action').value = 'bulkdelbookmarks'; 
     220                                        document.getElementById('submiteditbookmarks').onclick = confirmDeleteLinks; 
     221                                } 
     222                        } 
    197223 
    198 <p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Links') ?> &raquo;" onclick="return confirm('<?php echo js_escape(__("You are about to delete these links permanently.\n'Cancel' to stop, 'OK' to delete.")); ?>')" /></p> 
     224                        function confirmDeleteLinks() 
     225                        { 
     226                                return confirm("You are about to delete these links permanently.\n'Cancel' to stop, 'OK' to delete."); 
     227                        } 
     228                </script> 
     229                </li> 
     230        </ul> 
     231        <p class="submit" style="width: 420px"> 
     232                <?php echo $referer; ?> 
     233                <input type="submit" name="submiteditbookmarks" id="submiteditbookmarks" value="<?php _e('Bulk Update'); ?>" /> 
     234        </p> 
     235<p class="submit"> 
    199236</form> 
    200  
    201237<?php } ?> 
    202238 
    203239</div> 
  • Users/aaron/Sites/trunk/wp-admin/link.php

     
    11<?php 
    22require_once ('admin.php'); 
    3  
     3echo'<pre>'; 
     4print_r($_POST); 
     5echo'</pre>'; 
    46wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]')); 
    57 
    6 if ('' != $_POST['deletebookmarks']) 
     8if ('bulkdelbookmarks' == $_POST['action']) 
    79        $action = 'deletebookmarks'; 
    8 if ('' != $_POST['move']) 
     10if ('bulkmodbookmarks' == $_POST['action']) 
    911        $action = 'move'; 
    1012if ('' != $_POST['linkcheck']) 
    11         $linkcheck = $_POST[linkcheck]; 
     13        $linkcheck = $_POST['linkcheck'];  
    1214 
    1315$this_file = 'link-manager.php'; 
    1416 
     
    5052                        wp_redirect($this_file); 
    5153                        exit; 
    5254                } 
    53                 $all_links = join(',', $linkcheck); 
    54                 // should now have an array of links we can change 
    55                 //$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); 
    56  
     55                //$link_count = count($linkcheck); 
     56                foreach($linkcheck as $link_id) 
     57                { 
     58                        $link = get_link_to_edit( $link_id ); 
     59                         
     60                        $newlink['link_id'] = $link_id; 
     61                        $newlink['link_url'] = clean_url($link->link_url); 
     62                        $newlink['link_name'] = wp_specialchars( $link->link_name ); 
     63                        $newlink['link_image'] = wp_specialchars( $link->link_image ); 
     64                        $newlink['link_rss'] = clean_url($link->link_rss); 
     65                        $newlink['link_category'] = array($_POST['bookmarks_newcat']); 
     66                        wp_insert_link($newlink); 
     67                } 
    5768                wp_redirect($this_file); 
    5869                exit; 
    5970                break;