Compare commits

...

4 commits

Author SHA1 Message Date
Kazhnuz
0b3132d2bc fix: better mobile handling
Fixes #42
Fixes #41
2023-05-20 12:30:57 +02:00
Kazhnuz
94bb9103cd fix: featured
Fixes #55
2023-05-20 12:02:34 +02:00
Kazhnuz
3b1e2eca06 chore: split functions.php 2023-05-20 11:36:03 +02:00
Kazhnuz
69794803c2 fix: navigation moins redondante
Fixes #57
2023-05-20 11:13:36 +02:00
25 changed files with 526 additions and 386 deletions

View file

@ -17,8 +17,8 @@
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="card card-primary" id="post-<?php the_ID(); ?>">
<div class="card-header"><h1><?php the_title(); ?></h1></div>
<article class="card head-primary" id="post-<?php the_ID(); ?>">
<h1 class="card-header"><?php the_title(); ?></h1>
<div class="flex-that mb">
<div class="article-category">
<?php $category = get_the_category();
@ -28,7 +28,7 @@
</div>
<?php the_excerpt(); ?>
<p class="align-center"> <a href="<?php the_permalink(); ?>" class="btn btn-readmore" title="<?php the_title();?>">Lire l'article</a> </p>
</div>
</article>
<?php endwhile; ?> <?php wp_reset_query(); /*4*/ ?>
</div>

View file

@ -10,6 +10,12 @@
}
?>
<li class="social-li">
<a class="social-link" href="<?php bloginfo('rss2_url'); ?>">
<i class="fa fa-fw fa-rss" aria-hidden="true"></i>
<span class='sr-only'>Flux RSS du site</span>
</a>
</li>
<li class="social-li">
<a class="social-link" href="https://kazhnuz.space/links">
<i class="fa fa-fw fa-ellipsis-h" aria-hidden="true"></i>

View file

@ -18,21 +18,37 @@
}
?>
</ul>
<?php
$parent_categories = get_categories( array(
'orderby' => 'slug',
'order' => 'ASC',
'parent' => 0
) );
foreach( $parent_categories as $parent_category ) {
?>
<ul>
<h2>Liste des catégories</h2>
<h2><?php echo $parent_category->name ?></h2>
<?php
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
'orderby' => 'slug',
'order' => 'ASC',
'parent' => $parent_category->term_id
) );
foreach( $categories as $category ) {?>
<li>
<a class="menu-item" href="<?php echo get_category_link($category->term_id) ?>"><?php echo $category->name ?></a>
</li>
<?php }
foreach( $categories as $category ) {
if ($category->slug != "chapters") {
echo "<!-- " . get_category_link($category->term_id) . " -->";
echo '<li><a class="menu-element" href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
}
}
?>
</ul>
<?php
}
?>
<ul>
<h2>Pages</h2>
<?php

View file

@ -1,4 +1,4 @@
<nav class="container menu toolbar flex-that fg-light">
<nav class="container menu toolbar flex-that fg-light d-none d-flex-sm">
<h2 class="sr-only">Menu des pages</h2>
<ul>
<li>
@ -6,7 +6,6 @@
<i class="fa fa-home" aria-hidden="true"></i><span class="sr-only">Accueil</span>
</a>
</li>
<?php include(TEMPLATEPATH . '/components/navbar-category.php'); ?>
<?php
$listmenu = get_nav_menu_locations();
$menu = wp_get_nav_menu_items($listmenu['top-navbar']);
@ -21,9 +20,21 @@
$listmenu = get_nav_menu_locations();
$menu = wp_get_nav_menu_items($listmenu['top-navbar-2']);
foreach ($menu as $menuElement) {
echo '<li><a href="' . $menuElement->url . '" class="btn btn-navbar">'. $menuElement->title . '</a></li>';
echo '<li class="d-none d-block-sm"><a href="' . $menuElement->url . '" class="btn btn-navbar">'. $menuElement->title . '</a></li>';
}
?>
<li>
<a class="menu-item submenu" href="#">Mes sites <i class="fa fa-caret-down" aria-hidden="true"></i></a>
<ul class="bg-light menu fg-dark">
<?php
$listmenu = get_nav_menu_locations();
$menu = wp_get_nav_menu_items($listmenu['link-menu']);
foreach ($menu as $menuElement) {
echo '<li><a href="' . $menuElement->url . '" class="btn btn-navbar">'. $menuElement->title . '</a></li>';
}
?>
</ul>
</li>
<li><a href="<?php bloginfo('rss2_url'); ?>" class="btn btn-navbar"><i class="fa fa-rss" aria-hidden="true"></i><span class="sr-only">Flux RSS du site</span></a></li>
</ul>
</nav>

