當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Walker::display_element方法代碼示例

本文整理匯總了PHP中Walker::display_element方法的典型用法代碼示例。如果您正苦於以下問題:PHP Walker::display_element方法的具體用法?PHP Walker::display_element怎麽用?PHP Walker::display_element使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Walker的用法示例。


在下文中一共展示了Walker::display_element方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: display_element

 /**
  * Traverse elements to create list from elements.
  *
  * Display one element if the element doesn't have any children otherwise,
  * display the element and its children. Will only traverse up to the max.
  * depth and no ignore elements under that depth. It is possible to set the.
  * max depth to include all depths, see walk() method.
  *
  * This method shouldn't be called directly, use the walk() method instead.
  *
  * @since 2.5.0
  *
  * @param object $element Data object
  * @param array $children_elements List of elements to continue traversing.
  * @param int $max_depth Max depth to traverse.
  * @param int $depth Depth of current element.
  * @param array $args
  * @param string $output Passed by reference. Used to append additional content.
  * @return null Null on failure with no changes to parameters.
  */
 public function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
 {
     if (!$element || 0 === $element->count && !empty($args[0]['hide_empty'])) {
         return;
     }
     parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
 }
開發者ID:pelmered,項目名稱:woocommerce,代碼行數:27,代碼來源:class-product-cat-dropdown-walker.php

示例2:

 function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
 {
     $element = (object) $element;
     // make sure we have an object
     $element->parent = $element->id = 0;
     // don't care about this
     parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
 }
開發者ID:WordPressArt,項目名稱:conisia,代碼行數:8,代碼來源:walker-dropdown.php

示例3: count

 /**
  * Perform several checks and fill the class values
  *
  * @param string $element The current menu item
  * @param int    $children_elements  The element childrens
  * @param array  $max_depth
  * @param array  $depth
  * @param array  $args
  * @param array  $output
  */
 function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
 {
     if ($depth === 0) {
         // CHECK IF MENU IS ACTIVE
         $this->mm_active = get_post_meta($element->ID, '_menu_item_zn_mega_menu_enable', true);
         // COUNT ALL MEGA MENU CHILDRENS
         if ($this->mm_active && !empty($children_elements[$element->ID])) {
             $this->childrens_count = count($children_elements[$element->ID]);
         }
     }
     // DO THE NORMAL display_element();
     return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
 }
開發者ID:rock1media,項目名稱:wordpress,代碼行數:23,代碼來源:class-mega-menu.php

示例4: display_element

 /**
  * Taken from WordPress's Walker_Comment::display_element()
  *
  * This function is designed to enhance Walker::display_element() to
  * display children of higher nesting levels than selected inline on
  * the highest depth level displayed. This prevents them being orphaned
  * at the end of the comment list.
  *
  * Example: max_depth = 2, with 5 levels of nested content.
  * 1
  *  1.1
  *    1.1.1
  *    1.1.1.1
  *    1.1.1.1.1
  *    1.1.2
  *    1.1.2.1
  * 2
  *  2.2
  *
  * @see Walker_Comment::display_element()
  * @see Walker::display_element()
  * @see wp_list_comments()
  */
 public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output)
 {
     if (!$element) {
         return;
     }
     $id_field = $this->db_fields['id'];
     $id = $element->{$id_field};
     parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
     // If we're at the max depth, and the current element still has children, loop over those and display them at this level
     // This is to prevent them being orphaned to the end of the list.
     if ($max_depth <= $depth + 1 && isset($children_elements[$id])) {
         foreach ($children_elements[$id] as $child) {
             $this->display_element($child, $children_elements, $max_depth, $depth, $args, $output);
         }
         unset($children_elements[$id]);
     }
 }
開發者ID:StefanBonilla,項目名稱:CoupSoup,代碼行數:40,代碼來源:class.wpcom-json-api-list-comments-endpoint.php

