Changeset 638974
- Timestamp:
- 12/14/2012 04:12:38 AM (13 years ago)
- Location:
- gecka-submenu/trunk
- Files:
-
- 1 added
- 15 edited
-
css/admin-nav-menu-edit.css (modified) (1 diff)
-
gecka-submenu.class.php (modified) (9 diffs)
-
gecka-submenu.php (modified) (5 diffs)
-
index.php (added)
-
javascripts/widget-custom-menu.js (modified) (1 diff)
-
languages/gecka-submenu-fr_FR.mo (modified) (previous)
-
languages/gecka-submenu-fr_FR.po (modified) (3 diffs)
-
languages/gecka-submenu.pot (modified) (2 diffs)
-
models/NavMenuHacks.php (modified) (5 diffs)
-
models/Shortcodes.php (modified) (2 diffs)
-
models/Submenu.php (modified) (14 diffs)
-
readme.txt (modified) (5 diffs)
-
screenshot-1.png (modified) (previous)
-
screenshot-2.png (modified) (previous)
-
views/Nav-Menu-Fields.php (modified) (1 diff)
-
widgets/Custom-menu.php (modified) (8 diffs)
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 3 3 /** 4 4 * Main Plugin class 5 * @author lox5 * @author Gecka 6 6 * 7 7 */ … … 17 17 load_plugin_textdomain(self::Domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages'); 18 18 19 $this->Options = get_option( self::Domain . '_settings');20 21 19 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 23 25 // load widgets 24 26 add_action('widgets_init', array($this, 'widgetsInit') ); … … 27 29 add_filter('wp_get_nav_menu_items', array($this, 'wp_get_nav_menu_items' ), 15, 3); 28 30 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 32 42 if( !is_admin() ) { 33 43 require_once GKSM_PATH . '/models/Shortcodes.php'; 34 44 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 43 45 } 44 46 … … 46 48 require_once GKSM_PATH . '/models/NavMenuHacks.php'; 47 49 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 48 55 } 49 56 … … 53 60 remove_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' ); 54 61 } 62 63 55 64 56 65 /** … … 109 118 } 110 119 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 111 127 /** 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 119 131 */ 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) { 138 142 139 143 $size = $args->thumbnail; 140 144 if( strpos($size, ',') ) $size = explode(',',$size); 141 145 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>"; 143 147 144 148 } 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 153 184 function admin_notices() { 154 155 185 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>'; 156 186 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>"; … … 158 188 159 189 function dismiss_notice () { 160 161 190 update_option( 'gecka-submenu-pro-notice', '0'); 162 191 die(); 163 164 }192 } 193 165 194 function dismiss_notice_js () { 166 195 ?> … … 183 212 184 213 } 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 */ 222 class 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 } 185 266 } 186 267 … … 231 312 } 232 313 } 314 -
gecka-submenu/trunk/gecka-submenu.php
r462557 r638974 4 4 Plugin URI: http://gecka-apps.com/wordpress-plugins/geka-submenu/ 5 5 Description: Enhances the worpdress nav menu system, autopopulate with children pages 6 Version: 0. 66 Version: 0.7-beta3 7 7 Author: Gecka Apps 8 8 Author URI: http://gecka-apps.com … … 10 10 */ 11 11 12 /* Copyright 2010 Gecka SARL (email: [email protected]). All rights reserved12 /* Copyright 2010-2012 Gecka SARL (email: [email protected]). All rights reserved 13 13 14 14 This program is free software; you can redistribute it and/or modify … … 26 26 */ 27 27 28 // require PHP 5 28 define('GKSM_PATH' , WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)) ); 29 define('GKSM_URL' , WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) ); 30 31 define('GKSM_VERSION', '0.7-beta3'); 32 33 // requires PHP 5 29 34 function gksm_activation_check(){ 30 35 if (version_compare(PHP_VERSION, '5.0.0', '<')) { … … 32 37 wp_die("Sorry, Gecka Submenu requires PHP 5 or higher. Ask your host how to enable PHP 5 as the default on your servers."); 33 38 } 34 update_option( 'gecka-submenu-pro-notice', '1');39 update_option( 'gecka-submenu-pro-notice', '1'); 35 40 } 36 41 register_activation_hook(__FILE__, 'gksm_activation_check'); 37 42 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...) 42 44 $GKSM_ID = $GKSM_MENUID = null; 43 45 44 46 require GKSM_PATH . '/gecka-submenu.class.php'; 45 47 46 // Instantiate the class47 48 if (class_exists('Gecka_Submenu')) { 48 49 if (!isset($GkSm)) { … … 50 51 include GKSM_PATH . '/models/Submenu.php'; 51 52 $GkSm = new Gecka_Submenu(); 52 53 53 54 } 54 55 } -
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 3 3 "Project-Id-Version: Gecka Sub-Menu\n" 4 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 201 0-11-10 15:30+1100\n"5 "POT-Creation-Date: 2012-12-14 14:54+1100\n" 6 6 "PO-Revision-Date: \n" 7 7 "Last-Translator: Laurent Dinclaux <[email protected]>\n" 8 8 "Language-Team: Gecka <[email protected]>\n" 9 "Language: \n" 9 10 "MIME-Version: 1.0\n" 10 11 "Content-Type: text/plain; charset=UTF-8\n" 11 12 "Content-Transfer-Encoding: 8bit\n" 12 "Language: \n"13 13 "X-Poedit-KeywordsList: __;_e\n" 14 14 "X-Poedit-Basepath: .\n" … … 16 16 "X-Poedit-SearchPath-0: ..\n" 17 17 18 #: ../gecka-submenu.class.php:1 5318 #: ../gecka-submenu.class.php:186 19 19 msgid "You are using Gecka Submenu." 20 20 msgstr "Vous utilisez Gecka Submenu." 21 21 22 #: ../gecka-submenu.class.php:1 5322 #: ../gecka-submenu.class.php:186 23 23 msgid "<a href=\"http://www.gecka-apps.com\" target=\"_blank\">Discover the pro version</a> to get the most out of the Wordpress menu system." 24 24 msgstr "<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." … … 28 28 msgstr "Afficher les sous pages automatiquement" 29 29 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 94 31 msgid "Use this widget to add one of your custom menus as a widget." 95 msgstr " "96 97 #: ../widgets/Custom-menu.php:1 332 msgstr "Utilisez ce widget pour ajouter l’un de vos menus en tant que widget. " 33 34 #: ../widgets/Custom-menu.php:16 98 35 msgid "Custom Menu" 99 msgstr " "100 101 #: ../widgets/Custom-menu.php:1 336 msgstr "Menu personnalisé" 37 38 #: ../widgets/Custom-menu.php:16 102 39 msgid "[advanced]" 103 40 msgstr "[avancé]" 104 41 105 #: ../widgets/Custom-menu.php: 7642 #: ../widgets/Custom-menu.php:86 106 43 #, php-format 107 44 msgid "No menus have been created yet. <a href=\"%s\">Create some</a>." 108 45 msgstr "Aucun menu n'a encore été créét. <a href=\"%s\">An créer un</a>." 109 46 110 #: ../widgets/Custom-menu.php: 8247 #: ../widgets/Custom-menu.php:92 111 48 msgid "Title:" 112 49 msgstr "Titre:" 113 50 114 #: ../widgets/Custom-menu.php: 8751 #: ../widgets/Custom-menu.php:97 115 52 msgid "Use top parent item title" 116 53 msgstr "Utiliser le titre du parent le plus haut" 117 54 118 #: ../widgets/Custom-menu.php: 9055 #: ../widgets/Custom-menu.php:100 119 56 msgid "Select Menu:" 120 57 msgstr "Sélectionnez un menu:" 121 58 122 #: ../widgets/Custom-menu.php: 9359 #: ../widgets/Custom-menu.php:103 123 60 msgid "Select" 124 61 msgstr "Sélectionnez" 125 62 126 #: ../widgets/Custom-menu.php:1 0463 #: ../widgets/Custom-menu.php:114 127 64 msgid "Start menu from:" 128 65 msgstr "Commencer le menu à partir" 129 66 130 #: ../widgets/Custom-menu.php:1 0767 #: ../widgets/Custom-menu.php:117 131 68 msgid "Click save first" 132 69 msgstr "Veuillez d'abord sauvegarder" 133 70 134 #: ../widgets/Custom-menu.php:1 1371 #: ../widgets/Custom-menu.php:123 135 72 msgid "Depth:" 136 73 msgstr "Profondeur:" 137 74 138 #: ../widgets/Custom-menu.php:1 1975 #: ../widgets/Custom-menu.php:129 139 76 msgid "Show parent item" 140 77 msgstr "Afficher l'élément parent" 141 78 142 #: ../widgets/Custom-menu.php:1 2279 #: ../widgets/Custom-menu.php:131 143 80 msgid "Show description" 144 81 msgstr "Afficher la description" 145 82 146 #: ../widgets/Custom-menu.php:141 147 #: ../widgets/Custom-menu.php:150 83 #: ../widgets/Custom-menu.php:133 84 msgid "No" 85 msgstr "Non" 86 87 #: ../widgets/Custom-menu.php:134 88 msgid "Into link element" 89 msgstr "" 90 91 #: ../widgets/Custom-menu.php:135 92 msgid "Into li element" 93 msgstr "" 94 95 #: ../widgets/Custom-menu.php:138 96 msgid "Class:" 97 msgstr "" 98 99 #: ../widgets/Custom-menu.php:162 100 #: ../widgets/Custom-menu.php:171 148 101 msgid "First select a nav menu" 149 102 msgstr "Sélectionnez d'abord un menu" 150 103 151 #: ../widgets/Custom-menu.php:1 57104 #: ../widgets/Custom-menu.php:178 152 105 msgid "Error: Unknow menu." 153 106 msgstr "Erreur: menu inconnu." 154 107 155 #: ../widgets/Custom-menu.php:1 63108 #: ../widgets/Custom-menu.php:184 156 109 msgid "Nav menu root" 157 110 msgstr "Racine du menu" 158 111 159 #: ../widgets/Custom-menu.php:1 64112 #: ../widgets/Custom-menu.php:185 160 113 msgid "Current page" 161 114 msgstr "Page actuelle" 162 115 116 #: ../widgets/Custom-menu.php:186 117 msgid "Current page's top parent" 118 msgstr "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 123 msgid "%s (Pending)" 124 msgstr "" 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 129 msgid "Edit Menu Item" 130 msgstr "" 131 132 #: ../models/Nav-Menu-Edit-Walker.php:115 133 #: ../models/Nav-Menu-Edit-Walker.php:302 134 msgid "URL" 135 msgstr "" 136 137 #: ../models/Nav-Menu-Edit-Walker.php:122 138 #: ../models/Nav-Menu-Edit-Walker.php:309 139 msgid "Navigation Label" 140 msgstr "" 141 142 #: ../models/Nav-Menu-Edit-Walker.php:128 143 #: ../models/Nav-Menu-Edit-Walker.php:315 144 msgid "Title Attribute" 145 msgstr "" 146 147 #: ../models/Nav-Menu-Edit-Walker.php:134 148 msgid "Link Target" 149 msgstr "" 150 151 #: ../models/Nav-Menu-Edit-Walker.php:136 152 msgid "Same window or tab" 153 msgstr "" 154 155 #: ../models/Nav-Menu-Edit-Walker.php:137 156 msgid "New window or tab" 157 msgstr "" 158 159 #: ../models/Nav-Menu-Edit-Walker.php:143 160 #: ../models/Nav-Menu-Edit-Walker.php:327 161 msgid "CSS Classes (optional)" 162 msgstr "" 163 164 #: ../models/Nav-Menu-Edit-Walker.php:149 165 #: ../models/Nav-Menu-Edit-Walker.php:333 166 msgid "Link Relationship (XFN)" 167 msgstr "" 168 169 #: ../models/Nav-Menu-Edit-Walker.php:155 170 #: ../models/Nav-Menu-Edit-Walker.php:339 171 msgid "Description" 172 msgstr "" 173 174 #: ../models/Nav-Menu-Edit-Walker.php:157 175 #: ../models/Nav-Menu-Edit-Walker.php:341 176 msgid "The description will be displayed in the menu if the current theme supports it." 177 msgstr "" 178 179 #: ../models/Nav-Menu-Edit-Walker.php:166 180 #: ../models/Nav-Menu-Edit-Walker.php:350 181 #, php-format 182 msgid "Original: %s" 183 msgstr "" 184 185 #: ../models/Nav-Menu-Edit-Walker.php:179 186 #: ../models/Nav-Menu-Edit-Walker.php:363 187 msgid "Remove" 188 msgstr "" 189 190 #: ../models/Nav-Menu-Edit-Walker.php:180 191 #: ../models/Nav-Menu-Edit-Walker.php:364 192 msgid "Cancel" 193 msgstr "" 194 195 #: ../models/Nav-Menu-Edit-Walker.php:248 196 #, php-format 197 msgid "%s (Invalid)" 198 msgstr "" 199 200 #: ../models/Nav-Menu-Edit-Walker.php:322 201 msgid "Open link in a new window/tab" 202 msgstr "" 203 -
gecka-submenu/trunk/languages/gecka-submenu.pot
r311323 r638974 3 3 "Project-Id-Version: Gecka Sub-Menu\n" 4 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 201 0-11-10 15:30+1100\n"5 "POT-Creation-Date: 2012-12-14 14:54+1100\n" 6 6 "PO-Revision-Date: \n" 7 7 "Last-Translator: Laurent Dinclaux <[email protected]>\n" 8 8 "Language-Team: Gecka <[email protected]>\n" 9 "Language: \n" 9 10 "MIME-Version: 1.0\n" 10 11 "Content-Type: text/plain; charset=UTF-8\n" 11 12 "Content-Transfer-Encoding: 8bit\n" 12 "Language: \n"13 13 "X-Poedit-KeywordsList: __;_e\n" 14 14 "X-Poedit-Basepath: .\n" 15 15 "X-Poedit-SearchPath-0: ..\n" 16 16 17 #: ../gecka-submenu.class.php:1 5317 #: ../gecka-submenu.class.php:186 18 18 msgid "You are using Gecka Submenu." 19 19 msgstr "" 20 20 21 #: ../gecka-submenu.class.php:1 5321 #: ../gecka-submenu.class.php:186 22 22 msgid "<a href=\"http://www.gecka-apps.com\" target=\"_blank\">Discover the pro version</a> to get the most out of the Wordpress menu system." 23 23 msgstr "" … … 27 27 msgstr "" 28 28 29 #: ../models/NavMenuHacks.php:288 29 #: ../widgets/Custom-menu.php:14 30 msgid "Use this widget to add one of your custom menus as a widget." 31 msgstr "" 32 33 #: ../widgets/Custom-menu.php:16 34 msgid "Custom Menu" 35 msgstr "" 36 37 #: ../widgets/Custom-menu.php:16 38 msgid "[advanced]" 39 msgstr "" 40 41 #: ../widgets/Custom-menu.php:86 42 #, php-format 43 msgid "No menus have been created yet. <a href=\"%s\">Create some</a>." 44 msgstr "" 45 46 #: ../widgets/Custom-menu.php:92 47 msgid "Title:" 48 msgstr "" 49 50 #: ../widgets/Custom-menu.php:97 51 msgid "Use top parent item title" 52 msgstr "" 53 54 #: ../widgets/Custom-menu.php:100 55 msgid "Select Menu:" 56 msgstr "" 57 58 #: ../widgets/Custom-menu.php:103 59 msgid "Select" 60 msgstr "" 61 62 #: ../widgets/Custom-menu.php:114 63 msgid "Start menu from:" 64 msgstr "" 65 66 #: ../widgets/Custom-menu.php:117 67 msgid "Click save first" 68 msgstr "" 69 70 #: ../widgets/Custom-menu.php:123 71 msgid "Depth:" 72 msgstr "" 73 74 #: ../widgets/Custom-menu.php:129 75 msgid "Show parent item" 76 msgstr "" 77 78 #: ../widgets/Custom-menu.php:131 79 msgid "Show description" 80 msgstr "" 81 82 #: ../widgets/Custom-menu.php:133 83 msgid "No" 84 msgstr "" 85 86 #: ../widgets/Custom-menu.php:134 87 msgid "Into link element" 88 msgstr "" 89 90 #: ../widgets/Custom-menu.php:135 91 msgid "Into li element" 92 msgstr "" 93 94 #: ../widgets/Custom-menu.php:138 95 msgid "Class:" 96 msgstr "" 97 98 #: ../widgets/Custom-menu.php:162 99 #: ../widgets/Custom-menu.php:171 100 msgid "First select a nav menu" 101 msgstr "" 102 103 #: ../widgets/Custom-menu.php:178 104 msgid "Error: Unknow menu." 105 msgstr "" 106 107 #: ../widgets/Custom-menu.php:184 108 msgid "Nav menu root" 109 msgstr "" 110 111 #: ../widgets/Custom-menu.php:185 112 msgid "Current page" 113 msgstr "" 114 115 #: ../widgets/Custom-menu.php:186 116 msgid "Current page's top parent" 117 msgstr "" 118 119 #: ../models/Nav-Menu-Edit-Walker.php:65 120 #: ../models/Nav-Menu-Edit-Walker.php:252 30 121 #, php-format 31 122 msgid "%s (Pending)" 32 123 msgstr "" 33 124 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 36 128 msgid "Edit Menu Item" 37 129 msgstr "" 38 130 39 #: ../models/NavMenuHacks.php:338 131 #: ../models/Nav-Menu-Edit-Walker.php:115 132 #: ../models/Nav-Menu-Edit-Walker.php:302 40 133 msgid "URL" 41 134 msgstr "" 42 135 43 #: ../models/NavMenuHacks.php:345 136 #: ../models/Nav-Menu-Edit-Walker.php:122 137 #: ../models/Nav-Menu-Edit-Walker.php:309 44 138 msgid "Navigation Label" 45 139 msgstr "" 46 140 47 #: ../models/NavMenuHacks.php:351 141 #: ../models/Nav-Menu-Edit-Walker.php:128 142 #: ../models/Nav-Menu-Edit-Walker.php:315 48 143 msgid "Title Attribute" 49 144 msgstr "" 50 145 51 #: ../models/Nav MenuHacks.php:357146 #: ../models/Nav-Menu-Edit-Walker.php:134 52 147 msgid "Link Target" 53 148 msgstr "" 54 149 55 #: ../models/Nav MenuHacks.php:359150 #: ../models/Nav-Menu-Edit-Walker.php:136 56 151 msgid "Same window or tab" 57 152 msgstr "" 58 153 59 #: ../models/Nav MenuHacks.php:360154 #: ../models/Nav-Menu-Edit-Walker.php:137 60 155 msgid "New window or tab" 61 156 msgstr "" 62 157 63 #: ../models/NavMenuHacks.php:366 158 #: ../models/Nav-Menu-Edit-Walker.php:143 159 #: ../models/Nav-Menu-Edit-Walker.php:327 64 160 msgid "CSS Classes (optional)" 65 161 msgstr "" 66 162 67 #: ../models/NavMenuHacks.php:372 163 #: ../models/Nav-Menu-Edit-Walker.php:149 164 #: ../models/Nav-Menu-Edit-Walker.php:333 68 165 msgid "Link Relationship (XFN)" 69 166 msgstr "" 70 167 71 #: ../models/NavMenuHacks.php:378 168 #: ../models/Nav-Menu-Edit-Walker.php:155 169 #: ../models/Nav-Menu-Edit-Walker.php:339 72 170 msgid "Description" 73 171 msgstr "" 74 172 75 #: ../models/NavMenuHacks.php:380 173 #: ../models/Nav-Menu-Edit-Walker.php:157 174 #: ../models/Nav-Menu-Edit-Walker.php:341 76 175 msgid "The description will be displayed in the menu if the current theme supports it." 77 176 msgstr "" 78 177 79 #: ../models/NavMenuHacks.php:389 178 #: ../models/Nav-Menu-Edit-Walker.php:166 179 #: ../models/Nav-Menu-Edit-Walker.php:350 80 180 #, php-format 81 181 msgid "Original: %s" 82 182 msgstr "" 83 183 84 #: ../models/NavMenuHacks.php:402 184 #: ../models/Nav-Menu-Edit-Walker.php:179 185 #: ../models/Nav-Menu-Edit-Walker.php:363 85 186 msgid "Remove" 86 187 msgstr "" 87 188 88 #: ../models/NavMenuHacks.php:403 189 #: ../models/Nav-Menu-Edit-Walker.php:180 190 #: ../models/Nav-Menu-Edit-Walker.php:364 89 191 msgid "Cancel" 90 192 msgstr "" 91 193 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 196 msgid "%s (Invalid)" 197 msgstr "" 198 199 #: ../models/Nav-Menu-Edit-Walker.php:322 200 msgid "Open link in a new window/tab" 201 msgstr "" 202 -
gecka-submenu/trunk/models/NavMenuHacks.php
r462557 r638974 6 6 7 7 if(is_admin() ) { 8 9 /* use custom walker */ 8 9 /* use custom walker */ 10 10 add_filter( 'wp_edit_nav_menu_walker', array($this, 'custom_walker') ); 11 11 12 12 /* add custom field */ 13 13 add_action('wp_nav_menu_item_custom_fields', array($this, 'wp_nav_menu_item_custom_fields'),10,4 ); 14 14 15 15 /* save custom field */ 16 16 add_action('wp_update_nav_menu_item', array($this, 'wp_update_nav_menu_item'),10,3 ); 17 18 /* css */17 18 /* load custom css */ 19 19 add_action('admin_init', array($this, 'register_scripts')); 20 20 add_action( "admin_print_styles-nav-menus.php", array($this, 'admin_print_styles') ); 21 22 } 21 22 } 23 23 24 add_filter( 'wp_get_nav_menu_items', array($this, 'wp_get_nav_menu_items'),10,3 ); 24 25 25 26 /* set up nav menu item with custom properties */ 26 27 add_filter( 'wp_setup_nav_menu_item', array($this, 'wp_setup_nav_menu_item') ); 27 28 28 29 /* customize menu display */ 29 30 add_filter( 'walker_nav_menu_start_el', array($this, 'walker_nav_menu_start_el'), 10,4 ); 30 31 } 32 31 32 } 33 33 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 } 56 58 return $items; 57 59 } 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 61 63 $_ids = $this->get_ids($type, $order, $posts); 62 64 63 65 foreach($posts as $key=>$post) { 64 66 65 67 $id = isset($post->ID) ? $post->ID : $post->term_id; 66 68 67 69 $parent_id = $item->ID; 68 70 69 71 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 79 82 $order++; 80 81 } 82 83 84 } 85 83 86 return $posts; 84 85 } 86 87 88 } 89 87 90 function get_ids ($type, $order, $items) { 88 91 89 92 $ids = array(); 90 93 91 94 foreach($items as $item) { 92 95 93 96 $id = $type == 'post' ? $item->ID : $item->term_id; 94 97 95 98 $ids[$id] = -$order; 96 99 97 100 $order++; 98 101 } 99 100 102 103 101 104 return $ids; 102 103 } 104 105 106 } 107 105 108 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 108 112 $id = $_item->ID ; 109 113 110 114 $_item->ID = $_item->db_id = $pseudo_id ; 111 115 $_item->post_name = '' . $pseudo_id; … … 117 121 $_item->menu_order = $order; 118 122 $_item->description = $_item->post_excerpt; 119 123 124 120 125 $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 124 129 $_item->url = get_permalink( $post->ID ); 125 130 $_item->title = $post->post_title; … … 128 133 $_item->classes = array ( 0 => ''); 129 134 $_item->xfn = ''; 130 135 131 136 $_item->db_id = $pseudo_id; 132 137 133 138 return $_item; 134 135 } 136 139 140 } 141 137 142 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 144 149 //$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 150 155 151 156 /** … … 154 159 function wp_setup_nav_menu_item($menu_item) { 155 160 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 } 162 167 return $menu_item; 163 168 } 164 169 165 170 166 171 /** 167 172 * Saves the new fields 168 173 */ 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 171 177 $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 173 179 if ( empty( $args['menu-item-autopopulate_type'] ) ) { 174 $args['menu-item-autopopulate_type'] = '';180 $args['menu-item-autopopulate_type'] = ''; 175 181 } 176 182 177 183 update_post_meta( $menu_item_db_id, '_menu_item_autopopulate_type', $args['menu-item-autopopulate_type'] ); 178 184 179 185 180 186 if( $args['menu-item-autopopulate_type'] === 'subpages' ) $args['menu-item-autopopulate'] = '1'; 181 187 else $args['menu-item-autopopulate'] = '0'; … … 183 189 update_post_meta( $menu_item_db_id, '_menu_item_autopopulate', $args['menu-item-autopopulate'] ); 184 190 185 191 186 192 /* old version compatibility */ 187 193 188 194 if( get_post_meta($menu_item_db_id, '_menu_item_showsub', true) == '1') { 189 195 190 196 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 193 199 194 200 delete_post_meta( $menu_item_db_id, '_menu_item_showsub', $args['menu-item-showsub'] ); 195 201 } 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 203 209 function admin_print_styles () { 204 210 wp_enqueue_style('gecka-submenu-nav-menu-edit'); 205 211 } 206 207 function admin_print_scripts () { }208 212 209 213 /** 210 214 * Adds a custom fields 211 215 */ 212 function custom_walker($a) { 216 function custom_walker($a) 217 { 218 include 'Nav-Menu-Edit-Walker.php'; 213 219 return 'Gecka_Walker_Nav_Menu_Edit'; 214 220 } 215 221 216 222 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 222 226 } 223 224 /**225 * Create HTML list of nav menu input items.226 *227 * @package WordPress228 * @since 3.0.0229 * @uses Walker_Nav_Menu230 */231 class Gecka_Walker_Nav_Menu_Edit extends Walker_Nav_Menu {232 /**233 * @see Walker_Nav_Menu::start_lvl()234 * @since 3.0.0235 *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.0244 *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.0254 *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 $args260 */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="<?php312 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'); ?>">↑</abbr></a>323 |324 <a href="<?php325 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'); ?>">↓</abbr></a>336 </span>337 <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php _e('Edit Menu Item'); ?>" href="<?php338 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 <?php394 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="<?php403 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_id412 ); ?>"><?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 <?php425 $output .= ob_get_clean();426 }427 } -
gecka-submenu/trunk/models/Shortcodes.php
r462557 r638974 2 2 3 3 class Gecka_Submenu_Shortcodes { 4 4 5 5 static $cache = array (); 6 6 … … 9 9 add_shortcode( 'submenu', array( $this, 'submenu') ); 10 10 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 ); 12 12 13 13 } -
gecka-submenu/trunk/models/Submenu.php
r462557 r638974 30 30 'show_description' => false, 31 31 'thumbnail' => null, 32 'auto_title' => false33 32 34 33 ); … … 53 52 54 53 public function Get($Options = null) 55 { 54 { 55 56 56 return $this->Build($Options); 57 57 } … … 62 62 } 63 63 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); 68 68 69 69 $instance['container_class'] = 'submenu-widget'; 70 70 $instance['is_gk_submenu'] = 'widget'; 71 72 $args = apply_filters( 'gk_submenu_widget_args', $instance ); 71 73 72 74 $out = $this->Get($instance); … … 94 96 echo $after_widget; 95 97 } 98 else do_action('gk_submenu_widget_fallback', $widget_args, $args); 96 99 } 97 100 … … 103 106 104 107 $Options = wp_parse_args($Options, $this->DefaultOptions); 108 $Options = apply_filters( 'gk_submenu_args', $Options ); 105 109 106 110 extract($Options); … … 128 132 129 133 /* 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 142 147 $menu_items = wp_get_nav_menu_items($menu); 143 148 144 149 if(is_tax() || is_category()) $_type = 'taxonomy'; 145 150 else $_type = 'post_type'; 146 151 152 147 153 // current page is top level element 148 154 if( $submenu === 'current' ) { … … 150 156 $submenu = $this->get_associated_nav_menu_item($wp_query->get_queried_object_id(), &$menu_items, $_type); 151 157 } 158 152 159 // top parent page is the top level element 153 160 else if( $submenu === 'top' ) { … … 155 162 global $post, $wp_query; 156 163 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; 160 167 } 161 168 162 169 } 163 170 164 171 // a submenu has been specified 165 172 if( $submenu !== 0 ) { … … 172 179 173 180 $submenu_item = $this->get_menu_item ($submenu, &$menu_items); 174 175 181 176 182 if( !$submenu_item ) $submenu_item = $this->get_associated_nav_menu_item($submenu, &$menu_items, $type); 177 183 if(!$submenu_item) return; … … 186 192 global $GKSM_ID, $GKSM_MENUID; 187 193 $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 189 196 } 190 197 … … 196 203 $container_class .= " $container_class-" . $slug ; 197 204 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, 201 209 'menu'=> $menu, 202 210 'show_description'=> $show_description, 203 211 'depth'=>$depth, 204 212 'is_gk_submenu'=>$is_gk_submenu ); 205 213 214 if( empty($args['walker']) ) $args['walker'] = new Gecka_Walker_Nav_Menu; 215 206 216 $out = wp_nav_menu( wp_parse_args($args, $Options) ); 207 217 … … 212 222 } 213 223 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 214 248 /** 215 249 * Gets a menu item from a list of menu items, avoiding SQL queries … … 248 282 } 249 283 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; 253 286 $_menu_items = array(); 254 287 … … 259 292 } 260 293 } 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 ) { 261 302 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 317 324 } 318 325 } 319 -
gecka-submenu/trunk/readme.txt
r462557 r638974 3 3 Tags: nav menu, 3.0, submenu, sub-menu, child, child men, subpages, subpage, dynamic menu, dynamic subpages, dynamic submenu 4 4 Requires at least: 3.0 5 Tested up to: 3. 16 Stable tag: 0. 65 Tested up to: 3.5 6 Stable tag: 0.7-beta3 7 7 Donate link: http://gecka-apps.com/wordpress-plugins/gecka-submenu-pro/ 8 8 … … 14 14 **PHP 5 required. Please be sure to check your PHP version before marking the plugin as broken.** 15 15 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 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 18 18 Submenu also allows you to put menus or portion of menus anywhere in your site: sidebar, templates or page contents. 19 19 20 Languages available: english, french 20 Languages available: english, french 21 21 22 22 **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 26 http://www.youtube.com/watch?v=DHjMfD-k2Mo 27 28 28 == Installation == 29 29 … … 43 43 == Changelog == 44 44 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 45 52 = 0.6 = 46 53 * shortcodes caching … … 56 63 57 64 = 0.5.2 = 58 59 65 * corrected readme file 60 66 * added the start from "Top parent element" option to the widget 61 67 62 68 = 0.5.1 = 63 64 69 * bug fix 65 70 … … 71 76 = 0.4.2 = 72 77 * 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 = 90 95 * First version. -
gecka-submenu/trunk/views/Nav-Menu-Fields.php
r311323 r638974 3 3 <p class="edit-menu-item-autopopulate" > 4 4 <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'); ?> /> 6 6 <?php _e( 'Automaticaly populate with child pages', Gecka_Submenu::Domain ); ?> 7 7 </label> -
gecka-submenu/trunk/widgets/Custom-menu.php
r315553 r638974 7 7 'show_parent'=>0, 8 8 'show_description'=>0, 9 ); 9 'class'=>'' 10 ); 10 11 11 12 public function GKSM_Widget_Custom_Menu () { 13 12 14 $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); 14 17 15 18 // ajax select update 16 19 add_action('wp_ajax_gksm_update', array($this, 'submenuOptionsAjax')); 17 20 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 21 27 add_action( "admin_print_scripts-widgets.php", array($this, 'admin_print_scripts') ); 22 28 23 29 add_filter( 'dynamic_sidebar_params', array($this, 'dynamic_sidebar_params') ); 30 24 31 } 25 32 … … 31 38 ) 32 39 ); 33 40 wp_enqueue_style('gecka-submenu-widget-custom-menu'); 34 41 } 35 42 … … 55 62 } 56 63 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']; 60 67 61 68 return $instance; … … 70 77 $submenu = isset( $instance['submenu'] ) ? $instance['submenu'] : '0'; 71 78 $depth = isset( $instance['depth'] ) ? $instance['depth'] : 0; 72 79 $class = isset( $instance['class'] ) ? $instance['class'] : 0; 80 73 81 // Get menus 74 82 $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); … … 81 89 82 90 ?> 83 91 <div class="gksm"> 84 92 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label> 85 93 <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; ?>" /> … … 113 121 </select></p> 114 122 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> 116 124 <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; ?>" /> 117 125 </p> 118 126 119 <p >127 <p class="description-thin"> 120 128 <!-- <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'); ?>" /> 121 129 <label for="<?php echo $this->get_field_id('show_parent'); ?>"><?php _e('Show parent item', Gecka_Submenu::Domain); ?></label><br /> 122 130 --> 123 124 131 <label for="<?php echo $this->get_field_id('show_description'); ?>"><?php _e('Show description', Gecka_Submenu::Domain); ?>:</label><br /> 125 132 <select name="<?php echo $this->get_field_name('show_description'); ?>" id="<?php echo $this->get_field_id('show_description'); ?>"> … … 128 135 <option value="into_li" <?php selected('into_li', $instance['show_description']) ?>><?php _e('Into li element', Gecka_Submenu::Domain); ?></option> 129 136 </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> 131 145 132 146 <?php … … 177 191 } 178 192 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 } 180 234 }
Note: See TracChangeset
for help on using the changeset viewer.