View file

@ -1,7 +1,7 @@
<?php if(have_posts()) : ?>
<div class="preview-grid">
<?php while(have_posts()) : the_post(); ?>
<article class="card card-preview card-primary">
<article class="card card-preview head-primary">
<a href="<?php the_permalink(); ?>" class="preview-link">
<h1 class="card-header"><?php the_title(); ?></h1>
<div class="preview-content">

View file

@ -2,4 +2,3 @@
<?php include(TEMPLATEPATH . '/components/sidebar/categories.php'); ?>
<?php include(TEMPLATEPATH . '/components/sidebar/tags.php'); ?>
<?php include(TEMPLATEPATH . '/components/sidebar/archives.php'); ?>
<?php include(TEMPLATEPATH . '/components/sidebar/links.php'); ?>

View file

@ -7,7 +7,7 @@
foreach( $parent_categories as $parent_category ) {
?>
<section class="card head-primary">
<section class="card head-primary d-none d-block-sm">
<h2 class="card-header"><i class="fa fa-folder" aria-hidden="true"></i> <?php echo $parent_category->name ?></h2>
<div class="menu fg-dark">
<ul>

View file

@ -5,336 +5,29 @@
*
*/
include(TEMPLATEPATH . '/functions/posts-support.php');
include(TEMPLATEPATH . '/functions/niveaux.php');
include(TEMPLATEPATH . '/functions/flags.php');
include(TEMPLATEPATH . '/functions/breadcrumb.php');
include(TEMPLATEPATH . '/functions/tags-moreinfo.php');
include(TEMPLATEPATH . '/functions/profile-extra-fields.php');
include(TEMPLATEPATH . '/functions/romans.php');
include(TEMPLATEPATH . '/functions/reading-time.php');
include(TEMPLATEPATH . '/functions/cat-template.php');
/* 0. Excerpt and thumbnail support
*
* Ces fonctions ajoutent les fonctionnalités de base du theme,
* tel que les extraits et les miniatures.
*/
function kspace_post_supports() {
add_post_type_support( 'post', 'excerpt');
}
add_action( 'init', 'kspace_post_supports' );
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 825, 825, true );
/* 1. Niveau support
*
* Permet d'afficher les niveaux de post pour les post features
*/
// 1.1 - Enregistrement de la taxonomy pour le flag
register_taxonomy(
'flag',
'post',
array(
'label' => 'Flag',
'labels' => array(
'name' => 'Flags',
'singular_name' => 'Flag',
'all_items' => 'Tous les flags',
'edit_item' => 'Éditer le flag',
'view_item' => 'Voir le flag',
'update_item' => 'Mettre à jour le flag',
'add_new_item' => 'Ajouter un flag',
'new_item_name' => 'Nouveau flag',
'search_items' => 'Rechercher parmi les flags',
'popular_items' => 'Flags les plus utilisés'
),
'hierarchical' => false
)
);
register_taxonomy_for_object_type( 'flag', 'post' );
// 1.2 - Ajout/Modif du niveau du flag
function flags_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<tr class="form-field">
<th scope="row" valign="top">
<label for="niveau"><?php _e('Niveau du flag'); ?></label>
</th>
<td>
<input type="text" name="term_meta[niveau]" id="term_meta[niveau]" size="25" style="width:60%;" value="<?php echo $term_meta['niveau'] ? $term_meta['niveau'] : ''; ?>"><br />
<span class="description"><?php _e('Le niveau du flag (info, warning, danger…)'); ?></span>
</td>
</tr>
<?php
function wpb_custom_new_menu() {
register_nav_menus(
array(
'top-navbar' => __( 'Navbar (gauche)' ),
'top-navbar-2' => __( 'Navbar (droite)' ),
'link-menu' => __( 'Liste des liens' ),
'footer-pages' => __( 'Pages dans le footer' ),
'social' => __( 'Reseaux sociaux' ),
'social-plus' => __( 'Reseaux sociaux supplémentaires' ),
)
);
}
function flags_taxonomy_custom_fields_add( $taxonomy ) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<div class="form-field">
<label for="term_meta[niveau]"><?php _e('Niveau du flag'); ?></label>
<input type="text" name="term_meta[niveau]" id="term_meta[niveau]" />
<p><?php _e('Le niveau du flag (info, warning, danger…)'); ?>.</p>
</div>
<?php
}
add_action( 'post_tag_edit_form_fields', 'kspace_edit_term_fields', 10, 2 );
// 1.3 - Sauvegarde du niveau du flag
function save_taxonomy_custom_fields( $term_id ) {
if ( isset( $_POST['term_meta'] ) ) {
$t_id = $term_id;
$term_meta = get_option( "taxonomy_term_$t_id" );
$cat_keys = array_keys( $_POST['term_meta'] );
foreach ( $cat_keys as $key ){
if ( isset( $_POST['term_meta'][$key] ) ){
$term_meta[$key] = $_POST['term_meta'][$key];
}
}
//save the option array
update_option( "taxonomy_term_$t_id", $term_meta );
}
}
// Ajout des fields
add_action( 'flag_edit_form_fields', 'flags_taxonomy_custom_fields', 10, 2 );
add_action( 'flag_add_form_fields', 'flags_taxonomy_custom_fields_add' );
add_action( 'created_flag', 'save_taxonomy_custom_fields' );
add_action( 'edited_flag', 'save_taxonomy_custom_fields', 10, 2 );
function kspace_cat_breadcrumb_nav($categoryName, $icon) {
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?php echo site_url(); ?>">kazhnuz.space</a>
</li><li class="breadcrumb-item" aria-current="page">
<span class="active"><i class="fa fa-<?php echo $icon; ?>" aria-hidden="true"></i> <?php echo $categoryName; ?></span>
</li>
</ol>
</nav>
<?php
}
function kspace_cat_breadcrumb($categoryName, $icon) {
?>
<div class="flex-that d-none d-flex-sm pr-half pl-half">
<?php kspace_cat_breadcrumb_nav($categoryName, $icon); ?>
</div>
<?php
}
function kspace_cat_breadcrumb_with_rss($categoryName, $icon, $categoryType, $rssLink) {
?>
<div class="flex-that d-none d-flex-sm pr-half pl-half">
<?php kspace_cat_breadcrumb_nav($categoryName, $icon); ?>
<div class="rss">
<a href="<?php echo $rssLink; ?>" class="btn btn-warning d-block m-0" /><i class="fa fa-rss" aria-hidden="true"></i><span class="sr-only">Flux RSS de <?php echo $categoryType; ?></span></a>
</div>
</div>
<?php
}
/* 3. Plus d'info sur les tags
*
* Permet d'afficher un lien vers plus d'informations.
* Le liens est gardé comme un champ supplémentaire dans les tags.
*
*/
add_action( 'post_tag_add_form_fields', 'kspace_add_term_fields' );
function kspace_add_term_fields( $taxonomy ) {
echo '<div class="form-field">
<label for="plus-dinfo">Plus d\'Info</label>
<input type="text" name="plus-dinfo" id="plus-dinfo" />
<p>Une URL permettant d\'obtenir plus d\'information sur le tag.</p>
</div>';
}
add_action( 'post_tag_edit_form_fields', 'kspace_edit_term_fields', 10, 2 );
function kspace_edit_term_fields( $term, $taxonomy ) {
$value = get_term_meta( $term->term_id, 'plus-dinfo', true );
echo '<tr class="form-field">
<th>
<label for="plus-dinfo">Plus d\'Info</label>
</th>
<td>
<input name="plus-dinfo" id="plus-dinfo" type="text" value="' . esc_attr( $value ) .'" />
<p class="description">Une URL permettant d\'obtenir plus d\'information sur le tag.</p>
</td>
</tr>';
}
add_action( 'created_post_tag', 'kspace_save_term_fields' );
add_action( 'edited_post_tag', 'kspace_save_term_fields' );
function kspace_save_term_fields( $term_id ) {
update_term_meta(
$term_id,
'plus-dinfo',
sanitize_text_field( $_POST[ 'plus-dinfo' ] )
);
}
/* 3. Info supplémentaire sur profil utilisateur
*
* Permet d'afficher sous forme de chaine de caractères des infos supplémentaires qui seront
* transformé en un tableau..
*
*/
add_action( 'show_user_profile', 'kspace_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'kspace_show_extra_profile_fields' );
function kspace_show_extra_profile_fields( $user ) {
$year = get_the_author_meta( 'infodata', $user->ID );
?>
<h3><?php esc_html_e( 'More Info', 'kspace' ); ?></h3>
<table class="form-table">
<tr>
<th><label for="infodata"><?php esc_html_e( 'infodata', 'kspace' ); ?></label></th>
<td>
<input type="input"
id="infodata"
name="infodata"
value="<?php echo esc_attr( $year ); ?>"
class="regular-text"
/>
</td>
</tr>
</table>
<?php
}
add_action( 'personal_options_update', 'kspace_update_profile_fields' );
add_action( 'edit_user_profile_update', 'kspace_update_profile_fields' );
function kspace_update_profile_fields( $user_id ) {
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return false;
}
update_user_meta( $user_id, 'infodata', $_POST['infodata'] );
}
/* 4. Romans
*
* Permet de catégoriser des chapitres ensemble, via une catégorie spécifiques.
*
*/
register_taxonomy('roman', 'post',
array(
'label' => 'Roman',
'labels' => array(
'name' => 'Romans',
'singular_name' => 'Roman',
'all_items' => 'Tous les romans',
'edit_item' => 'Éditer le roman',
'view_item' => 'Voir le roman',
'update_item' => 'Mettre à jour le roman',
'add_new_item' => 'Ajouter un roman',
'new_item_name' => 'Nouveau roman',
'search_items' => 'Rechercher parmi les romans',
'popular_items' => 'Romans les plus utilisés'),
'rewrite' => array('slug' => 'roman'),
'hierarchical' => false,
'public' => true,
'hierarchical' => true,
'show_in_nav_menus' => true,
'has_archive' => true,
)
);
register_taxonomy_for_object_type( 'roman', 'post' );
// 1.2 - Ajout/Modif du niveau du flag
function romans_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<tr class="form-field">
<th scope="row" valign="top">
<label for="niveau"><?php _e('Couverture du roman'); ?></label>
</th>
<td>
<input type="text" name="term_meta[cover]" id="term_meta[cover]" size="25" style="width:60%;" value="<?php echo $term_meta['cover'] ? $term_meta['cover'] : ''; ?>"><br />
<span class="description"><?php _e('La couverture du roman, sous format URL'); ?></span>
</td>
</tr>
<?php
}
function romans_taxonomy_custom_fields_add( $taxonomy ) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<div class="form-field">
<label for="term_meta[cover]"><?php _e('Couverture du roman'); ?></label>
<input type="text" name="term_meta[cover]" id="term_meta[cover]" />
<p><?php _e('La couverture du roman, sous format URL)'); ?>.</p>
</div>
<?php
}
// Ajout des fields
add_action( 'roman_edit_form_fields', 'romans_taxonomy_custom_fields', 10, 2 );
add_action( 'roman_add_form_fields', 'romans_taxonomy_custom_fields_add' );
add_action( 'created_roman', 'save_taxonomy_custom_fields' );
add_action( 'edited_roman', 'save_taxonomy_custom_fields', 10, 2 );
/* 4. Menus custom
*
* Quelques menus custom
*
*/
function wpb_custom_new_menu() {
register_nav_menus(
array(
'top-navbar' => __( 'Navbar (gauche)' ),
'top-navbar-2' => __( 'Navbar (droite)' ),
'link-menu' => __( 'Liste des liens' ),
'footer-pages' => __( 'Pages dans le footer' ),
'social' => __( 'Reseaux sociaux' ),
'social-plus' => __( 'Reseaux sociaux supplémentaires' ),
)
);
}
add_action( 'init', 'wpb_custom_new_menu' );
add_action( 'init', 'wpb_custom_new_menu' );
//estimated reading time
function reading_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);
if ($readingtime == 1) {
$timer = " minute";
} else {
$timer = " minutes";
}
$totalreadingtime = $readingtime . $timer;
return $totalreadingtime;
}
?>