示例5: foreach

 /**
  * This modifies the default display_element() function to "flatten" any replies that exceed the max_depth.
  *
  * This function is taken from the Walker_Comment class in WordPress core.
  *
  * @see Walker::display_element()
  *
  * @param object $element           Data object.
  * @param array  $children_elements List of elements to continue traversing.
  * @param int    $max_depth         Max depth to traverse.
  * @param int    $depth             Depth of current element.
  * @param array  $args              An array of arguments. @see wp_list_comments()
  * @param string $output            Passed by reference. Used to append additional content.
  * @return null Null on failure with no changes to parameters.
  */
 function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output)
 {
     // Do nothing if $element is false...
     if (!$element) {
         return;
     }
     $id_field = $this->db_fields['id'];
     $id = $element->{$id_field};
     // Run the standard display_element() function now...
     parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
     // If we're at the max depth, and the current element still has children, loop over those and display them at
     // this level. This is to prevent them being orphaned to the end of the comment list.
     if ($max_depth <= $depth + 1 && isset($children_elements[$id])) {
         foreach ($children_elements[$id] as $child) {
             $this->display_element($child, $children_elements, $max_depth, $depth, $args, $output);
         }
         unset($children_elements[$id]);
     }
 }
開發者ID:mistergjh,項目名稱:nouveau,代碼行數:34,代碼來源:WalkerComments.php

示例6: display_element

 /**
  * @since bbPress (r4944)
  */
 public function display_element($element = false, &$children_elements = array(), $max_depth = 0, $depth = 0, $args = array(), &$output = '')
 {
     if (empty($element)) {
         return;
     }
     // Get element's id
     $id_field = $this->db_fields['id'];
     $id = $element->{$id_field};
     // Display element
     parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
     // If we're at the max depth and the current element still has children, loop over those
     // and display them at this level to prevent them being orphaned to the end of the list.
     if ($max_depth <= (int) $depth + 1 && isset($children_elements[$id])) {
         foreach ($children_elements[$id] as $child) {
             $this->display_element($child, $children_elements, $max_depth, $depth, $args, $output);
         }
         unset($children_elements[$id]);
     }
 }
開發者ID:igniterealtime,項目名稱:community-plugins,代碼行數:22,代碼來源:classes.php

示例7: isset

 function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
 {
     // check, whether there are children for the given ID and append it to the element with a (new) ID
     $element->has_children = isset($children_elements[$element->ID]) && !empty($children_elements[$element->ID]);
     return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
 }
開發者ID:akshayxhtmljunkies,項目名稱:brownglock,代碼行數:6,代碼來源:accesspress-mega-menu.php

示例8: display_element

 /**
  * render item
  * @param object $element
  * @param array $children_elements
  * @param int $max_depth
  * @param int $depth
  * @param array $args
  * @param string $output
  * @return null|void
  */
 public function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
 {
     $display = true;
     //default
     //add current menu item
     $this->menu_items[$element->term_id] = array('has_sub' => false, 'title' => $element->name);
     $current =& $this->menu_items[$element->term_id];
     /*
             // Check if element as a 'current element' class
             $current_element_markers = array( 'current-cat', 'current-item', 'current-cat-ancestor','current-cat-parent' );
             $current_class = array_intersect( $current_element_markers, (array)$element->classes );
     
             // If element has a 'current' class, it is an ancestor of the current element
             $ancestor_of_current = !empty($current_class);*/
     $children = get_term_children($element->term_id, $element->taxonomy);
     $current['has_sub'] = !empty($children);
     //display terms belong to current post
     if (!empty($this->args['mydata']['categories_by_current_post']) && isset($this->args['mydata']['enable_categories_by_current_post'])) {
         $display = false;
         $id = $element->term_id;
         if (in_array($id, $this->post_term_ids)) {
             // the current term is in the list
             $display = true;
         } elseif (isset($children_elements[$id])) {
             // the current term has children
             foreach ($children_elements[$id] as $child) {
                 if (in_array($child->term_id, $this->post_term_ids)) {
                     // one of the term's children is in the list
                     $display = true;
                     // can stop searching now
                     break;
                 }
             }
         }
     }
     if ($display) {
         parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
     }
 }
開發者ID:hoangsoft90,項目名稱:hw-hoangweb-plugin,代碼行數:49,代碼來源:hwlct_taxonomies_walker.php

示例9: display_element

 /**
  * Traverse elements to create list from elements.
  *
  * Calls parent function in wp-includes/class-wp-walker.php
  */
 function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
 {
     if (!$element) {
         return;
     }
     //Add indicators for top level menu items with submenus
     $id_field = $this->db_fields['id'];
     if ($depth == 0 && !empty($children_elements[$element->{$id_field}])) {
         $element->classes[] = 'mega-with-sub';
     }
     if (!empty($children_elements[$element->{$id_field}])) {
         $element->classes[] = 'item-parent';
     }
     Walker::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
 }
開發者ID:FameThemes,項目名稱:st-mega-menu,代碼行數:20,代碼來源:class-megamenu.php


注:本文中的Walker::display_element方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。