Skip to content

Instantly share code, notes, and snippets.

View ControlledChaos's full-sized avatar

Controlled Chaos Design ControlledChaos

View GitHub Profile
@scottjehl
scottjehl / whichones.js
Created August 21, 2020 15:40
which elements are wider than the viewport?
var list = [];
document.querySelectorAll("body *")
.forEach(function(elem){
if(elem.getBoundingClientRect().width > document.body.getBoundingClientRect().width){
list.push(elem.outerHTML.split('>')[0] + '>');
}
});
confirm( "these elements are wider than the viewport:\n\n " + list.join("\n") )
@ControlledChaos
ControlledChaos / README.md
Last active August 25, 2019 23:59
Display a random logo image from an ACF gallery field.

Random ACF Logo w/ Customizer Fallback

Displays a random logo image from a gallery field. Falls back first to the logo in the Customizer, then to a theme default file.

Requirements

  • Requires Advanced Custom Fields Pro to be active to display a random inage.
  • Set the ACF gallery to return the URL of images.
  • Use in a template as <?php ccd_random_logo(); ?>
@davewarfel
davewarfel / default-wordpress-blocks-sass.scss
Last active November 8, 2023 11:31
WordPress Blocks Styles - Cleaned Up, Commented & Sassified
/**
* WordPress Blocks
*
* Default block styling included with WordPress core.
* Provides a better starting point for WordPress theme developers,
* especially when using Sass.
*
* @link https://github.com/WordPress/WordPress/blob/master/wp-includes/css/dist/block-library/style.css
*
* Most styles from the above file are included.
@RichardBronosky
RichardBronosky / list-all-repos.py
Last active August 4, 2021 16:25 — forked from ralphbean/list-all-repos.py
Script to list all repos for a github organization
#!/usr/bin/env python2.7
""" Print all of the (git/ssh or http) urls for all repos (public or
private+public with personal_token) in a GitHub account (user or organization).
Usage example::
[HTTP_URLS=1] python2.7 list-all-repos.py account_name [personal_token]
It requires the pygithub3 module, which you can install on macos (Mac OSX) like this::
# get pip if you don't have it
@dnavarrojr
dnavarrojr / acf_href.php
Created August 7, 2018 22:41
Create an HREF link with a shortcode using ACF fields
<?php
/*****************************************************************************************************************************************************
*
* Usage: [acf_href href_before="mailto:" href="acf:field_name" text="acf:field_name"]
*
* acf:fieldname will retrieve the value of the specified "fieldname" and use that.
* get:url_variable will grab a variable from the URL and use that.
*
* [acf_href href="acf:my_link" text="Link to web site"]
@GaryJones
GaryJones / per-site-user-fields.php
Created July 9, 2018 20:38
WordPress plugin to store custom and built-in user fields on a per-site basis for WP multisite. Good for multilingual setups. Customise to your needs.
<?php
/**
* Per-Site User Fields
*
* @package GaryJones\PerSiteUserfields
* @author Gary Jones
* @copyright 2018 Gary Jones, Gamajo
* @license GPL-2.0-or-later
*
* @wordpress-plugin
@anthonyeden
anthonyeden / sample_map_with_markers.html
Last active September 25, 2022 20:17
OpenStreetMap & OpenLayers: Creating A Map With Markers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>OpenStreetMap &amp; OpenLayers - Marker Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/v4.6.5/build/ol.js" type="text/javascript"></script>
<script>
@johndyer
johndyer / index.php
Last active October 13, 2020 12:25
Gutenberg Shortcode Block with Live Preview
<?php
/**
* Plugin Name: JD Gutenberg Shortcode Preview
* Description: Live shortcode previews in Gutenberg
* Author: johndyer
* Version: 1.0.0
*
*/
// Exit if accessed directly.
@bacoords
bacoords / grab_vimeo_thumbnail.php
Last active October 1, 2024 08:59
Grab a thumbnail of a private (but embeddable) Vimeo video
<?php
/**
* Grab the url of a publicly embeddable video hosted on vimeo
* @param str $video_url The "embed" url of a video
* @return str The url of the thumbnail, or false if there's an error
*/
function grab_vimeo_thumbnail($vimeo_url){
if( !$vimeo_url ) return false;
$data = json_decode( file_get_contents( 'http://vimeo.com/api/oembed.json?url=' . $vimeo_url ) );