Skip to content

Instantly share code, notes, and snippets.

View JayWood's full-sized avatar
:octocat:
Levelling up, one commit at a time.

JayWood

:octocat:
Levelling up, one commit at a time.
View GitHub Profile
<?php
function get_oembed( $url, $post_id, $args = array() ) {
global $wp_embed;
$oembed_url = esc_url( $url );
// Sanitize object_id
$post_id = absint( $post_id );
<div id="wt-tags-box" class="wt-widget-bottom" <?php if ( wordtwit_post_box_cookie_check( 'wt-tags' ) ) { echo "style='display:none'"; } ?>>
<h4 class="wt-h4"><?php _e( "Hashtags", "wordtwit-pro" ); ?></h4>
<div class="wt-automatic">
<ul class="tagchecklist">
<?php if ( wordtwit_post_has_hash_tags() ) { ?>
<?php foreach( wordtwit_get_post_hash_tags() as $tag ) { ?>
<li id="<?php echo $tag; ?>-hashtag"><a href="#" class="hash-delete">X</a><span><?php echo $tag; ?></span></li>
<?php } ?>
<?php } ?>
</ul>
@JayWood
JayWood / dump.php
Created August 26, 2014 03:02
dump the data as soon as it's available
<?php
/**
* Dump wp_query data
*/
function jw_die(){
global $wp_query;
wp_die( '<pre>' . print_r( $wp_query, true ) . '</pre>');
}
add_action( 'wp', 'jw_die' );
@JayWood
JayWood / snippet.php
Created September 30, 2014 22:17
How NOT to get the featured thumbnail src of a WP Post....
<?php
// Featured Image for FB Like
$featured_image = get_the_post_thumbnail($post->ID);
// Get image source
if($featured_image) {
$doc = new DOMDocument();
$doc->loadHTML($featured_image);
$imageTags = $doc->getElementsByTagName('img');
@JayWood
JayWood / For Will
Created October 7, 2014 15:54
tech-tax.php
<?php
/**
* Tax Filter
* Can be used as a filter, or standalone method.
*/
function msft_openness_home_grid_post_tax_filter( $techclasses = array() ) {
$post = get_post();
$terms = wp_get_post_terms( $post->ID, 'technology', array( 'fields' => 'slug' ) );
if( empty( $terms ) || is_wp_error( $terms ) ) return $techclasses;
foreach ( $terms as $term ) {
@JayWood
JayWood / diff-thumbnails-for-last-post.php
Created November 10, 2014 15:01
different thumbnail for last post
<?php while (have_posts()) : the_post(); ?>
<?php if (is_paged()) : ?>
<?php $postclass = ('regular'); ?>
<?php else : ?>
<?php $postclass = ($post == $posts[0]) ? 'featured' : 'regular'; ?>
<?php endif; ?>
<div class="<?php echo $postclass; ?>">
<div class="thumbnail">
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
@JayWood
JayWood / books.lua
Created December 28, 2014 02:32
DW20 Books lua update
--[[
Books LUA file...
Originally by Direwolf20
Update by Jay
--]]
local data = {}
rednet.open("right")
p = peripheral.wrap("bottom")
<?php
/*
Plugin Name: WebDev AJAX
Plugin URI: http://#
Description: Quick AJAX Tutorial
Version: 0.1a
Author: Anonymous
Author URI: http://#
*/
local tArgs = { ... }
if (#tArgs ~= 3) then
print( "USAGE: gist get GIST_ID PROGRAM_NAME" )
return
end
local action = tArgs[1]
local gist_id = tArgs[2]
@JayWood
JayWood / filter.php
Last active August 29, 2015 14:14
CWV3 Dialog Filter
<?php
function cwv3_issue_17( $output ){
$exit_text = get_option( 'cwv3_exit_txt', __( 'Exit', 'cwv3' ) );
$enter_text = get_option( 'cwv3_enter_txt', __( 'Enter', 'cwv3' ) );
$cwv3_denial_title = get_option( 'cwv3_den_title', __( 'Access Denied', 'cwv3' ) );
$cwv3_denial_message = get_option( 'cwv3_den_msg', __( 'You have been denied access to this content. If you feel this is in error, please contact a site administrator.', 'cwv3' ) );
$cwv3_title = get_option( 'cwv3_d_title', __( 'Warning: Explicit Content', 'cwv3' ) );
$cwv3_message = get_option( 'cwv3_d_msg', __( 'The content you are about to view may be considered offensive and/or inappropriate. Furthermore, this content may be considered adult content, if you are not of legal age or are easily offended, you are required to click the exit button.', 'cwv3' ) );
$exit_url = get_option( 'cwv3_exit_link', '#' );