Skip to content

Instantly share code, notes, and snippets.

@squarestar
squarestar / install-wp-plugins.php
Last active April 20, 2024 08:02
Programmatically install and activate wordpress plugins
<?php
/**
* Programmatically install and activate wordpress plugins
*
* Usage:
* 1. Edit the $pluginSlugs array at the beginning of this file to include the slugs of all the
* plugins you want to install and activate
* 2. Upload this file to the wordpress root directory (the same directory that contains the
* 'wp-admin' directory).
* 3. Navigate to <your-domain-wordpress-root>/install-wp-plugins.php (If wordpress is installed
@squarestar
squarestar / detect-device.php
Created January 28, 2015 21:16
Detect Mobile Browser
<?php
/**
* Based on this: http://detectmobilebrowsers.com/
*/
$isMobile = false;
$useragent = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT');
if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|
// https://gist.githubusercontent.com/squarestar/b7673d7a7f214bcc6f2f/raw/_resrouces.scss
// https://gist.github.com/squarestar/b7673d7a7f214bcc6f2f
//========================================================================================
// FUNCTIONS <editor-fold desc="FUNCTIONS" defaultstate="collapsed">
//----------------------------------------------------------------------------------------
@function append($item, $append) {
@if $item {
$appended: #{$item}unquote(',') $append;
} @else {
@squarestar
squarestar / 960this!.js
Last active October 7, 2022 19:54
Bookmarklet to resize a website's content to a centred, 960px-wide main column.
(function() {
if(document.querySelector('#wrap960') ) return;
var content = document.body.innerHTML;
var wrap = document.createElement('div');
wrap.setAttribute('id','wrap960');
wrap.setAttribute('style','position:relative;width:960px;margin:auto;');
wrap.innerHTML = content;
document.body.innerHTML = '';
document.body.appendChild(wrap);
})();