Accès direct if (! défini ('apath')) {exit; } / ** * ====== Paramètres de thème de base ===== * / / // Définit les constantes du thème définit ('AnimeNew_version', '1.0.0'); Define ('AnimeNew_Theme_Dir', get_template_directory ()); Define ('AnimeNew_Theme_Url', get_template_directory_uri ()); / ** * Configuration du thème * / fonction AnimeNew_Theme_SetUp () {// Prise en charge de la traduction Load_Theme_TextDomain ('AnimeNew', AnimeNew_Theme_Dir. '/ Language'); // Prise en charge automatique pour alimenter RSS add_Theme_Support («Automatic-Feed-Links»); // Support de titre dynamique add_theme_support ('title-tag'); // Prise en charge des images en surbrillance add_theme_support («post-trimbnaute»); // tailles d'image personnalisées add_image_size ('animenew-card', 400, 225, true); // 16: 9 pour les cartes add_image_size ('AnimeNew-Featred', 800, 450, true); // Posts en vedette add_image_size ('AnimeNew-lage', 1200, 675, true); // Posts individuels // html5 add_theme_support ('html5', array (search-forme ',' commentaire ',' comment-list ',' galerie ',' légende ',' style ',' script ');); // prend en charge le logo personnalisable add_theme_support ('personnalisé-logo', array ('height' => 50, 'width' => 200, 'flex-width' => true, 'flex-height' => true,)); // Prise en charge sélective de rafraîchissement dans Customizer Add_Theme_Support («Persumer-selective-refresh-widgets»); // Enregistrer les menus register_nav_menus (array ('primaire' => __ ('Main menu', 'animeNew'), 'footter' => __ ('Footer menu', 'animenew'),),); } add_acition ('after_setup_theme', 'animenew_theme_setup'); /** * ====== SCRIPTS AND STYLES ===== */FUNCTION ANIMENW_SCRIPTS () {// CSS MAIN WP_Enqueue_style ('animeNew-Style', animenew_theme_url. // font awesome for wp_enqueue_style icons ('font-awesome', 'https://cdnjs.cloudflare.com/ajax/font-awesome/6.0/css/all.min.css', array (), '6.0.0'); (jQuery '), animenew_version, true); // le script de réponse de commentaire if (is_sicular () && commentaire_open () && get_option ('thread_comments')) {wp_enqueue_script ('comment-reply'); }} Add_action ('wp_enqueue_scripts', 'animenew_scripts'); / ** * ====== Widget Zone ===== * / Fonction Animenw_Widgets_Init () {// Sidebar Main Register_sidebar ('name' => __ ('Main Sidebar', 'AnimeNew'), 'Id' => 'Sidebar-1', 'Description' => __ ('Widgets of the Main Sidebar' '
',' After_Widget '=>'
',' Before_title '=>'

',' After_title '=>'

',); // Footer Area Register_sidebar (array ('name' => __ ('footer', 'animenew'), 'id' => 'footer-1', 'Description' => __ ('Jerks of the Footer', 'Animenew'), 'Before_Widget' => '
',' After_Widget '=>'
',' Before_title '=>'

',' After_title '=>'

