87 lines
2.5 KiB
PHP
87 lines
2.5 KiB
PHP
<?php
|
|
// FONCTIONS DU THEME
|
|
add_action( 'after_setup_theme', 'monTheme_setup' ); // PERMET L'EXECUTION DE LA FONCTION JUSTE APRES L'ACTIVATION DU THEME
|
|
function monTheme_setup() {
|
|
//Laisser wordpress gérer tag du title
|
|
add_theme_support( 'title-tag' );
|
|
|
|
//Autoriser le support de images dans les posts
|
|
add_theme_support( 'post-thumbnails' );
|
|
set_post_thumbnail_size( 825, 510, true );
|
|
|
|
// Autoriser les posts formats
|
|
add_theme_support( 'post-formats', array(
|
|
'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
|
|
) );
|
|
|
|
// Ajouter une menu
|
|
register_nav_menus( array(
|
|
'menu' => __( 'Menu accueil', 'sbv' ),
|
|
) );
|
|
|
|
/*
|
|
* Switch core wordpress pour les formulaires
|
|
* pour les valider en HTML5.
|
|
*/
|
|
add_theme_support( 'html5', array(
|
|
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
|
|
) );
|
|
}
|
|
|
|
// FONCTION DE DETECTION JS
|
|
function monTheme_js_detection() {
|
|
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
|
|
}
|
|
add_action( 'wp_head', 'monTheme_js_detection', 0 );
|
|
|
|
// FONCTION POUR LIER LES FICHIER CSS ET JS A WORDPRESS
|
|
function monTheme_ajout_scripts() {
|
|
// Charger style.css
|
|
wp_enqueue_style( 'style', get_template_directory_uri().'/style.css' );
|
|
wp_enqueue_style( 'fontAwesome', get_template_directory_uri().'/css/font-awesome.css' );
|
|
// Charger un fichier js
|
|
wp_enqueue_script( 'gmaps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', false );
|
|
wp_enqueue_script( 'app', get_template_directory_uri() . '/js/app.js', false );
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'monTheme_ajout_scripts' );
|
|
|
|
function custom_excerpt_length( $length ) {
|
|
return 20;
|
|
}
|
|
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
|
|
|
|
function ld_advanced_custom_field_in_feed($content) {
|
|
if(is_feed()) {
|
|
$post_id = get_the_ID();
|
|
|
|
$rsscontenu1 = get_field('contenu_1');
|
|
$rssimage = get_field('image');
|
|
$theContent =array(
|
|
"content"=>$content,
|
|
"contenu_1"=>$rsscontenu1,
|
|
"image" =>$rssimage
|
|
);
|
|
$content = json_encode($theContent);
|
|
// $content = 'toto';
|
|
}
|
|
return $content;
|
|
}
|
|
add_filter('the_content','ld_advanced_custom_field_in_feed');
|
|
|
|
|
|
|
|
/**
|
|
* Set post type to 'page' if it was requested.
|
|
*
|
|
* @param object $query
|
|
* @return void
|
|
*/
|
|
function t5_pages_in_feed( &$query )
|
|
{
|
|
if ( isset ( $_GET['post_type'] ) && $_GET['post_type'] === 'page' && is_feed() )
|
|
{
|
|
$query->set( 'post_type', 'page' );
|
|
}
|
|
}
|
|
|
|
add_action( 'pre_get_posts', 't5_pages_in_feed' );
|