'Menu Principal', )); add_theme_support('post-thumbnails'); add_theme_support('title-tag'); } add_action('after_setup_theme', 'wp_theme_sen2_setup'); // Ajout des feuilles de style et scripts function wp_theme_sen2_scripts() { wp_enqueue_style('wp-theme-sen2-style', get_stylesheet_uri()); wp_enqueue_style('wp-theme-sen2-google-fonts', 'https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&display=swap'); wp_enqueue_style('wp-theme-sen2-font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css'); } add_action('wp_enqueue_scripts', 'wp_theme_sen2_scripts'); // Custom Post Type pour Portfolio function wp_theme_sen2_custom_post_type() { register_post_type('portfolio', array( 'labels' => array( 'name' => 'Portfolio', 'singular_name' => 'Projet' ), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor', 'thumbnail'), ) ); } add_action('init', 'wp_theme_sen2_custom_post_type'); // Ajout d'une section "Slogan" dans le Customizer function wp_theme_sen2_customize_register($wp_customize) { $wp_customize->add_section('wp_theme_sen2_slogan_section', array( 'title' => __('Slogan du site', 'wp-theme-sen2'), 'priority' => 30, )); $wp_customize->add_setting('wp_theme_sen2_slogan', array( 'default' => 'Photographier l\'humain, révéler l\'essentiel.', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('wp_theme_sen2_slogan_control', array( 'label' => __('Slogan', 'wp-theme-sen2'), 'section' => 'wp_theme_sen2_slogan_section', 'settings' => 'wp_theme_sen2_slogan', 'type' => 'text', )); $wp_customize->add_setting('wp_theme_sen2_show_slogan', array( 'default' => true, 'sanitize_callback' => 'wp_theme_sen2_sanitize_checkbox', )); $wp_customize->add_control('wp_theme_sen2_show_slogan_control', array( 'label' => __('Afficher le slogan', 'wp-theme-sen2'), 'section' => 'wp_theme_sen2_slogan_section', 'settings' => 'wp_theme_sen2_show_slogan', 'type' => 'checkbox', )); } add_action('customize_register', 'wp_theme_sen2_customize_register'); function wp_theme_sen2_sanitize_checkbox($checked) { return (isset($checked) && $checked === true) ? true : false; } // Mise à jour automatique via Gitea add_filter('site_transient_update_themes', 'wp_theme_sen2_check_for_updates'); function wp_theme_sen2_check_for_updates($transient) { if (empty($transient->checked)) return $transient; $theme_data = wp_get_theme('wp-theme-sen2'); $current_version = $theme_data->get('Version'); $remote_style_css = 'http://gitea.sen2.lab/admnh/wp-theme-sen2/raw/branch/main/style.css'; $remote_data = wp_remote_get($remote_style_css, array( 'sslverify' => false, )); if (!is_wp_error($remote_data) && $remote_data['response']['code'] === 200) { preg_match('/Version:\s*(.*)/i', $remote_data['body'], $matches); $remote_version = $matches[1] ?? null; if ($remote_version && version_compare($current_version, $remote_version, '<')) { $transient->response['wp-theme-sen2'] = array( 'theme' => 'wp-theme-sen2', 'new_version' => $remote_version, 'url' => 'http://gitea.sen2.lab/admnh/wp-theme-sen2', 'package' => 'http://gitea.sen2.lab/admnh/wp-theme-sen2/archive/main.zip', ); } } return $transient; } function wp_theme_sen2_setup() { register_nav_menus(array( 'primary' => 'Menu Principal', 'secondary' => 'Menu Secondaire' // Nouveau menu )); add_theme_support('post-thumbnails'); add_theme_support('title-tag'); } ?>