Version 1.0.0 - Initialisation du thème WP Theme SEN2
This commit is contained in:
+34
-40
@@ -1,24 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
// Enregistrement des menus
|
// Enregistrement des menus
|
||||||
function portfolio_photo_setup() {
|
function wp_theme_sen2_setup() {
|
||||||
register_nav_menus(array(
|
register_nav_menus(array(
|
||||||
'primary' => 'Menu Principal',
|
'primary' => 'Menu Principal',
|
||||||
));
|
));
|
||||||
add_theme_support('post-thumbnails');
|
add_theme_support('post-thumbnails');
|
||||||
add_theme_support('title-tag');
|
add_theme_support('title-tag');
|
||||||
}
|
}
|
||||||
add_action('after_setup_theme', 'portfolio_photo_setup');
|
add_action('after_setup_theme', 'wp_theme_sen2_setup');
|
||||||
|
|
||||||
// Ajout des feuilles de style et scripts
|
// Ajout des feuilles de style et scripts
|
||||||
function portfolio_photo_scripts() {
|
function wp_theme_sen2_scripts() {
|
||||||
wp_enqueue_style('wordpress-style', get_stylesheet_uri());
|
wp_enqueue_style('wp-theme-sen2-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('wp-theme-sen2-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');
|
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', 'portfolio_photo_scripts');
|
add_action('wp_enqueue_scripts', 'wp_theme_sen2_scripts');
|
||||||
|
|
||||||
// Custom Post Type pour Portfolio
|
// Custom Post Type pour Portfolio
|
||||||
function portfolio_photo_custom_post_type() {
|
function wp_theme_sen2_custom_post_type() {
|
||||||
register_post_type('portfolio',
|
register_post_type('portfolio',
|
||||||
array(
|
array(
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
@@ -31,62 +31,56 @@ function portfolio_photo_custom_post_type() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
add_action('init', 'portfolio_photo_custom_post_type');
|
add_action('init', 'wp_theme_sen2_custom_post_type');
|
||||||
|
|
||||||
// Ajout d'une section "Slogan" dans le Customizer
|
// Ajout d'une section "Slogan" dans le Customizer
|
||||||
function portfolio_photo_customize_register($wp_customize) {
|
function wp_theme_sen2_customize_register($wp_customize) {
|
||||||
// Section pour le slogan
|
$wp_customize->add_section('wp_theme_sen2_slogan_section', array(
|
||||||
$wp_customize->add_section('portfolio_photo_slogan_section', array(
|
'title' => __('Slogan du site', 'wp-theme-sen2'),
|
||||||
'title' => __('Slogan du site', 'wordpress'),
|
|
||||||
'priority' => 30,
|
'priority' => 30,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Setting pour le slogan
|
$wp_customize->add_setting('wp_theme_sen2_slogan', array(
|
||||||
$wp_customize->add_setting('portfolio_photo_slogan', array(
|
|
||||||
'default' => 'Photographier l\'humain, révéler l\'essentiel.',
|
'default' => 'Photographier l\'humain, révéler l\'essentiel.',
|
||||||
'sanitize_callback' => 'sanitize_text_field',
|
'sanitize_callback' => 'sanitize_text_field',
|
||||||
));
|
));
|
||||||
|
|
||||||
// Contrôle pour éditer le slogan
|
$wp_customize->add_control('wp_theme_sen2_slogan_control', array(
|
||||||
$wp_customize->add_control('portfolio_photo_slogan_control', array(
|
'label' => __('Slogan', 'wp-theme-sen2'),
|
||||||
'label' => __('Slogan', 'wordpress'),
|
'section' => 'wp_theme_sen2_slogan_section',
|
||||||
'section' => 'portfolio_photo_slogan_section',
|
'settings' => 'wp_theme_sen2_slogan',
|
||||||
'settings' => 'portfolio_photo_slogan',
|
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
));
|
));
|
||||||
|
|
||||||
// Option pour afficher/masquer le slogan
|
$wp_customize->add_setting('wp_theme_sen2_show_slogan', array(
|
||||||
$wp_customize->add_setting('portfolio_photo_show_slogan', array(
|
|
||||||
'default' => true,
|
'default' => true,
|
||||||
'sanitize_callback' => 'portfolio_photo_sanitize_checkbox',
|
'sanitize_callback' => 'wp_theme_sen2_sanitize_checkbox',
|
||||||
));
|
));
|
||||||
|
|
||||||
$wp_customize->add_control('portfolio_photo_show_slogan_control', array(
|
$wp_customize->add_control('wp_theme_sen2_show_slogan_control', array(
|
||||||
'label' => __('Afficher le slogan', 'wordpress'),
|
'label' => __('Afficher le slogan', 'wp-theme-sen2'),
|
||||||
'section' => 'portfolio_photo_slogan_section',
|
'section' => 'wp_theme_sen2_slogan_section',
|
||||||
'settings' => 'portfolio_photo_show_slogan',
|
'settings' => 'wp_theme_sen2_show_slogan',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
add_action('customize_register', 'portfolio_photo_customize_register');
|
add_action('customize_register', 'wp_theme_sen2_customize_register');
|
||||||
|
|
||||||
// Fonction pour sanitizer le checkbox
|
function wp_theme_sen2_sanitize_checkbox($checked) {
|
||||||
function portfolio_photo_sanitize_checkbox($checked) {
|
|
||||||
return (isset($checked) && $checked === true) ? true : false;
|
return (isset($checked) && $checked === true) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise à jour automatique via Gitea
|
// Mise à jour automatique via Gitea
|
||||||
add_filter('site_transient_update_themes', 'portfolio_photo_check_for_updates');
|
add_filter('site_transient_update_themes', 'wp_theme_sen2_check_for_updates');
|
||||||
function portfolio_photo_check_for_updates($transient) {
|
function wp_theme_sen2_check_for_updates($transient) {
|
||||||
if (empty($transient->checked)) return $transient;
|
if (empty($transient->checked)) return $transient;
|
||||||
|
|
||||||
$theme_data = wp_get_theme('wordpress');
|
$theme_data = wp_get_theme('wp-theme-sen2');
|
||||||
$current_version = $theme_data->get('Version');
|
$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/wp-theme-sen2/raw/branch/main/style.css';
|
||||||
$remote_style_css = 'http://gitea.sen2.lab/admnh/wordpress/raw/branch/main/style.css';
|
|
||||||
$remote_data = wp_remote_get($remote_style_css, array(
|
$remote_data = wp_remote_get($remote_style_css, array(
|
||||||
'sslverify' => false, // Désactive la vérification SSL si ton certificat est auto-signé
|
'sslverify' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!is_wp_error($remote_data) && $remote_data['response']['code'] === 200) {
|
if (!is_wp_error($remote_data) && $remote_data['response']['code'] === 200) {
|
||||||
@@ -94,11 +88,11 @@ function portfolio_photo_check_for_updates($transient) {
|
|||||||
$remote_version = $matches[1] ?? null;
|
$remote_version = $matches[1] ?? null;
|
||||||
|
|
||||||
if ($remote_version && version_compare($current_version, $remote_version, '<')) {
|
if ($remote_version && version_compare($current_version, $remote_version, '<')) {
|
||||||
$transient->response['wordpress'] = array(
|
$transient->response['wp-theme-sen2'] = array(
|
||||||
'theme' => 'wordpress',
|
'theme' => 'wp-theme-sen2',
|
||||||
'new_version' => $remote_version,
|
'new_version' => $remote_version,
|
||||||
'url' => 'http://gitea.sen2.lab/admnh/wordpress',
|
'url' => 'http://gitea.sen2.lab/admnh/wp-theme-sen2',
|
||||||
'package' => 'http://gitea.sen2.lab/admnh/wordpress/archive/main.zip',
|
'package' => 'http://gitea.sen2.lab/admnh/wp-theme-sen2/archive/main.zip',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -12,8 +12,8 @@
|
|||||||
<div class="site-branding">
|
<div class="site-branding">
|
||||||
<h1 class="site-title">
|
<h1 class="site-title">
|
||||||
<a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a>
|
<a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a>
|
||||||
<?php if (get_theme_mod('portfolio_photo_show_slogan', true)) : ?>
|
<?php if (get_theme_mod('wp_theme_sen2_show_slogan', true)) : ?>
|
||||||
<span class="site-slogan"><?php echo esc_html(get_theme_mod('portfolio_photo_slogan', 'Photographier l\'humain, révéler l\'essentiel.')); ?></span>
|
<span class="site-slogan"><?php echo esc_html(get_theme_mod('wp_theme_sen2_slogan', 'Photographier l\'humain, révéler l\'essentiel.')); ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
Theme Name: Portfolio Photo Blanc Cassé
|
Theme Name: WP Theme SEN2
|
||||||
Theme URI: https://ton-site.com/portfolio-photo
|
Theme URI: https://ton-site.com/wp-theme-sen2
|
||||||
Author: Nicolas Houzeau
|
Author: Nicolas Houzeau
|
||||||
Author URI: https://ton-site.com
|
Author URI: https://ton-site.com
|
||||||
Description: Un thème sobre et moderne pour portfolio photo, en blanc cassé. Compatible avec Envira Gallery et personnalisable via le Customizer.
|
Description: Un thème sobre et moderne pour portfolio photo, en blanc cassé. Compatible avec Envira Gallery et personnalisable via le Customizer.
|
||||||
Version: 1.1.0
|
Version: 1.0.0
|
||||||
License: GNU General Public License v2 or later
|
License: GNU General Public License v2 or later
|
||||||
Text Domain: portfolio-photo
|
Text Domain: wp-theme-sen2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Réinitialisation et base */
|
/* Réinitialisation et base */
|
||||||
|
|||||||
Reference in New Issue
Block a user