40
functions/breadcrumb.php Normal file
View file

@ -0,0 +1,40 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Breadcrumb supports
// Functions to show a breadcrumb
// @author Kazhnuz
function kspace_cat_breadcrumb_nav($categoryName, $icon) {
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?php echo site_url(); ?>">kazhnuz.space</a>
</li><li class="breadcrumb-item" aria-current="page">
<span class="active"><i class="fa fa-<?php echo $icon; ?>" aria-hidden="true"></i> <?php echo $categoryName; ?></span>
</li>
</ol>
</nav>
<?php
}
function kspace_cat_breadcrumb($categoryName, $icon) {
?>
<div class="flex-that d-none d-flex-sm pr-half pl-half">
<?php kspace_cat_breadcrumb_nav($categoryName, $icon); ?>
</div>
<?php
}
function kspace_cat_breadcrumb_with_rss($categoryName, $icon, $categoryType, $rssLink) {
?>
<div class="flex-that d-none d-flex-sm pr-half pl-half">
<?php kspace_cat_breadcrumb_nav($categoryName, $icon); ?>
<div class="rss">
<a href="<?php echo $rssLink; ?>" class="btn btn-warning d-block m-0" /><i class="fa fa-rss" aria-hidden="true"></i><span class="sr-only">Flux RSS de <?php echo $categoryType; ?></span></a>
</div>
</div>
<?php
}
?>

