Skip to content

Instantly share code, notes, and snippets.

@larsmqller
larsmqller / my-plugin-snippet.php
Created November 4, 2015 12:02 — forked from szbl/my-plugin-snippet.php
How I auto-include my library of "controllers" in a theme/plugin.
<?php
// include all PHP files in ./lib/ directory:
foreach ( glob( dirname( __FILE__ ) . '/lib/*.php' ) as $file )
include $file;
@larsmqller
larsmqller / countCSSRules.js
Created October 6, 2015 12:30 — forked from psebborn/countCSSRules.js
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@larsmqller
larsmqller / gist:0172157a2737dd8755f7
Created June 17, 2015 16:15
Load translation files from your child theme instead of the parent theme
function my_child_theme_locale() {
load_child_theme_textdomain( 'my_child_theme', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'my_child_theme_locale' );
<?php
/*
Check if protocol is https
Nb: port 443 does not guarantee connection is encrypted
http://stackoverflow.com/questions/1175096/how-to-find-out-if-you-are-using-https-without-serverhttps#answer-2886224
*/
function isSecure() {
return
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|| $_SERVER['SERVER_PORT'] == 443;