Skip to content

Instantly share code, notes, and snippets.

There are three options (that I know of) for automatically enabling a plugin in new sites.

  1. Move the plugin from wp-content/plugins/ to wp-content/mu-plugins/ (MU = Must Use). But then it cannot be deactivated for any site.

  2. Click Network Activate instead of Activate to enable it for all sites. I didn't want to use this though because I didn't want to affect existing sites. Also I couldn't work out how to deactivate it for some sites (although I've read this should be possible).

  3. Write a plugin (in wp-content/mu-plugins/) with a hook that activates the plugin at creation time. This way it only affects new blogs, can be deactivated easily, and I can also set the default configuration at the same time.

@quickredfox
quickredfox / perlincanvas.js
Created December 9, 2012 17:36 — forked from donpark/perlincanvas.js
Rendering Perlin Noise Fast to HTML5 Canvas
/* Following canvas-based Perlin generation code originates from
* iron_wallaby's code at: http://www.ozoneasylum.com/30982
*/
function randomNoise(canvas, x, y, width, height, alpha) {
x = x || 0;
y = y || 0;
width = width || canvas.width;
height = height || canvas.height;
alpha = alpha || 255;
var g = canvas.getContext("2d"),
@quickredfox
quickredfox / express-stylus.html
Created December 4, 2012 22:56 — forked from bentruyman/express-stylus.html
Using Stylus Middleware with Express
<!doctype html>
<html lang="en">
<head>
<title>My Web Page</title>
<meta charset="utf-8">
<link href="/stylesheets/main.css" rel="stylesheet">
</head>
<body>
</body>
</html>
@quickredfox
quickredfox / app.js
Created December 4, 2012 22:55 — forked from marlun/app.js
Using stylus with Express.js
/**
* Module dependencies.
*/
var express = require('express')
, stylus = require('stylus');
var app = express.createServer();
// This must be BEFORE other app.use
@quickredfox
quickredfox / twitter-oauth.js
Created July 26, 2012 03:28 — forked from santosh79/twitter-oauth.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('util');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = process.env['TWITTER_CONSUMER_KEY'];
var _twitterConsumerSecret = process.env['TWITTER_CONSUMER_SECRET'];
console.log("_twitterConsumerKey: %s and _twitterConsumerSecret %s", process.env['TWITTER_CONSUMER_KEY'], process.env['TWITTER_CONSUMER_SECRET']);
@quickredfox
quickredfox / chest.md
Created May 4, 2012 19:24
The Github Pirates' Chest
require.extensions[".json"] = function (module, filename) {
module.exports = JSON.parse(require("fs").readFileSync(filename, "utf8"))
}
var fs = require('fs');
/**
* Offers functionality similar to mkdir -p
*
* Asynchronous operation. No arguments other than a possible exception
* are given to the completion callback.
*/
function mkdir_p(path, mode, callback, position) {
mode = mode || 0777;
function element(value, context) {
var ret = $([]); // $(context) ?
if (value.jquery) {
ret = value;
} else if (value == 'parent') {
ret = $(context).parent();
} else if (value == 'clone') {
ret = $(context).clone().removeAttr('id');
} else if (value == 'window') {
defineImportCallback = (script, callback) ->
unless script.readyState?
script.onload = -> callback()
return
# IE case
script.onreadystatechange = ->
if script.readyState is "loaded" or script.readyState is "complete"
script.onreadystatechange = null
callback()