';
$margin = 0;
$lastParent = 0;
// loop posts of current post-type
foreach ( $cats as $catName => $posts ) {
if ( empty( $posts ) ) {
continue;
}
if ( !$postType->hierarchical ) {
echo '
' . $catName . '
';
}
foreach ( $posts as $post ) {
$style = '';
if ( empty( $post->post_parent ) ) {
$margin = 0;
} else if ( $post->post_parent === $lastParent ) {
// do nothing
} else {
// has parent, not same as before
$margin += 10;
$lastParent = $post->post_parent;
}
if ( !empty( $margin ) && $postType->hierarchical ) {
$style = ' style="margin-left:' . $margin . 'px;" ';
}
echo '
';
// echo thumb
if ( has_post_thumbnail( $post ) ) {
// from post-thumbnail
$attachmentId = get_post_thumbnail_id( $post->ID );
$path = get_attached_file( $attachmentId );
$url = wp_get_attachment_image_src( $attachmentId, 'thumbnail' );
$url = !empty( $url ) ? $url[0] : '';
} else if ( $post->post_type == 'attachment' ) {
// direct from attachment
$path = get_attached_file( $post->ID );
$url = wp_get_attachment_image_src( $post->ID, 'thumbnail' );
$url = !empty( $url ) ? $url[0] : '';
}
if ( empty( $url ) && class_exists( 'Lib\PostGalleryImageList' ) ) {
// from post-gallery
$postGalleryImages = Lib\PostGalleryImageList::get( $post->ID );
if ( count( $postGalleryImages ) ) {
$firstThumb = array_shift( $postGalleryImages );
$path = $firstThumb['path'];
}
}
if ( !empty( $path ) && class_exists( 'Lib\Thumb' ) ) {
$path = explode( '/wp-content/', $path );
$path = '/wp-content/' . array_pop( $path );
$thumbInstance = new Lib\Thumb();
$thumb = $thumbInstance->getThumb( array(
'path' => $path,
'width' => '150',
'height' => '150',
'scale' => '0',
) );
if ( !empty( $thumb['url'] ) ) {
echo '
![]()
';
}
} else if ( !empty( $url ) ) {
echo '
![]()
';
}
// reset vars
$thumb = null;
$path = null;
$url = null;
// echo post-title
if ( !empty( $post->post_title ) ) {
echo $post->post_title;
} else if ( !empty( $post->post_name ) ) {
echo $post->post_name;
} else {
echo $post->ID;
}
$link = admin_url() . 'post.php?post=' . $post->ID;
if ( $postType->name === 'wpcf7' ) {
$link = admin_url() . 'admin.php?page=wpcf7&post=' . $post->ID;
}
echo '
';
echo '
';
// add button for elementor-edit
if ( defined( 'ELEMENTOR_VERSION' ) ) {
echo '
';
}
echo '
';
echo '
'; // .admin-quickbar-post-options
echo '
'; // .admin-quickbar-postlist-inner
}
}
echo '