Plugin Directory

Changeset 443817


Ignore:
Timestamp:
09/26/2011 06:53:17 PM (15 years ago)
Author:
dexxaye
Message:

1.0 Commit

Location:
auto-url/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • auto-url/trunk/auto-url-data.php

    r439221 r443817  
    44    '%categories%',
    55    '%categorypath%',
    6     '%tags%', 
     6    '%tags%',
    77);
    88
     
    113113    return $path;
    114114}
     115
     116function auto_url_get_category_tree($pid = 0, $d=1) {
     117    $cats = get_categories(array(
     118        'parent' => $pid,
     119        'hide_empty' => false
     120            ));
     121
     122    for ($i = 0; $i < count($cats); $i++) {
     123        $children = auto_url_get_category_tree($cats[$i]->cat_ID, $d + 1);
     124        if (!empty($children)) {
     125            for ($j = 0; $j < count($children); $j++) {
     126                $children[$j]->cat_name = str_repeat('&ndash;', $d) . ' ' . $children[$j]->cat_name;
     127            }
     128            $cats[$i]->children = $children;
     129        }
     130    }
     131
     132    return $cats;
     133}
     134
     135function auto_url_walk_category_tree($categories, $patterns) {
     136    $output = '';
     137    foreach ($categories as $c) {
     138        $output .=
     139                '<div class="formRow patternRow">
     140                <label>' . $c->name . '</label>
     141                <input type="text" name="p[category][' . $c->term_id . ']" value="' . (isset($patterns['category'][$c->term_id]) ? $patterns['category'][$c->term_id] : '') . '" />
     142            </div>';
     143
     144        if (isset($c->children) && !empty($c->children))
     145            $output .= auto_url_walk_category_tree($c->children, $patterns);
     146    }
     147
     148    return $output;
     149}
  • auto-url/trunk/auto-url.php

    r442720 r443817  
    55  Plugin URI: http://www.bunchacode.com/programming/auto-url
    66  Description: generates customized permalinks according to post types, categories and tags
    7   Version: 0.9.1
     7  Version: 1.0
    88  Author: FunkyDude
    99  Author URI: http://www.bunchacode.com
     
    177177    $patterns = json_decode(get_option(AU_OPTION_PATTERN_NAME), true);
    178178    $tags = get_tags();
    179     $categories = get_categories();
     179    $categories = auto_url_get_category_tree();
    180180
    181181    require(AU_TEMPLATE . 'pattern.php');
  • auto-url/trunk/readme.txt

    r442720 r443817  
    44Requires at least: 3.1
    55Tested up to: 3.2.1
    6 Stable tag: 0.9.1
     6Stable tag: 1.0
    77
    88Auto URL generates customized permalinks according to post types, categories and tags
  • auto-url/trunk/templates/pattern.php

    r439221 r443817  
    2828</fieldset>
    2929<fieldset>
    30     <legend>Post/Page URL Patterns by Tag</legend>
     30    <legend>Post URL Patterns by Tag</legend>
    3131    <div class="formRow">
    3232    <?php foreach($tags as $t){?>
     
    3939</fieldset>
    4040<fieldset>
    41     <legend>Post/Page URL Patterns by Category</legend>
    42     <?php foreach($categories as $c){?>
    43     <div class="formRow patternRow">
    44         <label><?php echo $c->name;?></label>
    45         <input type="text" name="p[category][<?php echo $c->term_id;?>]" value="<?php echo isset($patterns['category'][$c->term_id])?$patterns['category'][$c->term_id]:'';?>" />
    46     </div>
    47     <?php }?>
     41    <legend>Post URL Patterns by Category</legend>
     42    <?php echo auto_url_walk_category_tree($categories, $patterns);?>
    4843</fieldset>
    4944<fieldset>
Note: See TracChangeset for help on using the changeset viewer.