View file

@ -0,0 +1,30 @@
<?php
// Use a parent category slug if it exists
function child_force_category_template($template) {
$cat = get_query_var('cat');
$category = get_category($cat);
if ( file_exists(TEMPLATEPATH . '/category-' . $category->cat_ID . '.php') ) {
$cat_template = TEMPLATEPATH . '/category-' . $category ->cat_ID . '.php';
} elseif ( file_exists(TEMPLATEPATH . '/category-' . $category->slug . '.php') ) {
$cat_template = TEMPLATEPATH . '/category-' . $category ->slug . '.php';
} elseif ( file_exists(TEMPLATEPATH . '/category-' . $category->category_parent . '.php') ) {
$cat_template = TEMPLATEPATH . '/category-' . $category->category_parent . '.php';
} else {
// Get Parent Slug
$cat_parent = get_category($category->category_parent);
if ( file_exists(TEMPLATEPATH . '/category-' . $cat_parent->slug . '.php') ) {
$cat_template = TEMPLATEPATH . '/category-' . $cat_parent->slug . '.php';
} else {
$cat_template = $template;
}
}
return $cat_template;
}
add_action('category_template', 'child_force_category_template');
?>

91
functions/flags.php Normal file
View file

@ -0,0 +1,91 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Flags supports
// Allow to show a banner with a custom message, via a special taxonomy
//
// Version 0.1
// Register the taxonomy
register_taxonomy(
'flag',
'post',
array(
'label' => 'Flag',
'labels' => array(
'name' => 'Flags',
'singular_name' => 'Flag',
'all_items' => 'Tous les flags',
'edit_item' => 'Éditer le flag',
'view_item' => 'Voir le flag',
'update_item' => 'Mettre à jour le flag',
'add_new_item' => 'Ajouter un flag',
'new_item_name' => 'Nouveau flag',
'search_items' => 'Rechercher parmi les flags',
'popular_items' => 'Flags les plus utilisés'
),
'hierarchical' => false
)
);
register_taxonomy_for_object_type( 'flag', 'post' );
// Add field to be able to change the flags
function flags_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<tr class="form-field">
<th scope="row" valign="top">
<label for="niveau"><?php _e('Niveau du flag'); ?></label>
</th>
<td>
<input type="text" name="term_meta[niveau]" id="term_meta[niveau]" size="25" style="width:60%;" value="<?php echo $term_meta['niveau'] ? $term_meta['niveau'] : ''; ?>"><br />
<span class="description"><?php _e('Le niveau du flag (info, warning, danger…)'); ?></span>
</td>
</tr>
<?php
}
function flags_taxonomy_custom_fields_add( $taxonomy ) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<div class="form-field">
<label for="term_meta[niveau]"><?php _e('Niveau du flag'); ?></label>
<input type="text" name="term_meta[niveau]" id="term_meta[niveau]" />
<p><?php _e('Le niveau du flag (info, warning, danger…)'); ?>.</p>
</div>
<?php
}
add_action( 'post_tag_edit_form_fields', 'kspace_edit_term_fields', 10, 2 );
// Sauvegarde du niveau du flag
function save_taxonomy_custom_fields( $term_id ) {
if ( isset( $_POST['term_meta'] ) ) {
$t_id = $term_id;
$term_meta = get_option( "taxonomy_term_$t_id" );
$cat_keys = array_keys( $_POST['term_meta'] );
foreach ( $cat_keys as $key ){
if ( isset( $_POST['term_meta'][$key] ) ){
$term_meta[$key] = $_POST['term_meta'][$key];
}
}
//save the option array
update_option( "taxonomy_term_$t_id", $term_meta );
}
}
// Ajout des fields
add_action( 'flag_edit_form_fields', 'flags_taxonomy_custom_fields', 10, 2 );
add_action( 'flag_add_form_fields', 'flags_taxonomy_custom_fields_add' );
add_action( 'created_flag', 'save_taxonomy_custom_fields' );
add_action( 'edited_flag', 'save_taxonomy_custom_fields', 10, 2 );
?>

