WordPress.org

Plugin Directory

Changeset 373093


Ignore:
Timestamp:
04/14/11 23:12:05 (3 years ago)
Author:
bergius
Message:

page order number now respects depth (resets to 1 at every new level)

Location:
cms-page-order/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cms-page-order/trunk/cms-page-order.php

    r372720 r373093  
    109109    if ( !empty($_REQUEST['order']) ) { 
    110110        global $wpdb; 
     111        unset( $_REQUEST['order'][0] ); 
     112 
     113        $prev_depth = 1; 
     114        $order = array(); 
     115        $order[1] = 1; 
     116         
    111117        foreach ( $_REQUEST['order'] as $i => $page ) { 
     118             
    112119            $post_id = (int) $page['item_id']; 
    113120            if ($page['parent_id'] == 'root') 
     
    115122            else 
    116123                $parent = (int) $page['parent_id']; 
    117              
    118             $data = array( 'menu_order' => $i, 'post_parent' => $parent ); 
     124 
     125            if ( $page['depth'] > $prev_depth ) { 
     126                $order[$page['depth']] = 1; 
     127                $menu_order = $order[$page['depth']]; 
     128            } 
     129            else if ( $page['depth'] < $prev_depth ) 
     130                $menu_order = $order[$page['depth']]; 
     131             
     132            $prev_depth = (int) $page['depth']; 
     133             
     134            $data = array( 'menu_order' => $order[$page['depth']], 'post_parent' => $parent ); 
    119135            $where = array( 'ID' => $post_id ); 
    120136             
    121137            $wpdb->update( $wpdb->posts, $data, $where ); 
    122138            clean_page_cache($post_id); 
    123  
     139             
     140            $order[$page['depth']]++; 
    124141        } 
    125142        global $wp_rewrite; 
  • cms-page-order/trunk/readme.txt

    r372720 r373093  
    3232== Installation == 
    3333 
    34 1. Upload the folder `page-order` to the `/wp-content/plugins/` directory 
     341. Upload the folder `cms-page-order` to the `/wp-content/plugins/` directory 
    35352. Activate the plugin through the 'Plugins' menu in WordPress 
    3636 
Note: See TracChangeset for help on using the changeset viewer.