Skip to content

Instantly share code, notes, and snippets.

@dieppon
dieppon / jquery.browser.js
Last active August 29, 2015 14:03
Add classes to the HTML element based on os, browser's engine and browser client.
jQuery(document).ready(function($) {
// Add browser class to html
if (navigator.userAgent.indexOf('Mac OS X') != -1) {
// Mac
if ($.browser.opera) { $('html').addClass('opera'); }
if ($.browser.webkit) { $('html').addClass('webkit'); }
if ($.browser.mozilla) { $('html').addClass('mozilla'); }
if (/camino/.test(navigator.userAgent.toLowerCase())){ $('html').addClass('camino'); }
if (/chrome/.test(navigator.userAgent.toLowerCase())) { $('html').addClass('chrome'); }
if (navigator && navigator.platform && navigator.platform.match(/^(iPad|iPod|iPhone|iPhone Simulator|iPad Simulator)$/)) {
@dieppon
dieppon / _base-64.scss
Created January 16, 2015 10:15
Base64 background images mixin
@mixin background-64($code,$code-hd:null,$width:null,$height:null,$type:png) {
background-image: url('data:image/' + $type + ';base64,' + $code);
@if $code-hd == null {
} @else {
@media print, (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
background-image: url('data:image/' + $type + ';base64,' + $code-hd);
-webkit-background-size: $width $height;
background-size: $width $height;
}
@dieppon
dieppon / functions.php
Last active January 18, 2017 11:55
Filter paragraphs and breaks on given shortcodes
<?php
function shortcode_empty_paragraph_fix( $content ) {
// define your shortcodes to filter
$shortcodes = array( 'example_shortcode_1', 'example_shortcode_2', 'example_shortcode_3' );
// array of custom shortcodes requiring the fix
$block = join("|",$shortcodes);
// opening tag
@dieppon
dieppon / currency_symbols.php
Last active February 13, 2023 15:46 — forked from gibbs/currency_symbols.php
An array of currency symbols as HTML entities
<?php
$currency_symbols = array(
'AED' => '&#1583;.&#1573;', // ?
'AFN' => '&#65;&#102;',
'ALL' => '&#76;&#101;&#107;',
'AMD' => '&#1380;',
'ANG' => '&#402;',
'AOA' => '&#75;&#122;', // ?
'ARS' => '&#36;',
'AUD' => '&#36;',
@dieppon
dieppon / _extra-large.scss
Created November 2, 2018 10:23
Extra breakpoint for Bootstrap 3
@include min-screen (xl) {
.container{
width: 1410px;
}
.col-xl-1,
.col-xl-2,
.col-xl-3,
.col-xl-4,
.col-xl-5,
.col-xl-6,
@dieppon
dieppon / css-rules.txt
Last active March 25, 2019 12:24
List of css rules grouped with most common rules first
/* Display & Box Model */
-webkit-box-sizing: inherit;
box-sizing: inherit;
content: inherit;
display: inherit;
float: inherit;
clear: inherit;
overflow: inherit;
overflow-wrap: inherit;
overflow-x: inherit;
@dieppon
dieppon / _only-browser.scss
Created May 21, 2019 10:37
Target browsers with css
@mixin only-browser($browser) {
// Firefox
@if $browser == 'mozilla' or $browser == 'firefox' {
@-moz-document url-prefix() { @content; }
}
// IE
@if $browser == 'ie' {
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { @content; }
@dieppon
dieppon / auto-add-terms-to-menu.php
Created January 31, 2020 15:01
Automatically add terms to a menu on Wordpress
<?php
/**
* Display Categories on the Primary menu
*/
add_filter('wp_get_nav_menu_items', function ($items, $menu, $args) {
$primary_menu_id = 47; // the id of the main menu;
$shop_menu_item_id = 1248; // the id of the main item that serves as the parent;
$taxonomy_name = 'product_cat'; // the machine name of the vocavulary you want to use;
@dieppon
dieppon / 0001-Fix-autoptimize-making-new-files-with-600-permission.patch
Last active April 24, 2020 15:27
Fix autoptimize making new files with 600 permissions
From 78f71273f3152048786edac8690ffae22cbd1001 Mon Sep 17 00:00:00 2001
From: Victor Dieppa Garriga <victor-dg@lightflows.co.uk>
Date: Fri, 24 Apr 2020 12:46:23 +0100
Subject: [PATCH] Fix autoptimize making new files with 600 permissions
---
.../autoptimize/classes/autoptimizeCache.php | 33 +++++++++++++------
.../plugins/autoptimize/config/default.php | 4 +--
2 files changed, 25 insertions(+), 12 deletions(-)
@dieppon
dieppon / advanced-menu-widget-php-errors.patch
Last active May 18, 2024 12:39
Fixes walker php error on Wordpress Advanced Menu Widget
diff --git a/class-advanced-menu-walker.php b/class-advanced-menu-walker.php
index 324777f..c97c831 100644
--- a/class-advanced-menu-walker.php
+++ b/class-advanced-menu-walker.php
@@ -160,7 +160,7 @@ class AMW_Related_Sub_Items_Walker extends Walker_Nav_Menu {
}
}
- function walk( $elements, $max_depth ) {
+ function walk( $elements, $max_depth, ...$args ) {