Skip to content

Instantly share code, notes, and snippets.

View ppezier's full-sized avatar

Patrick Pézier ppezier

View GitHub Profile
@ppezier
ppezier / functions-wp-add_editor_style.php
Created February 16, 2024 11:51
application des styles CSS du site à l'éditeur WP
<?php
function my_setup_theme() {
add_theme_support( 'editor-styles' ); // add support for styles to the editor
add_editor_style( get_stylesheet_uri() ); // add the site styles to the editor
}
add_action( 'after_setup_theme', 'my_setup_theme' );
@ppezier
ppezier / functions-wp-login_head.php
Last active February 16, 2024 11:23
Personnalisation de la page de login (logo et url)
<?php
/**
* Remplacement du logo WP de la page de login
*/
function my_login_head() {
if ( has_custom_logo() ) {
if ( $logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'medium' ) ) {
printf(
@ppezier
ppezier / functions-wp-secure.php
Created February 16, 2024 10:56
Suppression de la balise <meta name="generator">
<?php
remove_action( 'wp_head', 'wp_generator' );
@ppezier
ppezier / functions-wp-remove_emoji_support.php
Created February 16, 2024 10:54
Suppression du support des emojis (scripts & styles)
<?php
// remove emoji support
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
// remove emoji support from admin
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
@ppezier
ppezier / git-tag-delete.sh
Last active February 16, 2024 10:39
Delete local and remote (pushed) git tag
# delete local tag 'vx.y.z'
git tag -d vx.y.z
# delete remote tag
git push --delete origin vx.y.z
@ppezier
ppezier / functions-wp-theme_version.php
Last active February 16, 2024 10:44
Versioning des enqueue js et css dans WordPress
<?php
// constant for the theme version
$theme_data = wp_get_theme();
define( 'THEME_VERSION', $theme_data->get( 'Version' ) );
// use it in the enqueues
wp_enqueue_style( 'style-name', get_stylesheet_uri(), array(), THEME_VERSION );
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), THEME_VERSION, true );
@ppezier
ppezier / web.config
Created September 23, 2018 20:02
Fichier de config IIS avec URL canonique et HTTPS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="CanonicalHTTPSRule" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^www\.my-domain\.com$" negate="true" />
<add input="{HTTPS}" pattern="off" />
@ppezier
ppezier / bump-version.sh
Last active October 24, 2018 16:02 — forked from pete-otaqui/bumpversion.sh
Bump a software project's VERSION, add the CHANGES, and tag with GIT
#!/bin/bash
# Thanks to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
# Original version modified & translated by Patrick Pézier
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# More information about semantic versioning:
@ppezier
ppezier / functions-wp-admin_color_scheme_picker.php
Last active February 16, 2024 10:43
Personnalisation de la barre de choix de couleurs d'interface admin WP
<?php
// suppression de la barre de choix de couleurs d'interface pour les utilisateurs lambda
if ( is_admin() && ! current_user_can( 'manage_options' ) ) {
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
}
// définition de la couleur par défaut de l'interface en "océan"
function set_default_admin_color( int $user_id ) {
$args = array(
@ppezier
ppezier / youtube-api.cfm
Created September 28, 2015 22:39
Récupération des données associées à une vidéo YouTube via l'API v3 en conservant le bon encodage de caractères
<cfscript>
json = deserializeJSON( cfhttp.fileContent.toString("utf-8") );
</cfscript>