'Menu Principal', )); add_theme_support('post-thumbnails'); add_theme_support('title-tag'); } add_action('after_setup_theme', 'portfolio_photo_setup'); // Ajout des feuilles de style et scripts function portfolio_photo_scripts() { wp_enqueue_style('wordpress-style', get_stylesheet_uri()); wp_enqueue_style('wordpress-google-fonts', 'https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&display=swap'); wp_enqueue_style('wordpress-font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css'); } add_action('wp_enqueue_scripts', 'portfolio_photo_scripts'); // Custom Post Type pour Portfolio function portfolio_photo_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', 'portfolio_photo_custom_post_type'); // Ajout d'une section "Slogan" dans le Customizer function portfolio_photo_customize_register($wp_customize) { // Section pour le slogan $wp_customize->add_section('portfolio_photo_slogan_section', array( 'title' => __('Slogan du site', 'wordpress'), 'priority' => 30, )); // Setting pour le slogan $wp_customize->add_setting('portfolio_photo_slogan', array( 'default' => 'Photographier l\'humain, révéler l\'essentiel.', 'sanitize_callback' => 'sanitize_text_field', )); // Contrôle pour éditer le slogan $wp_customize->add_control('portfolio_photo_slogan_control', array( 'label' => __('Slogan', 'wordpress'), 'section' => 'portfolio_photo_slogan_section', 'settings' => 'portfolio_photo_slogan', 'type' => 'text', )); // Option pour afficher/masquer le slogan $wp_customize->add_setting('portfolio_photo_show_slogan', array( 'default' => true, 'sanitize_callback' => 'portfolio_photo_sanitize_checkbox', )); $wp_customize->add_control('portfolio_photo_show_slogan_control', array( 'label' => __('Afficher le slogan', 'wordpress'), 'section' => 'portfolio_photo_slogan_section', 'settings' => 'portfolio_photo_show_slogan', 'type' => 'checkbox', )); } add_action('customize_register', 'portfolio_photo_customize_register'); // Fonction pour sanitizer le checkbox function portfolio_photo_sanitize_checkbox($checked) { return (isset($checked) && $checked === true) ? true : false; } // Mise à jour automatique via Gitea add_filter('site_transient_update_themes', 'portfolio_photo_check_for_updates'); function portfolio_photo_check_for_updates($transient) { if (empty($transient->checked)) return $transient; $theme_data = wp_get_theme('wordpress'); $current_version = $theme_data->get('Version'); // Remplace par l'URL de ton dépôt Gitea (raw) $remote_style_css = 'http://gitea.sen2.lab/admnh/wordpress/raw/branch/main/style.css'; $remote_data = wp_remote_get($remote_style_css, array( 'sslverify' => false, // Désactive la vérification SSL si ton certificat est auto-signé )); 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['wordpress'] = array( 'theme' => 'wordpress', 'new_version' => $remote_version, 'url' => 'http://gitea.sen2.lab/admnh/wordpress', 'package' => 'http://gitea.sen2.lab/admnh/wordpress/archive/main.zip', ); } } return $transient; } ?>