コード例 #1
0
 /**
  * Get the Anchor and its contents
  * @param  array $atts An array of attributes to add to the anchor
  * @return string       The HTML for the anchor
  */
 function get_anchor($atts)
 {
     if ($this->item->title == '--divide--') {
         return '<div class="ubermenu-divider"><hr/></div>';
     }
     $a = '';
     $tag = 'a';
     //Highlight
     if ($this->getSetting('highlight') == 'on') {
         $atts['class'] .= ' ubermenu-highlight';
     }
     //Image
     $image = $this->get_image();
     if ($image) {
         $atts['class'] .= ' ubermenu-target-with-image';
     }
     //Icon
     $icon = $this->getSetting('icon');
     if ($icon) {
         $atts['class'] .= ' ubermenu-target-with-icon';
         $icon = '<i class="ubermenu-icon ' . $icon . '"></i>';
     }
     //Layout
     $layout = $this->getSetting('item_layout');
     $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     //Content Align
     $content_align = $this->getSetting('content_alignment');
     if ($content_align != 'default') {
         $atts['class'] .= ' ubermenu-content-align-' . $content_align;
     }
     if ($layout == 'default') {
         if ($image) {
             $layout = 'image_left';
         } else {
             if ($icon) {
                 if (function_exists('ubermenu_icon_layout_default')) {
                     $layout = ubermenu_icon_layout_default($this);
                 } else {
                     $layout = 'icon_left';
                 }
             } else {
                 $layout = 'text_only';
             }
         }
         $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     }
     $layout_order = ubermenu_get_item_layouts($layout);
     if (!$layout_order) {
         ubermenu_admin_notice(__('Unknown layout order:', 'ubermenu') . ' ' . $layout . ' [' . $this->item->title . '] (' . $this->ID . ')');
     }
     //No wrap
     if ($this->getSetting('no_wrap') == 'on') {
         $atts['class'] .= ' ubermenu-target-nowrap';
     }
     //Disabled Link (change tag)
     $disable_link = false;
     if ($this->getSetting('disable_link') == 'on') {
         $tag = 'span';
         $disable_link = true;
         unset($atts['href']);
     }
     //Disable Submenu Indicator
     $disable_submenu_indicator = false;
     if ($this->getSetting('disable_submenu_indicator') == 'on') {
         $atts['class'] .= ' ubermenu-noindicator';
     }
     //ScrollTo
     $scrollTo = $this->getSetting('scrollto');
     if ($scrollTo) {
         $atts['data-ubermenu-scrolltarget'] = $scrollTo;
     }
     //Target ID
     $target_id = $this->getSetting('target_id');
     if ($target_id) {
         $atts['id'] = $target_id;
     }
     //Target Class
     $target_class = $this->getSetting('target_class');
     if ($target_class) {
         $atts['class'] .= ' ' . $target_class;
     }
     //Note: anchor atts used to be here
     //Title
     $title = '';
     if ($this->getSetting('disable_text') == 'off') {
         $_title = $this->item->title;
         if ($this->get_menu_op('allow_shortcodes_in_labels') == 'on') {
             $_title = do_shortcode($_title);
         }
         $title .= '<span class="ubermenu-target-title ubermenu-target-text">';
         $title .= apply_filters('the_title', $_title, $this->item->ID);
         //$title .= $_title;
         $title .= '</span>';
     } else {
         //Flag items with disabled text
         $atts['class'] .= ' ubermenu-item-notext';
     }
     //Description
     $description = '';
     //if( $this->getSetting( 'disable_text' ) == 'off' ){
     if ($this->item->description) {
         if ($this->depth == 0 && $this->get_menu_op('descriptions_top_level') == 'on' || $this->depth > 0 && $this->getSetting('item_display_calc') == 'header' && $this->get_menu_op('descriptions_headers') == 'on' || $this->depth > 0 && $this->getSetting('item_display_calc') == 'normal' && $this->get_menu_op('descriptions_normal') == 'on') {
             $_desc = $this->item->description;
             if ($this->get_menu_op('allow_shortcodes_in_labels') == 'on') {
                 $_desc = do_shortcode($_desc);
             }
             //Divider
             $divider = $this->get_menu_op('target_divider');
             if ($title && $divider) {
                 $description .= '<span class="ubermenu-target-divider">' . $divider . '</span>';
             }
             $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
             $description .= $_desc;
             $description .= '</span>';
         }
     }
     //ShiftNav Toggle
     if ($this->getSetting('shiftnav_target')) {
         $atts['data-shiftnav-target'] = $this->getSetting('shiftnav_target');
         $atts['class'] .= ' shiftnav-toggle';
     }
     //Anchor Attributes
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value) || $value === 0) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     //Check if we still have something to print
     if (!$title && !$description && !$image && !$icon) {
         return '';
     }
     //Build the Layout
     //Get custom pieces
     $custom_pieces = array();
     extract(apply_filters('ubermenu_custom_item_layout_data', $custom_pieces, $layout, $this->ID, $this->item->object_id));
     //Gather all the pieces in the layout order into an array
     $layout_pieces = compact($layout_order);
     //Output the anchor
     $a .= $this->args->before;
     $a .= '<' . $tag . $attributes . '>';
     $a .= $this->args->link_before;
     //Add pieces based on layout order
     foreach ($layout_pieces as $piece) {
         $a .= $piece;
     }
     $a .= $this->args->link_after;
     $a .= '</' . $tag . '>';
     $a .= $this->args->after;
     return $a;
 }
 /**
  * Get the Anchor and its contents
  * @param  array $atts An array of attributes to add to the anchor
  * @return string       The HTML for the anchor
  */
 function get_anchor($atts)
 {
     $term = $this->term;
     //up( $term );
     $a = '';
     $tag = 'a';
     //Image
     //$image = $this->get_image();
     $this->settings['item_image'] = apply_filters('ubermenu_dt_image', '', $this->ID, $term);
     $image = $this->get_image();
     if ($image) {
         $atts['class'] .= ' ubermenu-target-with-image';
     }
     //Icon
     $icon = $this->getSetting('icon');
     if ($icon) {
         $atts['class'] .= ' ubermenu-target-with-icon';
         $icon = '<i class="ubermenu-icon ' . $icon . '"></i>';
     }
     //Layout
     $layout = $this->getSetting('item_layout');
     $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     //Content Align
     $content_align = $this->getSetting('content_alignment');
     if ($content_align != 'default') {
         $atts['class'] .= ' ubermenu-content-align-' . $content_align;
     }
     if ($layout == 'default') {
         if ($image) {
             $layout = 'image_left';
         } else {
             if ($icon) {
                 if (function_exists('ubermenu_icon_layout_default')) {
                     $layout = ubermenu_icon_layout_default($this);
                 } else {
                     $layout = 'icon_left';
                 }
             } else {
                 $layout = 'text_only';
             }
         }
         $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     }
     $layout_order = ubermenu_get_item_layouts($layout);
     if (!$layout_order) {
         ubermenu_admin_notice(__('Unknown layout order:', 'ubermenu') . ' ' . $layout . ' [' . $this->item->title . '] (' . $this->ID . ')');
     }
     //No wrap
     if ($this->getSetting('no_wrap') == 'on') {
         $atts['class'] .= ' ubermenu-target-nowrap';
     }
     //Disabled Link (change tag)
     $disable_link = false;
     if ($this->getSetting('disable_link') == 'on') {
         $tag = 'span';
         $disable_link = true;
         unset($atts['href']);
     }
     //Anchor Attributes
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     //Title
     $title = '';
     if ($this->getSetting('disable_text') == 'off') {
         $title .= '<span class="ubermenu-target-title ubermenu-target-text">';
         $title .= $term->name;
         //apply_filters( 'the_title', $term->name, $this->item->ID );
         if ($this->getSetting('dt_display_term_counts') == 'on') {
             $title .= ' <span class="ubermenu-term-count">' . UBERMENU_TERM_COUNT_WRAP_START . $term->count . UBERMENU_TERM_COUNT_WRAP_END . '</span>';
         }
         //$title .= ' ['. $term->term_id .'] ['.$this->ID.']';
         $title .= '</span>';
     } else {
         //Flag items with disabled text
         $atts['class'] .= ' ubermenu-item-notext';
     }
     //Description
     $description = '';
     //if( $this->getSetting( 'disable_text' ) == 'off' ){
     if ($this->item->description) {
         $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
         $description .= $this->item->description;
         $description .= '</span>';
     }
     //Check if we still have something to print
     if (!$title && !$description && !$image && !$icon) {
         return '';
     }
     //Build the Layout
     //Get custom pieces
     $custom_pieces = array();
     extract(apply_filters('ubermenu_custom_item_layout_data', $custom_pieces, $layout, $this->ID, $term->term_id));
     //Gather all the pieces in the layout order into an array
     $layout_pieces = compact($layout_order);
     //Output the anchor
     $a .= $this->args->before;
     $a .= '<' . $tag . $attributes . '>';
     $a .= $this->args->link_before;
     //Add pieces based on layout order
     foreach ($layout_pieces as $piece) {
         $a .= $piece;
     }
     $a .= $this->args->link_after;
     $a .= '</' . $tag . '>';
     $a .= $this->args->after;
     return $a;
 }
