chore: improve functions file
This commit is contained in:
parent
860038b1e7
commit
f47183844d
1 changed files with 51 additions and 41 deletions
|
@ -1,22 +1,30 @@
|
|||
<?php
|
||||
/* functions.php
|
||||
*
|
||||
* All the function of Quarante-Douze
|
||||
* All the function of Kazhnuz.Space
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* 1. Sidebar support */
|
||||
/* 0. Excerpt and thumbnail support
|
||||
*
|
||||
* Ces fonctions ajoutent les fonctionnalités de base du theme,
|
||||
* tel que les extraits et les miniatures.
|
||||
*/
|
||||
|
||||
if ( function_exists('register_sidebar') )
|
||||
register_sidebar(array(
|
||||
'before_widget' => '<section id="%1$s" class="widget %2$s card card-primary">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<div class="section card-header"><h1>',
|
||||
'after_title' => '</h1></div>',
|
||||
));
|
||||
function kspace_post_supports() {
|
||||
add_post_type_support( 'post', 'excerpt');
|
||||
}
|
||||
|
||||
/* 2. Niveau support (for featured posts) */
|
||||
add_action( 'init', 'kspace_post_supports' );
|
||||
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
set_post_thumbnail_size( 825, 510, true );
|
||||
|
||||
/* 1. Niveau support
|
||||
*
|
||||
* Permet d'afficher les niveaux de post pour les post features
|
||||
*/
|
||||
|
||||
register_taxonomy(
|
||||
'niveau',
|
||||
|
@ -41,18 +49,11 @@ register_taxonomy(
|
|||
|
||||
register_taxonomy_for_object_type( 'niveau', 'post' );
|
||||
|
||||
/* 3. Excerpt and thumbnail support */
|
||||
|
||||
function wpqdouze_post_supports() {
|
||||
add_post_type_support( 'post', 'excerpt');
|
||||
}
|
||||
|
||||
add_action( 'init', 'wpqdouze_post_supports' );
|
||||
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
set_post_thumbnail_size( 825, 510, true );
|
||||
|
||||
/* 4. Social Network */
|
||||
/* 2. Réseaux sociaux
|
||||
*
|
||||
* Permet d'afficher les réseaux sociaux en bas du post.
|
||||
*
|
||||
*/
|
||||
|
||||
function mypost_social_sharing_buttons($content) {
|
||||
// Fork of mypost_social_sharing_buttons
|
||||
|
@ -103,25 +104,32 @@ function mypost_social_sharing_buttons($content) {
|
|||
};
|
||||
add_filter( 'the_content', 'mypost_social_sharing_buttons');
|
||||
|
||||
/* 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="misha-text">Plus d\'Info</label>
|
||||
<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', 'misha_edit_term_fields', 10, 2 );
|
||||
add_action( 'post_tag_edit_form_fields', 'kspace_edit_term_fields', 10, 2 );
|
||||
|
||||
function misha_edit_term_fields( $term, $taxonomy ) {
|
||||
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="misha-text">Plus d\'Info</label>
|
||||
<label for="plus-dinfo">Plus d\'Info</label>
|
||||
</th>
|
||||
<td>
|
||||
<input name="plus-dinfo" id="plus-dinfo" type="text" value="' . esc_attr( $value ) .'" />
|
||||
|
@ -130,10 +138,10 @@ function misha_edit_term_fields( $term, $taxonomy ) {
|
|||
</tr>';
|
||||
}
|
||||
|
||||
add_action( 'created_post_tag', 'misha_save_term_fields' );
|
||||
add_action( 'edited_post_tag', 'misha_save_term_fields' );
|
||||
add_action( 'created_post_tag', 'kspace_save_term_fields' );
|
||||
add_action( 'edited_post_tag', 'kspace_save_term_fields' );
|
||||
|
||||
function misha_save_term_fields( $term_id ) {
|
||||
function kspace_save_term_fields( $term_id ) {
|
||||
|
||||
update_term_meta(
|
||||
$term_id,
|
||||
|
@ -143,22 +151,24 @@ function misha_save_term_fields( $term_id ) {
|
|||
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
// Ajout des champs custom pour l'utilisateur
|
||||
// ---------------------------------------------
|
||||
/* 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' );
|
||||
|
||||
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 ) {
|
||||
function kspace_show_extra_profile_fields( $user ) {
|
||||
$year = get_the_author_meta( 'infodata', $user->ID );
|
||||
?>
|
||||
<h3><?php esc_html_e( 'More Info', 'crf' ); ?></h3>
|
||||
<h3><?php esc_html_e( 'More Info', 'kspace' ); ?></h3>
|
||||
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th><label for="infodata"><?php esc_html_e( 'infodata', 'crf' ); ?></label></th>
|
||||
<th><label for="infodata"><?php esc_html_e( 'infodata', 'kspace' ); ?></label></th>
|
||||
<td>
|
||||
<input type="input"
|
||||
id="infodata"
|
||||
|
@ -172,10 +182,10 @@ function crf_show_extra_profile_fields( $user ) {
|
|||
<?php
|
||||
}
|
||||
|
||||
add_action( 'personal_options_update', 'crf_update_profile_fields' );
|
||||
add_action( 'edit_user_profile_update', 'crf_update_profile_fields' );
|
||||
add_action( 'personal_options_update', 'kspace_update_profile_fields' );
|
||||
add_action( 'edit_user_profile_update', 'kspace_update_profile_fields' );
|
||||
|
||||
function crf_update_profile_fields( $user_id ) {
|
||||
function kspace_update_profile_fields( $user_id ) {
|
||||
if ( ! current_user_can( 'edit_user', $user_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
|
Reference in a new issue