EcoWP/functions.php

122 lines
3.2 KiB
PHP

<?php
/**
* Functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
*/
if ( ! defined( 'MATT_VERSION' ) ) {
// Replace the version number of the theme on each release.
define( 'MATT_VERSION', '1.0.0' );
}
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function matt_setup() {
add_theme_support( 'editor-styles' ); // if you don't add this line, your stylesheet won't be added
add_editor_style( 'css/content.css' ); // tries to include style-editor.css directly from your theme folder
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'menu-1' => esc_html( 'Primary' ),
'menu-2' => esc_html( 'Footer' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'gallery',
'caption',
'style',
'script',
)
);
}
add_action( 'after_setup_theme', 'matt_setup' );
/**
* Enqueue scripts and styles.
*/
function matt_scripts() {
wp_enqueue_style( 'matt-style', get_stylesheet_uri(), array(), MATT_VERSION );
// Ajout des CSS du thèmes
wp_enqueue_style('matt-normalize', get_template_directory_uri(). '/css/normalize.css', array(), MATT_VERSION);
wp_enqueue_style('matt-content', get_template_directory_uri(). '/css/content.css', array(), MATT_VERSION);
// Suppression des styles Gutenberg de base
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
}
add_action( 'wp_enqueue_scripts', 'matt_scripts' );
// Load only used blocks styles
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
//remove prefix from archive titles
add_filter( 'get_the_archive_title_prefix', '__return_empty_string' );
/**
******** Enhancing scripts **********
**/
/**
* Cleanup unnecessary functionalities
*/
require get_template_directory() . '/inc/cleanup.php';
/**
* Honeypot for comments
*/
require get_template_directory() . '/inc/comments-honeypot.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/*** Change a few FR translations *********/
function filter_gettext($translated, $original, $domain) {
// Use the text string exactly as it is in the translation file
if ( $translated == "Laisser un commentaire" ) {
$translated = "Commenter";
}
return $translated;
}
add_filter('gettext', 'filter_gettext', 10, 3);