30
functions/niveaux.php Normal file
View file

@ -0,0 +1,30 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Post level support
// Handle featured posts
//
// Version 0.1
register_taxonomy(
'niveau',
'post',
array(
'label' => 'Niveau',
'labels' => array(
'name' => 'Niveaux',
'singular_name' => 'Niveaux',
'all_items' => 'Tous les niveaux',
'edit_item' => 'Éditer le niveau',
'view_item' => 'Voir le niveau',
'update_item' => 'Mettre à jour le niveau',
'add_new_item' => 'Ajouter un niveau',
'new_item_name' => 'Nouveau niveau',
'search_items' => 'Rechercher parmi les niveaux',
'popular_items' => 'Niveaux les plus utilisés'
),
'hierarchical' => false
)
);
register_taxonomy_for_object_type( 'niveau', 'post' );
?>

View file

@ -0,0 +1,20 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Posts supports
// Activate the different elements supported by the posts
//
// Version 0.1
// Support des extraits
function kspace_post_supports() {
add_post_type_support( 'post', 'excerpt');
}
add_action( 'init', 'kspace_post_supports' );
// Support des thumbnails
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 825, 825, true );
?>

View file

@ -0,0 +1,42 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Info supplémentaire sur profil utilisateur
// Permet d'afficher sous forme de chaine de caractères des infos supplémentaires qui seront
// transformé en un tableau.
add_action( 'show_user_profile', 'kspace_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'kspace_show_extra_profile_fields' );
function kspace_show_extra_profile_fields( $user ) {
$year = get_the_author_meta( 'infodata', $user->ID );
?>
<h3><?php esc_html_e( 'More Info', 'kspace' ); ?></h3>
<table class="form-table">
<tr>
<th><label for="infodata"><?php esc_html_e( 'infodata', 'kspace' ); ?></label></th>
<td>
<input type="input"
id="infodata"
name="infodata"
value="<?php echo esc_attr( $year ); ?>"
class="regular-text"
/>
</td>
</tr>
</table>
<?php
}
add_action( 'personal_options_update', 'kspace_update_profile_fields' );
add_action( 'edit_user_profile_update', 'kspace_update_profile_fields' );
function kspace_update_profile_fields( $user_id ) {
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return false;
}
update_user_meta( $user_id, 'infodata', $_POST['infodata'] );
}
?>

