Skip to content

Instantly share code, notes, and snippets.

View timotheemoulin's full-sized avatar

Timothee Moulin timotheemoulin

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@timotheemoulin
timotheemoulin / outdooractive.html
Created February 20, 2023 09:39
Test OA MAP integration
<script type="text/javascript" defer="true" src="//www.outdooractive.com/alpportal/oa_head.js?proj=api-aupaysdustbernard&amp;key=IRFNHNTB-EMWGMGXI-4OSSAFZ3&amp;lang=fr" done="true">
</script>
<script>
(function (){
$(function () {
oax.api.maps(initOAX);
function initOAX(oamaps, gm) {
@timotheemoulin
timotheemoulin / L.KML.js
Last active April 14, 2022 12:39
custom kml
/*!
Original File https://raw.githubusercontent.com/windycom/leaflet-kml/master/L.KML.js
Copyright (c) 2011-2015, Pavel Shramov, Bruno Bergot - MIT licence
*/
L.KML = L.FeatureGroup.extend({
initialize: function (kml, kmlOptions) {
this._kml = kml;
this._layers = {};
@timotheemoulin
timotheemoulin / sass-display-flex-with-gutter.scss
Last active November 26, 2020 21:54
Render a flex view with unified gutter between elements
/**
* Use this mixin to generate a grid layout with flexbox.
* @param $gutter: the distance between two elements.
* @param $elementsPerLine: the number of elements on every row.
* @param $children: the children selector. Default value every children directly inside the wrapper.
* @param $elementsPerLineSmall: the number of elements on every row on smaller screens.
*/
@mixin display-flex-with-gutter($gutter, $elementsPerLine, $children: '*', $elementsPerLineSmall: 0) {
display: flex;
flex-wrap: wrap;
@timotheemoulin
timotheemoulin / wp-add-categories-in-body-classes.php
Last active November 24, 2020 18:04
[WP] Add the page/post categories in the body classes
<?php
/**
* Add the post/page categories in the body class list.
*
* @param string[] $classes An array of body class names.
*
* @return array
*/
function timwp_add_category_name_to_body_classes( array $classes ): array {
@timotheemoulin
timotheemoulin / wp-woocommerce-add-space-currency.php
Last active November 24, 2020 18:02
woocommerce add space between currency and price
<?php
/**
* Add a spcae after the CHF currency in WooCommerce.
*
* @param string $currency_symbol
* @param string $currency
*
* @return string
*/
@timotheemoulin
timotheemoulin / wp-acf-force-json-load-translation.php
Last active November 24, 2020 18:08
Force ACF fields loaded over JSON fiels to be translated though gettext
<?php
/**
* Force ACF fields loaded over JSON fiels to be translated though gettext
*/
add_filter( 'acf/load_field',
/**
* Force ACF to try to translate fields even when they come from JSON.
*
@timotheemoulin
timotheemoulin / wp-core-translation-override-fr_FR.php
Last active November 24, 2020 18:10
Nasty way to override the core WordPress translations (PHP, gettext, JS, React)
<?php
// Load the translations and store them in the session
/**
* Define the string messages to override
*/
if ( ! isset( $_SESSION['translation-override']['fr_FR'] ) ) {
$_SESSION['translation-override']['fr_FR'] = [];
}
@timotheemoulin
timotheemoulin / disable-fullscreen.js
Last active November 24, 2020 18:10
Gutenberg disable fullscreen as the default editor
/**
* This checks if the fullscreen mode is "on" on page load and toggle it off.
*/
(function (wp) {
const isFullscreenMode = wp.data.select('core/edit-post').isFeatureActive('fullscreenMode');
if (isFullscreenMode) {
wp.data.dispatch('core/edit-post').toggleFeature('fullscreenMode');
}
})(window.wp);
@timotheemoulin
timotheemoulin / php-coalesce-operator.php
Last active April 8, 2020 11:35
Check what really does the coalesce operator
<?php
// undefined variable
echo "?? prints 'default'";
echo "<br>";
var_dump($a ?? 'default');
echo "<br><br>";
echo "?: sends a notice 'undefined variable' and prints 'default'";