Skip to content

Instantly share code, notes, and snippets.

@mi-ca
mi-ca / .htaccess
Created April 18, 2017 14:21
Force http 2 https with .htaccess file
# FORCE https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@mi-ca
mi-ca / wordpress clean body classes
Last active January 7, 2022 21:40
remove useless classes from body
<?php
/**
* Add and remove body_class() classes
*/
function mica_body_class($classes) {
// Add post/page slug if not present
if (is_single() || is_page() && !is_front_page()) {
if (!in_array(basename(get_permalink()), $classes)) {
$classes[] = basename(get_permalink());
}
@mi-ca
mi-ca / bandcamp.embed.php
Last active November 12, 2021 03:36
Bandcamp Embed - YouTube Embed & SoundCloud Embed : PHP Classes to auto embed and grab links from Bandcamp, Youtube and Soundcloud
<?php
/**
* Analyse a string , grab Bandcamp links and replace them by embed player
* You may change the html code of the player in buildEmbed method
*
* @author Michael CAILLET <a href="https://mi-ca.ch">mi-ca.ch</a>
* @version 1.0
* @uses $bc=new BandCampEmbed($string);
* echo $bc->getEmbededText();
* // OR
@mi-ca
mi-ca / easing.css
Last active February 8, 2021 10:59
easing.css
root{
--linear: cubic-bezier( 0.250, 0.250, 0.750, 0.750 );
--ease: cubic-bezier( 0.250, 0.100, 0.250, 1.000 );
--easein: cubic-bezier( 0.420, 0.000, 1.000, 1.000 );
--easeout:cubic-bezier( 0.000, 0.000, 0.580, 1.000 );
--easeinout:cubic-bezier( 0.420, 0.000, 0.580, 1.000 );
--outquad:cubic-bezier( 0.250, 0.460, 0.450, 0.940 );
--outcubic:cubic-bezier( 0.215, 0.610, 0.355, 1.000 );
@mi-ca
mi-ca / functions.php
Created November 26, 2020 15:13
Woocommerce cart & checkout skinning
<?php
/* code à ajouter au functions.php
// WOOCOMMERCE special styling
// charge une css à ajouter dans le dossier du child-theme enfold perso APRES celle d'Enfold -> du coup elle prend le dessus
function wc29d_scripts(){
wp_enqueue_style( 'wc29d-css', get_stylesheet_directory_uri() . '/wc_29degres.css', array('avia-style'), null );
}
// chagement des styles et scripts
@mi-ca
mi-ca / .htaccess
Created November 13, 2020 14:22
htaccess subfolder forced to root
#place htaccess in subfolder
<IfModule mod_rewrite.c>
RewriteEngine On
#redirect /folder to root
RewriteRule ^(.*)$ /$1 [R=301,L]
</IfModule>
@mi-ca
mi-ca / disableRoutes.php
Created August 16, 2017 12:16
Wordpress disable useless Routes
<?php
/**
* Disable routes
*/
/**
* disable useless routes
* prevent user to call routes that you don't skin ;)
* comment the lines you skin //
*/
function disable_useless_routes() {
@mi-ca
mi-ca / solution.md
Last active October 23, 2020 09:28
custom woocommerce_thumbnail size (no crop) woocommerce_cart_item_thumbnail woocommerce_thumbnail
<?php
function getLazyLoadImg($id,$lb=true,$size='large',$title=false){
$lbOpen=$lbClose='';
$tiny = wp_get_attachment_image_src( $id, 'thumbnail' ); // récup la miniature
$largeimg = wp_get_attachment_image_src( $id, $size); // récup la taille souhaité
$image_alt = get_post_meta($id, '_wp_attachment_image_alt', TRUE);
if(!$largeimg){ // si pas de taille demandé
@mi-ca
mi-ca / meta_query acf dates repeater field.php
Last active August 22, 2020 11:32
meta_query acf dates repeater field (related futures events)
<?php
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'dates_$", "meta_key LIKE 'dates_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
function getRelatedEvents($id,$taxonomies){
$today = date('Ymd');
$tlist=[];