Skip to content

Instantly share code, notes, and snippets.

View mwender's full-sized avatar
👨‍💻

Michael Wender mwender

👨‍💻
View GitHub Profile
@mwender
mwender / genesis_cpt_intro_text.php
Created September 23, 2013 14:09
Echo intro text from Genesis Custom Post Type (CPT) Archive Settings page
if( genesis_has_post_type_archive_support() ){
$intro_text = genesis_get_cpt_option( 'intro_text' );
if( !empty( $intro_text ) ){
echo apply_filters( 'genesis_term_intro_text_output', $intro_text );
}
}
@mwender
mwender / next_prev_pages.php
Created September 23, 2013 20:21
Retrieves next/prev links for WordPress pages or 'heirarchical' post_types.
global $post;
$pageID = $post->ID;
$args = array(
'parent' => 0,
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
);
$pagelist = get_pages( $args );
@mwender
mwender / functions.php
Created October 17, 2013 13:44
Remove features from WordPress parent theme. Great for removing things like shortcodes.
add_action( 'after_setup_theme', 'remove_parent_theme_features', 10 );
function remove_parent_theme_features(){
// remove shortcode from parent theme
remove_shortcode( 'example' );
// replace with child theme shortcode callback
add_shortcode( 'example', 'child_theme_example_callback' );
}
@mwender
mwender / rackspace_cloud_sites_gen_ssh_key.sh
Created November 6, 2013 21:56
Generate an SSH key for your Rackspace Cloud Site. Replace _REMOTE_REPO_HOST_ with the domain of your remote repo host (e.g. bitbucket.org, github.com, etc). Upload this script somewhere above your web root and run it as a Perl cron. After it runs you'll find `id_rsa.pub` in /.ssh/.
#!/bin/sh
cd .ssh
ssh-keygen -trsa -fid_rsa
ssh-keyscan -t rsa _REMOTE_REPO_HOST_ >> known_hosts
@mwender
mwender / force_ie_edge_rendering.php
Created November 8, 2013 16:13
Force IE to render a site in the latest version of its rendering engine. Useful to add to functions.php for WordPress themes.
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) )
header('X-UA-Compatible: IE=edge,chrome=1');
@mwender
mwender / table_html.html
Created November 14, 2013 15:26
Properly formatted table HTML for use on new.triadsemi.com
<table>
<caption>Wafer Fab</caption>
<colgroup>
<col style="width: 25%;" />
<col style="width: 25%;" />
<col style="width: 25%;" />
<col style="width: 25%;" />
</colgroup>
<thead>
<tr>
@mwender
mwender / wordpress_query_functions.php
Created November 25, 2013 21:40
Functions which allow querying WordPress directly. Useful for AJAX callbacks.
add_filter( 'query_vars', 'theme_query_vars' );
/**
* Adds variables to $wp->query_vars
*
* @param array $vars Global WP query vars.
* @return array Array used in $wp->query_vars.
*/
function theme_query_vars( $vars ){
$vars[] = 'qa'; // "query_action" - used for switch in theme_parse_request()
return $vars;
@mwender
mwender / jquery_ajax_request.js
Created November 25, 2013 21:47
Example jQuery AJAX request
jQuery( function($){
$( 'a.button' ).click( function( e ){
$.post( '?qa=default', { var1: var1, var2: var2 }, function( data ){
console.log( '[jQuery AJAX Request] ' + data.message );
});
e.preventDefault();
});
});
@mwender
mwender / recent_feed_posts_shortcode.php
Created November 26, 2013 18:32
Revised shortcode handling for a recent posts widget that pulls content from an RSS feed. For use in a child theme of Avada.
add_shortcode('mcm_recent_feed_posts', 'shortcode_mcm_recent_feed_posts');
/**
* shortcode_mcm_recent_feed_posts() - Retrieves posts from RSS feed
*
* @see fetch_feed()
*
* @since 1.0.0
*
* @param array $atts {
* @type string $url RSS feed URL.
@mwender
mwender / impbcopy.m
Last active April 15, 2024 03:20
Command line copy an image file to the clipboard in Mac OS X. See first comment for install instructions.
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
if([path isEqualToString:@"-"])
{
// http://caiustheory.com/read-standard-input-using-objective-c