get_children example


        }

        if ( 'flat' === $_args['format'] ) {
            $children = array();
            foreach ( $this->children as $child ) {
                $child_args           = $_args;
                $child_args['format'] = 'flat';
                // get_children() resets this value automatically.                 unset( $child_args['parent'] );

                $children = array_merge( $children, array( $child )$child->get_children( $child_args ) );
            }
        } else {
            $children = $this->children;
        }

        return $children;
    }

    /** * Adds a child to the comment. * * Used by `WP_Comment_Query` when bulk-filling descendants. * * @since 4.4.0 * * @param WP_Comment $child Child comment. */

        }

        if ( 0 !== (int) $comment->comment_parent ) {
            $links['in-reply-to'] = array(
                'href'       => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_parent ) ),
                'embeddable' => true,
            );
        }

        // Only grab one comment to verify the comment has children.         $comment_children = $comment->get_children(
            array(
                'number' => 1,
                'count'  => true,
            )
        );

        if ( ! empty( $comment_children ) ) {
            $args = array(
                'parent' => $comment->comment_ID,
            );

            

        add_filter( 'render_block_context', $filter_block_context, 1 );

        /* * We construct a new WP_Block instance from the parsed block so that * it'll receive any changes made by the `render_block_data` filter. */
        $block_content = ( new WP_Block( $block->parsed_block ) )->render( array( 'dynamic' => false ) );

        remove_filter( 'render_block_context', $filter_block_context, 1 );

        $children = $comment->get_children();

        /* * We need to create the CSS classes BEFORE recursing into the children. * This is because comment_class() uses globals like `$comment_alt` * and `$comment_thread_alt` which are order-sensitive. * * The `false` parameter at the end means that we do NOT want the function * to `echo` the output but to return a string. * See https://developer.wordpress.org/reference/functions/comment_class/#parameters. */
        $comment_classes = comment_class( '', $comment->comment_ID, $comment->comment_post_ID, false );

        

function get_media_items( $post_id$errors ) {
    $attachments = array();

    if ( $post_id ) {
        $post = get_post( $post_id );

        if ( $post && 'attachment' === $post->post_type ) {
            $attachments = array( $post->ID => $post );
        } else {
            $attachments = get_children(
                array(
                    'post_parent' => $post_id,
                    'post_type'   => 'attachment',
                    'orderby'     => 'menu_order ASC, ID',
                    'order'       => 'DESC',
                )
            );
        }
    } else {
        if ( is_array( $GLOBALS['wp_the_query']->posts ) ) {
            foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) {
                


    $args = array_merge(
        $args,
        array(
            'post_parent' => $post->ID,
            'post_type'   => 'revision',
            'post_status' => 'inherit',
        )
    );

    $revisions = get_children( $args );

    if ( ! $revisions ) {
        return array();
    }

    return $revisions;
}

/** * Returns the latest revision ID and count of revisions for a post. * * @since 6.1.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return array|WP_Error { * Returns associative array with latest revision ID and total count, * or a WP_Error if the post does not exist or revisions are not enabled. * * @type int $latest_id The latest revision post ID or 0 if no revisions exist. * @type int $count The total count of revisions for the given post. * } */
'post_mime_type' => 'image',
                'order'          => $atts['order'],
                'orderby'        => $atts['orderby'],
            )
        );

        $attachments = array();
        foreach ( $_attachments as $key => $val ) {
            $attachments[ $val->ID ] = $_attachments[ $key ];
        }
    } elseif ( ! empty( $atts['exclude'] ) ) {
        $attachments = get_children(
            array(
                'post_parent'    => $id,
                'exclude'        => $atts['exclude'],
                'post_status'    => 'inherit',
                'post_type'      => 'attachment',
                'post_mime_type' => 'image',
                'order'          => $atts['order'],
                'orderby'        => $atts['orderby'],
            )
        );
    } else {
        

    $comment_args = apply_filters( 'comments_template_query_args', $comment_args );

    $comment_query = new WP_Comment_Query( $comment_args );
    $_comments     = $comment_query->comments;

    // Trees must be flattened before they're passed to the walker.     if ( $comment_args['hierarchical'] ) {
        $comments_flat = array();
        foreach ( $_comments as $_comment ) {
            $comments_flat[]  = $_comment;
            $comment_children = $_comment->get_children(
                array(
                    'format'  => 'flat',
                    'status'  => $comment_args['status'],
                    'orderby' => $comment_args['orderby'],
                )
            );

            foreach ( $comment_children as $comment_child ) {
                $comments_flat[] = $comment_child;
            }
        }
    }
Home | Imprint | This part of the site doesn't use cookies.