Sindbad~EG File Manager
<?php
/**
* Add action and add filter
* Class Thim_Realpress_Include
*/
function thim_get_theme_option( $name = '', $value_default = '' ) {
$data = get_theme_mods();
if ( isset( $data[$name] ) ) {
return $data[$name];
} else {
return $value_default;
}
}
/**
* Get prefix for key customizer
*/
if ( ! function_exists( 'thim_get_prefix_key' ) ) {
function thim_get_prefix_key() {
if ( get_post_type() == "product" ) {
$prefix = 'thim_woo';
} elseif ( get_post_type() == 'realpress-property' ) {
$prefix = 'thim_realpress';
} else {
$prefix = 'thim_archive';
}
if ( is_single() ) {
$prefix .= '_single';
}
if ( is_page() ) {
$prefix = 'thim_page';
}
return $prefix;
}
}
class Thim_Wrapper_Layout {
public function __construct() {
// action thim_wrapper_loop_start
add_action( 'thim_wrapper_loop_start', array( $this, 'thim_wrapper_div_open' ), 1, 0 );
add_action( 'thim_wrapper_loop_start', array( $this, 'thim_wrapper_loop_start' ), 10, 0 );
add_action( 'thim_wrapper_loop_start', array( $this, 'thim_wrapper_page_title' ), 5, 0 );
// action thim_wrapper_loop_end
add_action( 'thim_wrapper_loop_end', array( $this, 'thim_wrapper_loop_end' ), 10, 0 );
add_action( 'thim_wrapper_loop_end', array( $this, 'thim_wrapper_div_close' ), 30, 0 );
//add thim_wrapper_loop_start
add_action( 'woocommerce_before_main_content', array( $this,'thim_wrapper_div_open'), 1, 0 );
add_action( 'woocommerce_before_main_content', array( $this,'thim_wrapper_page_title'), 2, 0 );
add_action( 'woocommerce_before_main_content', array( $this,'thim_wrapper_loop_start'), 5, 0 );
//add thim_wrapper_loop_end
add_action( 'woocommerce_after_main_content', array( $this,'thim_wrapper_loop_end'), 50, 0 );
add_action( 'woocommerce_after_main_content', array( $this,'thim_wrapper_div_close'), 51, 0 );
//
add_action( 'thim_before_archive_loop', array( $this,'thim_get_four_post'), 5, 0);
}
function thim_wrapper_layout() {
$col_container = 3;
$class_col = 'col-md-9';
$prefix = thim_get_prefix_key();
$wrapper_layout = thim_get_theme_option( $prefix . '_layout');
if ( is_page() || is_single() ) {
$postid = get_the_ID();
/***********custom layout*************/
$using_custom_layout = get_post_meta( $postid, 'thim_mtb_custom_layout', true );
if ( $using_custom_layout ) {
$wrapper_layout = get_post_meta( $postid, 'thim_mtb_layout', true );
}
}
// fix not active sidebar
if ( get_post_type() == "product" && ! is_active_sidebar( 'sidebar_shop' ) ) {
$wrapper_layout = 'full-content';
}
if (!is_active_sidebar( 'sidebar' ) && get_post_type() != "product" ) {
$wrapper_layout = 'full-content';
}
if ( $wrapper_layout == 'full-content' || is_404()) {
$class_col = "col-sm-12 full-width";
}
if ( $wrapper_layout == 'sidebar-right' ) {
$class_col = 'col-md-'. esc_attr( 12-$col_container );
}
if ( $wrapper_layout == 'sidebar-left' ) {
$class_col = 'col-md-'. esc_attr( 12-$col_container );
}
return $class_col;
}
public function thim_wrapper_div_open() {
echo '<div class="content-area">';
}
public function thim_wrapper_loop_end() {
$class_col = $this->thim_wrapper_layout();
echo '</main>';
if ( $class_col != "col-sm-12 full-width" ) {
if ( get_post_type() == "product" ) {
get_sidebar( 'shop' );
} else {
get_sidebar();
}
}
echo '</div>';
do_action( 'thim_after_site_content' );
echo '</div>';
}
public function thim_wrapper_loop_start() {
$sidebar_class = '';
$class_col = $this->thim_wrapper_layout();
$prefix = thim_get_prefix_key();
$wrapper_layout = thim_get_theme_option( $prefix . '_layout');
if ( is_page() || is_single() ) {
$postid = get_the_ID();
/***********custom layout*************/
$using_custom_layout = get_post_meta( $postid, 'thim_mtb_custom_layout', true );
if ( $using_custom_layout ) {
$wrapper_layout = get_post_meta( $postid, 'thim_mtb_layout', true );
}
// no padding top
$mtb_no_padding = get_post_meta( get_the_ID(), 'thim_mtb_no_padding', true );
if ( $mtb_no_padding ) {
$sidebar_class .= ' no-padding-top';
}
}
if ( $wrapper_layout == 'sidebar-right' ) {
$sidebar_class = ' sidebar-right';
}
if ( $wrapper_layout == 'sidebar-left' ) {
$sidebar_class = ' sidebar-left';
}
do_action( 'thim_before_site_content' );
echo '<div class="container site-content' . $sidebar_class . '">';
echo '<div class="row"><main id="main" class="site-main ' . $class_col. '">';
}
public function thim_wrapper_div_close() {
echo '</div>';
}
public function thim_wrapper_page_title() {
$prefix = thim_get_prefix_key();
//Hide breadcrumbs default from customizer options
$hide_breadcrumbs = thim_get_theme_option( $prefix . '_hide_breadcrumbs', 0 );
if ( is_page() || is_single() ) {
$post_id = get_the_ID();
//Check using custom heading on single
$hide_breadcrumbs = get_post_meta( $post_id, 'thim_mtb_hide_breadcrumbs', true );
}
if ( $hide_breadcrumbs != '1' && ! is_front_page() && ! is_404() ) {
?>
<div class="top_heading">
<div class="banner-wrapper container">
<?php
//Check seo by yoast breadcrumbs
$wpseo = get_option( 'wpseo_titles' );
if ( ( class_exists( 'WPSEO' ) || class_exists( 'WPSEO_Premium' ) ) && $wpseo['breadcrumbs-enable'] && function_exists( 'yoast_breadcrumb' ) ) {
yoast_breadcrumb( '<div id="breadcrumbs">', '</div>' );
} else {
do_action( 'thim_breadcrumbs' );
}
?>
</div>
</div>
<?php
}
}
// Get 4 post page archive only pagination first page
public function thim_get_four_post() {
$query_args = array(
'post_type' => 'post',
'posts_per_page' => 4,
'order' => 'desc',
'orderby' => 'post_date',
'ignore_sticky_posts' => true,
);
$query_vars = new \WP_Query( $query_args );
$queryclass = '';
?>
<div class="top-archive">
<?php
if(is_home()) {
echo '<h1 class="page-title">';
echo single_post_title();
echo '</h1>';
} else {
the_archive_title('<h1 class="page-title">', '</h1>');
}
the_archive_description();
?>
</div>
<?php
if(get_query_var('paged') > 1) {
$queryclass = 'no-query';
}
if ( $query_vars->have_posts() ) {
?>
<div class="realpro-four-post <?php echo esc_attr__($queryclass); ?>">
<div class="wrapper-list-post">
<?php
if(get_query_var('paged') < 2) {
while ( $query_vars->have_posts() ) {
$query_vars->the_post();
get_template_part( 'templates/template-parts/content' );
}
}
?>
</div>
</div>
<?php
}
}
}
new Thim_Wrapper_Layout();
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists