Skip to content

Instantly share code, notes, and snippets.

View theukedge's full-sized avatar

Dave Clements theukedge

View GitHub Profile
<?php function limit_soup( $args ) {
$args['post_status'] = array( 'draft', 'future' );
return $args;
}
add_filter( 'soup_query', 'limit_soup' );
<?php function load_parent_theme_css() {
$parentcss = get_template_directory() . '/style.css';
wp_enqueue_style(
'parent-theme',
get_template_directory_uri() . '/style.css',
array(),
filemtime( $parentcss )
);
}
add_action( 'wp_enqueue_scripts', 'load_parent_theme_css', 11 );
@theukedge
theukedge / gist:7456141
Last active June 11, 2016 09:50
Stop posts from showing up multiple times on the same page.
<div id="top-featured" class="clearfix home-block">
<?php
$do_not_duplicate = array();
$my_query = new WP_Query( array(
'post_type' => 'features',
'posts_per_page' => 1
) );
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="above-post">
@theukedge
theukedge / do-snapshot.rb
Last active May 7, 2016 00:02
Creates snapshots of your DigitalOcean droplets automatically and deletes the oldest snapshots to ensure you only maintain the most recent "x" snapshots (where x is configurable). Forked from https://www.digitalocean.com/community/tutorials/how-to-use-digitalocean-snapshots-to-automatically-backup-your-droplets
#!/usr/bin/env ruby
require 'rest-client'
require 'json'
require 'colorize'
$api_token = "xxxxxxxx"
$baseUrl = "https://api.digitalocean.com/v2/"
$headers = {:content_type => :json, "Authorization" => "Bearer #{$api_token}"}
$snapshots_to_keep = 10
<?php
function getBitly($url) {
$bitly = file_get_contents("http://api.bit.ly/v3/shorten?login=yourbitlyusername&apiKey=yourbitlyAPIkey&longUrl=$url%2F&format=txt");
return $bitly;
}
?>
[note]evanescent - adjective. having no permanence[/note]
<?php function displaydate(){
return date('F jS, Y');
}
add_shortcode( 'date', 'displaydate' );
[not_logged_in]
[signup_success]
[symple_box color="green" text_align="left" width="50%" float="none"]
Your signup was successful! You can login to the client area below. Remember that your username is your email address, and the password is the one that you specified during signup.
[/symple_box]
[symple_spacing size="20px"]
[/signup_success]
[login_form]
[/not_logged_in]
<?php // add shortcode to display message
function signup_complete_shortcode( $atts, $content = null ) {
$signup = get_query_var('signup');
if( $signup == "success" ) {
return do_shortcode( $content );
}
}
add_shortcode( 'signup_success', 'signup_complete_shortcode' );
<?php // allow query var to be retrieved
function add_query_vars_filter( $vars ){
$vars[] = "signup";
return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );