2018-10-24 14:35:25 +02:00
|
|
|
<?php
|
2018-10-24 14:50:01 +02:00
|
|
|
/* functions.php
|
2018-10-24 14:35:25 +02:00
|
|
|
*
|
|
|
|
* All the function of Quarante-Douze
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* 1. Sidebar support */
|
|
|
|
|
|
|
|
if ( function_exists('register_sidebar') )
|
|
|
|
register_sidebar(array(
|
2018-10-24 14:56:16 +02:00
|
|
|
'before_widget' => '<section id="%1$s" class="widget %2$s card card-secondary">',
|
|
|
|
'after_widget' => '</section>',
|
2018-10-25 10:49:25 +02:00
|
|
|
'before_title' => '<div class="section card-header"><h1>',
|
|
|
|
'after_title' => '</h1></div>',
|
2018-10-24 14:35:25 +02:00
|
|
|
));
|
2018-10-24 14:50:01 +02:00
|
|
|
|
2018-10-24 17:09:54 +02:00
|
|
|
/* 2. Niveau support (for featured posts) */
|
2018-10-24 14:50:01 +02:00
|
|
|
|
2018-10-24 17:09:54 +02:00
|
|
|
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' );
|
2018-10-25 11:04:50 +02:00
|
|
|
|
2018-10-27 14:29:52 +02:00
|
|
|
/* 3. Excerpt and thumbnail support */
|
2018-10-25 11:04:50 +02:00
|
|
|
|
|
|
|
function wpqdouze_post_supports() {
|
|
|
|
add_post_type_support( 'post', 'excerpt');
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action( 'init', 'wpqdouze_post_supports' );
|
2018-10-25 11:07:13 +02:00
|
|
|
|
2018-10-27 14:32:21 +02:00
|
|
|
add_theme_support( 'post-thumbnails' );
|
|
|
|
set_post_thumbnail_size( 825, 510, true );
|
|
|
|
|
2018-10-25 11:07:13 +02:00
|
|
|
/* 4. Social Network */
|
|
|
|
|
2018-10-25 11:16:16 +02:00
|
|
|
function mypost_social_sharing_buttons($content) {
|
|
|
|
// Fork of mypost_social_sharing_buttons
|
|
|
|
// You can find the original at the following url:
|
|
|
|
// https://mypost_.com/how-to-create-social-sharing-button-without-any-plugin-and-script-loading-wordpress-speed-optimization-goal/
|
|
|
|
|
2018-10-25 11:07:13 +02:00
|
|
|
global $post;
|
|
|
|
if(is_singular() || is_home()){
|
|
|
|
|
|
|
|
// Get current page URL
|
2018-10-25 11:16:16 +02:00
|
|
|
$mypost_URL = urlencode(get_permalink());
|
2018-10-25 11:07:13 +02:00
|
|
|
|
|
|
|
// Get current page title
|
2018-10-25 11:16:16 +02:00
|
|
|
$mypost_Title = htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8');
|
|
|
|
// $mypost_Title = str_replace( ' ', '%20', get_the_title());
|
2018-10-25 11:07:13 +02:00
|
|
|
|
|
|
|
// Get Post Thumbnail for pinterest
|
2018-10-25 11:16:16 +02:00
|
|
|
$mypost_Thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
|
2018-10-25 11:07:13 +02:00
|
|
|
|
|
|
|
// Construct sharing URL without using any script
|
2018-10-25 11:16:16 +02:00
|
|
|
$twitterURL = 'https://twitter.com/intent/tweet?text='.$mypost_Title.'&url='.$mypost_URL.'&via=mypost_';
|
|
|
|
$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$mypost_URL;
|
|
|
|
$bufferURL = 'https://bufferapp.com/add?url='.$mypost_URL.'&text='.$mypost_Title;
|
|
|
|
$whatsappURL = 'whatsapp://send?text='.$mypost_Title . ' ' . $mypost_URL;
|
|
|
|
$linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url='.$mypost_URL.'&title='.$mypost_Title;
|
2018-10-25 11:19:55 +02:00
|
|
|
$diasporaURL = 'http://sharetodiaspora.github.io/?title=' . $mypost_Title . '&url=' . $mypost_URL;
|
2018-10-25 11:07:13 +02:00
|
|
|
|
|
|
|
// Based on popular demand added Pinterest too
|
2018-10-25 11:16:16 +02:00
|
|
|
$pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$mypost_URL.'&media='.$mypost_Thumbnail[0].'&description='.$mypost_Title;
|
2018-10-25 11:07:13 +02:00
|
|
|
|
|
|
|
// Add sharing button at the end of page/page content
|
2018-10-25 11:19:55 +02:00
|
|
|
$content .= '<!-- based on crunchify social sharing. Get your copy here: http://crunchify.me/1VIxAsz -->';
|
2018-10-25 11:11:50 +02:00
|
|
|
$content .= '<div class="reagir share-buttons">';
|
|
|
|
$content .= '<a class="btn btn-twitter" href="'. $twitterURL .'" target="_blank"><i alt="twitter" class="fa fa-fw fa-twitter"></i></a>';
|
|
|
|
$content .= '<a class="btn btn-facebook" href="'.$facebookURL.'" target="_blank"><i alt="facebook" class="fa fa-fw fa-facebook"></i></a>';
|
2018-10-25 11:19:55 +02:00
|
|
|
$content .= '<a title="Share to Diaspora*" class="btn btn-social btn-diaspora" href="'.$diasporaURL.'" target="_blank"><i class="fa fa-fw fa-diaspora"></i></a>';
|
2018-10-25 11:11:50 +02:00
|
|
|
$content .= '<a class="btn btn-whatsapp" href="'.$whatsappURL.'" target="_blank"><i alt="whatsapp" class="fa fa-fw fa-whatsapp"></i></a>';
|
2018-10-25 11:14:02 +02:00
|
|
|
// $content .= '<a class="btn btn-buffer" href="'.$bufferURL.'" target="_blank"><i alt="buffer" class="fa fa-fw fa-buffer"></i></a>';
|
2018-10-25 11:11:50 +02:00
|
|
|
$content .= '<a class="btn btn-linkedin" href="'.$linkedInURL.'" target="_blank"><i alt="linkedin" class="fa fa-fw fa-linkedin"></i></a>';
|
|
|
|
$content .= '<a class="btn btn-pinterest" href="'.$pinterestURL.'" data-pin-custom="true" target="_blank"><i alt="Pin It" class="fa fa-fw fa-pinterest"></i></a>';
|
2018-10-25 11:07:13 +02:00
|
|
|
$content .= '</div>';
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}else{
|
|
|
|
// if not a post/page then don't include sharing button
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
};
|
2018-10-25 11:16:16 +02:00
|
|
|
add_filter( 'the_content', 'mypost_social_sharing_buttons');
|