コード例 #3
0
 /**
  * Get the Anchor and its contents
  * @param  array $atts An array of attributes to add to the anchor
  * @return string       The HTML for the anchor
  */
 function get_anchor($atts)
 {
     $p = $this->post;
     $a = '';
     $tag = 'a';
     //Image
     $image = $this->get_image();
     if ($image) {
         $atts['class'] .= ' ubermenu-target-with-image';
     }
     //Icon
     $icon = $this->getSetting('icon');
     if ($icon) {
         $atts['class'] .= ' ubermenu-target-with-icon';
         $icon = '<i class="ubermenu-icon ' . $icon . '"></i>';
     }
     //Layout
     $layout = $this->getSetting('item_layout');
     $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     //Content Align
     $content_align = $this->getSetting('content_alignment');
     if ($content_align != 'default') {
         $atts['class'] .= ' ubermenu-content-align-' . $content_align;
     }
     if ($layout == 'default') {
         if ($image) {
             $layout = 'image_above';
             //Different from normal
         } else {
             if ($icon) {
                 if (function_exists('ubermenu_icon_layout_default')) {
                     $layout = ubermenu_icon_layout_default($this);
                 } else {
                     $layout = 'icon_left';
                 }
             } else {
                 $layout = 'text_only';
             }
         }
         $atts['class'] .= ' ubermenu-item-layout-' . $layout;
     }
     $layout_order = ubermenu_get_item_layouts($layout);
     if (!$layout_order) {
         ubermenu_admin_notice(__('Unknown layout order:', 'ubermenu') . ' ' . $layout . ' [' . $this->item->title . '] (' . $this->ID . ')');
     }
     //No wrap
     if ($this->getSetting('no_wrap') == 'on') {
         $atts['class'] .= ' ubermenu-target-nowrap';
     }
     //Disabled Link (change tag)
     $disable_link = false;
     if ($this->getSetting('disable_link') == 'on') {
         $tag = 'span';
         $disable_link = true;
         unset($atts['href']);
     }
     //Anchor Attributes
     $attributes = '';
     foreach ($atts as $attr => $value) {
         if (!empty($value)) {
             $value = 'href' === $attr ? esc_url($value) : esc_attr($value);
             $attributes .= ' ' . $attr . '="' . $value . '"';
         }
     }
     //Disabled (change el)
     //TODO
     //Title
     $title = '';
     if ($this->getSetting('disable_text') == 'off') {
         $title = apply_filters('the_title', $p->post_title, $p->ID);
         $title = apply_filters('ubermenu_dp_title', $title, $this->source_id, $p->ID);
         $title = '<span class="ubermenu-target-title ubermenu-target-text">' . $title . '</span>';
     }
     //Description
     $description = '';
     //if( $this->getSetting( 'disable_text' ) == 'off' ){
     if ($this->item->description) {
         $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
         $description .= $this->item->description;
         $description .= '</span>';
     }
     //Dynamic Subcontent
     //Treat as description
     //$subcontent = '';
     $subcontent_type = $this->getSetting('dp_subcontent');
     if ($subcontent_type != 'none') {
         switch ($subcontent_type) {
             case 'excerpt':
                 $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
                 $description .= $p->post_excerpt;
                 $description .= '</span>';
                 break;
             case 'date':
                 $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
                 $description .= mysql2date(get_option('date_format'), $p->post_date);
                 $description .= '</span>';
                 break;
             case 'author':
                 $description .= '<span class="ubermenu-target-description ubermenu-target-text">';
                 $description .= get_the_author_meta('display_name', $p->post_author);
                 $description .= '</span>';
                 break;
             case 'custom':
                 $description = apply_filters('ubermenu_dp_subcontent', $description, $p, $this->ID);
                 break;
             default:
                 break;
         }
     }
     //$description.= $subcontent;	//Treat as description
     //Check if we still have something to print
     if (!$title && !$description && !$image && !$icon) {
         return '';
     }
     //Build the Layout
     //Get custom pieces
     $custom_pieces = array();
     extract(apply_filters('ubermenu_custom_item_layout_data', $custom_pieces, $layout, $this->ID, $p->ID));
     //Gather all the pieces in the layout order into an array
     $layout_pieces = compact($layout_order);
     //Output the anchor
     $a .= $this->args->before;
     $a .= '<' . $tag . $attributes . '>';
     $a .= $this->args->link_before;
     //Add pieces based on layout order
     foreach ($layout_pieces as $piece) {
         $a .= $piece;
     }
     $a .= $this->args->link_after;
     $a .= '</' . $tag . '>';
     $a .= $this->args->after;
     return $a;
 }