View file

@ -0,0 +1,23 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Reading time
// Return the average reading time of an article
//
// Version 0.1
function reading_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);
if ($readingtime == 1) {
$timer = " minute";
} else {
$timer = " minutes";
}
$totalreadingtime = $readingtime . $timer;
return $totalreadingtime;
}
?>

73
functions/romans.php Normal file
View file

@ -0,0 +1,73 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Romans
// Permet de catégoriser des chapitres ensemble, via une catégorie spécifiques.
//
register_taxonomy('roman', 'post',
array(
'label' => 'Roman',
'labels' => array(
'name' => 'Romans',
'singular_name' => 'Roman',
'all_items' => 'Tous les romans',
'edit_item' => 'Éditer le roman',
'view_item' => 'Voir le roman',
'update_item' => 'Mettre à jour le roman',
'add_new_item' => 'Ajouter un roman',
'new_item_name' => 'Nouveau roman',
'search_items' => 'Rechercher parmi les romans',
'popular_items' => 'Romans les plus utilisés'),
'rewrite' => array('slug' => 'roman'),
'hierarchical' => false,
'public' => true,
'hierarchical' => true,
'show_in_nav_menus' => true,
'has_archive' => true,
)
);
register_taxonomy_for_object_type( 'roman', 'post' );
// 1.2 - Ajout/Modif du niveau du flag
function romans_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<tr class="form-field">
<th scope="row" valign="top">
<label for="niveau"><?php _e('Couverture du roman'); ?></label>
</th>
<td>
<input type="text" name="term_meta[cover]" id="term_meta[cover]" size="25" style="width:60%;" value="<?php echo $term_meta['cover'] ? $term_meta['cover'] : ''; ?>"><br />
<span class="description"><?php _e('La couverture du roman, sous format URL'); ?></span>
</td>
</tr>
<?php
}
function romans_taxonomy_custom_fields_add( $taxonomy ) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>
<div class="form-field">
<label for="term_meta[cover]"><?php _e('Couverture du roman'); ?></label>
<input type="text" name="term_meta[cover]" id="term_meta[cover]" />
<p><?php _e('La couverture du roman, sous format URL)'); ?>.</p>
</div>
<?php
}
// Ajout des fields
add_action( 'roman_edit_form_fields', 'romans_taxonomy_custom_fields', 10, 2 );
add_action( 'roman_add_form_fields', 'romans_taxonomy_custom_fields_add' );
add_action( 'created_roman', 'save_taxonomy_custom_fields' );
add_action( 'edited_roman', 'save_taxonomy_custom_fields', 10, 2 );
?>

