Plugin Directory

Changeset 638974


Ignore:
Timestamp:
12/14/2012 04:12:38 AM (13 years ago)
Author:
Gecka
Message:

Version 7.0-beta3

Location:
gecka-submenu/trunk
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • gecka-submenu/trunk/css/admin-nav-menu-edit.css

    r311323 r638974  
    1 .edit-menu-item-autopopulate label {
    2 
    3     font-size: 110%;
    4     font-weight: bold;
    5 
    6 }
    7 
    8 .edit-menu-item-autopopulate-options {
    9 
    10 margin-right: 7px;
    11 
    12 }
    13 
    14 .gsm_posts_options, .gsm_taxonomies_options {
    15     margin-top: 2px;
    16     display: block;
    17 
    18 }
    19 
    20 .gsm_posts_options span.description-thin, .gsm_taxonomies_options  span.description-thin{
    21 
    22     display: block;
    23     width: 180px;
    24 }
    25 
    26 .gsm-autopopulate-posttype {
    27 
    28     font-size: 12px;   
    29 
    30 }
    31 
    32 .gsm-title {display: block; border-bottom: 1px solid #DFDFDF;}
     1.edit-menu-item-autopopulate label{font-size:110%;font-weight:bold}.edit-menu-item-autopopulate-options{margin-right:7px}.gsm_posts_options,.gsm_taxonomies_options{margin-top:2px;display:block}.gsm_posts_options span.description-thin,.gsm_taxonomies_options span.description-thin{display:block;width:180px}.gsm-autopopulate-posttype{font-size:12px}.gsm-title{display:block;border-bottom:1px solid #dfdfdf}
  • gecka-submenu/trunk/gecka-submenu.class.php

    r462557 r638974  
    33/**
    44 * Main Plugin class
    5  * @author lox
     5 * @author Gecka
    66 *
    77 */
     
    1717        load_plugin_textdomain(self::Domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages');
    1818       
    19         $this->Options = get_option( self::Domain . '_settings');
    20        
    2119        add_action('init', array($this, 'init') );
    22        
     20
     21        // pro upgrade notice
     22        add_action('current_screen', array($this, 'pro_notice') );
     23        add_action('wp_ajax_gecka_submenu_dismiss_notice', array($this, 'dismiss_notice'));
     24
    2325        // load widgets
    2426        add_action('widgets_init', array($this, 'widgetsInit') );
     
    2729        add_filter('wp_get_nav_menu_items', array($this, 'wp_get_nav_menu_items' ), 15, 3);
    2830       
    29         // filter to show the description of menu items if asked
    30         add_filter('walker_nav_menu_start_el', array($this, 'walker_nav_menu_start_el'), 10, 4);
    31    
     31        // filter to use our custom nav menu walker
     32        add_filter('wp_nav_menu_args', array($this, 'wp_nav_menu_args'));
     33        add_filter('wp_page_menu_args', array($this, 'wp_page_menu_args'));
     34       
     35        // filter to add thumbnail to menu item
     36        add_filter('nav_menu_item_before', array($this, 'nav_menu_item_before'), 10, 5);
     37       
     38        // filters to add description to menu item
     39        add_filter('nav_menu_item_after', array($this, 'nav_menu_item_after'), 10, 4);
     40        add_filter('nav_menu_item_link_after', array($this, 'nav_menu_item_link_after'), 10, 4);
     41       
    3242        if( !is_admin() )  {
    3343            require_once  GKSM_PATH . '/models/Shortcodes.php';
    3444            new Gecka_Submenu_Shortcodes();
    35         }
    36         else {
    37        
    38             if( get_option( self::Domain . '-pro-notice', '0') == 1 )
    39             add_action('admin_notices', array( $this, 'admin_notices') );
    40             add_action('wp_ajax_gecka_submenu_dismiss_notice', array($this, 'dismiss_notice'));
    41             add_action('admin_head', array($this, 'dismiss_notice_js') );
    42 
    4345        }
    4446       
     
    4648        require_once  GKSM_PATH . '/models/NavMenuHacks.php';
    4749        new Gecka_Submenu_NavMenuHacks();
     50       
     51        // Licence API
     52        // require_once  GKSM_PATH . '/models/Pro.php';
     53        // new Gecka_plugin_Pro(plugin_basename(dirname(__FILE__) . '/gecka-submenu.php'), GKSM_VERSION);
     54   
    4855    }
    4956   
     
    5360        remove_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
    5461    }
     62   
     63
    5564   
    5665    /**
     
    109118    }
    110119   
     120    public function wp_nav_menu_args ($args) {
     121       
     122        if($args['walker'] === '') $args['walker'] = new Gecka_Walker_Nav_Menu;
     123        return $args;
     124       
     125    }   
     126
    111127    /**
    112      * Filter to show nav-menu items description
    113      *       
    114      * @param $item_output
    115      * @param $item
    116      * @param $depth
    117      * @param $args
    118      * @return $item_output
     128     * If fallback to wp_page_menu, we unset our walker has it seems incompatible, and not needed
     129     * @param array $args
     130     * @return array
    119131     */
    120     public function walker_nav_menu_start_el ($item_output, $item, $depth, $args) {
    121 
    122         $after_link = '';
    123 
    124         if(isset($args->show_description) && $args->show_description) {
    125             $after_link = !empty( $item->description ) ? '<span class="description">'    . esc_html( $item->description) .'</span>' : '';
    126         }
    127        
    128         $after_link = apply_filters('nav_menu_item_after_link', $after_link, $item, $args, $depth);
    129            
    130         if($args->show_description == 'into_link') $after_link = $after_link . '</a>';
    131         else $after_link = '</a>' . $after_link;
    132            
    133         $item_output = str_replace('</a>', $after_link, $item_output);
    134        
    135        
    136         $before_link = '';
    137         if(isset($args->thumbnail) && $args->thumbnail) {
     132    public function wp_page_menu_args ($args) {
     133   
     134        if($args['walker'] instanceof Walker_Nav_Menu) $args['walker'] = '';
     135        return $args;
     136   
     137    }
     138   
     139    public function nav_menu_item_before ($content, $item, $depth, $args, $link_attributes) {
     140       
     141        if(isset($args->thumbnail) && $args->thumbnail) {
    138142         
    139143            $size = $args->thumbnail;
    140144            if( strpos($size, ',') ) $size = explode(',',$size);
    141145       
    142             $before_link = get_the_post_thumbnail( $item->object_id, $size );
     146            $content  .= "<a $link_attributes>" . get_the_post_thumbnail( $item->object_id, $size ) . "</a>";
    143147           
    144148        }
    145        
    146         $before_link = apply_filters('nav_menu_item_before_link', $before_link, $item, $args, $depth);
    147        
    148         $item_output = str_replace('<a', $before_link.'<a', $item_output);
    149        
    150         return $item_output;
    151     }
    152    
     149        return $content;
     150    }
     151   
     152    public function nav_menu_item_after ($content, $item, $depth, $args) {
     153       
     154        if( isset($args->show_description) && $args->show_description && $args->show_description !== 'into_link') {
     155            $description = !empty( $item->description ) ? '<span class="description">'    . esc_html( $item->description) .'</span>' : '';
     156           
     157            $content .= $description;
     158        }
     159        return $content;
     160       
     161    }
     162   
     163    public function nav_menu_item_link_after ($content, $item, $depth, $args) {
     164        if( isset($args->show_description) && $args->show_description && $args->show_description === 'into_link') {
     165            $description = !empty( $item->description ) ? '<span class="description">'    . esc_html( $item->description) .'</span>' : '';
     166           
     167            $content .= $description;
     168        }
     169        return $content;
     170    }
     171
     172    public function pro_notice ($screen) {
     173
     174        if( ! in_array($screen->base, array('nav-menus', 'plugins')) ) return;
     175
     176        if( get_option( 'gecka-submenu-pro-notice', '1') === '0' ) return;
     177
     178        add_action('admin_notices', array( $this, 'admin_notices') );
     179
     180        wp_enqueue_script('jquery');
     181        add_action('admin_head', array($this, 'dismiss_notice_js') );
     182    }
     183
    153184    function admin_notices() {
    154    
    155185        echo '<div class="updated" id="gecka_submenu_notice"><div style="float: right; margin-top: 3px"><a href="#" onclick="gecka_submenu_dismiss_notice(); return false;">Dismiss</a></div>';
    156186        echo '<p>' . __('You are using Gecka Submenu.', self::Domain ) . ' '. __('<a href="http://www.gecka-apps.com" target="_blank">Discover the pro version</a> to get the most out of the Wordpress menu system.', self::Domain ). "</p></div>";
     
    158188   
    159189    function dismiss_notice () {
    160    
    161190        update_option( 'gecka-submenu-pro-notice', '0');
    162191        die();
    163        
    164     }
     192    }
     193   
    165194    function dismiss_notice_js () {
    166195        ?>
     
    183212
    184213    }
     214}
     215
     216/**
     217 * Custom nav menu walker
     218 * This nav menu walker adds 4 filters to allow to fully customize the menu items output
     219 * @author Gecka
     220 *
     221 */
     222class Gecka_Walker_Nav_Menu extends Walker_Nav_Menu {
     223   
     224    /**
     225     * @see Walker::start_el()
     226     * @since 3.0.0
     227     *
     228     * @param string $output Passed by reference. Used to append additional content.
     229     * @param object $item Menu item data object.
     230     * @param int $depth Depth of menu item. Used for padding.
     231     * @param int $current_page Menu item ID.
     232     * @param object $args
     233     */
     234    function start_el(&$output, $item, $depth, $args) {
     235        global $wp_query;
     236        $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
     237
     238        $class_names = $value = '';
     239
     240        $classes = empty( $item->classes ) ? array() : (array) $item->classes;
     241        $classes[] = 'menu-item-' . $item->ID;
     242
     243        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
     244        $class_names = ' class="' . esc_attr( $class_names ) . '"';
     245
     246        $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
     247        $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
     248
     249        $output .= $indent . '<li' . $id . $value . $class_names .'>';
     250
     251        $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
     252        $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
     253        $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
     254        $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
     255
     256        $item_output = apply_filters( 'nav_menu_item_before', $args->before, $item, $depth, $args, $attributes );
     257        $item_output .= '<a'. $attributes .'>';
     258        $item_output .= apply_filters( 'nav_menu_item_link_before', $args->link_before, $item, $depth, $args );
     259        $item_output .= apply_filters( 'the_title', $item->title, $item->ID );
     260        $item_output .= apply_filters( 'nav_menu_item_link_after', $args->link_after, $item, $depth, $args );
     261        $item_output .= '</a>';
     262        $item_output .= apply_filters( 'nav_menu_item_after', $args->after, $item, $depth, $args, $attributes );
     263
     264        $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
     265    }
    185266}
    186267
     
    231312    }
    232313}
     314
  • gecka-submenu/trunk/gecka-submenu.php

    r462557 r638974  
    44Plugin URI: http://gecka-apps.com/wordpress-plugins/geka-submenu/
    55Description: Enhances the worpdress nav menu system, autopopulate with children pages
    6 Version: 0.6
     6Version: 0.7-beta3
    77Author: Gecka Apps
    88Author URI: http://gecka-apps.com
     
    1010*/
    1111
    12 /* Copyright 2010  Gecka SARL (email: [email protected]). All rights reserved
     12/* Copyright 2010-2012  Gecka SARL (email: [email protected]). All rights reserved
    1313
    1414    This program is free software; you can redistribute it and/or modify
     
    2626*/
    2727
    28 // require PHP 5
     28define('GKSM_PATH' , WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)) );
     29define('GKSM_URL'  , WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) );
     30
     31define('GKSM_VERSION', '0.7-beta3');
     32
     33// requires PHP 5
    2934function gksm_activation_check(){
    3035    if (version_compare(PHP_VERSION, '5.0.0', '<')) {
     
    3237        wp_die("Sorry, Gecka Submenu requires PHP 5 or higher. Ask your host how to enable PHP 5 as the default on your servers.");
    3338    }
    34     update_option( 'gecka-submenu-pro-notice', '1');
     39    update_option( 'gecka-submenu-pro-notice', '1');
    3540}
    3641register_activation_hook(__FILE__, 'gksm_activation_check');
    3742
    38 define('GKSM_PATH' , WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)) );
    39 define('GKSM_URL'  , WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) );
    40 
    41 //needed global vars for widget usage
     43// needed global vars for widget usage (hugly hack...)
    4244$GKSM_ID = $GKSM_MENUID = null;
    4345
    4446require GKSM_PATH . '/gecka-submenu.class.php';
    4547
    46 // Instantiate the class
    4748if (class_exists('Gecka_Submenu')) {
    4849    if (!isset($GkSm)) {
     
    5051        include GKSM_PATH . '/models/Submenu.php';
    5152        $GkSm = new Gecka_Submenu();
    52        
     53   
    5354    }
    5455}
  • gecka-submenu/trunk/javascripts/widget-custom-menu.js

    r311323 r638974  
    1 (function($) {
    2 
    3     gksm_widget_update_select = function (elem, target) {
    4 
    5         var data = { action: 'gksm_update',
    6                      ID: elem.value,
    7                      _ajax_nonce: gksm_widget.custom_menu_nonce
    8                     };
    9                
    10         // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
    11         $.post(ajaxurl, data, function(response) {
    12             $(target).html(response);
    13         });
    14     };
    15 
    16 
    17 })(jQuery);
     1(function(a){gksm_widget_update_select=function(b,d){var c={action:"gksm_update",ID:b.value,_ajax_nonce:gksm_widget.custom_menu_nonce};a.post(ajaxurl,c,function(e){a(d).html(e)})}})(jQuery);
  • gecka-submenu/trunk/languages/gecka-submenu-fr_FR.po

    r311323 r638974  
    33"Project-Id-Version: Gecka Sub-Menu\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2010-11-10 15:30+1100\n"
     5"POT-Creation-Date: 2012-12-14 14:54+1100\n"
    66"PO-Revision-Date: \n"
    77"Last-Translator: Laurent Dinclaux <[email protected]>\n"
    88"Language-Team: Gecka <[email protected]>\n"
     9"Language: \n"
    910"MIME-Version: 1.0\n"
    1011"Content-Type: text/plain; charset=UTF-8\n"
    1112"Content-Transfer-Encoding: 8bit\n"
    12 "Language: \n"
    1313"X-Poedit-KeywordsList: __;_e\n"
    1414"X-Poedit-Basepath: .\n"
     
    1616"X-Poedit-SearchPath-0: ..\n"
    1717
    18 #: ../gecka-submenu.class.php:153
     18#: ../gecka-submenu.class.php:186
    1919msgid "You are using Gecka Submenu."
    2020msgstr "Vous utilisez Gecka Submenu."
    2121
    22 #: ../gecka-submenu.class.php:153
     22#: ../gecka-submenu.class.php:186
    2323msgid "<a href=\"http://www.gecka-apps.com\" target=\"_blank\">Discover the pro version</a> to get the most out of the Wordpress menu system."
    2424msgstr "<a href=\"http://www.gecka-apps.com\" target=\"_blank\">Découvrez la version pro</a> pour obtenir le maximum du système de menus de Wordpress."
     
    2828msgstr "Afficher les sous pages automatiquement"
    2929
    30 #: ../models/NavMenuHacks.php:288
    31 #, php-format
    32 msgid "%s (Pending)"
    33 msgstr ""
    34 
    35 #: ../models/NavMenuHacks.php:327
    36 #: ../models/NavMenuHacks.php:329
    37 msgid "Edit Menu Item"
    38 msgstr ""
    39 
    40 #: ../models/NavMenuHacks.php:338
    41 msgid "URL"
    42 msgstr ""
    43 
    44 #: ../models/NavMenuHacks.php:345
    45 msgid "Navigation Label"
    46 msgstr ""
    47 
    48 #: ../models/NavMenuHacks.php:351
    49 msgid "Title Attribute"
    50 msgstr ""
    51 
    52 #: ../models/NavMenuHacks.php:357
    53 msgid "Link Target"
    54 msgstr ""
    55 
    56 #: ../models/NavMenuHacks.php:359
    57 msgid "Same window or tab"
    58 msgstr ""
    59 
    60 #: ../models/NavMenuHacks.php:360
    61 msgid "New window or tab"
    62 msgstr ""
    63 
    64 #: ../models/NavMenuHacks.php:366
    65 msgid "CSS Classes (optional)"
    66 msgstr ""
    67 
    68 #: ../models/NavMenuHacks.php:372
    69 msgid "Link Relationship (XFN)"
    70 msgstr ""
    71 
    72 #: ../models/NavMenuHacks.php:378
    73 msgid "Description"
    74 msgstr ""
    75 
    76 #: ../models/NavMenuHacks.php:380
    77 msgid "The description will be displayed in the menu if the current theme supports it."
    78 msgstr ""
    79 
    80 #: ../models/NavMenuHacks.php:389
    81 #, php-format
    82 msgid "Original: %s"
    83 msgstr ""
    84 
    85 #: ../models/NavMenuHacks.php:402
    86 msgid "Remove"
    87 msgstr ""
    88 
    89 #: ../models/NavMenuHacks.php:403
    90 msgid "Cancel"
    91 msgstr ""
    92 
    93 #: ../widgets/Custom-menu.php:12
     30#: ../widgets/Custom-menu.php:14
    9431msgid "Use this widget to add one of your custom menus as a widget."
    95 msgstr ""
    96 
    97 #: ../widgets/Custom-menu.php:13
     32msgstr "Utilisez ce widget pour ajouter l’un de vos menus en tant que widget. "
     33
     34#: ../widgets/Custom-menu.php:16
    9835msgid "Custom Menu"
    99 msgstr ""
    100 
    101 #: ../widgets/Custom-menu.php:13
     36msgstr "Menu personnalisé"
     37
     38#: ../widgets/Custom-menu.php:16
    10239msgid "[advanced]"
    10340msgstr "[avancé]"
    10441
    105 #: ../widgets/Custom-menu.php:76
     42#: ../widgets/Custom-menu.php:86
    10643#, php-format
    10744msgid "No menus have been created yet. <a href=\"%s\">Create some</a>."
    10845msgstr "Aucun menu n'a encore été créét. <a href=\"%s\">An créer un</a>."
    10946
    110 #: ../widgets/Custom-menu.php:82
     47#: ../widgets/Custom-menu.php:92
    11148msgid "Title:"
    11249msgstr "Titre:"
    11350
    114 #: ../widgets/Custom-menu.php:87
     51#: ../widgets/Custom-menu.php:97
    11552msgid "Use top parent item title"
    11653msgstr "Utiliser le titre du parent le plus haut"
    11754
    118 #: ../widgets/Custom-menu.php:90
     55#: ../widgets/Custom-menu.php:100
    11956msgid "Select Menu:"
    12057msgstr "Sélectionnez un menu:"
    12158
    122 #: ../widgets/Custom-menu.php:93
     59#: ../widgets/Custom-menu.php:103
    12360msgid "Select"
    12461msgstr "Sélectionnez"
    12562
    126 #: ../widgets/Custom-menu.php:104
     63#: ../widgets/Custom-menu.php:114
    12764msgid "Start menu from:"
    12865msgstr "Commencer le menu à partir"
    12966
    130 #: ../widgets/Custom-menu.php:107
     67#: ../widgets/Custom-menu.php:117
    13168msgid "Click save first"
    13269msgstr "Veuillez d'abord sauvegarder"
    13370
    134 #: ../widgets/Custom-menu.php:113
     71#: ../widgets/Custom-menu.php:123
    13572msgid "Depth:"
    13673msgstr "Profondeur:"
    13774
    138 #: ../widgets/Custom-menu.php:119
     75#: ../widgets/Custom-menu.php:129
    13976msgid "Show parent item"
    14077msgstr "Afficher l'élément parent"
    14178
    142 #: ../widgets/Custom-menu.php:122
     79#: ../widgets/Custom-menu.php:131
    14380msgid "Show description"
    14481msgstr "Afficher la description"
    14582
    146 #: ../widgets/Custom-menu.php:141
    147 #: ../widgets/Custom-menu.php:150
     83#: ../widgets/Custom-menu.php:133
     84msgid "No"
     85msgstr "Non"
     86
     87#: ../widgets/Custom-menu.php:134
     88msgid "Into link element"
     89msgstr ""
     90
     91#: ../widgets/Custom-menu.php:135
     92msgid "Into li element"
     93msgstr ""
     94
     95#: ../widgets/Custom-menu.php:138
     96msgid "Class:"
     97msgstr ""
     98
     99#: ../widgets/Custom-menu.php:162
     100#: ../widgets/Custom-menu.php:171
    148101msgid "First select a nav menu"
    149102msgstr "Sélectionnez d'abord un menu"
    150103
    151 #: ../widgets/Custom-menu.php:157
     104#: ../widgets/Custom-menu.php:178
    152105msgid "Error: Unknow menu."
    153106msgstr "Erreur: menu inconnu."
    154107
    155 #: ../widgets/Custom-menu.php:163
     108#: ../widgets/Custom-menu.php:184
    156109msgid "Nav menu root"
    157110msgstr "Racine du menu"
    158111
    159 #: ../widgets/Custom-menu.php:164
     112#: ../widgets/Custom-menu.php:185
    160113msgid "Current page"
    161114msgstr "Page actuelle"
    162115
     116#: ../widgets/Custom-menu.php:186
     117msgid "Current page's top parent"
     118msgstr "Le parent le plus haut"
     119
     120#: ../models/Nav-Menu-Edit-Walker.php:65
     121#: ../models/Nav-Menu-Edit-Walker.php:252
     122#, php-format
     123msgid "%s (Pending)"
     124msgstr ""
     125
     126#: ../models/Nav-Menu-Edit-Walker.php:104
     127#: ../models/Nav-Menu-Edit-Walker.php:106
     128#: ../models/Nav-Menu-Edit-Walker.php:293
     129msgid "Edit Menu Item"
     130msgstr ""
     131
     132#: ../models/Nav-Menu-Edit-Walker.php:115
     133#: ../models/Nav-Menu-Edit-Walker.php:302
     134msgid "URL"
     135msgstr ""
     136
     137#: ../models/Nav-Menu-Edit-Walker.php:122
     138#: ../models/Nav-Menu-Edit-Walker.php:309
     139msgid "Navigation Label"
     140msgstr ""
     141
     142#: ../models/Nav-Menu-Edit-Walker.php:128
     143#: ../models/Nav-Menu-Edit-Walker.php:315
     144msgid "Title Attribute"
     145msgstr ""
     146
     147#: ../models/Nav-Menu-Edit-Walker.php:134
     148msgid "Link Target"
     149msgstr ""
     150
     151#: ../models/Nav-Menu-Edit-Walker.php:136
     152msgid "Same window or tab"
     153msgstr ""
     154
     155#: ../models/Nav-Menu-Edit-Walker.php:137
     156msgid "New window or tab"
     157msgstr ""
     158
     159#: ../models/Nav-Menu-Edit-Walker.php:143
     160#: ../models/Nav-Menu-Edit-Walker.php:327
     161msgid "CSS Classes (optional)"
     162msgstr ""
     163
     164#: ../models/Nav-Menu-Edit-Walker.php:149
     165#: ../models/Nav-Menu-Edit-Walker.php:333
     166msgid "Link Relationship (XFN)"
     167msgstr ""
     168
     169#: ../models/Nav-Menu-Edit-Walker.php:155
     170#: ../models/Nav-Menu-Edit-Walker.php:339
     171msgid "Description"
     172msgstr ""
     173
     174#: ../models/Nav-Menu-Edit-Walker.php:157
     175#: ../models/Nav-Menu-Edit-Walker.php:341
     176msgid "The description will be displayed in the menu if the current theme supports it."
     177msgstr ""
     178
     179#: ../models/Nav-Menu-Edit-Walker.php:166
     180#: ../models/Nav-Menu-Edit-Walker.php:350
     181#, php-format
     182msgid "Original: %s"
     183msgstr ""
     184
     185#: ../models/Nav-Menu-Edit-Walker.php:179
     186#: ../models/Nav-Menu-Edit-Walker.php:363
     187msgid "Remove"
     188msgstr ""
     189
     190#: ../models/Nav-Menu-Edit-Walker.php:180
     191#: ../models/Nav-Menu-Edit-Walker.php:364
     192msgid "Cancel"
     193msgstr ""
     194
     195#: ../models/Nav-Menu-Edit-Walker.php:248
     196#, php-format
     197msgid "%s (Invalid)"
     198msgstr ""
     199
     200#: ../models/Nav-Menu-Edit-Walker.php:322
     201msgid "Open link in a new window/tab"
     202msgstr ""
     203
  • gecka-submenu/trunk/languages/gecka-submenu.pot

    r311323 r638974  
    33"Project-Id-Version: Gecka Sub-Menu\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2010-11-10 15:30+1100\n"
     5"POT-Creation-Date: 2012-12-14 14:54+1100\n"
    66"PO-Revision-Date: \n"
    77"Last-Translator: Laurent Dinclaux <[email protected]>\n"
    88"Language-Team: Gecka <[email protected]>\n"
     9"Language: \n"
    910"MIME-Version: 1.0\n"
    1011"Content-Type: text/plain; charset=UTF-8\n"
    1112"Content-Transfer-Encoding: 8bit\n"
    12 "Language: \n"
    1313"X-Poedit-KeywordsList: __;_e\n"
    1414"X-Poedit-Basepath: .\n"
    1515"X-Poedit-SearchPath-0: ..\n"
    1616
    17 #: ../gecka-submenu.class.php:153
     17#: ../gecka-submenu.class.php:186
    1818msgid "You are using Gecka Submenu."
    1919msgstr ""
    2020
    21 #: ../gecka-submenu.class.php:153
     21#: ../gecka-submenu.class.php:186
    2222msgid "<a href=\"http://www.gecka-apps.com\" target=\"_blank\">Discover the pro version</a> to get the most out of the Wordpress menu system."
    2323msgstr ""
     
    2727msgstr ""
    2828
    29 #: ../models/NavMenuHacks.php:288
     29#: ../widgets/Custom-menu.php:14
     30msgid "Use this widget to add one of your custom menus as a widget."
     31msgstr ""
     32
     33#: ../widgets/Custom-menu.php:16
     34msgid "Custom Menu"
     35msgstr ""
     36
     37#: ../widgets/Custom-menu.php:16
     38msgid "[advanced]"
     39msgstr ""
     40
     41#: ../widgets/Custom-menu.php:86
     42#, php-format
     43msgid "No menus have been created yet. <a href=\"%s\">Create some</a>."
     44msgstr ""
     45
     46#: ../widgets/Custom-menu.php:92
     47msgid "Title:"
     48msgstr ""
     49
     50#: ../widgets/Custom-menu.php:97
     51msgid "Use top parent item title"
     52msgstr ""
     53
     54#: ../widgets/Custom-menu.php:100
     55msgid "Select Menu:"
     56msgstr ""
     57
     58#: ../widgets/Custom-menu.php:103
     59msgid "Select"
     60msgstr ""
     61
     62#: ../widgets/Custom-menu.php:114
     63msgid "Start menu from:"
     64msgstr ""
     65
     66#: ../widgets/Custom-menu.php:117
     67msgid "Click save first"
     68msgstr ""
     69
     70#: ../widgets/Custom-menu.php:123
     71msgid "Depth:"
     72msgstr ""
     73
     74#: ../widgets/Custom-menu.php:129
     75msgid "Show parent item"
     76msgstr ""
     77
     78#: ../widgets/Custom-menu.php:131
     79msgid "Show description"
     80msgstr ""
     81
     82#: ../widgets/Custom-menu.php:133
     83msgid "No"
     84msgstr ""
     85
     86#: ../widgets/Custom-menu.php:134
     87msgid "Into link element"
     88msgstr ""
     89
     90#: ../widgets/Custom-menu.php:135
     91msgid "Into li element"
     92msgstr ""
     93
     94#: ../widgets/Custom-menu.php:138
     95msgid "Class:"
     96msgstr ""
     97
     98#: ../widgets/Custom-menu.php:162
     99#: ../widgets/Custom-menu.php:171
     100msgid "First select a nav menu"
     101msgstr ""
     102
     103#: ../widgets/Custom-menu.php:178
     104msgid "Error: Unknow menu."
     105msgstr ""
     106
     107#: ../widgets/Custom-menu.php:184
     108msgid "Nav menu root"
     109msgstr ""
     110
     111#: ../widgets/Custom-menu.php:185
     112msgid "Current page"
     113msgstr ""
     114
     115#: ../widgets/Custom-menu.php:186
     116msgid "Current page's top parent"
     117msgstr ""
     118
     119#: ../models/Nav-Menu-Edit-Walker.php:65
     120#: ../models/Nav-Menu-Edit-Walker.php:252
    30121#, php-format
    31122msgid "%s (Pending)"
    32123msgstr ""
    33124
    34 #: ../models/NavMenuHacks.php:327
    35 #: ../models/NavMenuHacks.php:329
     125#: ../models/Nav-Menu-Edit-Walker.php:104
     126#: ../models/Nav-Menu-Edit-Walker.php:106
     127#: ../models/Nav-Menu-Edit-Walker.php:293
    36128msgid "Edit Menu Item"
    37129msgstr ""
    38130
    39 #: ../models/NavMenuHacks.php:338
     131#: ../models/Nav-Menu-Edit-Walker.php:115
     132#: ../models/Nav-Menu-Edit-Walker.php:302
    40133msgid "URL"
    41134msgstr ""
    42135
    43 #: ../models/NavMenuHacks.php:345
     136#: ../models/Nav-Menu-Edit-Walker.php:122
     137#: ../models/Nav-Menu-Edit-Walker.php:309
    44138msgid "Navigation Label"
    45139msgstr ""
    46140
    47 #: ../models/NavMenuHacks.php:351
     141#: ../models/Nav-Menu-Edit-Walker.php:128
     142#: ../models/Nav-Menu-Edit-Walker.php:315
    48143msgid "Title Attribute"
    49144msgstr ""
    50145
    51 #: ../models/NavMenuHacks.php:357
     146#: ../models/Nav-Menu-Edit-Walker.php:134
    52147msgid "Link Target"
    53148msgstr ""
    54149
    55 #: ../models/NavMenuHacks.php:359
     150#: ../models/Nav-Menu-Edit-Walker.php:136
    56151msgid "Same window or tab"
    57152msgstr ""
    58153
    59 #: ../models/NavMenuHacks.php:360
     154#: ../models/Nav-Menu-Edit-Walker.php:137
    60155msgid "New window or tab"
    61156msgstr ""
    62157
    63 #: ../models/NavMenuHacks.php:366
     158#: ../models/Nav-Menu-Edit-Walker.php:143
     159#: ../models/Nav-Menu-Edit-Walker.php:327
    64160msgid "CSS Classes (optional)"
    65161msgstr ""
    66162
    67 #: ../models/NavMenuHacks.php:372
     163#: ../models/Nav-Menu-Edit-Walker.php:149
     164#: ../models/Nav-Menu-Edit-Walker.php:333
    68165msgid "Link Relationship (XFN)"
    69166msgstr ""
    70167
    71 #: ../models/NavMenuHacks.php:378
     168#: ../models/Nav-Menu-Edit-Walker.php:155
     169#: ../models/Nav-Menu-Edit-Walker.php:339
    72170msgid "Description"
    73171msgstr ""
    74172
    75 #: ../models/NavMenuHacks.php:380
     173#: ../models/Nav-Menu-Edit-Walker.php:157
     174#: ../models/Nav-Menu-Edit-Walker.php:341
    76175msgid "The description will be displayed in the menu if the current theme supports it."
    77176msgstr ""
    78177
    79 #: ../models/NavMenuHacks.php:389
     178#: ../models/Nav-Menu-Edit-Walker.php:166
     179#: ../models/Nav-Menu-Edit-Walker.php:350
    80180#, php-format
    81181msgid "Original: %s"
    82182msgstr ""
    83183
    84 #: ../models/NavMenuHacks.php:402
     184#: ../models/Nav-Menu-Edit-Walker.php:179
     185#: ../models/Nav-Menu-Edit-Walker.php:363
    85186msgid "Remove"
    86187msgstr ""
    87188
    88 #: ../models/NavMenuHacks.php:403
     189#: ../models/Nav-Menu-Edit-Walker.php:180
     190#: ../models/Nav-Menu-Edit-Walker.php:364
    89191msgid "Cancel"
    90192msgstr ""
    91193
    92 #: ../widgets/Custom-menu.php:12
    93 msgid "Use this widget to add one of your custom menus as a widget."
    94 msgstr ""
    95 
    96 #: ../widgets/Custom-menu.php:13
    97 msgid "Custom Menu"
    98 msgstr ""
    99 
    100 #: ../widgets/Custom-menu.php:13
    101 msgid "[advanced]"
    102 msgstr ""
    103 
    104 #: ../widgets/Custom-menu.php:76
    105 #, php-format
    106 msgid "No menus have been created yet. <a href=\"%s\">Create some</a>."
    107 msgstr ""
    108 
    109 #: ../widgets/Custom-menu.php:82
    110 msgid "Title:"
    111 msgstr ""
    112 
    113 #: ../widgets/Custom-menu.php:87
    114 msgid "Use top parent item title"
    115 msgstr ""
    116 
    117 #: ../widgets/Custom-menu.php:90
    118 msgid "Select Menu:"
    119 msgstr ""
    120 
    121 #: ../widgets/Custom-menu.php:93
    122 msgid "Select"
    123 msgstr ""
    124 
    125 #: ../widgets/Custom-menu.php:104
    126 msgid "Start menu from:"
    127 msgstr ""
    128 
    129 #: ../widgets/Custom-menu.php:107
    130 msgid "Click save first"
    131 msgstr ""
    132 
    133 #: ../widgets/Custom-menu.php:113
    134 msgid "Depth:"
    135 msgstr ""
    136 
    137 #: ../widgets/Custom-menu.php:119
    138 msgid "Show parent item"
    139 msgstr ""
    140 
    141 #: ../widgets/Custom-menu.php:122
    142 msgid "Show description"
    143 msgstr ""
    144 
    145 #: ../widgets/Custom-menu.php:141
    146 #: ../widgets/Custom-menu.php:150
    147 msgid "First select a nav menu"
    148 msgstr ""
    149 
    150 #: ../widgets/Custom-menu.php:157
    151 msgid "Error: Unknow menu."
    152 msgstr ""
    153 
    154 #: ../widgets/Custom-menu.php:163
    155 msgid "Nav menu root"
    156 msgstr ""
    157 
    158 #: ../widgets/Custom-menu.php:164
    159 msgid "Current page"
    160 msgstr ""
    161 
     194#: ../models/Nav-Menu-Edit-Walker.php:248
     195#, php-format
     196msgid "%s (Invalid)"
     197msgstr ""
     198
     199#: ../models/Nav-Menu-Edit-Walker.php:322
     200msgid "Open link in a new window/tab"
     201msgstr ""
     202
  • gecka-submenu/trunk/models/NavMenuHacks.php

    r462557 r638974  
    66
    77        if(is_admin() ) {
    8        
    9             /* use custom walker */     
     8
     9            /* use custom walker */
    1010            add_filter( 'wp_edit_nav_menu_walker', array($this, 'custom_walker') );
    11            
     11
    1212            /* add custom field */
    1313            add_action('wp_nav_menu_item_custom_fields', array($this, 'wp_nav_menu_item_custom_fields'),10,4  );
    14            
     14
    1515            /* save custom field */
    1616            add_action('wp_update_nav_menu_item', array($this, 'wp_update_nav_menu_item'),10,3  );
    17            
    18             /* css */
     17
     18            /* load custom css */
    1919            add_action('admin_init', array($this, 'register_scripts'));
    2020            add_action( "admin_print_styles-nav-menus.php", array($this, 'admin_print_styles') );
    21        
    22         }
     21
     22        }
     23
    2324        add_filter( 'wp_get_nav_menu_items', array($this, 'wp_get_nav_menu_items'),10,3 );
    24            
     25
    2526        /* set up nav menu item with custom properties */
    2627        add_filter( 'wp_setup_nav_menu_item', array($this, 'wp_setup_nav_menu_item') );
    27    
     28
    2829        /* customize menu display */
    2930        add_filter( 'walker_nav_menu_start_el', array($this, 'walker_nav_menu_start_el'), 10,4 );
    30          
    31     }
    32    
     31
     32    }
    3333    function wp_get_nav_menu_items ($items, $menu, $args) {
    34    
    35         if( is_admin() && $GLOBALS['pagenow'] == 'nav-menus.php' ) return $items;
    36    
    37             $order = sizeof($items)+1;
    38    
    39             foreach($items as $item) {
    40            
    41                 if($item->autopopulate !== '1') continue;
    42                
    43                 switch ($item->autopopulate_type) {
    44                
    45                     case 'subpages':
    46                        
    47                         $pages = get_pages( apply_filters('gecka-submenu-get_pages', array('child_of' => $item->object_id, 'sort_column' => 'menu_order, post_title')) );
    48                        
    49                         $this->setup_posts ('post', &$item, &$pages, &$items, &$order);
    50                        
    51                         break;
    52                    
    53                 }
    54            
    55             }
     34
     35        //we don't autopopulate in the nav menu edit screen in wp-admin
     36        if (is_admin () && $GLOBALS ['pagenow'] == 'nav-menus.php')
     37            return $items;
     38
     39        $order = sizeof ( $items ) + 1;
     40
     41        foreach ( $items as $item ) {
     42
     43            if ($item->autopopulate !== '1')
     44                continue;
     45
     46            switch ($item->autopopulate_type) {
     47
     48                case 'subpages' :
     49
     50                    $pages = get_pages ( apply_filters ( 'gecka-submenu-get_pages', array ('child_of' => $item->object_id, 'sort_column' => 'menu_order, post_title', 'post_type'=> isset($item->object) ? $item->object : 'page' ) ) );
     51
     52                    $this->setup_posts ( 'post', &$item, &$pages, &$items, &$order );
     53
     54                    break;
     55            }
     56
     57        }
    5658        return $items;
    5759    }
    58    
    59     function setup_posts ($type, &$item, &$posts, &$items, &$order) {
    60        
     60
     61    function setup_posts ($type, &$item, &$posts, &$items, &$order, $child_of=0) {
     62
    6163        $_ids = $this->get_ids($type, $order, $posts);
    62        
     64
    6365        foreach($posts as $key=>$post) {
    64            
     66
    6567            $id = isset($post->ID) ? $post->ID : $post->term_id;
    66                            
     68
    6769            $parent_id = $item->ID;
    68                            
     70
    6971            if( isset($post->post_parent) && $post->post_parent && $post->post_parent != $item->object_id ) {
    70                $parent_id = $_ids[$post->post_parent];
    71             }
    72            
    73             if( isset($post->parent) && $post->parent && $post->parent != $item->object_id ) {
    74                $parent_id = $_ids[$post->parent];
    75             }
    76            
    77             $items[] = $this->menu_item_from_post($post, $_ids[$id], $parent_id, $order);
    78            
     72                $parent_id = $_ids[$post->post_parent];
     73            }
     74
     75            if( isset($post->parent) && $post->parent && $post->parent != $item->object_id && $post->parent!=$child_of ) {
     76                $parent_id = $_ids[$post->parent];
     77            }
     78
     79            if(isset($post->term_id)) $items[] = $this->menu_item_from_tax($post, $_ids[$id], $parent_id, $order);
     80            else $items[] = $this->menu_item_from_post($post, $_ids[$id], $parent_id, $order);
     81
    7982            $order++;
    80                            
    81         }
    82                        
     83
     84        }
     85
    8386        return $posts;
    84    
    85     }
    86    
     87
     88    }
     89
    8790    function get_ids ($type, $order, $items) {
    88    
     91
    8992        $ids = array();
    90    
     93
    9194        foreach($items as $item) {
    92        
     95
    9396            $id = $type == 'post' ? $item->ID : $item->term_id;
    94        
     97
    9598            $ids[$id] = -$order;
    96        
     99
    97100            $order++;
    98101        }
    99        
    100        
     102
     103
    101104        return $ids;
    102    
    103     }
    104    
     105
     106    }
     107
    105108    function menu_item_from_post ($post, $pseudo_id, $parent_id = 0, $order=0) {
    106         $_item = is_object($post) ? clone $post : clone get_post($post);
    107        
     109        $post = get_post($post);
     110        $_item = clone $post;
     111
    108112        $id = $_item->ID ;
    109        
     113
    110114        $_item->ID = $_item->db_id =  $pseudo_id ;
    111115        $_item->post_name = '' . $pseudo_id;
     
    117121        $_item->menu_order = $order;
    118122        $_item->description = $_item->post_excerpt;
    119        
     123
     124
    120125        $object = get_post_type_object( $post->post_type );
    121         $_item->object      = $object->name;
    122         $_item->type_label  = $object->labels->singular_name;
    123        
     126        $_item->object      = $object->name;
     127        $_item->type_label  = $object->labels->singular_name;
     128
    124129        $_item->url = get_permalink( $post->ID );
    125130        $_item->title = $post->post_title;
     
    128133        $_item->classes = array ( 0 => '');
    129134        $_item->xfn = '';
    130                
     135
    131136        $_item->db_id =  $pseudo_id;
    132        
     137
    133138        return $_item;
    134    
    135     }   
    136    
     139
     140    }
     141
    137142    function walker_nav_menu_start_el ( $item_output, $item, $depth, $args) {
    138  
    139          if( isset($item->autopopulate) && $item->autopopulate =='subpages') {
    140             $args = array( 'depth'        => 0,
    141                             'child_of'     => $item->object_id,
    142                             'echo'         => 0, 'title_li' => '' );
    143            
     143
     144        if( isset($item->autopopulate) && $item->autopopulate =='subpages' ) {
     145            $args = array( 'depth'        => 0,
     146                            'child_of'     => $item->object_id,
     147                            'echo'         => 0, 'title_li' => '' );
     148
    144149            //$item_output = $item_output . '<ul class="sub-menu" >' . wp_list_pages($args) . '</ul>';
    145            
    146         }
    147         return $item_output;
    148     }
    149    
     150
     151        }
     152        return $item_output;
     153    }
     154
    150155
    151156    /**
     
    154159    function wp_setup_nav_menu_item($menu_item) {
    155160        if ( isset( $menu_item->post_type ) ) {
    156        
    157             if ( 'nav_menu_item' == $menu_item->post_type ) {
    158                 $menu_item->autopopulate = empty( $menu_item->autopopulate ) ? get_post_meta( $menu_item->ID, '_menu_item_autopopulate', true ) : $menu_item->autopopulate;
    159                 $menu_item->autopopulate_type = empty( $menu_item->autopopulate_type ) ? get_post_meta( $menu_item->ID, '_menu_item_autopopulate_type', true ) : $menu_item->autopopulate_type;     
    160             }
    161         }
     161
     162            if ( 'nav_menu_item' == $menu_item->post_type ) {
     163                $menu_item->autopopulate = empty( $menu_item->autopopulate ) ? get_post_meta( $menu_item->ID, '_menu_item_autopopulate', true ) : $menu_item->autopopulate;
     164                $menu_item->autopopulate_type = empty( $menu_item->autopopulate_type ) ? get_post_meta( $menu_item->ID, '_menu_item_autopopulate_type', true ) : $menu_item->autopopulate_type;
     165            }
     166        }
    162167        return $menu_item;
    163168    }
    164    
     169
    165170
    166171    /**
    167172     * Saves the new fields
    168173     */
    169     function wp_update_nav_menu_item($menu_id, $menu_item_db_id, $args) {
    170    
     174    function wp_update_nav_menu_item($menu_id, $menu_item_db_id, $args)
     175    {
     176
    171177        $args['menu-item-autopopulate_type'] = isset( $_POST['menu-item-autopopulate_type'][$menu_item_db_id] ) ? $_POST['menu-item-autopopulate_type'][$menu_item_db_id] : '';
    172        
     178
    173179        if ( empty( $args['menu-item-autopopulate_type'] ) ) {
    174             $args['menu-item-autopopulate_type'] = '';
     180            $args['menu-item-autopopulate_type'] = '';
    175181        }
    176182
    177183        update_post_meta( $menu_item_db_id, '_menu_item_autopopulate_type', $args['menu-item-autopopulate_type'] );
    178184
    179        
     185
    180186        if( $args['menu-item-autopopulate_type'] === 'subpages' )  $args['menu-item-autopopulate'] = '1';
    181187        else  $args['menu-item-autopopulate'] = '0';
     
    183189        update_post_meta( $menu_item_db_id, '_menu_item_autopopulate', $args['menu-item-autopopulate'] );
    184190
    185        
     191
    186192        /* old version compatibility */
    187          
     193
    188194        if(  get_post_meta($menu_item_db_id, '_menu_item_showsub', true) == '1') {
    189                
     195
    190196            update_post_meta( $menu_item_db_id, '_menu_item_autopopulate_type', 'subpages' );
    191             update_post_meta( $menu_item_db_id, '_menu_item_autopopulate', '1' );
    192            
     197            update_post_meta( $menu_item_db_id, '_menu_item_autopopulate', '1' );
     198
    193199
    194200            delete_post_meta( $menu_item_db_id, '_menu_item_showsub', $args['menu-item-showsub'] );
    195201        }
    196        
    197     }
    198    
    199     function register_scripts () {   
    200        wp_register_style('gecka-submenu-nav-menu-edit', GKSM_URL . '/css/admin-nav-menu-edit.css' );
    201     }
    202    
     202    }
     203
     204    function register_scripts () {
     205        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
     206        wp_register_style('gecka-submenu-nav-menu-edit', GKSM_URL . "/css/admin-nav-menu-edit$suffix.css", array(), GKSM_VERSION );
     207    }
     208
    203209    function admin_print_styles () {
    204210        wp_enqueue_style('gecka-submenu-nav-menu-edit');
    205211    }
    206    
    207     function admin_print_scripts () { }
    208212
    209213    /**
    210214     * Adds a custom fields
    211215     */
    212     function custom_walker($a) {
     216    function custom_walker($a)
     217    {
     218        include 'Nav-Menu-Edit-Walker.php';
    213219        return 'Gecka_Walker_Nav_Menu_Edit';
    214220    }
    215    
     221
    216222    function wp_nav_menu_item_custom_fields ( $item_id, $item, $depth, $args) {
    217         if($item->object === 'page') {
    218             include GKSM_PATH . '/views/Nav-Menu-Fields.php';
    219         }
    220     }
    221    
     223        include GKSM_PATH . '/views/Nav-Menu-Fields.php';
     224    }
     225
    222226}
    223 
    224 /**
    225  * Create HTML list of nav menu input items.
    226  *
    227  * @package WordPress
    228  * @since 3.0.0
    229  * @uses Walker_Nav_Menu
    230  */
    231 class Gecka_Walker_Nav_Menu_Edit extends Walker_Nav_Menu  {
    232     /**
    233      * @see Walker_Nav_Menu::start_lvl()
    234      * @since 3.0.0
    235      *
    236      * @param string $output Passed by reference.
    237      * @param int $depth Depth of page.
    238      */
    239     function start_lvl(&$output) {}
    240 
    241     /**
    242      * @see Walker_Nav_Menu::end_lvl()
    243      * @since 3.0.0
    244      *
    245      * @param string $output Passed by reference.
    246      * @param int $depth Depth of page.
    247      */
    248     function end_lvl(&$output) {
    249     }
    250 
    251     /**
    252      * @see Walker::start_el()
    253      * @since 3.0.0
    254      *
    255      * @param string $output Passed by reference. Used to append additional content.
    256      * @param object $item Menu item data object.
    257      * @param int $depth Depth of menu item. Used for padding.
    258      * @param int $current_page Menu item ID.
    259      * @param object $args
    260      */
    261     function start_el(&$output, $item, $depth, $args)
    262     {
    263         global $_wp_nav_menu_max_depth;
    264         $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
    265 
    266         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    267 
    268         ob_start();
    269         $item_id = esc_attr( $item->ID );
    270         $removed_args = array(
    271             'action',
    272             'customlink-tab',
    273             'edit-menu-item',
    274             'menu-item',
    275             'page-tab',
    276             '_wpnonce',
    277         );
    278 
    279         $original_title = '';
    280         if ( 'taxonomy' == $item->type ) {
    281             $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
    282         } elseif ( 'post_type' == $item->type ) {
    283             $original_object = get_post( $item->object_id );
    284             $original_title = $original_object->post_title;
    285         }
    286 
    287         $classes = array(
    288             'menu-item menu-item-depth-' . $depth,
    289             'menu-item-' . esc_attr( $item->object ),
    290             'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
    291         );
    292 
    293         $title = $item->title;
    294 
    295         if ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
    296             $classes[] = 'pending';
    297             /* translators: %s: title of menu item in draft status */
    298             $title = sprintf( __('%s (Pending)'), $item->title );
    299         }
    300 
    301         $title = empty( $item->label ) ? $title : $item->label;
    302 
    303         ?>
    304         <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
    305             <dl class="menu-item-bar">
    306                 <dt class="menu-item-handle">
    307                     <span class="item-title"><?php echo esc_html( $title ); ?></span>
    308                     <span class="item-controls">
    309                         <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
    310                         <span class="item-order">
    311                             <a href="<?php
    312                                 echo wp_nonce_url(
    313                                     add_query_arg(
    314                                         array(
    315                                             'action' => 'move-up-menu-item',
    316                                             'menu-item' => $item_id,
    317                                         ),
    318                                         remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
    319                                     ),
    320                                     'move-menu_item'
    321                                 );
    322                             ?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up'); ?>">&#8593;</abbr></a>
    323                             |
    324                             <a href="<?php
    325                                 echo wp_nonce_url(
    326                                     add_query_arg(
    327                                         array(
    328                                             'action' => 'move-down-menu-item',
    329                                             'menu-item' => $item_id,
    330                                         ),
    331                                         remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
    332                                     ),
    333                                     'move-menu_item'
    334                                 );
    335                             ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">&#8595;</abbr></a>
    336                         </span>
    337                         <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php _e('Edit Menu Item'); ?>" href="<?php
    338                             echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
    339                         ?>"><?php _e( 'Edit Menu Item' ); ?></a>
    340                     </span>
    341                 </dt>
    342             </dl>
    343 
    344             <div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
    345                 <?php if( 'custom' == $item->type ) : ?>
    346                     <p class="field-url description description-wide">
    347                         <label for="edit-menu-item-url-<?php echo $item_id; ?>">
    348                             <?php _e( 'URL' ); ?><br />
    349                             <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
    350                         </label>
    351                     </p>
    352                 <?php endif; ?>
    353                 <p class="description description-thin">
    354                     <label for="edit-menu-item-title-<?php echo $item_id; ?>">
    355                         <?php _e( 'Navigation Label' ); ?><br />
    356                         <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
    357                     </label>
    358                 </p>
    359                 <p class="description description-thin">
    360                     <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
    361                         <?php _e( 'Title Attribute' ); ?><br />
    362                         <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
    363                     </label>
    364                 </p>
    365                 <p class="field-link-target description description-thin">
    366                     <label for="edit-menu-item-target-<?php echo $item_id; ?>">
    367                         <?php _e( 'Link Target' ); ?><br />
    368                         <select id="edit-menu-item-target-<?php echo $item_id; ?>" class="widefat edit-menu-item-target" name="menu-item-target[<?php echo $item_id; ?>]">
    369                             <option value="" <?php selected( $item->target, ''); ?>><?php _e('Same window or tab'); ?></option>
    370                             <option value="_blank" <?php selected( $item->target, '_blank'); ?>><?php _e('New window or tab'); ?></option>
    371                         </select>
    372                     </label>
    373                 </p>
    374                 <p class="field-css-classes description description-thin">
    375                     <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
    376                         <?php _e( 'CSS Classes (optional)' ); ?><br />
    377                         <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
    378                     </label>
    379                 </p>
    380                 <p class="field-xfn description description-thin">
    381                     <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
    382                         <?php _e( 'Link Relationship (XFN)' ); ?><br />
    383                         <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
    384                     </label>
    385                 </p>
    386                 <p class="field-description description description-wide">
    387                     <label for="edit-menu-item-description-<?php echo $item_id; ?>">
    388                         <?php _e( 'Description' ); ?><br />
    389                         <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); ?></textarea>
    390                         <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
    391                     </label>
    392                 </p>
    393                 <?php
    394                 do_action('wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args);
    395                 ?>
    396                 <div class="menu-item-actions description-wide submitbox">
    397                     <?php if( 'custom' != $item->type ) : ?>
    398                         <p class="link-to-original">
    399                             <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
    400                         </p>
    401                     <?php endif; ?>
    402                     <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
    403                     echo wp_nonce_url(
    404                         add_query_arg(
    405                             array(
    406                                 'action' => 'delete-menu-item',
    407                                 'menu-item' => $item_id,
    408                             ),
    409                             remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
    410                         ),
    411                         'delete-menu_item_' . $item_id
    412                     ); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep"> | </span> <a class="item-cancel submitcancel" id="cancel-<?php echo $item_id; ?>" href="<?php echo add_query_arg( array('edit-menu-item' => $item_id, 'cancel' => time()), remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) );
    413                         ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a>
    414                 </div>
    415 
    416                 <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
    417                 <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
    418                 <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
    419                 <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
    420                 <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
    421                 <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
    422             </div><!-- .menu-item-settings-->
    423             <ul class="menu-item-transport"></ul>
    424         <?php
    425         $output .= ob_get_clean();
    426     }
    427 }
  • gecka-submenu/trunk/models/Shortcodes.php

    r462557 r638974  
    22
    33class Gecka_Submenu_Shortcodes {
    4 
     4   
    55    static $cache = array ();
    66   
     
    99        add_shortcode( 'submenu',   array( $this, 'submenu') );
    1010        add_shortcode( 'menu',  array( $this, 'menu') );
    11         add_action( 'gk-menu', array( $this,'gk_menu'), 10, 1 );
     11        add_action( 'gk-menu', array( $this, 'gk_menu'), 10, 1 );
    1212               
    1313    }
  • gecka-submenu/trunk/models/Submenu.php

    r462557 r638974  
    3030                                        'show_description' => false,
    3131                                        'thumbnail' => null,
    32                                         'auto_title' => false
    3332                                   
    3433                                    );
     
    5352   
    5453    public function Get($Options = null)
    55     {       
     54    {
     55       
    5656        return $this->Build($Options);
    5757    }
     
    6262    }
    6363   
    64     public function Widget($args, $instance)
    65     {
    66 
    67         extract( wp_parse_args($args, $this->DefaultOptions), EXTR_SKIP);
     64    public function Widget($widget_args, $instance)
     65    {
     66
     67        extract( wp_parse_args($widget_args, $this->DefaultOptions), EXTR_SKIP);
    6868       
    6969        $instance['container_class'] = 'submenu-widget';
    7070        $instance['is_gk_submenu'] = 'widget';
     71       
     72        $args = apply_filters( 'gk_submenu_widget_args', $instance );
    7173       
    7274        $out = $this->Get($instance);
     
    9496            echo $after_widget;
    9597        }
     98        else do_action('gk_submenu_widget_fallback', $widget_args, $args);
    9699    }
    97100   
     
    103106       
    104107        $Options = wp_parse_args($Options, $this->DefaultOptions);
     108        $Options = apply_filters( 'gk_submenu_args', $Options );
    105109       
    106110        extract($Options);
     
    128132       
    129133        /* WPML support */
    130         if( function_exists('icl_object_id') ) {
    131                        
    132             global $sitepress;
    133                        
    134             /* not default language */
    135             if(ICL_LANGUAGE_CODE !== $sitepress->get_default_language() ) {
    136                 $translated_menu_id = icl_object_id($menu, 'nav_menu');
    137                 $menu = $translated_menu_id ? $translated_menu_id : $menu;
    138             }
    139         }
    140        
    141         /* */       
     134        if( function_exists('icl_object_id') ) {
     135               
     136            global $sitepress;
     137               
     138            /* not default language */
     139               
     140            if(ICL_LANGUAGE_CODE !== $sitepress->get_default_language() ) {
     141                $translated_menu_id = icl_object_id($menu, 'nav_menu');
     142                $menu = $translated_menu_id ? $translated_menu_id : $menu;
     143            }
     144        }
     145        /* */
     146       
    142147        $menu_items = wp_get_nav_menu_items($menu);
    143148       
    144149        if(is_tax() || is_category()) $_type = 'taxonomy';
    145150        else $_type = 'post_type';
    146                
     151       
     152       
    147153        // current page is top level element
    148154        if( $submenu === 'current' ) {
     
    150156            $submenu = $this->get_associated_nav_menu_item($wp_query->get_queried_object_id(), &$menu_items, $_type);
    151157        }
     158
    152159        // top parent page is the top level element
    153160        else if( $submenu === 'top' ) {
     
    155162            global $post, $wp_query;
    156163           
    157             if( is_a($post, 'stdClass') && (int)$post->ID ) {
    158                 if( $submenu = $this->get_top_ancestor ($wp_query->get_queried_object_id(), &$menu_items, $_type) ) 
    159                     $submenu = $submenu->ID;
     164            if( ( is_a($post, 'stdClass') || is_a($post, 'WP_Post') ) && (int)$post->ID ) {
     165                if( $submenu = $this->get_top_ancestor ($wp_query->get_queried_object_id(), &$menu_items, $_type) )
     166                    $submenu = $submenu->ID;
    160167            }
    161168           
    162169        }
    163                
     170       
    164171        // a submenu has been specified
    165172        if( $submenu !== 0 ) {
     
    172179               
    173180                $submenu_item = $this->get_menu_item ($submenu, &$menu_items);
    174                
    175                
     181
    176182                if( !$submenu_item ) $submenu_item = $this->get_associated_nav_menu_item($submenu, &$menu_items, $type);
    177183                if(!$submenu_item) return;
     
    186192            global $GKSM_ID, $GKSM_MENUID;
    187193            $menu_object = wp_get_nav_menu_object($menu);
    188             $GKSM_ID = $submenu_id; $GKSM_MENUID = $menu_object->term_id;
     194            $GKSM_ID = $submenu_id; $GKSM_MENUID = $menu_object->term_id;
     195       
    189196        }
    190197       
     
    196203            $container_class .= " $container_class-" . $slug ;
    197204       
    198         }// gets the nav menu
    199        
    200         $args =  array( 'container_class' => $container_class,
     205        }
     206       
     207        // gets the nav menu
     208        $args =  array(  'container_class' => $container_class,
    201209                         'menu'=> $menu,
    202210                         'show_description'=> $show_description,
    203211                         'depth'=>$depth,
    204212                         'is_gk_submenu'=>$is_gk_submenu );
    205    
     213       
     214        if( empty($args['walker']) ) $args['walker'] = new Gecka_Walker_Nav_Menu;
     215
    206216        $out = wp_nav_menu( wp_parse_args($args, $Options) );
    207217       
     
    212222    }
    213223   
     224    /**
     225     * Gets the top parent menu item of a given post from a specific menu
     226     * @param int $menu menu ID to seach for post
     227     * @param int $postID post ID to look for
     228     * @return object $Item a menu item object or false
     229     */
     230    private function get_top_ancestor ($postID, &$menu_items, $type='post_type')  {
     231       
     232        $Item = $this->get_associated_nav_menu_item($postID, &$menu_items, $type);
     233       
     234        if(!$Item) return;
     235       
     236        $Ancestror = $Item;
     237        while(1) {
     238            if($Item->menu_item_parent) {
     239                $Item = $this->get_menu_item($Item->menu_item_parent, &$menu_items);
     240                continue;
     241            }
     242            break;
     243        }
     244       
     245        return $Item;
     246    }
     247   
    214248    /**
    215249     * Gets a menu item from a list of menu items, avoiding SQL queries
     
    248282    }
    249283   
    250     function get_associated_nav_menu_items( $object_id, &$menu_items, $object_type = 'post_type') {
    251 
    252         $object_id = (int) $object_id;
     284    function get_associated_nav_menu_items( $object_id, &$menu_items, $object_type = 'post_type') {
     285        $object_id = (int) $object_id;
    253286        $_menu_items = array();
    254287
     
    259292            }
    260293        }
     294
     295        if( !empty($_menu_items) || $object_type !== 'post_type' ) return $_menu_items;
     296
     297        // no associated 'post_type' menu item found, looking for associated 'taxonomy' menu item
     298        return $this->get_associated_nav_menu_terms_items ( $object_id, &$menu_items );; 
     299    }
     300
     301    function get_associated_nav_menu_terms_items ( $object_id, &$menu_items ) {
    261302       
    262         if( !empty($_menu_items) || $object_type !== 'post_type' ) return $_menu_items;
    263        
    264         // no associated 'post_type' menu item found, looking for associated 'taxonomy' menu item
    265         return $this->get_associated_nav_menu_terms_items ( $object_id, &$menu_items );
    266    
    267     }   
    268    
    269     function get_associated_nav_menu_terms_items ( $object_id, &$menu_items ) {
    270        
    271         $post = get_post($object_id);
    272        
    273         if(!$post) return array();
    274        
    275         $_menu_items    = array();
    276         $taxonomies     = get_object_taxonomies($post->post_type);
    277        
    278        
    279         foreach ($taxonomies as $taxonomy) {
    280            
    281             if( !$terms = get_the_terms( $object_id, $taxonomy ) ) continue;
    282            
    283             foreach ($terms as $term) {
    284                
    285                 $_menu_items = $this->get_associated_nav_menu_items($term->term_id, &$menu_items, 'taxonomy');
    286                 if( !empty($_menu_items) ) return $_menu_items;
    287                
    288             }
    289         }
    290  
    291         return $_menu_items; 
    292        
    293     }
    294    
    295     /**
    296      * Gets the top parent menu item of a given post from a specific menu
    297      * @param int $menu menu ID to seach for post
    298      * @param int $postID post ID to look for
    299      * @return object $Item a menu item object or false
    300      */
    301     private function get_top_ancestor ($postID, &$menu_items, $type='post_type')  {
    302        
    303         $Item = $this->get_associated_nav_menu_item($postID, &$menu_items, $type);
    304        
    305         if(!$Item) return;
    306        
    307         $Ancestror = $Item;
    308         while(1) {
    309             if($Item->menu_item_parent) {
    310                 $Item = $this->get_menu_item($Item->menu_item_parent, &$menu_items);
    311                 continue;
    312             }
    313             break;
    314         }
    315        
    316         return $Item;
     303        $post = get_post($object_id);
     304   
     305        if(!$post) return array();
     306       
     307        $_menu_items = array();
     308        $taxonomies = get_object_taxonomies($post->post_type);
     309       
     310        foreach ($taxonomies as $taxonomy) {
     311       
     312            if( !$terms = get_the_terms( $object_id, $taxonomy ) ) continue;
     313       
     314            foreach ($terms as $term) {
     315       
     316                $_menu_items = $this->get_associated_nav_menu_items($term->term_id, &$menu_items, 'taxonomy');
     317                if( !empty($_menu_items) ) return $_menu_items;
     318       
     319            }
     320        }
     321         
     322        return $_menu_items;
     323
    317324    }
    318325}
    319 
  • gecka-submenu/trunk/readme.txt

    r462557 r638974  
    33Tags: nav menu, 3.0, submenu, sub-menu, child, child men, subpages, subpage, dynamic menu, dynamic subpages, dynamic submenu
    44Requires at least: 3.0
    5 Tested up to: 3.1
    6 Stable tag: 0.6
     5Tested up to: 3.5
     6Stable tag: 0.7-beta3
    77Donate link: http://gecka-apps.com/wordpress-plugins/gecka-submenu-pro/
    88
     
    1414**PHP 5 required. Please be sure to check your PHP version before marking the plugin as broken.**
    1515
    16 Submenu enhances the WordPress 3.x navigation system. When you have a website based on WordPress with a lot of pages, but you need a custom menu, it can be tedious to have to add a menu entry for each page created. Submenu just does it automatically. 
    17  
     16Submenu enhances the WordPress 3.x navigation system. When you have a website based on WordPress with a lot of pages, but you need a custom menu, it can be tedious to have to add a menu entry for each page created. Submenu just does it automatically.
     17
    1818Submenu also allows you to put menus or portion of menus anywhere in your site: sidebar, templates or page contents.
    1919
    20 Languages available: english, french 
     20Languages available: english, french
    2121
    2222**Contribute:** [This plugin is on GitHub](https://github.com/Gecka-Apps/Wordpress_Gecka_Submenu) !
    23  
    24 [Discover the pro version](http://gecka-apps.com/wordpress-plugins/gecka-submenu-pro/ "Discover the pro version") by checking out the [Gecka Submenu Pro video](http://www.youtube.com/watch?v=DHjMfD-k2Mo): 
    25  
    26 http://www.youtube.com/watch?v=DHjMfD-k2Mo 
    27  
     23
     24[Discover the pro version](http://gecka-apps.com/wordpress-plugins/gecka-submenu-pro/ "Discover the pro version") by checking out the [Gecka Submenu Pro video](http://www.youtube.com/watch?v=DHjMfD-k2Mo):
     25
     26http://www.youtube.com/watch?v=DHjMfD-k2Mo
     27
    2828== Installation ==
    2929
     
    4343== Changelog ==
    4444
     45= 0.7 =
     46* performances enhancements
     47* better widget with specific class support
     48* added a gk_submenu_widget_fallback action to use to display custom content
     49  when the widget has no menu entries to display
     50* Wordpress 3.5 compatibility
     51
    4552= 0.6 =
    4653* shortcodes caching
     
    5663
    5764= 0.5.2 =
    58 
    5965* corrected readme file 
    6066* added the start from "Top parent element" option to the widget
    6167
    6268= 0.5.1 =
    63 
    6469* bug fix
    6570
     
    7176= 0.4.2 = 
    7277* More fixes 
    73 * Menu parameter is no more mandatory, gets the lowest ID menu if not set   
    74  
    75 = 0.4.1 = 
    76 * Fixed bug in submenu builder 
    77  
    78 = 0.4 = 
    79 * Fixed some notice errors 
    80 * Experimental functionnality to autopopulate a page menu item with its subpages for WP 3.0 nav menu system 
    81  
    82 = 0.3 = 
    83 * Added template tag and shortcode support 
    84  
    85 = 0.2 = 
    86 * Bugs fixes 
    87 * Localization support (French added). 
    88  
    89 = 0.1 = 
     78* Menu parameter is no more mandatory, gets the lowest ID menu if not set 
     79
     80= 0.4.1 =
     81* Fixed bug in submenu builder
     82
     83= 0.4 =
     84* Fixed some notice errors
     85* Experimental functionnality to autopopulate a page menu item with its subpages for WP 3.0 nav menu system
     86
     87= 0.3 =
     88* Added template tag and shortcode support
     89
     90= 0.2 =
     91* Bugs fixes
     92* Localization support (French added).
     93
     94= 0.1 =
    9095* First version.
  • gecka-submenu/trunk/views/Nav-Menu-Fields.php

    r311323 r638974  
    33                <p class="edit-menu-item-autopopulate" >
    44                <label for="edit-menu-item-autopopulate-<?php echo $item_id; ?>">
    5                     <input type="checkbox" id="edit-menu-item-autopopulate_type-<?php echo $item_id; ?>-subpages" class="edit-menu-item-autopopulate_type" name="menu-item-autopopulate_type[<?php echo $item_id; ?>]" value="subpages" <?php echo checked($item->autopopulate_type , 'subpages'); ?> />
     5                    <input type="checkbox" id="edit-menu-item-autopopulate-<?php echo $item_id; ?>" class="edit-menu-item-autopopulate_type" name="menu-item-autopopulate_type[<?php echo $item_id; ?>]" value="subpages" <?php echo checked($item->autopopulate_type , 'subpages'); ?> />
    66                    <?php _e( 'Automaticaly populate with child pages', Gecka_Submenu::Domain ); ?>
    77                </label>
  • gecka-submenu/trunk/widgets/Custom-menu.php

    r315553 r638974  
    77                                        'show_parent'=>0,
    88                                        'show_description'=>0,
    9                                          );
     9                                        'class'=>''
     10                                      );
    1011   
    1112    public function GKSM_Widget_Custom_Menu () {
     13       
    1214        $widget_ops = array('classname' => 'gksm-custom-menu-widget', 'description' => __('Use this widget to add one of your custom menus as a widget.'));
    13         parent::WP_Widget('gksm-custom-menu-widget', __('Custom Menu') . ' ' .  __('[advanced]', Gecka_Submenu::Domain ), $widget_ops);
     15        $control_ops = array('width' => 350, 'height' => 350);
     16        parent::WP_Widget('gksm-custom-menu-widget', __('Custom Menu') . ' ' .  __('[advanced]', Gecka_Submenu::Domain ), $widget_ops, $control_ops);
    1417       
    1518        // ajax select update
    1619        add_action('wp_ajax_gksm_update', array($this, 'submenuOptionsAjax'));
    1720       
    18         // needed javasccript for widget admin     
    19         wp_register_script('gecka-submenu-widget-custom-menu', GKSM_URL . '/javascripts/widget-custom-menu.js', 'jquery' );
    20        
     21        // needed javasccript & css for widget admin     
     22        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
     23       
     24        wp_register_script('gecka-submenu-widget-custom-menu', GKSM_URL . "/javascripts/widget-custom-menu$suffix.js", array('jquery'), GKSM_VERSION );
     25        wp_register_style('gecka-submenu-widget-custom-menu', GKSM_URL . "/css/widget-custom-menu$suffix.css", array(), GKSM_VERSION);
     26       
    2127        add_action( "admin_print_scripts-widgets.php", array($this, 'admin_print_scripts') );
    2228       
    23        
     29        add_filter( 'dynamic_sidebar_params', array($this, 'dynamic_sidebar_params') );
     30       
    2431    }
    2532   
     
    3138                                )
    3239                        );
    33 
     40        wp_enqueue_style('gecka-submenu-widget-custom-menu');
    3441    }
    3542   
     
    5562        }
    5663       
    57         $instance['depth'] = (int) $new_instance['depth'];
    58        
    59         $instance['show_description'] = $new_instance['show_description'];
     64        $instance['show_description']   = $new_instance['show_description'];
     65        $instance['class']              = $new_instance['class'];
     66        $instance['depth']              = (int) $new_instance['depth'];
    6067       
    6168        return $instance;
     
    7077        $submenu   = isset( $instance['submenu'] ) ? $instance['submenu'] : '0';
    7178        $depth     = isset( $instance['depth'] ) ? $instance['depth'] : 0;
    72        
     79        $class     = isset( $instance['class'] ) ? $instance['class'] : 0;
     80
    7381         // Get menus
    7482        $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
     
    8189   
    8290        ?>
    83            
     91            <div class="gksm">
    8492            <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
    8593            <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
     
    113121            </select></p>
    114122           
    115             <p><label for="<?php echo $this->get_field_id('depth'); ?>"><?php _e( 'Depth:', Gecka_Submenu::Domain ); ?></label>
     123            <p class="description-thin"><label for="<?php echo $this->get_field_id('depth'); ?>"><?php _e( 'Depth:', Gecka_Submenu::Domain ); ?></label>
    116124            <input class="widefat" id="<?php echo $this->get_field_id('depth'); ?>" name="<?php echo $this->get_field_name('depth'); ?>" type="text" value="<?php echo $depth; ?>" />
    117125            </p>
    118126           
    119             <p>         
     127            <p class="description-thin">         
    120128            <!-- <input class="checkbox" type="checkbox" <?php checked($instance['show_parent'], true) ?> id="<?php echo $this->get_field_id('show_parent'); ?>" name="<?php echo $this->get_field_name('show_parent'); ?>" />
    121129            <label for="<?php echo $this->get_field_id('show_parent'); ?>"><?php _e('Show parent item', Gecka_Submenu::Domain); ?></label><br />
    122130             -->
    123            
    124131            <label for="<?php echo $this->get_field_id('show_description'); ?>"><?php _e('Show description', Gecka_Submenu::Domain); ?>:</label><br />
    125132            <select name="<?php echo $this->get_field_name('show_description'); ?>" id="<?php echo $this->get_field_id('show_description'); ?>">
     
    128135                <option value="into_li" <?php selected('into_li', $instance['show_description']) ?>><?php _e('Into li element', Gecka_Submenu::Domain); ?></option>
    129136            </select>
    130             </p>
     137           
     138            <p class="description-thin"><label for="<?php echo $this->get_field_id('class'); ?>"><?php _e( 'Class:', Gecka_Submenu::Domain ); ?></label>
     139            <input class="widefat" id="<?php echo $this->get_field_id('class'); ?>" name="<?php echo $this->get_field_name('class'); ?>" type="text" value="<?php echo $class; ?>" />
     140            </p>
     141           
     142            <p class="description-thin">         
     143            </p>
     144            </div>
    131145       
    132146        <?php
     
    177191    }
    178192   
    179    
     193    public function dynamic_sidebar_params($params) {
     194        global $wp_registered_sidebars, $wp_registered_widgets;
     195   
     196        $widget_id = $params[0]['widget_id'];
     197        $widget = $wp_registered_widgets[$widget_id];
     198   
     199        // is our widget
     200        if( !empty($widget['callback']) && is_array($widget['callback'])
     201                && $widget['callback'][0] instanceof GKSM_Widget_Custom_Menu ) {
     202   
     203            //get widget instance
     204            $instance = $widget['callback'][0]->get_settings();
     205   
     206            if (! array_key_exists($params[1]['number'], $instance)) {
     207                return $params;
     208            }
     209   
     210            $instance = $instance[$params[1]['number']];
     211            if( empty($instance['class']) ) return $params;
     212   
     213            $class = $instance['class'];
     214   
     215            // from wp-includes/widgets.php
     216            $classname_ = '';
     217            foreach ( (array) $widget['classname'] as $cn ) {
     218                if ( is_string($cn) )
     219                    $classname_ .= '_' . $cn;
     220                elseif ( is_object($cn) )
     221                $classname_ .= '_' . get_class($cn);
     222            }
     223            $classname_ = ltrim($classname_, '_');
     224   
     225            // we add our class
     226            $classname_ .= ' ' . $class;
     227   
     228            $before_widget = $wp_registered_sidebars[$params[0]['id']]['before_widget'];
     229            $params[0]['before_widget'] = sprintf($before_widget, $widget['id'], $classname_);
     230        }
     231   
     232        return $params;
     233    }   
    180234}
Note: See TracChangeset for help on using the changeset viewer.