Skip to content

Commit

Permalink
Merge pull request #69 from sinanisler:serkanalgur/issue48
Browse files Browse the repository at this point in the history
Serkanalgur/issue48
  • Loading branch information
serkanalgur committed Aug 22, 2022
2 parents 4e7d984 + cf9e1bd commit c44e719
Show file tree
Hide file tree
Showing 7 changed files with 587 additions and 290 deletions.
197 changes: 117 additions & 80 deletions archive.php
@@ -1,102 +1,139 @@
<?php get_header(); ?>

<?php $termid = get_queried_object_id(); $color_code = get_term_meta($termid, 'color_code', true); ?>
<?php
$termid = get_queried_object_id();
$color_code = get_term_meta( $termid, 'color_code', true );
?>
<div class="category-header" style="background:<?php echo $color_code; ?>">
<div class="container">
<span style="color:white" class="dashicons <?php echo get_term_meta($termid, 'icon_slug', true); ?>"></span>
<span class="category-header-title"><?php if(is_category()){ single_cat_title(); } if(is_tag()){ single_tag_title(); } ?></span>
<p style=""><?php if(is_category() or is_tag()){ echo category_description( ); } ?></p>
</div>
<div class="container">
<span style="color:white" class="dashicons <?php echo get_term_meta( $termid, 'icon_slug', true ); ?>"></span>
<span class="category-header-title">
<?php
if ( is_category() ) {
single_cat_title();
} if ( is_tag() ) {
single_tag_title(); }
?>
</span>
<p style="">
<?php
if ( is_category() or is_tag() ) {
echo category_description(); }
?>
</p>
</div>
</div>


<div class="container index-container">
<div class="row">
<div class="col-md-3 sidebar_index">

<?php include('sidecategories.php'); ?>

<?php //dynamic_sidebar('Sidebar_Index'); ?>


</div>
<div class="col-md-9">

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<a href="<?php the_permalink(); ?>" class="forum-post-index">
<span class="forum-post-index-comment-count">
<span class="dashicons dashicons-welcome-comments"></span><?php echo get_comments_number($post->ID); ?>
</span>
<span class="forum-post-index-category">
<?php
$categories = get_the_terms( $post->ID, 'category' ); $i=1;
foreach( $categories as $c ) {
$termid = $c->term_id;
$color_code = get_term_meta($termid, 'color_code', true);
echo '<span style="background:'.$color_code.'">' . $c->name.'</span>'; if(++$i > 3) break;
} ?>
</span>
<div class="forum-post-index-avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ), 50 ); ?></div>
<div href="<?php the_permalink(); ?>" class="forum-post-index-title"><?php the_title(); ?> </div>
<span class="forum-post-index-author"><b><?php the_author(); ?></b>
<?php $t = get_the_time('U'); echo human_time_diff($t,current_time( 'U' )). __( ' ago','siforum' ); ?>
</span>
</a>
<?php endwhile; else : ?><p><?php esc_html_e( 'No posts here.' ); ?></p><?php endif; ?>




<?php
global $wp_query;

if ( $wp_query->max_num_pages > 1 )
echo '<div class="load_more_posts">'.__( 'Load More','siforum' ).'</div>';
?>




</div>
</div>
<div class="row">
<div class="col-md-3 sidebar_index">

<?php include( 'sidecategories.php' ); ?>

<?php //dynamic_sidebar('Sidebar_Index'); ?>


</div>
<div class="col-md-9">

<?php
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
?>

<a href="<?php the_permalink(); ?>" class="forum-post-index">
<span class="forum-post-index-comment-count">
<span
class="dashicons dashicons-welcome-comments"></span><?php echo get_comments_number( $post->ID ); ?>
</span>
<span class="forum-post-index-category">
<?php
$categories = get_the_terms( $post->ID, 'category' );
$i = 1;
foreach ( $categories as $c ) {
$termid = $c->term_id;
$color_code = get_term_meta( $termid, 'color_code', true );
echo '<span style="background:' . $color_code . '">' . $c->name . '</span>';
if ( ++$i > 3 ) {
break;
}
}
?>
</span>
<div class="forum-post-index-avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ), 50 ); ?></div>
<div href="<?php the_permalink(); ?>" class="forum-post-index-title"><?php the_title(); ?> </div>
<span class="forum-post-index-author"><b><?php the_author(); ?></b>
<?php
$t = get_the_time( 'U' );
//phpcs:disable
echo human_time_diff( $t, current_time( 'U' ) ) . __( ' ago', 'siforum' );
//phpcs:enable
?>

</span>
</a>
<?php
endwhile; else :
?>
<p><?php esc_html_e( 'No posts here.' ); ?></p><?php endif; ?>




<?php
global $wp_query;

if ( $wp_query->max_num_pages > 1 ) {
echo '<div class="load_more_posts">' . __( 'Load More', 'siforum' ) . '</div>';
}
?>




</div>
</div>
</div>


