Skip to content

Instantly share code, notes, and snippets.

@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>
@cgrymala
cgrymala / wpe-ssl-port-fix.php
Created September 1, 2015 14:07
Attempt to fix the way CASMaestro/phpCAS on WPEngine sends the application URL to the CAS server
<?php
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
if ( isset( $_SERVER['HTTP_X_FORWARDED_PORT'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_PORT'] ) ) {
$ports = explode(',', $_SERVER['HTTP_X_FORWARDED_PORT']);
error_log( 'The forwarded Port var is set to: ' . $ports[0] );
} else if ( isset( $_SERVER['SERVER_PORT'] ) && ! empty( $_SERVER['SERVER_PORT'] ) ) {
error_log( 'The server Port var is set to: ' . $_SERVER['SERVER_PORT'] );
$_SERVER['SERVER_PORT'] = 443;
}
}
@cgrymala
cgrymala / jetpack-fluid-video-embed-fix.php
Created July 21, 2015 17:58
Attempt to make JetPack Shortcode Embeds compatible with Fluid Video Embeds plugin
<?php
/**
* Attempts to override the stupid way JetPack short-circuits native oEmbeds
* so that the Fluid Video Embeds plugin can work properly
*/
function fve_jetpack_filter_video_embed( $html, $atts=array() ) {
/**
* Attempt to make sure the Fluid Video Embeds plugin is
* active and that the global $fve object is instantiated
*/
@cgrymala
cgrymala / jetpack-allow-native-oembed.php
Created July 21, 2015 16:39
Removes the [youtube] and [vimeo] shortcodes from JetPack Shortcode Embeds module
<?php
/**
* Filter the list of JetPack shortcodes to remove the YouTube and
* Vimeo shortcodes from the list
* @param array $shortcodes a numerically-indexed array of the absolute
* paths to the shortcode definition files
* @return array the filtered array
*/
function jetpack_allow_native_youtube_vimeo_oembeds( $shortcodes ) {
$good_shortcodes = array();
@cgrymala
cgrymala / cwa-filter-usage-reference.php
Last active August 29, 2015 14:24
Usage Examples for Collapsible Widget Area Filters
<?php
/**
* Example usage of the collapsible-widget-ui-theme filter
* We set the priority to 10, and tell WordPress that the callback function should receive 2 arguments
* @see http://codex.wordpress.org/Function_Reference/add_filter
*/
add_filter( 'collapsible-widget-ui-theme', 'my_theme_cwa_ui_theme', 10, 2 );
function my_theme_cwa_ui_theme( $theme, $opt=null ) {
/**
* Set a custom jQueryUI theme specifically for use with our WordPress theme
@cgrymala
cgrymala / cwa-modify-js-args.php
Created July 13, 2015 14:07
Modify Collapsible Widget Area arguments to use "content" height style instead of "auto"
<?php
/**
* Sets the heightStyle argument for all accordion widget areas
* @see http://api.jqueryui.com/accordion/#option-heightStyle
*/
add_filter( 'collapsible-widget-javascript-arguments', 'my_theme_modify_cwa_js_args' );
function my_theme_modify_cwa_js_args( $args = array() ) {
/**
* Loop through all of the existing Collapsible Widget Areas
*/
@cgrymala
cgrymala / delete-plugin-tables.php
Created July 10, 2015 14:50
Delete Extra Plugin Tables When a Site Is Deleted in WordPress Multisite
<?php
/**
* Add any custom tables that this plugin creates for an individual site to the list
* of tables that get deleted when a site is deleted.
* @see https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-admin/includes/ms.php#L116
*/
add_filter( 'wpmu_drop_tables', 'delete_my_plugin_tables', 10, 2 );
function delete_my_plugin_tables( $tables=array(), $blog_id=null ) {
/**
* Make sure the blog ID parameter was sent, so we don't
@cgrymala
cgrymala / jetpack-override-genesis-favicon.php
Created February 13, 2015 14:36
Allow JetPack to control your WordPress site's favicon instead of Genesis
<?php
/**
* The 'genesis_pre_load_favicon' filter runs at the beginning of the genesis_load_favicon() function.
* If the value returned by that filter ends up as anything except boolean false, Genesis bails on the
* genesis_load_favicon() process.
*/
add_filter( 'genesis_pre_load_favicon', 'check_jetpack_site_icon_status' );
function check_jetpack_site_icon_status() {
/**
* If the JetPack module is active and a JetPack Site Icon has been set,