View file

@ -0,0 +1,50 @@
<?php
/////////////////////////////////////////////////////////////////////////////
// Tags - More Info
// Permet d'afficher un lien vers plus d'informations.
// Le liens est gardé comme un champ supplémentaire dans les tags.
//
add_action( 'post_tag_add_form_fields', 'kspace_add_term_fields_moreinfo' );
function kspace_add_term_fields_moreinfo( $taxonomy ) {
echo '<div class="form-field">
<label for="plus-dinfo">Plus d\'Info</label>
<input type="text" name="plus-dinfo" id="plus-dinfo" />
<p>Une URL permettant d\'obtenir plus d\'information sur le tag.</p>
</div>';
}
add_action( 'post_tag_edit_form_fields', 'kspace_edit_term_fields_moreinfo', 10, 2 );
function kspace_edit_term_fields_moreinfo( $term, $taxonomy ) {
$value = get_term_meta( $term->term_id, 'plus-dinfo', true );
echo '<tr class="form-field">
<th>
<label for="plus-dinfo">Plus d\'Info</label>
</th>
<td>
<input name="plus-dinfo" id="plus-dinfo" type="text" value="' . esc_attr( $value ) .'" />
<p class="description">Une URL permettant d\'obtenir plus d\'information sur le tag.</p>
</td>
</tr>';
}
add_action( 'created_post_tag', 'kspace_save_term_fields_moreinfo' );
add_action( 'edited_post_tag', 'kspace_save_term_fields_moreinfo' );
function kspace_save_term_fields_moreinfo( $term_id ) {
update_term_meta(
$term_id,
'plus-dinfo',
sanitize_text_field( $_POST[ 'plus-dinfo' ] )
);
}
?>

View file

