Skip to content

Instantly share code, notes, and snippets.

@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 / checkmq.js
Created July 4, 2017 17:35
check media queries with js
/**
* check media queries
* @return {string} tablet | desktop | phone
* @author CAILLET Michael <https://mi-ca.ch>
*/
function checkMQ(){
if(window.matchMedia('(min-width: 40em) and (max-width: 64em)').matches){
return "tablet";
}
else if(window.matchMedia('(min-width: 64em)').matches){
@mi-ca
mi-ca / clean-wp-menu.php
Created June 27, 2017 08:41
clean wp-menu.php
<?php
/* CLEAN MENU */
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
@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 / 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 / slugify.js
Created February 21, 2017 14:15 — forked from vincentorback/slugify.js
Slugify a string - javascript and php
/**
* Slugify a string
* @param {String} text
* @return {String}
*/
export function slugify(text) {
return text.toString().toLowerCase()
.replace(/([å,ä])/g, 'a') // Replace å and ä with aa
.replace(/(ö)/g, 'o') // Replace ö with o
.replace(/\s+/g, '-') // Replace spaces with -
@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());
}
$args = array(
'post_type'=>'events',
'posts_per_page'=>1
);
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) : ?>
<ul>
@mi-ca
mi-ca / _instructions
Last active August 29, 2015 14:13
exercices jQuery : ex 43 - 71 + update v4.0
Instructions pour la mise à jour
des exercices css v3.0
-- 12 jan. 2015 --
*********************************
1° Fichier index.html
line ~36
Ajouter un nouvel élément de menu jQuery
@mi-ca
mi-ca / _ instructions
Last active August 29, 2015 14:07
ex 31 - 42 + update v3.0
Instructions pour la mise à jour
des exercices css v3.0
-- 13 oct. 2014 --
*********************************
1° Fichier: css/mi-ca.css
Ligne 8 changer la valeur du z-index de 1 à 10
z-index:1; -> z-index:10;