Skip to content

Instantly share code, notes, and snippets.

View joedolson's full-sized avatar

Joe Dolson joedolson

View GitHub Profile
@joedolson
joedolson / gist:9e14117850d9e4b6aa7e039a609bfe48
Created April 12, 2024 00:06
Console JS for viewing uploaded images in Gravity Forms admin list
let images = document.querySelectorAll( '.field_id-18 a' ); images.forEach( function( el ) { let url = el.getAttribute( 'href' ); let img = el.querySelector( 'img' ); img.setAttribute( 'src', url ); } );
@joedolson
joedolson / wowza.php
Last active November 1, 2023 18:49
Load Wowza in WordPress
/**
* Embed a Wowza streaming player in WordPress. Maps the `$` function to `jQuery.noConflict()` before running embed so that variable is available.
* Usage: [wowza url="//player.video.wowza.com/hosted/WOWZA_ID/wowza.js"]
*
* @param array $atts Shortcode attributes.
* @param string $content Container content. Not used.
*
* @return string
*/
function embed_wowza( $atts, $content ) {
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
$rand = '_' . mt_rand( 10000, 99999 );
?>
<label for="search<?php echo $rand; ?>"><?php echo _x( 'Search for:', 'label', 'textdomain' ); ?></label>
<input id="search<?php echo $rand; ?>" type="search" class="search-field" value="<?php echo get_search_query(); ?>" name="s" />
<button type="submit" class="search-submit"><?php echo _x( 'Search', 'submit button', 'textdomain' ); ?></button>
</form>
@joedolson
joedolson / table-demo-alt.html
Last active November 11, 2020 20:58
WordPress Accessibility Pattern Library - Table (alt)
<table class="form-table" role="presentation">
<tr>
<th scope="row"><label for="blogname">Site Title</label></th>
<td><input name="blogname" type="text" id="blogname" value="Make WordPress Accessible" class="regular-text" /></td>
</tr>
<tr>
<th scope="row"><label for="blogdescription">Tagline</label></th>
<td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="Equal Access For All" class="regular-text" />
@joedolson
joedolson / table-demo.html
Created November 11, 2020 20:47
WordPress Accessibility Pattern Library - Table Demo
<table class="wp-list-table widefat fixed striped table-view-excerpt pages">
<thead>
<tr>
<td id='cb' class='manage-column column-cb check-column'><label class="screen-reader-text" for="cb-select-all-1">Select All</label><input id="cb-select-all-1" type="checkbox" /></td><th scope="col" id='title' class='manage-column column-title column-primary sortable desc'><a href="https://make.wordpress.org/accessibility/wp-admin/edit.php?post_type=handbook&#038;orderby=title&#038;order=asc"><span>Title</span><span class="sorting-indicator"></span></a></th><th scope="col" id='author' class='manage-column column-author'>Author</th><th scope="col" id='date' class='manage-column column-date sortable asc'><a href="https://make.wordpress.org/accessibility/wp-admin/edit.php?post_type=handbook&#038;orderby=date&#038;order=desc"><span>Date</span><span class="sorting-indicator"></span></a></th>
</tr>
</thead>
<tbody id="the-list">
...
</tbody>
@joedolson
joedolson / events-as-posts.php
Last active August 29, 2015 14:22
Add My Calendar Events as Blog Posts
add_action( 'mc_save_event', 'my_event_post', 10, 3 );
function my_event_post( $action, $data, $new_event ) {
// if the event save was successful.
if ( $action == 'add' ) {
$title = $data['event_title'];
$content = "[my_calendar_event event='$new_event' template='details' list='']";
$post_status = 'publish';
$auth = $data['event_author'];
$type = 'post';
$my_post = array(
@joedolson
joedolson / ID24 Demo 1
Created May 23, 2015 16:59
This is the essentials for creating any WordPress plug-in: Informational comment block and internationalization.
<?php
/*
* Plugin Name: ID24 Social Sharing
* Plugin URI:
* Plugin Description: Demo plug-in for #ID24 and #GAAD
* Version: 1.0
* Author: Joe Dolson
* Author URI: http://www.joedolson.com
*/
@joedolson
joedolson / ID24 Demo 2
Created May 23, 2015 16:59
We need to acquire some basic data that will be useful in Social Sharing URLs. Title, URL, image data.
/*
* Get the post data that will be sent to social sharing pages.
*
* @param integer $post_ID ID of the current post.
*
* @return array of post data.
*/
function id24_post_information( $post_ID ) {
$data = array();
$data['title'] = get_the_title( $post_ID );
@joedolson
joedolson / ID24 Demo 3
Created May 23, 2015 17:00
Using that data, we format the URLs. Data gets urlencoded so the URLs will be valid.
/*
* Generate the URLs used to post data to services.
*
* @param integer $post_ID of current post
*
* @return array of URLs for posting to each service.
*/
function id24_create_urls( $post_ID ) {
$data = id24_post_information( $post_ID );
$twitter = "https://twitter.com/intent/tweet?text=" . urlencode( $data['title'] . ' ' . $data['url'] );
@joedolson
joedolson / ID24 Demo 4
Created May 23, 2015 17:00
Set up some basic HTML around these URLs, so that we have some standard links we'll use.
/*
* Generate the HTML links using URLs.
*
* @param integer $post_ID of current post
*
* @return string block of HTML links.
*/
function id24_create_links( $post_ID ) {
$urls = id24_create_urls( $post_ID );
$html = '';