📁 File Manager Pro
v10.0.2 | PHP: 8.1.34
Server: LiteSpeed
2026-06-26 08:42:04
📂
/
/
home
/
pallabnv
/
public_html
/
wp-content__3bb9dea
/
themes
/
berich
/
elements
✏️
Editing: element-templates.php
<?php if(!function_exists('berich_get_post_grid')){ function berich_get_post_grid($posts = [], $settings = []){ if (empty($posts) || !is_array($posts) || empty($settings) || !is_array($settings)) { return false; } switch ($settings['layout']) { case 'post-1': berich_get_post_grid_layout1($posts, $settings); break; case 'portfolio-1': berich_get_portfolio_grid_layout1($posts, $settings); break; default: return false; break; } } } // Start Post Grid //-------------------------------------------------- function berich_get_post_grid_layout1($posts = [], $settings = []){ extract($settings); $images_size = !empty($img_size) ? $img_size : '600x393'; if (is_array($posts)): foreach ($posts as $key => $post): $item_class = "pxl-grid-item col-xl-{$col_xl} col-lg-{$col_lg} col-md-{$col_md} col-sm-{$col_sm} col-{$col_xs}"; if(isset($grid_masonry) && !empty($grid_masonry[$key]) && (count($grid_masonry) > 1)) { if($grid_masonry[$key]['col_xl_m'] == 'col-66') { $col_xl_m = '66-pxl'; } else { $col_xl_m = 12 / $grid_masonry[$key]['col_xl_m']; } if($grid_masonry[$key]['col_lg_m'] == 'col-66') { $col_lg_m = '66-pxl'; } else { $col_lg_m = 12 / $grid_masonry[$key]['col_lg_m']; } $col_md_m = 12 / $grid_masonry[$key]['col_md_m']; $col_sm_m = 12 / $grid_masonry[$key]['col_sm_m']; $col_xs_m = 12 / $grid_masonry[$key]['col_xs_m']; $item_class = "pxl-grid-item col-xl-{$col_xl_m} col-lg-{$col_lg_m} col-md-{$col_md_m} col-sm-{$col_sm_m} col-{$col_xs_m}"; $img_size_m = $grid_masonry[$key]['img_size_m']; if(!empty($img_size_m)) { $images_size = $img_size_m; } } elseif (!empty($img_size)) { $images_size = $img_size; } if(!empty($tax)) $filter_class = pxl_get_term_of_post_to_class($post->ID, array_unique($tax)); else $filter_class = ''; $author = get_user_by('id', $post->post_author); $author_avatar = get_avatar( $post->post_author, 60, '', $author->display_name, array( 'class' => '' ) ); $user_position = get_user_meta(get_the_author_meta( 'ID' ), 'user_position', true); $post_video_link = get_post_meta($post->ID, 'post_video_link', true); ?> <div class="<?php echo esc_attr($item_class . ' ' . $filter_class); ?>"> <div class="pxl-post--inner <?php echo esc_attr($pxl_animate); ?>" data-wow-duration="1.2s"> <?php if (has_post_thumbnail($post->ID) && wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), false)): $img_id = get_post_thumbnail_id($post->ID); $img = pxl_get_image_by_size( array( 'attach_id' => $img_id, 'thumb_size' => $images_size ) ); $thumbnail = $img['thumbnail']; ?> <div class="pxl-post--featured hover-imge-effect2"> <a href="<?php echo esc_url(get_permalink( $post->ID )); ?>"><?php echo wp_kses_post($thumbnail); ?></a> <?php if(!empty($post_video_link)) : ?> <a href="<?php echo esc_url($post_video_link); ?>" class="post-button-video pxl-action-popup"><i class="caseicon-play1"></i></a> <span class="button-video-overlay bg-image"></span> <?php endif; ?> </div> <?php endif; ?> <div class="pxl-post--meta"> <?php if($show_category == 'true'): ?> <div class="pxl-post--category"> <?php the_terms( $post->ID, 'category', '', ' ' ); ?> </div> <?php endif; ?> <?php if($show_date == 'true'): ?> <div class="pxl-post--date"><?php $date_formart = get_option('date_format'); echo get_the_date($date_formart, $post->ID); ?></div> <?php endif; ?> </div> <h3 class="pxl-post--title title-hover-line"><a href="<?php echo esc_url(get_permalink( $post->ID )); ?>"><?php echo esc_attr(get_the_title($post->ID)); ?></a></h3> <?php if($show_author == 'true'): ?> <div class="pxl-post--author pxl-flex"> <div class="pxl-author--img pxl-mr-6"> <?php pxl_print_html($author_avatar); ?> </div> <div class="pxl-author-meta"> <h6><?php echo esc_html($author->display_name); ?></h6> <span><?php echo esc_attr($user_position); ?><span> </div> <a href="<?php echo esc_url(get_author_posts_url($post->post_author, $author->user_nicename)); ?>"></a> </div> <?php endif; ?> </div> </div> <?php endforeach; endif; } // End Post Grid //-------------------------------------------------- // Start Portfolio Grid //-------------------------------------------------- function berich_get_portfolio_grid_layout1($posts = [], $settings = []){ extract($settings); $images_size = !empty($img_size) ? $img_size : '570x360'; if (is_array($posts)): foreach ($posts as $key => $post): $item_class = "pxl-grid-item col-xl-{$col_xl} col-lg-{$col_lg} col-md-{$col_md} col-sm-{$col_sm} col-{$col_xs}"; if(isset($grid_masonry) && !empty($grid_masonry[$key]) && (count($grid_masonry) > 1)) { if($grid_masonry[$key]['col_xl_m'] == 'col-66') { $col_xl_m = '66-pxl'; } else { $col_xl_m = 12 / $grid_masonry[$key]['col_xl_m']; } if($grid_masonry[$key]['col_lg_m'] == 'col-66') { $col_lg_m = '66-pxl'; } else { $col_lg_m = 12 / $grid_masonry[$key]['col_lg_m']; } $col_md_m = 12 / $grid_masonry[$key]['col_md_m']; $col_sm_m = 12 / $grid_masonry[$key]['col_sm_m']; $col_xs_m = 12 / $grid_masonry[$key]['col_xs_m']; $item_class = "pxl-grid-item col-xl-{$col_xl_m} col-lg-{$col_lg_m} col-md-{$col_md_m} col-sm-{$col_sm_m} col-{$col_xs_m}"; $img_size_m = $grid_masonry[$key]['img_size_m']; if(!empty($img_size_m)) { $images_size = $img_size_m; } } elseif (!empty($img_size)) { $images_size = $img_size; } if(!empty($tax)) $filter_class = pxl_get_term_of_post_to_class($post->ID, array_unique($tax)); else $filter_class = ''; $img_id = get_post_thumbnail_id($post->ID); if (has_post_thumbnail($post->ID) && wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), false)): if($img_id) { $img = pxl_get_image_by_size( array( 'attach_id' => $img_id, 'thumb_size' => $images_size, 'class' => 'no-lazyload', )); $thumbnail = $img['thumbnail']; } else { $thumbnail = get_the_post_thumbnail($post->ID, $images_size); } ?> <div class="<?php echo esc_attr($item_class . ' ' . $filter_class); ?>"> <div class="pxl-post--inner <?php echo esc_attr($pxl_animate); ?>" data-wow-duration="1.2s"> <div class="pxl-post--featured hover-imge-effect3"><?php echo wp_kses_post($thumbnail); ?></div> <div class="pxl-post--overlay"></div> <div class="pxl-post--holder"> <div class="pxl-holder--inner"> <?php if($show_button == 'true'): ?> <div class="pxl-post--icon"> <i class="flaticon-right-up"></i> </div> <?php endif; ?> <h5 class="pxl-post--title"><?php echo esc_attr(get_the_title($post->ID)); ?></h5> <?php if($show_category == 'true'): ?> <div class="pxl-post--category link-none"> <?php the_terms( $post->ID, 'portfolio-category', '', ' ' ); ?> </div> <?php endif; ?> </div> </div> <?php if($show_button == 'true'): ?><a class="pxl-post--link" href="<?php echo esc_url(get_permalink( $post->ID )); ?>"></a><?php endif; ?> </div> </div> <?php endif; ?> <?php endforeach; endif; } // End Portfolio Grid //-------------------------------------------------- // Start Service Grid //-------------------------------------------------- // End Service Grid //------------------------------------------------- // Start Product Grid //-------------------------------------------------- // End Product Grid //-------------------------------------------------- add_action( 'wp_ajax_berich_load_more_post_grid', 'berich_load_more_post_grid' ); add_action( 'wp_ajax_nopriv_berich_load_more_post_grid', 'berich_load_more_post_grid' ); function berich_load_more_post_grid(){ if ( ! check_ajax_referer( '_ajax_nonce', 'wpnonce' ) || empty( sanitize_text_field( wp_unslash($_POST['wpnonce'] ))) ) { wp_send_json( array( 'status' => false, 'message' => esc_attr__('Nonce error, please reload.', 'berich'), 'data' => array(), ) ); } try{ if(!isset($_POST['settings'])){ throw new Exception(__('Something went wrong while requesting. Please try again!', 'berich')); } $settings = isset($_POST['settings']) ? $_POST['settings'] : null; $source = isset($settings['source']) ? $settings['source'] : ''; $term_slug = isset($settings['term_slug']) ? $settings['term_slug'] : ''; if( !empty($term_slug) && $term_slug !='*'){ $term_slug = str_replace('.', '', $term_slug); $source = [$term_slug.'|'.$settings['tax'][0]]; } if( isset($_POST['handler_click']) && sanitize_text_field(wp_unslash( $_POST[ 'handler_click' ] )) == 'filter'){ set_query_var('paged', 1); $settings['paged'] = 1; }else{ set_query_var('paged', $settings['paged']); } extract(pxl_get_posts_of_grid($settings['post_type'], [ 'source' => $source, 'orderby' => isset($settings['orderby'])?$settings['orderby']:'date', 'order' => isset($settings['order'])?$settings['order']:'desc', 'limit' => isset($settings['limit'])?$settings['limit']:'6', 'post_ids' => isset($settings['post_ids'])?$settings['post_ids']: [], 'post_not_in' => isset($settings['post_not_in'])?$settings['post_not_in']: [], ], $settings['tax'] )); ob_start(); berich_get_post_grid($posts, $settings); $html = ob_get_clean(); $pagin_html = ''; if( isset($settings['pagination_type']) && $settings['pagination_type'] == 'pagination' ){ ob_start(); berich()->page->get_pagination( $query, true ); $pagin_html = ob_get_clean(); } wp_send_json( array( 'status' => true, 'message' => esc_attr__('Load Successfully!', 'berich'), 'data' => array( 'html' => $html, 'pagin_html' => $pagin_html, 'paged' => $settings['paged'], 'posts' => $posts, 'max' => $max, ), ) ); } catch (Exception $e){ wp_send_json(array('status' => false, 'message' => $e->getMessage())); } die; }
💾 Save Changes
❌ Cancel