Skip to content

Instantly share code, notes, and snippets.

View mwender's full-sized avatar
👨‍💻

Michael Wender mwender

👨‍💻
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 );
}
}