Make WordPress Core

Ticket #3130: quickcategories-001.diff

File quickcategories-001.diff, 5.4 KB (added by markjaquith, 19 years ago)

Work so far...

  • wp-admin/admin-ajax.php

     
    106106        }
    107107        die('0');
    108108        break;
     109case 'add-quickcategory' : // On the Fly
     110        if ( !current_user_can( 'manage_categories' ) )
     111                die('-1');
     112        $names = explode(',', $_POST['newcat']);
     113        $x = new WP_Ajax_Response();
     114        foreach ( $names as $cat_name ) {
     115                $cat_name = trim($cat_name);
     116                if ( !$category_nicename = sanitize_title($cat_name) )
     117                        die('0');
     118                if ( !$cat_id = category_exists( $cat_name ) )
     119                        $cat_id = wp_create_category( $cat_name );
     120                $cat_name = wp_specialchars(stripslashes($cat_name));
     121                $x->add( array(
     122                        'what' => 'quickcategory',
     123                        'id' => $cat_id,
     124                        'data' => "<li id='quickcategory-$cat_id'><span>[<a href='#' onclick='quickCatList.ajaxDelete(\"quickcategory\", \"$cat_id\"); return false;'>x</a>]</span> <b>$cat_name</b></li>"
     125                ) );
     126        }
     127        $x->send();
     128        break;
     129case 'delete-quickcategory' :
     130        if ( !current_user_can( 'manage_categories') )
     131                die('-1');
     132        break;
    109133case 'add-category' : // On the Fly
    110134        if ( !current_user_can( 'manage_categories' ) )
    111135                die('-1');
  • wp-admin/wp-admin.css

     
    10731073        background-position: 0 -28px;
    10741074}
    10751075
     1076#moremeta h4 {
     1077        margin: 0;
     1078        background: #eee;
     1079        position: relative;
     1080        left: -5px;
     1081        width: 182px;
     1082        text-indent: 10px;
     1083        color: #444;
     1084display: none;
     1085}
     1086
    10761087#categorychecklist {
    10771088        margin-right: 6px;
    10781089}
    10791090
     1091#categorylist {
     1092        font-size: 10px;
     1093        color: #333;
     1094        list-style: none;
     1095}
     1096
     1097#categorylist a {
     1098        color: #f00;
     1099        border-bottom: 0;
     1100}
     1101
     1102#categorylist b {
     1103        color: #000;
     1104}
     1105
     1106#categorylist span {
     1107        display: block;
     1108        position: absolute;
     1109        left: -15px;
     1110        color: #888;
     1111}
     1112
     1113#categorylist li {
     1114        left: -20px;
     1115        position: relative;
     1116        width: 155px;
     1117}
     1118
    10801119/* additional clone styles */
    10811120.dbx-clone {
    10821121        opacity: 0.8;
  • wp-admin/edit-form-advanced.php

     
    7171<div id="moremeta">
    7272<div id="grabit" class="dbx-group">
    7373
    74 <fieldset id="categorydiv" class="dbx-box">
    75 <h3 class="dbx-handle"><?php _e('Categories') ?></h3>
     74<fieldset id="quickcategorydiv" class="dbx-box" style="display: none;">
     75<h3 class="dbx-handle"><?php _e('Quick Categories') ?></h3>
    7676<div class="dbx-content">
    7777<p id="jaxcat"></p>
    78 <ul id="categorychecklist"><?php dropdown_categories(get_option('default_category')); ?></ul></div>
     78<h4>Assigned categories</h4>
     79<ul id="categorylist">
     80
     81</ul>
     82<!--
     83        <li id="quickcategory-1"><span>[<a href="#">x</a>]</span> <b>Category name</b></li>
     84        <li id="quickcategory-2"><span>[<a href="#">x</a>]</span> Parent &raquo; <b>Child</b></li>
     85        <li id="quickcategory-3"><span>[<a href="#">x</a>]</span> Another Category &raquo; With &raquo; <b>a grandchild</b></li>
     86-->
     87</div>
    7988</fieldset>
     89<script type="text/javascript">
     90<!--
     91document.getElementByID('quickcategorydiv').style.display = 'auto';
     92//-->
     93</script>
    8094
     95<fieldset id="categorydiv" class="dbx-box">
     96<h3 class="dbx-handle"><?php _e('Category Tree') ?></h3>
     97<div class="dbx-content">
     98<ul id="categorychecklist"><?php dropdown_categories(get_option('default_category')); ?></ul>
     99</div>
     100</fieldset>
     101
    81102<fieldset id="commentstatusdiv" class="dbx-box">
    82103<h3 class="dbx-handle"><?php _e('Discussion') ?></h3>
    83104<div class="dbx-content">
  • wp-admin/cat-js.php

     
    22require_once('../wp-config.php');
    33cache_javascript_headers();
    44?>
    5 addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;});
     5addLoadEvent(function(){quickCatList=new listMan('categorylist');quickCatList.ajaxRespEl='jaxcat';quickCatList.topAdder=1;quickCatList.alt=0;quickCatList.showLink=0;});
     6addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=0;catList.alt=0;catList.showLink=0;});
    67addLoadEvent(newCatAddIn);
    78function newCatAddIn() {
    89        var jaxcat = $('jaxcat');
    910        if ( !jaxcat )
    1011                return false;
    1112        jaxcat.update('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="<?php _e('Add'); ?>"/><span id="howto"><?php _e('Separate multiple categories with commas.'); ?></span></span>');
    12         $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); };
    13         $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); };
    14 }
     13
     14/*
     15killSubmit("catList.ajaxAdder('category','jaxcat');", e);
     16catList.ajaxAdder('category', 'jaxcat');
     17
     18I'm having problems sending both ajaxAdder() calls.  The first one works, but the second has an error.
     19I think it is because the first one is "taking" the input field and blanking it and the second one gets
     20blank data.  No idea how to fix it.
     21*/
     22        $('newcat').onkeypress = function(e) { return killSubmit("quickCatList.ajaxAdder('quickcategory','jaxcat');", e); };
     23        $('catadd').onclick = function() { quickCatList.ajaxAdder('quickcategory', 'jaxcat'); };
     24}
     25 No newline at end of file