Skip to content

Instantly share code, notes, and snippets.

View dsturm's full-sized avatar

Daniel Sturm dsturm

View GitHub Profile
// ==UserScript==
// @name anti key-grabber
// @version 1
// ==/UserScript==
document.addEventListener('keydown', function(e) {
// only if Command key is pressed
if (!e.metaKey) {
return;
}
@dsturm
dsturm / slider.php
Created August 20, 2015 12:38
Rosa - Slider Shortcode Autoplay
$autoplay = '';
// if shortcode has attribute "autoplay", use autoplay on slider
if ( isset($atts['autoplay']) ) {
$delay = (int)$atts['autoplay'];
$autoplay = ' data-sliderautoplay=""';
if ( 0 < $delay ) {
// if $delay < 1000, suppose value unit is meant to be seconds
if ( 1000 > $delay ) {
$delay*= 1000;
}
@dsturm
dsturm / adminMaps.js
Created October 6, 2015 08:35 — forked from darylldoyle/adminMaps.js
Set zoom level for Advanced Custom Fields map field.
var googleMapsLoaded = false;
var timeout;
if(googleMapsLoaded === false) {
timeout = setInterval("checkVariable()", 500);
}
function doGoogleMapsHook() {
// set current zoom level
var currentZoom = parseInt(jQuery('#acf-field-zoom_level').val());
@dsturm
dsturm / gist:71876b7be343d9e77bf8
Created November 9, 2015 15:08
Advanced Custom Fields PRO for Composer
{
"repositories": [
{
"type": "package",
"package": {
"name": "advanced-custom-fields/advanced-custom-fields-pro",
"version": "5.0",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
@dsturm
dsturm / _cursor-mixins.scss
Created November 14, 2015 21:10 — forked from laurendorman/_cursor-mixins.scss
Sass mixins + classes for cursors – For use with online photo editors, drag/drop tools, text editors and WYSIWYGs.
// Used to @include a cursor within a pre-existing class
@mixin cursor($cursor-type) {
cursor: $cursor-type;
}
// Used to generate cursor classes
@mixin cursor-class($cursor-type) {
.#{$cursor-type}-cursor { cursor: $cursor-type; }
}
@dsturm
dsturm / gist:361094442b1f181e420f
Created March 4, 2016 12:53 — forked from fjarrett/gist:5544469
Return an attachment ID using a URL in WordPress
<?php
/**
* Return an ID of an attachment by searching the database with the file URL.
*
* First checks to see if the $url is pointing to a file that exists in
* the wp-content directory. If so, then we search the database for a
* partial match consisting of the remaining path AFTER the wp-content
* directory. Finally, if a match is found the attachment ID will be
* returned.
*
@dsturm
dsturm / fix-wordpress-permissions.sh
Last active July 29, 2023 06:29 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions (for bedrock)
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_ROOT=$1 # <-- wordpress root directory
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group

bindkey "^?" backward-delete-char

$param_value = isset( $$param['param_name'] ) ? $$param['param_name'] : '';
$param_value = isset(${$param['param_name']}) ? ${$param['param_name']} : '';
@dsturm
dsturm / auth_token.php
Last active April 26, 2017 09:29
Create Auth Tokens with PHP
function create_auth_token($length = 64)
{
if (!$length || intval($length) <= 8) {
$length = 64;
}
$bytes = null;
if (function_exists('random_bytes')) {
$bytes = random_bytes($length);
} elseif (function_exists('mcrypt_create_iv')) {
$bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);