@ -26,19 +26,40 @@
<?php wp_list_pages( 'sort_column=menu_order&depth=1&title_li=' ) ?>
</ul>
</section>
<section class="mb-1">
<h2>Catégories</h2>
<ul>
<?php
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
) );
foreach( $categories as $category ) {
echo '<li><a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
}?>
<?php
$parent_categories = get_categories( array(
'orderby' => 'slug',
'order' => 'ASC',
'parent' => 0
) );
foreach( $parent_categories as $parent_category ) {
?>
<ul>
<h3><?php echo $parent_category->name ?></h3>
<?php
$categories = get_categories( array(
'orderby' => 'slug',
'order' => 'ASC',
'parent' => $parent_category->term_id
) );
foreach( $categories as $category ) {
if ($category->slug != "chapters") {
echo "<!-- " . get_category_link($category->term_id) . " -->";
echo '<li><a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
}
}
?>
</ul>
<?php
}
?>
</section>
<section class="mb-1">
<h2>Archive des articles</h2>

View file

@ -23,6 +23,7 @@ $card-smallpad: $lineheight_rel / 4;
.fa {
margin-right: 0.5em;
}
font-family: $basefont;
}
}

View file

@ -112,7 +112,7 @@
left: 0;
display: none;
padding:0.33rem;
z-index:1;
z-index:2;
}
&:hover ul,

View file

@ -1,14 +1,3 @@
#featured-articles {
display:grid;
grid-template-columns: 1fr;
grid-template-rows: auto;
grid-gap: $lineheight;
padding-bottom: $lineheight;
@include lg() {
grid-template-columns: 1fr 1fr 1fr;
}
}
.preview-featured {
font-size: 0.8rem;

View file

@ -35,10 +35,16 @@
border-top: 6px solid get-color("dark");
background-position: bottom center;
background-repeat: repeat-x;
margin-bottom:1.5rem;
margin-bottom:-1.5rem;
padding-bottom:5rem;
.fa {
font-size: 1rem;
}
@include sm() {
padding-bottom: 0;
margin-bottom: 1.5rem;
}
}
header h1 {

View file

@ -14,6 +14,8 @@
@include sm() {
display:none;
}
z-index:10;
}
.menu-button {
@ -30,10 +32,10 @@
justify-content: center;
aspect-ratio: 1;
border-radius:999px;
opacity: 0.75;
z-index: 12;
&:hover {
opacity:1;
background-color: $color-primary;
}
@include sm() {

View file

@ -1382,7 +1382,8 @@ nav.pagination {
z-index: 1;
overflow: visible;
background-color: transparent;
border-radius: 0; }
border-radius: 0;
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Cantarell, Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; }
.card-header:before {
content: " ";
position: absolute;
@ -1593,7 +1594,7 @@ ul.card-list, .card > ul {
left: 0;
display: none;
padding: 0.33rem;
z-index: 1; }
z-index: 2; }
.toolbar li:hover ul,
.toolbar li ul:hover, .toolbar li:focus-within ul {
visibility: visible;
@ -2463,10 +2464,14 @@ textarea {
border-top: 6px solid #002b36;
background-position: bottom center;
background-repeat: repeat-x;
margin-bottom: 1.5rem; }
margin-bottom: -1.5rem;
padding-bottom: 5rem; }
#page-header .fa {
font-size: 1rem; }
@media (min-width: 576px) {
#page-header {
padding-bottom: 0;
margin-bottom: 1.5rem; } }
header h1 {
border-style: none !important;
font-weight: 800;
@ -2968,15 +2973,6 @@ ul.social {
top: -240px;
margin: auto; } }
#featured-articles {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto;
grid-gap: 1.6rem;
padding-bottom: 1.6rem; }
@media (min-width: 992px) {
#featured-articles {
grid-template-columns: 1fr 1fr 1fr; } }
.preview-featured {
font-size: 0.8rem; }
.preview-featured .preview-link {
@ -3040,7 +3036,8 @@ ul.social {
height: 100vh;
transition: left 0.2s;
padding: 1rem;
overflow: scroll; }
overflow: scroll;
z-index: 10; }
#mobile-sidebar.shown {
left: 0; }
@media (min-width: 576px) {
@ -3060,9 +3057,9 @@ ul.social {
justify-content: center;
aspect-ratio: 1;
border-radius: 999px;
opacity: 0.75; }
z-index: 12; }
.menu-button:hover {
opacity: 1; }
background-color: #CB357D; }
@media (min-width: 576px) {
.menu-button {
display: none; } }