',); } add_acition ('widgets_init', 'animenew_widgets_init'); / ** * ===== Fonctions auxiliaires ===== * // ** * Obtenir un extrait personnalisé * / fonction animmeNew_get_excerpt ($ limit = 150) {$ Excerpt = get_the_excerpt (); if (strlen ($ Excerpt)> $ limit) {$ Exterpt = substr ($ Excerpt, 0, $ limit). '...'; } return $ extrait; } / ** * Obtenez le temps de lecture estimé * / fonction animmeNew_reading_time () {$ content = get_post_field ('post_content', get_the_id ()); $ Word_count = str_word_count (strip_tags ($ contenu)); $ Reading_time = ceil ($ word_count / 200); // 200 mots par minute if ($ lise_time == 1) {return '1 min Reading'; } else {return $ Reading_time. «Lire min»; }} / ** * Date de format en portugais * / fonction animenew_format_date ($ date = null) {if (! $ Date) {$ date = get_the_date ('ym-d'); } $ mois = array ('01' => 'janvier', '02' => 'février', '03' => 'mars', '04' => 'avril', '05' => 'mai' => 'juin', '07', '08' => 'août', '=>' '=>' 11 '=>' = 11 ',',> '11' => '=>' '11' => '=>' ',>' ',' '11',> '' 11 ',' '11',> '' 11 ',' '11', '' => ',>' '12' => 'décembre'); $ date_parts = explosage ('-', $ date); $ day = $ date_parts [2]; $ mois = $ mois [$ date_parts [1]]; $ An = $ date_parts [0]; Retour $ jour. 'de'. $ mois. 'de'. $ An; } / ** * ===== BreadCruumbs ===== * / Fonction AnimeNew_Breadcruumbs () {if (is_home () || is_front_page ()) return; $ Séparateur = '>'; $ home_title = 'home'; écho '';; } / ** * ====== PAGINY PAGAY ===== * / fonction animmeNew_pagoniation ($ pages = '', $ range = 4) {$ showItems = ($ range * 2) + 1; Global $ paged; If (vide ($ paged)) $ paged = 1; if ($ pages == '') {global $ wp_query; $ pages = $ wp_query-> max_num_pages; if (! $ pages) {$ pages = 1; }} if (1! = $ pages) {echo "\ n ";}} / ** * ====== Performance Optimizations ===== * / / / / / Suppter des chaînes de requête Fonction Animenw_Script_Vernsion ($ Src) {$ Parts = Explode ('? Voir', $ src); return $ part 15, 1); 'Print_emoji_styles');'. "\ n"; if (has_post_thumbnail ()) {$ thumbnail = wp_get_attachment_image_src (get_post_thumbnail_id (), 'grand'); écho ''. "\ n"; }}} Add_action ('wp_head', 'animenew_meta_tags'); / ** * ====== WP_HEAD ===== * ///// Supprime les liens inutiles Remove_Action ('WP_head', 'WP_Generator'); Retire_action ('wp_head', 'rsd_link'); Retire_action ('wp_head', 'wlwmanifest_link'); Retire_action ('wp_head', 'wp_shortlink_wp_head'); / ** * ===== Personnalisation de l'administrateur ===== * /// Ajouter une miniature dans la fonction AnimeNew_Add_Addd_Column ($ Columns) Post Listing {$ colonnes ['Thumbnail'] = 'image'; Retourner $ colonnes; } add_filter ('manager_posts_columns', 'animenew_add_thumbnail_column'); Fonction animmenew_show_thumbnail_column ($ colonnen_name, $ post_id) {if ($ column_name == 'thumbnail') {if (has_post_thumbnail ($ post_id))); } else {echo 'sans image'; }}} Add_action ('manage_posts_custom_column', 'animenew_show_thumbnail_column', 10, 2); / ** * ====== Compatibilité avec les plugins ===== * // ** * Compatibilité avec yoast seo * / fonction animmenew_yoast_compatibilité () {// supprimer le paincruumbs propre si yoast est actif if (function_exists ('yoast_breadcrub'))) )vas «animenew_breadcruumbs»); // Utilisez la fonction Yoast BreadCruumbs animeNew_yoast_breadcruumbs () {if (function_exists ('yoast_breadcruumb') &&! is_front_page ()) {yoast_breadcruumb (''); }} add_action ('animenew_breadcruumbs', 'animenew_yoast_breadcruumbs'); }} Add_action ('init', 'animenew_yoast_compatibilité'); / ** * Compatibilité avec WP Rocket * / Fonction Animenew_WP_Rocket_Compatibity () {// Ajouter une précharge pour les ressources critiques add_action ('wp_head', function () {echo ''. "\ n"; écho ''. "\ n"; écho ''. "\ n"; }, 1); } Add_action ('init', 'animenew_wp_rocket_compatibilité'); / ** * Compatibilité avec wooCommerce * / fonction animmenw_woocommerce_support () {add_theme_support ('wooCommerce'); add_theme_support ('wc - product-gallery-zoom'); add_theme_support ('wc - produit-galllery-mightbox'); add_theme_support ('wc - produit-gal-gallery-slider'); } add_action ('after_setup_theme', 'animenew_woocommerce_support'); / ** * Compatibilité avec le formulaire de contact 7 * / fonction animenew_cf7_compatibity () {// Styles personnalisés pour les formulaires add_action ('wp_enqueue_scripts', function () {if (function_exists ('wpcf7_enqueue_scripts'))) '.wpcf7-forme {background: var (- (- secondaire-couleur); rembourrage: 2re; border-radius: var (-border-radius); border: 1px solide var (-border-color); .wpcf7 formel textarea {background: var (-background-darker); border: 1px solid var (-border-color);.. "Soumettre"] {fond: var (-primary-color); Array ('Container' => 'Posts-Container', 'Render' => 'Animenew_infinite_Scroll_render', 'Footer' => 'Page',)); 'AnimeNew_Jetpack_Compatibilité'); get_template_part ('template-partits / contenu', 'carte'); }} / ** * Compatibilité avec l'élément * / fonction animeNew_elementor_compatibilité () {// widget elementor widget support add_theme_support ('élément'); // Enregistrer les zones de widget pour if (did_action ('elementar / chargé')) {add_action ('elementor / widgets / widgets_geisterd', function () {// registre widgets personnalisés si nécessaire}); }} Add_action ('init', 'animenew_elementor_compatibilité'); / ** * Compatibilité des plugins de cache * / fonction animenew_cache_compatibity () {// optimisations pour w3 cache total, wp super cache, etc. if (! Is_admin ()) {// add cache Headders Add_action ('Cache-ContracTrol: public, max-age = 3600'); () {// rankmath, tout en un seul SEO, etc. retire_action ('wp_head', 'animenew_meta_tags');); Targets de chèvre;} // Sinon, utilisez nos balises add_action (WP_HEAD ',' Animenew_Meta_Tags '); GDPR Cookie Compliance, etc. add_action ('wp_footer', function () {if (function_exists ('cn_cookies_accepted') || function_exists ('gdpr_cookie_is_accepted'))) {echo 'gdpr_cookie_is_accepted'))) {echo '';; }}); } add_action ('init', 'animenew_gdpr_compatibilité'); / ** * ===== Ajax Handlers pour plugins ===== * // ** * ajax pour augmenter les vues * / fonction animmenew_ajax_increment_views () {check_ajax_referent ('animenew_nonce', 'noce'); $ post_id = intval ($ _ post ['post_id']); if ($ post_id) {$ vues = get_post_meta ($ post_id, 'vues', true); $ vues = $ vues? $ vues + 1: 1; Update_post_meta ($ post_id, «vues», $ vues); wp_send_json_success (array ('vues' => $ vues)); } wp_send_json_error (); } Add_action ('wp_ajax_increment_post_views', 'animenew_ajax_increment_vings'); add_acition ('wp_ajax_nopriv_increment_post_vings', 'animenew_ajax_increment_vings'); / ** * ajax pour la recherche instantanée * / fonction animenew_ajax_instant_search () {check_ajax_referent ('animenew_nonce', 'noce'); $ query = Sanitize_text_field ($ _ post ['query']); $ poters = get_posts ('post_type' => 'post', 'post_page' => 5, 's' => $ query, 'post_status' => 'publish')); $ results = array (); Foreach ($ publie comme $ post) {$ Results [] = array ('title' => get_the_title ($ post-> id), 'url' => get_permalink ($ post-> id), 'thumbnail' => get_the_the_thumbnail_url ($ post-> id, 'catégorie' => = => => => => Getthe [0] -> Nom ?? Chargez plus de messages * / fonction AnimeNew_Ajax_Load_more_Posts () {Check_ajax_refers ('AnimeNew_Nonce', 'Noce'); 'Post_status' => 'Publish'); (). 'animenew_ajax_load_more_posts'); {Wp_add_inline_script ('animenew-script', '// attendez le chargement de linge avant de démarrer document.addeventListener ("domContentEded", function () {setTimeout (function () {// re-initialize events après traduction if (window.animeNewupils) {window.animenewupils.reinitafterTransLation (); // 2. Ajouter des classes à des éléments qui ne doivent pas être traduits add_oction ('wp_head', function () {echo '';; }); // 3. Meta Tags for Lingise add_action ('wp_head', function () {echo ''. "\ n"; écho ''. "\ n"; }, 5); // 4. Configurations de cache compatibles add_filter ('lingise_cache_enabled', '__return_true'); // 5. Assurez-vous des URL correctes pour différentes langues add_filter ('thème_mod_custom_logo', 'animenew_linge_logo_ull'); add_filter ('home_url', 'animenew_linge_home_url', 10, 2); }} Add_action ('init', 'animenew_linge_compatibilité'); / ** * Ajuster l'URL du logo pour différentes langues * / fonction animenew_linge_logo_url ($ logo_id) {if (function_exists ('linguise_get_current_language_code')) {$ current_lang = lingise_get_current_lanage_code (); if ($ current_lang && $ current_lang! == 'pt') {// Continuez même bientôt pour toutes les langues return $ logo_id; }} return $ logo_id; } / ** * Assurez-vous des URL correctes pour la maison * / fonction animenew_linge_home_url ($ url, $ path) {if (function_exists ('linguise_get_current_language_code')))) {$ current_lang = lingise_get_language_code (); if ($ current_lang && $ current_lang! == 'pt') {// Lingise gère déjà les URL URL URL; }} Return $ url; } / ** * Textes traduits à partir du thème * / fonction animenew_linge_transladable_strings () {// record strings for Automatic traduction $ strings = array ('' actualités '=> __ (' animenew '),' voir plus '=> __ (' ' `` Animenew ''), 'Résultat de' => __ ('' Recherche Résultats pour ',' Animenew '),' Related Posts '=> __ (' LELL POSTS ',' AnimeNew '),' Page non fondée '=> __ (Page non trouvée', 'animenew'),, 'menu' => '(' menu ',', '),'),,, menu '=>' (menu ',', '),'),,, menu '=>' (menu ',', '),'),,, menu '=>' (menu ','), '),, " `` Recherche '=> __ (' search ',' animenew '),' => __ ('by', ',' in '=> __ (' 'animenew'), 'tags' => __ ('tags', 'animenew'), 'home' => __ ('home', 'animenew'), 'Contact' => __ ('Contact', ',' Animenew '),'), '),') Politique de confidentialité '=> __ (Privacy Polycy', 'Animenew'), 'Termes d'utilisation' => __ ('Termes d'utilisation', 'Animenew'); lingise_get_available_langue écho ''. "\ n"; } // Ajouter un écho x-default ''. "\ n"; }} Add_action ('wp_head', 'animenew_linge_hreflang'); / ** * Paramètres spécifiques pour Linguise * / Fonction AnimeNew_linge_Settings () {// Éléments qui ne doivent pas être traduits add_action ('wp_head', function () {echo '';; }); } Add_action ('wp_head', 'animenew_linge_settings', 20); ?