Plugin Directory

Changeset 725318


Ignore:
Timestamp:
06/11/2013 01:58:40 PM (13 years ago)
Author:
Faison
Message:

Added feature allowing users to specify what the menu ul will be wrapped in.

Location:
advanced-custom-fields-nav-menu-field
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • advanced-custom-fields-nav-menu-field/trunk/fz-acf-nav-menu.php

    r710363 r725318  
    44Plugin URI: http://faisonz.com
    55Description: Add-On plugin for Advanced Custom Fields (ACF) that adds a 'Nav Menu' Field type.
    6 Version: 1.0.0
     6Version: 1.1.0
    77Author: Faison Zutavern
    88Author URI: http://faisonz.com
  • advanced-custom-fields-nav-menu-field/trunk/nav-menu-v4.php

    r710363 r725318  
    3737            'path' => apply_filters('acf/helpers/get_path', __FILE__),
    3838            'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
    39             'version' => '0.1.0'
     39            'version' => '1.1.0'
    4040        );
    4141
     
    8484                'id'        =>  __("Nav Menu ID",'acf')
    8585            )
     86        ));
     87       
     88        ?>
     89    </td>
     90</tr>
     91<tr class="field_option field_option_<?php echo $this->name; ?>">
     92    <td class="label">
     93        <label><?php _e("Menu Container",'acf'); ?></label>
     94        <p class="description">What to wrap the Menu's ul with.<br />Only used when returning HTML.</p>
     95    </td>
     96    <td>
     97        <?php
     98
     99        $choices = $this->get_allowed_nav_container_tags();
     100       
     101        do_action('acf/create_field', array(
     102            'type'      =>  'select',
     103            'name'      =>  'fields['.$key.'][container]',
     104            'value'     =>  $field['container'],
     105            'layout'    =>  'horizontal',
     106            'choices'   =>  $choices
    86107        ));
    87108       
     
    162183        return $nav_menus;
    163184    }
     185
     186    function get_allowed_nav_container_tags() {
     187        $tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
     188        $formatted_tags = array(
     189            array( '0' => 'None' )
     190        );
     191        foreach( $tags as $tag ) {
     192            $formatted_tags[0][$tag] = ucfirst( $tag );
     193        }
     194        return $formatted_tags;
     195    }
    164196   
    165197    function format_value_for_api( $value, $post_id, $field )
     
    194226
    195227            wp_nav_menu( array(
    196                 'menu' => $value
     228                'menu' => $value,
     229                'container' => $field['container']
    197230            ) );
    198231           
  • advanced-custom-fields-nav-menu-field/trunk/readme.txt

    r710657 r725318  
    66Requires at least: 3.4
    77Tested up to: 3.5.1
    8 Stable tag: 1.0.0
     8Stable tag: 1.1.0
    99License: GPL2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7979== Changelog ==
    8080
     81= 1.1.0 =
     82* Added a field which allows users to choose the containing element for the Menu's ul. See [wp_nav_menu's container parameter](http://codex.wordpress.org/Function_Reference/wp_nav_menu#Parameters)
     83
    8184= 1.0.0 =
    8285* Initial Release.
     
    8487== Upgrade Notice ==
    8588
     89= 1.1.0 =
     90Added a new minor feature for selecting the Menu's containing element.
     91
    8692= 1.0.0 =
    8793If you have a version less than 0.1.0, something went really, really wrong. Upgrade now, because I have no idea what will happen if you don't!
Note: See TracChangeset for help on using the changeset viewer.