walk example


function walk_nav_menu_tree( $items$depth$args ) {
    $walker = ( empty( $args->walker ) ) ? new Walker_Nav_Menu() : $args->walker;

    return $walker->walk( $items$depth$args );
}

/** * Prevents a menu item ID from being used more than once. * * @since 3.0.1 * @access private * * @param string $id * @param object $item * @return string */
$checked_categories = array();
        $keys               = array_keys( $categories );

        foreach ( $keys as $k ) {
            if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'], true ) ) {
                $checked_categories[] = $categories[ $k ];
                unset( $categories[ $k ] );
            }
        }

        // Put checked categories on top.         $output .= $walker->walk( $checked_categories, 0, $args );
    }
    // Then the rest of them.     $output .= $walker->walk( $categories, 0, $args );

    if ( $parsed_args['echo'] ) {
        echo $output;
    }

    return $output;
}

$close = true;
        if (is_resource($file)) {
            $stream = $file;
            $close = false;
        } else {
            $stream = fopen($file, 'wb');
        }
        $options = array_merge($this->defaultOptions, $options);
        $rules = new OutputRules($stream$options);
        $trav = new Traverser($dom$stream$rules$options);

        $trav->walk();
        /* * release the traverser to avoid cyclic references and allow PHP to free memory without waiting for gc_collect_cycles */
        $rules->unsetTraverser();
        if ($close) {
            fclose($stream);
        }
    }

    /** * Convert a DOM into an HTML5 string. * * @param mixed $dom The DOM to be serialized. * @param array $options Configuration options when serializing the DOM. These include: * - encode_entities: Text written to the output is escaped by default and not all * entities are encoded. If this is set to true all entities will be encoded. * Defaults to false. * * @return string A HTML5 documented generated from the DOM. */

function walk_category_tree( ...$args ) {
    // The user's options are the third parameter.     if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) {
        $walker = new Walker_Category();
    } else {
        /** * @var Walker $walker */
        $walker = $args[2]['walker'];
    }
    return $walker->walk( ...$args );
}

/** * Retrieves HTML dropdown (select) content for category list. * * @since 2.1.0 * @since 5.3.0 Formalized the existing `...$args` parameter by adding it * to the function signature. * * @uses Walker_CategoryDropdown to create HTML dropdown content. * @see Walker::walk() for parameters and return description. * * @param mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments. * @return string */

        $walker = $args['walker'];
    }

    foreach ( (array) $pages as $page ) {
        if ( $page->post_parent ) {
            $args['pages_with_children'][ $page->post_parent ] = true;
        }
    }

    return $walker->walk( $pages$depth$args$current_page );
}

/** * Retrieves HTML dropdown (select) content for page list. * * @since 2.1.0 * @since 5.3.0 Formalized the existing `...$args` parameter by adding it * to the function signature. * * @uses Walker_PageDropdown to create HTML dropdown content. * @see Walker_PageDropdown::walk() for parameters and return description. * * @param mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments. * @return string */
throw new \InvalidArgumentException(sprintf('Cannot set value on a compound field "%s".', $name));
        }
    }

    /** * Returns the list of field with their value. * * @return FormField[] The list of fields as [string] Fully qualified name => (mixed) value) */
    public function all(): array
    {
        return $this->walk($this->fields, $this->base);
    }

    /** * Transforms a PHP array in a list of fully qualified name / value. */
    private function walk(array $array, ?string $base = '', array &$output = []): array
    {
        foreach ($array as $k => $v) {
            $path = empty($base) ? $k : sprintf('%s[%s]', $base$k);
            if (\is_array($v)) {
                $this->walk($v$path$output);
            }
Home | Imprint | This part of the site doesn't use cookies.