<script>
jQuery(function($){
$('.load_more_posts').click(function(){
<script>
jQuery(function($) {
$('.load_more_posts').click(function() {

var button = $(this),
data = {
'action': 'loadmore',
'query': misha_loadmore_params.posts,
'page' : misha_loadmore_params.current_page
};
$.ajax({
url : misha_loadmore_params.ajaxurl,
data : data,
type : 'POST',
beforeSend : function ( xhr ) {
button.text('<?php _e('Loading...','siforum'); ?>...');
data = {
'action': 'loadmore',
'query': misha_loadmore_params.posts,
'page': misha_loadmore_params.current_page
};

$.ajax({
url: misha_loadmore_params.ajaxurl,
data: data,
type: 'POST',
beforeSend: function(xhr) {
button.text('<?php _e( 'Loading...', 'siforum' ); ?>...');
},
success : function( data ){
if( data ) {
button.text( '<?php _e('Load More','siforum'); ?>' ).prev().before(data);
success: function(data) {
if (data) {
button.text('<?php _e( 'Load More', 'siforum' ); ?>').prev().before(
data);
misha_loadmore_params.current_page++;

if ( misha_loadmore_params.current_page == misha_loadmore_params.max_page )
button.remove();

if (misha_loadmore_params.current_page == misha_loadmore_params
.max_page)
button.remove();
} else {
button.remove();
button.remove();
}
}
});
});
});
</script>
</script>



<?php get_footer(); ?>
<?php get_footer(); ?>
145 changes: 145 additions & 0 deletions class-siforumcustomizer.php
@@ -0,0 +1,145 @@
<?php

// Disable directly access
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! class_exists( 'SiForumCustomizer' ) ) {
class SiForumCustomizer {
public function __construct() {
add_action( 'customize_register', array( $this, 'siforum_customizer_register' ) );
}

public function siforum_customizer_register( $wp_customize ) {

/* ----------PANEL------------- */
$wp_customize->add_panel(
'siforum_panel',
array(
'priority' => 40,
'title' => __( 'Theme Settings', 'siforum' ),
'description' => __( 'SiForum theme settings', 'siforum' ),
)
);
/* /---------PANEL------------- */
/* ----------SECTIONS---------- */
$wp_customize->add_section(
'siforum_theme_settings',
array(
'title' => __( 'Logo & URL & Other', 'cttheme' ),
'panel' => 'siforum_panel',
)
);
$wp_customize->add_section(
'siforum_theme_settings_fontawesome',
array(
'title' => __( 'Fontawesome', 'cttheme' ),
'panel' => 'siforum_panel',
)
);
/* /---------SECTIONS---------- */
/* ----------SETTINGS---------- */
$wp_customize->add_setting(
'siforum_header_image',
array(
'type' => 'theme_mod',
'transport' => 'refresh',
'sanitize_callback' => array( $this, 'siforum_sanitize_image' ),
)
);
$wp_customize->add_setting(
'siforum_header_link',
array(
'type' => 'theme_mod',
'default' => 'https://atarikafa.com',
'transport' => 'refresh',
)
);
$wp_customize->add_setting(
'siforum_header_background_color',
array(
'type' => 'theme_mod',
'transport' => 'refresh',
'default' => '#c10c0c',
)
);
$wp_customize->add_setting(
'siforum_fontawesome_select',
array(
'type' => 'theme_mod',
'transport' => 'refresh',
'default' => 'no',
)
);
/* /---------SETTINGS---------- */
/* ----------CONTROLLERS------- */
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'siforum_header_image_control',
array(
'label' => __( 'Header Logo', 'siforum' ),
'section' => 'siforum_theme_settings',
'settings' => 'siforum_header_image',
)
)
);
$wp_customize->add_control(
'siforum_header_link',
array(
'id' => 'siforum_header_link_control',
'label' => 'Header Link',
'section' => 'siforum_theme_settings',
)
);
// Add Controls
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'siforum_header_background_color_control',
array(
'label' => 'Header Background Color',
'section' => 'siforum_theme_settings',
'settings' => 'siforum_header_background_color',

)
)
);

$wp_customize->add_control(
'siforum_fontawesome_select',
array(
'type' => 'select',
'section' => 'siforum_theme_settings_fontawesome',
'label' => __( 'Enable Font Awesome Usage', 'siforum' ),
'choices' => array(
'no' => __( 'No' ),
'yes' => __( 'Yes' ),
),
)
);
/* /---------CONTROLLERS------- */
}


public function siforum_sanitize_image( $file, $setting ) {

$mimes = array(
'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
'svg' => 'image/svg+xml',
);

//check file type from file name
$file_ext = wp_check_filetype( $file, $mimes );

//if file has a valid mime type return it, otherwise return default
return ( $file_ext['ext'] ? $file : $setting->default );
}

}

$cutoms = new SiForumCustomizer();
}

0 comments on commit c44e719

Please sign in to comment.