feat: ajout d'une page a propos

Fixes #7
This commit is contained in:
Kazhnuz 2021-01-03 11:40:57 +01:00
parent 30dce209f0
commit 860038b1e7
4 changed files with 106 additions and 13 deletions

View file

@ -142,3 +142,43 @@ function misha_save_term_fields( $term_id ) {
);
}
// ---------------------------------------------
// Ajout des champs custom pour l'utilisateur
// ---------------------------------------------
add_action( 'show_user_profile', 'crf_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'crf_show_extra_profile_fields' );
function crf_show_extra_profile_fields( $user ) {
$year = get_the_author_meta( 'infodata', $user->ID );
?>
<h3><?php esc_html_e( 'More Info', 'crf' ); ?></h3>
<table class="form-table">
<tr>
<th><label for="infodata"><?php esc_html_e( 'infodata', 'crf' ); ?></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', 'crf_update_profile_fields' );
add_action( 'edit_user_profile_update', 'crf_update_profile_fields' );
function crf_update_profile_fields( $user_id ) {
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return false;
}
update_user_meta( $user_id, 'infodata', $_POST['infodata'] );
}

48
page-about.php Normal file
View file

@ -0,0 +1,48 @@
<?php /* Template Name: page-about */ ?>
<?php get_header(); ?> <!-- ouvrir header,php -->
<main>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<article class="article-content container-article" id="post-<?php the_ID(); ?>">
<h1 class="page-title"><?php the_title(); ?></h1>
<div class="article-body">
<?php the_content(); ?>
</div>
</article>
<?php endwhile; ?>
<?php endif; ?>
</main>
<aside class="sidebar">
<div class="card card-info">
<?php $desc = explode(";", get_the_author_meta( 'infodata' )) ?>
<div class="card-header"><i class="fa fa-info"></i> <?php
if (!empty($desc[1])) {
echo $desc[1];
} else {
the_author();
}
?></div>
<p class="mwarea"><? echo get_avatar( get_the_author_meta('user_email'), $size = '500'); ?></p>
<table style="width:100%" class="table-primary">
<tr>
<th>Pseudo</th>
<td><?php the_author() ?></td>
</tr>
<?php $user_description = $desc[0];
$array_tr = explode ( ",", $user_description);
foreach ($array_tr as $tr) {
echo "<tr>";
$array_td = explode(':', $tr);
echo "<th>" . $array_td[0] . "</th>";
echo "<td>" . $array_td[1] . "</td>";
echo "</tr>";
}
?>
</table>
</div>
<?php include(TEMPLATEPATH . '/components/sidebar-content.php'); ?>
</aside>
<?php get_footer(); ?>

View file

@ -225,15 +225,18 @@ $preview-height: 8*$lineheight;
margin:auto;
}
.mwarea {
padding-bottom: $lineheight;
.avatar {
background: transparent;
}
.mwaimg {
width:100%;
height:auto;
display:block;
margin:auto;
.mwarea {
padding-bottom: $lineheight;
.avatar {
width:80%;
height:auto;
display:block;
margin:auto;
}
}
.cover {

View file

@ -1934,14 +1934,16 @@ ul.breadcrumb, ol.breadcrumb, .breadcrumb {
height: auto;
margin: auto; }
.avatar {
background: transparent; }
.mwarea {
padding-bottom: 1.5rem; }
.mwaimg {
width: 100%;
height: auto;
display: block;
margin: auto; }
.mwarea .avatar {
width: 80%;
height: auto;
display: block;
margin: auto; }
.cover {
width: 100%;