Skip to content

Instantly share code, notes, and snippets.

@wpscholar
wpscholar / functions.php
Last active March 1, 2021 13:26
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
@mfields
mfields / theme-options.php
Created January 31, 2013 01:12
Sample theme options page for WordPress Themes.
<?php
/**
* _s Theme Options
*
* @package _s
* @since _s 1.0
*/
/**
* Register the form setting for our _s_options array.
@nsisodiya
nsisodiya / iframe.js
Last active December 16, 2020 14:45
Dynamic IFRAME Using Dynamic Document Fragment when html & css are provided as Strings
var html = '<h1 class="nar">Narendra</div>';
var css = '.nar { color: red; background: url("http://google.com/images/google_favicon_128.png") repeat scroll 0 0 transparent;}';
var nodeWhereToAppend = document.body;
//var nodeWhereToAppend = document.getElementById("container");
function CreateIframe(html, css, nodeWhereToAppend){
var fragment = document.createDocumentFragment();
var iframe = document.createElement('iframe');
iframe.onload = function(){
var doc = this.contentWindow.document;
@tessas-capella
tessas-capella / resiglogtrace.js
Last active October 12, 2015 08:18
John Resig's handy catch-all log (As seen in: "Secrets of the Javascript Ninja"). Amended with my own line number add-on for Chrome & Firefox. 2013.03.01 update: just added css support for chrome and console.time and console.timeEnd so you can track how fast your code is!
//John Resig's handy catch-all log (amended with my own linenumber add-on + new and improved CSS support for chrome!):
function trace() {//just cause I like "trace" better than his "log"
try {
var dA = navigator.userAgent.toLowerCase(), fF = dA.match(/(firefox)/);
//show linenumber in FireFox & Chrome
if(fF){var lnVal = 1;}else{var lnVal = 2;}//fireFox sorts Error stack differently
var linenumber = new Error().stack.split("\n")[lnVal], index = linenumber.indexOf("at "), clean = linenumber.slice(index+2, linenumber.length), cleaner = clean.split(":");
console.log.apply(console, arguments);
if(fF){
console.log("--------------------------------------------------------------- line:"+Array.prototype.slice.call(cleaner)[2]);
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@karthikshiraly
karthikshiraly / myapp.html
Created January 11, 2012 08:18
Very simple, basic backbone.js example with comments - Demonstrates how to get a value from one porition of UI and update it in another portion of UI via the model
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Backbone.js example</title>
<link rel="stylesheet" type="text/css" href="css/sunny/jqueryui.min.css"/>
</head>
<body>
<!-- "slider" is a jquery slider -->
<div id="slider"></div>
@irae
irae / _Stay_standalone.md
Last active January 29, 2024 12:38 — forked from kylebarrow/example.html
Stay Standalone: Prevent links in standalone web apps opening Mobile Safari

#Stay Standalone

A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.

@necolas
necolas / snippet.js
Created June 14, 2011 20:36
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
// HOWTO: load LABjs itself dynamically!
// inline this code in your page to load LABjs itself dynamically, if you're so inclined.
(function (global, oDOC, handler) {
var head = oDOC.head || oDOC.getElementsByTagName("head");
function LABjsLoaded() {
// do cool stuff with $LAB here
}