Skip to content

Instantly share code, notes, and snippets.

View ppezier's full-sized avatar

Patrick Pézier ppezier

View GitHub Profile
@ppezier
ppezier / .htaccess
Created September 17, 2015 02:02
Redirection 301 Apache d'une URL avec www vers la même URL (en https) sans les www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
@ppezier
ppezier / .htaccess
Created September 17, 2015 02:04
Redirection 301 Apache d'une URL sans www vers la même URL (en https) avec les www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
@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>
@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 / 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-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 / 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 / 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' );