Skip to content

Instantly share code, notes, and snippets.

@cgrymala
cgrymala / adjust-wp-admin-menu.php
Created May 18, 2016 16:40
Modifies WordPress Admin Menu to adjust cap used for specific menu
add_action( 'admin_menu', 'adjust_admin_menu', 11 );
function adjust_admin_menu() {
$test_slug = 'my-menu-slug';
$new_cap = 'edit_posts';
global $menu;
foreach ( $menu as $k=>$v ) {
if ( $test_slug == $v[2] ) {
$menu[$k][1] = $new_cap;
@cgrymala
cgrymala / remove-jetpack-sharing-filter.php
Created November 14, 2013 17:21
Brief example showing how to remove a filter (in this case, the "Sharing" buttons that JetPack outputs at the end of content) within WordPress.
<?php
function output_featured_image() {
echo '<figure class="featured-image">';
the_post_thumbnail( 'archive-feature', array( 'class' => 'alignnone' ) );
// First, check to see if the Sharing buttons are supposed to display on content or excerpt
// Remove those sharing buttons if they are
$sharecontent = false;
$shareexcerpt = false;
if ( has_filter( 'the_content', 'sharing_display' ) ) {
@cgrymala
cgrymala / gist:5950168
Created July 8, 2013 16:09
New method of retrieving latitude and longitude from a Google Maps marker
// Retrieve the latitude and longitude of the search result
lat = Math.round( lat * 100000 ) / 100000;
long = Math.round( long * 100000 ) / 100000;
for ( var i = 0; i < limit; i++ ) {
// Retrieve a new LatLng object for the marker
var markLatLng = markers[i].getPosition();
// Retrieve the latitude and longitude of the marker, separately
var markLat = Math.round( markLatLng.lat() * 100000 ) / 100000;
var markLong = Math.round( markLatLng.lng() * 100000 ) / 100000;
@cgrymala
cgrymala / gist:5950109
Created July 8, 2013 16:01
Old method of getting lat & long from Google Maps marker
// Get the latitude and longitude of the search result
lat = Math.round( lat * 100000 ) / 100000;
long = Math.round( long * 100000 ) / 100000;
for ( var i = 0; i < limit; i++ ) {
// Retrieve the latitude and longitude of the marker
var markLat = Math.round( markers[i].position.Ra * 100000 ) / 100000;
var markLong = Math.round( markers[i].position.Sa * 100000 ) / 100000;
// Compare the search result to the current marker
@cgrymala
cgrymala / gist:5901462
Created July 1, 2013 14:46
JetPack developer constant - avoid connecting to WP.com
define( 'JETPACK_DEV_DEBUG', true );
@cgrymala
cgrymala / umw-timely-customizer.html
Last active December 11, 2015 20:48
Implements the custom header/footer on UMW's Time.ly calendar
<!-- Custom Head Code -->
<link rel='stylesheet' id='genericons-css' href='//www.umw.edu/wp-content/plugins/jetpack/_inc/genericons/genericons/genericons.css?ver=3.1' type='text/css' media='all' />
<link rel='stylesheet' id='umw-fonts-css' href='//www.umw.edu/wp-content/plugins/umw-fonts/fonts.css?ver=0.2' type='text/css' media='all' />
<link rel='stylesheet' id='umw-online-tools-font-css' href='//www.umw.edu/wp-content/plugins/online-tools/images/icons/svg-online-tools/icon-font/style.css?ver=0.5.2' type='text/css' media='all' />
<link rel='stylesheet' id='umw-online-tools-css' href='//www.umw.edu/wp-content/plugins/online-tools/styles/umw-online-tools.css?ver=0.5.2' type='text/css' media='all' />
<link rel='stylesheet' id='outreach-pro-css' href='//www.umw.edu/wp-content/mu-plugins/styles/outreach-pro.css?ver=1.0.20' type='text/css' media='all' />
<link rel='stylesheet' id='umw-outreach-mods-css' href='//www.umw.edu/wp-content/mu-plugins/styles/umw-outreach-mods.css?ver=1.0.20' type='text/css' media='
@cgrymala
cgrymala / analytics-head.js
Created November 6, 2015 17:49
Standard call for Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-[your-analytics-id]-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
@cgrymala
cgrymala / gf-a11y-sample-complex-fields.html
Created September 4, 2015 20:09
Proposed re-structuring of Gravity Forms complex fields for a11y
<ul>
<!-- Original First Name/Last Name Complex Field -->
<li id="field_6_13" class="gfield field_sublabel_below field_description_above">
<label class="gfield_label" for="input_6_13_3">Name</label>
<div class="ginput_complex ginput_container no_prefix has_first_name no_middle_name has_last_name no_suffix" id="input_6_13">
<span id="input_6_13_3_container" class="name_first">
<input type="text" name="input_13.3" id="input_6_13_3" value="" aria-label="First name" vk_1cc20="subscribed" data-cip-id="input_6_13_3">
<label for="input_6_13_3">First</label>
</span>
<span id="input_6_13_6_container" class="name_last">
@cgrymala
cgrymala / customizer-custom-image-sizes.php
Created September 4, 2015 16:38
Pulls Resized Images From Customizer Settings in WordPress
<?php
if ( ! class_exists( 'My_Customizer_Theme_Mods' ) ) {
class My_Customizer_Theme {
var $version = '0.1';
function __construct() {
/**
* We have two basic sizes of images used from the images set in the Customizer
* One of them is full-width of the browser, so let's make it large, but not unlimited
* The other is a 125x125 icon, but, just in case it needs to be a bit larger on mobile or
@cgrymala
cgrymala / valid-html-page-no-closing.html
Created September 3, 2015 15:42
Ugly, Valid HTML5 code
<!doctype html>
<html>
<head>
<title>My Document Title</title>
<body>
<ul>
<li>First list item
<li>Second list item
<li>Third list item
</ul>