本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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]);
}
}
示例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]);
}
}
示例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]);
}
}
示例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);
}
示例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);
}
}
示例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);
}