WordPress.org

Plugin Directory

Changeset 536937


Ignore:
Timestamp:
04/26/12 19:10:59 (2 years ago)
Author:
phill_brown
Message:

Version 1.1

Location:
menu-rules
Files:
99 added
6 edited

Legend:

Unmodified
Added
Removed
  • menu-rules/trunk/admin/meta-box.php

    r522118 r536937  
    3333        // Condition fields 
    3434        $fields['conditions_adv'] = array( 
    35             array( 
     35            'menu-rules-conditional-exp' => array( 
    3636                'title' => __('When these conditions match:', 'menu-rules'), 
    3737                'type' => 'textarea', 
     
    4848        // Rules 
    4949        $fields['rules'] = array( 
    50             array( 
    51                 'title' => __( 'Apply these rules:' , 'menu-rules'), 
    52                 'type' => 'checkbox', 
     50            'menu-rules-rules' => array( 
     51                'title' => __( 'Apply this rule:' , 'menu-rules'), 
     52                'type' => 'radio', 
    5353                'name' => 'menu-rules-rules', 
    54                 'text' => __( 'Choose rules' , 'menu-rules'), 
    5554                'value' => array_combine( 
    5655                    array_keys( Menu_Rules::get_var( 'rules_handlers' ) ), 
     
    6261        // Nav menus 
    6362        $fields['nav_menus'] = array( 
    64             array( 
     63            'menu-rules-menu-items' => array( 
    6564                'title' => __( 'To these menu items:' , 'menu-rules'), 
    6665                'type' => 'select', 
     
    9291        echo PB_Forms::table( $this->get_fields( 'conditions_adv' ), $postmeta ); 
    9392        echo PB_Forms::table( $this->get_fields( 'rules' ), $postmeta ); 
     93 
     94        // Backward compatibility notice for 1.0 - 1.1 upgrades 
     95        if ( count( $postmeta['menu-rules-rules'] ) > 1 ) { 
     96            echo '<div class="error">'; 
     97 
     98            echo '<p>' . __( 'We&apos;ve changed the behaviour of Menu Rules so you can only select one rule per Menu Rule item. You have the following rules selected:', 'menu-rules' ) . '</p>'; 
     99 
     100            echo '<ul>'; 
     101            $menu_rules_rules_field = $this->get_field_def( 'menu-rules-rules' ); 
     102            foreach ( $postmeta['menu-rules-rules'] as $rule_value ) { 
     103                echo '<li>' . $menu_rules_rules_field['value'][$rule_value] . '</li>'; 
     104            } 
     105            echo '</ul>'; 
     106 
     107            echo '<p>' . sprintf( 
     108                _n(  
     109                    'Please apply 1 of these rules to this item. %sThen create another menu rule%s, copy these conditions and menu items and apply the other rule.',  
     110                    'Please apply 1 of these rules to this item. %sThen create more menu rules%s, copy these conditions and menu items and apply the other rules.',  
     111                    count( $postmeta['menu-rules-rules'] ) - 1,  
     112                    'menu-rules'  
     113                ), 
     114                '<a href="' . admin_url( 'post-new.php?post_type=menu_rule' ) . '">', 
     115                '</a>' 
     116            ) . '</p>'; 
     117 
     118            echo '</div>'; 
     119        } 
     120 
    94121        echo PB_Forms::table( $this->get_fields( 'nav_menus' ), $postmeta ); 
    95122        echo '<p>' . sprintf( __('A full list of conditonal tags can be %sfound on the WordPress.org codex%s. Do not include an if statement or a semicolon.', 'menu-rules'), '<a href="http://codex.wordpress.org/Conditional_Tags" target="_blank">', '</a>' ) . '</p>'; 
  • menu-rules/trunk/libs/pb-framework/forms.php

    r521950 r536937  
    217217 
    218218        $opts = ''; 
     219        $counter = 0; 
    219220        foreach ( $values as $value => $title ) { 
     221            if ( $counter > 0 ) $opts .= '<br/>'; 
     222 
    220223            if ( empty( $value ) || empty( $title ) ) 
    221224                continue; 
    222  
     225             
    223226            $checkbox_args = array( 
    224227                'type' => 'radio', 
    225228                'value' => $value, 
    226                 'checked' => ( (string) $value == (string) $selected ), 
     229                'checked' => is_array( $selected ) 
     230                    ? in_array( $value, $selected ) 
     231                    : ( (string) $value == (string) $selected ), 
    227232                'desc' => $title, 
    228233                'desc_pos' => 'after' 
     
    230235            if ( isset( $extra ) ) $checkbox_args['extra'] = $extra; 
    231236            $opts .= self::_checkbox( $checkbox_args ); 
     237 
     238            $counter++; 
    232239        } 
    233240 
  • menu-rules/trunk/libs/pb-framework/meta-box.php

    r521961 r536937  
    8484        return $this->fields_flat = $fields; 
    8585    } 
     86 
     87    // Get a specific field definition data 
     88    protected function get_field_def( $name ) { 
     89        $all_fields = $this->get_fields_flat(); 
     90        //print_r($all_fields); 
     91        return isset( $all_fields[$name] ) ? $all_fields[$name] : false; 
     92    } 
    8693} 
  • menu-rules/trunk/menu-rules.php

    r521955 r536937  
    4242        // Setup built-in rules handers 
    4343        require_once dirname( __FILE__ ) . '/rules/active-parent.php'; 
     44        require_once dirname( __FILE__ ) . '/rules/inactive-parent.php'; 
    4445        require_once dirname( __FILE__ ) . '/rules/child-page.php'; 
    4546 
  • menu-rules/trunk/readme.txt

    r521950 r536937  
    44Tags: menus, menu, context, rules, parent menu, active menu 
    55Requires at least: 3.2 
    6 Tested up to: 3.3 
    7 Stable tag: 1.0 
     6Tested up to: 3.3.2 
     7Stable tag: 1.1 
    88 
    99An extension of the menu system with context-based rules and a flexible framework to write your own. 
     
    44441. Open the 'Appearance' menu item and click the 'Menu Rules' link 
    45451. Add a new menu rule and click ok. 
     46 
     47== Changelog == 
     48 
     49= 1.1 = 
     50* Added new 'force inactive parent' rule 
     51* Changed behaviour to one rule per item 
     52* Minor enhancements to PB Framework 
     53* Cleaned some unused code 
  • menu-rules/trunk/rules/active-parent.php

    r521955 r536937  
    5757    } 
    5858 
    59     protected function setup_parent_classes( $menu_item ) { 
    60     } 
    61  
    6259    protected function setup_ancestor_classes( &$menu_items, $active_ancestor_item_ids ) { 
    6360        $active_ancestor_item_ids = array_filter( array_unique( $active_ancestor_item_ids ) ); 
Note: See TracChangeset for help on using the changeset viewer.