516 lines
18 KiB
PHP
516 lines
18 KiB
PHP
<?php
|
|
|
|
add_action('init', 'cyber_blog_sections');
|
|
|
|
if(!function_exists('cyber_blog_sections')):
|
|
|
|
function cyber_blog_sections(){
|
|
|
|
if(function_exists('kc_add_map')):
|
|
|
|
kc_add_map(
|
|
|
|
array(
|
|
|
|
'cyber_blog' => array(
|
|
'name' => esc_html__('EM blog Section', 'cyber'),
|
|
'description' => esc_html__('Display Blog Style', 'cyber'),
|
|
'icon' => 'kc-icon-blog-posts',
|
|
'category' => 'cyber',
|
|
'params' => array(
|
|
|
|
|
|
'General' => array(
|
|
array(
|
|
'name' => 'items',
|
|
'label' => __( 'Items Limit', 'cyber' ),
|
|
'type' => 'number_slider',
|
|
'value' => '3',
|
|
'description' => __(' Specify number of post that you want to show. Set 0 to get all team', 'cyber'),
|
|
'options' => array(
|
|
'min' => 0,
|
|
'max' => 75,
|
|
'unit' => '',
|
|
'show_input' => false
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'select',
|
|
'label' => __( 'Order By', 'cyber' ),
|
|
'name' => 'order',
|
|
'options' => array(
|
|
'DESC' => __( 'Descending', 'cyber' ),
|
|
'ASC' => __( 'Ascending', 'cyber' )
|
|
)
|
|
),
|
|
array(
|
|
'type' => 'radio_image',
|
|
'label' => __( 'Select blog Style', 'cyber' ),
|
|
'name' => 'layout',
|
|
'admin_label' => true,
|
|
'options' => array(
|
|
'1' => EM40_EXTENSION_URI . 'asstes/images/blog/layout1.jpg',
|
|
'2' => EM40_EXTENSION_URI . 'asstes/images/blog/layout2.jpg',
|
|
'3' => EM40_EXTENSION_URI . 'asstes/images/blog/layout3.jpg',
|
|
),
|
|
'description' => __( 'When select style 2 that time, set column and set gutter not work', 'cyber' ),
|
|
'value' => '1'
|
|
),
|
|
array(
|
|
'type' => 'select',
|
|
'label' => __( 'Set Column', 'cyber' ),
|
|
'name' => 'set_column',
|
|
'description' => __( 'Enter number item per row', 'cyber' ),
|
|
'value' => '4',
|
|
'options' => array(
|
|
'12' => __( '1 Column', 'cyber' ),
|
|
'6' => __( '2 Column', 'cyber' ),
|
|
'4' => __( '3 Column', 'cyber' ),
|
|
'3' => __( '4 Column', 'cyber' )
|
|
),
|
|
),
|
|
array(
|
|
'name' => 'gutter',
|
|
'label' => __( 'Select No Gutter', 'cyber' ),
|
|
'type' => 'toggle',
|
|
'value' => 'no',
|
|
'description' => __( 'Remove column Spacing', 'cyber' ),
|
|
),
|
|
array(
|
|
'name' => 'show_pagination',
|
|
'label' => __( 'Show/Hide Pagination', 'cyber' ),
|
|
'type' => 'toggle',
|
|
'value' => 'no',
|
|
),
|
|
array(
|
|
'name' => 'show_content',
|
|
'label' => __( 'Display Pragraph', 'cyber' ),
|
|
'type' => 'toggle',
|
|
'value' => 'yes',
|
|
),
|
|
array(
|
|
'name' => 'show_button',
|
|
'label' => __( 'Display Button', 'cyber' ),
|
|
'type' => 'toggle',
|
|
'value' => 'yes',
|
|
),
|
|
|
|
array(
|
|
'type' => 'text',
|
|
'label' => __( 'Button Text', 'cyber' ),
|
|
'name' => 'btn_text',
|
|
'value' => 'Read More',
|
|
'description' => __( 'Enter Button Text', 'cyber' )
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => __( 'Custom class', 'cyber' ),
|
|
'name' => 'custom_class',
|
|
'description' => __( 'Enter extra custom class', 'cyber' )
|
|
)
|
|
|
|
),
|
|
'styling' => array(
|
|
array(
|
|
'name' => 'css_custom',
|
|
'type' => 'css',
|
|
'options' => array(
|
|
array(
|
|
"screens" => "any,1024,999,767,479",
|
|
'Title' => array(
|
|
array('property' => 'color', 'label' => 'Color', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
array('property' => 'color', 'label' => 'Hover Color', 'selector' => '.blog-page-title_adn a:hover'),
|
|
array('property' => 'font-family', 'label' => 'Font Family', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
array('property' => 'font-size', 'label' => 'Font Size', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
array('property' => 'line-height', 'label' => 'Line Height', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
array('property' => 'font-weight', 'label' => 'Font Weight', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
array('property' => 'text-transform', 'label' => 'Text Transform', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
array('property' => 'margin', 'label' => 'Margin', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
array('property' => 'padding', 'label' => 'Padding', 'selector' => '.blog-page-title_adn2 h2 a,.blog-page-title_adn a'),
|
|
),
|
|
'Post Meta' => array(
|
|
array('property' => 'color', 'label' => 'Color', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'background-color', 'label' => 'Background Color', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'font-family', 'label' => 'Font Family', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'font-size', 'label' => 'Font Size', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'line-height', 'label' => 'Line Height', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'font-weight', 'label' => 'Font Weight', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'text-transform', 'label' => 'Text Transform', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'padding', 'label' => 'Padding', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
array('property' => 'margin', 'label' => 'Margin', 'selector' => '.cyber-blog-meta-left a, .cyber-blog-meta-left span'),
|
|
),
|
|
'Text' => array(
|
|
array('property' => 'color', 'label' => 'Color', 'selector' => '.blog-content_adn p'),
|
|
array('property' => 'font-family', 'label' => 'Font Family', 'selector' => '.blog-content_adn p'),
|
|
array('property' => 'font-size', 'label' => 'Font Size', 'selector' => '.blog-content_adn p'),
|
|
array('property' => 'line-height', 'label' => 'Line Height', 'selector' => '.blog-content_adn p'),
|
|
array('property' => 'font-weight', 'label' => 'Font Weight', 'selector' => '.blog-content_adn p'),
|
|
array('property' => 'text-transform', 'label' => 'Text Transform', 'selector' => '.blog-content_adn p'),
|
|
array('property' => 'padding', 'label' => 'Padding', 'selector' => '.blog-content_adn p'),
|
|
array('property' => 'margin', 'label' => 'Margin', 'selector' => '.blog-content_adn p'),
|
|
),
|
|
'Button' => array(
|
|
array('property' => 'color', 'label' => 'Text Color', 'selector' => '.cyber-blog-readmore a'),
|
|
array('property' => 'color', 'label' => 'Text Hover Color', 'selector' => '.cyber-blog-readmore a:hover'),
|
|
array('property' => 'border', 'label' => 'Border', 'selector' => '.learn_btn'),
|
|
array('property' => 'border-color', 'label' => 'Hover Border', 'selector' => '.cyber-blog-readmore a:hover'),
|
|
array('property' => 'background-color', 'label' => 'Background Color', 'selector' => '.cyber-blog-readmore a'),
|
|
array('property' => 'background-color', 'label' => 'BG Color Hover', 'selector' => '.cyber-blog-readmore a:hover'),
|
|
array('property' => 'font-size', 'label' => 'Font Size', 'selector' => '.cyber-blog-readmore a'),
|
|
array('property' => 'text-transform', 'label' => 'Text Transform', 'selector' => '.cyber-blog-readmore a'),
|
|
array('property' => 'margin', 'label' => 'Margin', 'selector' => '.cyber-blog-readmore a'),
|
|
array('property' => 'padding', 'label' => 'Padding', 'selector' => '.cyber-blog-readmore a'),
|
|
),
|
|
|
|
'Box' => array(
|
|
array('property' => 'background'),
|
|
array('property' => 'background-color', 'label' => 'BG Color', 'selector' => '+ .cyber-single-blog_adn'),
|
|
array('property' => 'background-color', 'label' => 'BG Color Hover', 'selector' => '+:hover'),
|
|
array('property' => 'text-align', 'label' => 'Box Text Align'),
|
|
array('property' => 'border', 'label' => 'Border'),
|
|
array('property' => 'border-color', 'label' => 'Border Color Hover'),
|
|
array('property' => 'display', 'label' => 'Display'),
|
|
array('property' => 'border-radius', 'label' => 'Border Radius'),
|
|
array('property' => 'box-shadow', 'label' => 'Box Shadow', 'selector' => '+.cyber-single-blog_adn',),
|
|
array('property' => 'box-shadow', 'label' => 'Box Shadow Hover', 'selector' => '+.cyber-single-blog_adn:hover'),
|
|
array('property' => 'margin', 'label' => 'Margin'),
|
|
array('property' => 'padding', 'label' => 'Padding'),
|
|
array('property' => 'margin', 'label' => 'Position Hover', 'selector' => '+.cyber-single-blog_adn:hover')
|
|
)
|
|
|
|
)
|
|
)
|
|
)
|
|
),
|
|
'animate' => array(
|
|
array(
|
|
'name' => 'animate',
|
|
'type' => 'animate'
|
|
)
|
|
),
|
|
|
|
|
|
|
|
)// Params
|
|
|
|
)// end shortcode key
|
|
|
|
)// first array
|
|
|
|
); // End add map
|
|
|
|
endif;
|
|
|
|
}
|
|
|
|
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ========== blog Area
|
|
if(!function_exists('cyber_blog_area')){
|
|
function cyber_blog_area( $atts , $content = null ){
|
|
|
|
ob_start();
|
|
// Attributes
|
|
$em_blog_box = shortcode_atts(array(
|
|
'layout' => '1',
|
|
'set_column' => '3',
|
|
'show_pagination' => '',
|
|
'items' => '3',
|
|
'order' => '',
|
|
'gutter' => '',
|
|
'btn_text' => '',
|
|
'show_content' => '',
|
|
'show_button' => '',
|
|
'custom_css' => '',
|
|
'custom_class' => '',
|
|
),$atts);
|
|
extract( $em_blog_box );
|
|
|
|
|
|
|
|
//custom class
|
|
$wrap_class = apply_filters( 'kc-el-class', $atts );
|
|
if( !empty( $custom_class ) ):
|
|
$wrap_class[] = $custom_class;
|
|
endif;
|
|
$extra_class = implode( ' ', $wrap_class );
|
|
|
|
|
|
|
|
$page = ( get_query_var( 'page' ) ? get_query_var( 'page' ) : 1 );
|
|
$paged = ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : $page );
|
|
|
|
|
|
$args = array(
|
|
'post_type' => 'post',
|
|
'posts_per_page' => intval( $items ),
|
|
'order' => $order ,
|
|
'paged' => $paged,
|
|
'page' => $paged
|
|
);
|
|
$the_query = new WP_Query($args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( $the_query->have_posts() ) {
|
|
|
|
|
|
switch ( $layout ) {
|
|
case '3':
|
|
?>
|
|
<div class=" blog_style_adn_2">
|
|
<div class="blog_wrap blog_carousel owl-carousel curosel-style">
|
|
|
|
<?php while ($the_query->have_posts()) : $the_query->the_post();
|
|
|
|
?>
|
|
<!-- single blog -->
|
|
<div class=" <?php if( $gutter == 'yes' ){echo 'blog_nospace_adn';}?> col-md-12 col-xs-12 col-sm-12 " >
|
|
<div class="single_blog_adn <?php echo esc_attr( $extra_class ); ?>">
|
|
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
|
<div class="cyber-single-blog_adn style-three ">
|
|
<!-- BLOG THUMB -->
|
|
<?php if(has_post_thumbnail()){?>
|
|
<div class="cyber-blog-thumb_adn ">
|
|
<a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('cyber-blog-default'); ?> </a>
|
|
<div class="cyber-blog-meta-top">
|
|
<?php the_category();?>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
<!-- BLOG CONTENT -->
|
|
<div class="em-blog-content-area_adn ">
|
|
<!-- BLOG META -->
|
|
<div class="cyber-blog-meta-left ">
|
|
<!-- <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"> <?php the_author(); ?></a>-->
|
|
<span><?php echo get_the_time(get_option('date_format')); ?></span>
|
|
</div>
|
|
<!-- BLOG TITLE -->
|
|
<div class="blog-page-title_adn ">
|
|
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
|
</div>
|
|
<!-- BLOG CONTENT -->
|
|
<div class="blog-inner_adn ">
|
|
<?php if($show_content=="yes"){ ?>
|
|
<div class="blog-content_adn ">
|
|
<p><?php echo wp_trim_words( get_the_content(), 17, ' ' ); ?></p>
|
|
</div>
|
|
|
|
<?php } ?>
|
|
</div>
|
|
<!-- BLOG BUTTON -->
|
|
<?Php if($show_button=="yes"){?>
|
|
|
|
<div class="cyber-blog-readmore">
|
|
<?php if($btn_text){?>
|
|
<a href="<?php the_permalink(); ?>" class="btn-link"><?php echo $btn_text;?> <i class="fa fa-angle-right"></i></a>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
<?php }?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div> <!-- END SINGLE BLOG -->
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<?php endwhile; ?>
|
|
<?php wp_reset_query(); ?>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
break;
|
|
case '2':
|
|
?>
|
|
<div class=" blog_style_adn_2">
|
|
<div class="blog_wrap blog_carousel owl-carousel curosel-style">
|
|
|
|
<?php while ($the_query->have_posts()) : $the_query->the_post();
|
|
|
|
?>
|
|
<!-- single blog -->
|
|
<div class=" <?php if( $gutter == 'yes' ){echo 'blog_nospace_adn';}?> col-md-12 col-xs-12 col-sm-12 " >
|
|
<div class="single_blog_adn <?php echo esc_attr( $extra_class ); ?>">
|
|
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
|
<div class="cyber-single-blog_adn ">
|
|
<!-- BLOG THUMB -->
|
|
<?php if(has_post_thumbnail()){?>
|
|
<div class="cyber-blog-thumb_adn ">
|
|
<a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('cyber-blog-default'); ?> </a>
|
|
</div>
|
|
<?php } ?>
|
|
<!-- BLOG CONTENT -->
|
|
<div class="em-blog-content-area_adn ">
|
|
<!-- BLOG META -->
|
|
<div class="cyber-blog-meta-left ">
|
|
<!-- <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"> <?php the_author(); ?></a>-->
|
|
<span><?php echo get_the_time(get_option('date_format')); ?></span>
|
|
</div>
|
|
<!-- BLOG TITLE -->
|
|
<div class="blog-page-title_adn ">
|
|
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
|
</div>
|
|
<!-- BLOG CONTENT -->
|
|
<div class="blog-inner_adn ">
|
|
<?php if($show_content=="yes"){ ?>
|
|
<div class="blog-content_adn ">
|
|
<p><?php echo wp_trim_words( get_the_content(), 17, ' ' ); ?></p>
|
|
</div>
|
|
|
|
<?php } ?>
|
|
</div>
|
|
<!-- BLOG BUTTON -->
|
|
<?Php if($show_button=="yes"){?>
|
|
|
|
<div class="cyber-blog-readmore">
|
|
<?php if($btn_text){?>
|
|
<a href="<?php the_permalink(); ?>" class="btn-link"><?php echo $btn_text;?> <i class="fa fa-angle-right"></i></a>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
<?php }?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div> <!-- END SINGLE BLOG -->
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<?php endwhile; ?>
|
|
<?php wp_reset_query(); ?>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
break;
|
|
|
|
default:
|
|
?>
|
|
<div class=" em_load_adn bgimgload blog_style_adn_1">
|
|
<div class="blog_wrap blog-messonary">
|
|
<?php while ($the_query->have_posts()) : $the_query->the_post();
|
|
|
|
?>
|
|
<!-- single blog -->
|
|
<div class=" <?php if( $gutter == 'yes' ){echo 'blog_nospace_adn';}?> col-lg-<?php if( !empty( $set_column ) ){echo $set_column;}?> grid-item col-md-6 col-sm-12" >
|
|
<div class="single_blog_adn <?php echo esc_attr( $extra_class ); ?>">
|
|
|
|
|
|
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
|
<div class="cyber-single-blog_adn ">
|
|
<!-- BLOG THUMB -->
|
|
<?php if(has_post_thumbnail()){?>
|
|
<div class="cyber-blog-thumb_adn ">
|
|
<a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('cyber-blog-default'); ?> </a>
|
|
</div>
|
|
<?php } ?>
|
|
<!-- BLOG CONTENT -->
|
|
<div class="em-blog-content-area_adn ">
|
|
<!-- BLOG META -->
|
|
<div class="cyber-blog-meta-left ">
|
|
<!-- <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"> <?php the_author(); ?></a>-->
|
|
<span><?php echo get_the_time(get_option('date_format')); ?></span>
|
|
</div>
|
|
<!-- BLOG TITLE -->
|
|
<div class="blog-page-title_adn ">
|
|
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
|
</div>
|
|
<!-- BLOG CONTENT -->
|
|
<div class="blog-inner_adn ">
|
|
<?php if($show_content=="yes"){ ?>
|
|
<div class="blog-content_adn ">
|
|
<p><?php echo wp_trim_words( get_the_content(), 17, ' ' ); ?></p>
|
|
</div>
|
|
|
|
<?php } ?>
|
|
</div>
|
|
<!-- BLOG BUTTON -->
|
|
<?Php if($show_button=="yes"){?>
|
|
|
|
<div class="cyber-blog-readmore">
|
|
<?php if($btn_text){?>
|
|
<a href="<?php the_permalink(); ?>" class="learn_btn"><?php echo $btn_text;?> <i class="fa fa-angle-right"></i></a>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
<?php }?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div> <!-- END SINGLE BLOG -->
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<?php endwhile; ?>
|
|
<?php wp_reset_query(); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
|
|
if( $show_pagination == 'yes' ){?>
|
|
<!-- START PAGINATION -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="paginations">
|
|
|
|
<?php
|
|
|
|
echo paginate_links( array(
|
|
'prev_next' => true,
|
|
'prev_text' => '<i class="fa fa-long-arrow-left"></i>',
|
|
'next_text' => '<i class="fa fa-long-arrow-right"></i>',
|
|
'type' => 'list',
|
|
'current' => $paged,
|
|
'total' => $the_query->max_num_pages
|
|
) );
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php }
|
|
|
|
|
|
} //end have
|
|
|
|
return ob_get_clean();
|
|
}
|
|
}
|
|
add_shortcode ('cyber_blog', 'cyber_blog_area' );
|