Skip to content

Instantly share code, notes, and snippets.

View bueltge's full-sized avatar
Always interested

Frank Bültge bueltge

Always interested
View GitHub Profile
@bueltge
bueltge / gist:1019737
Created June 10, 2011 20:44
"view Source" Marker
HTML:
<a lass="viewsource" title="view Source of this page" href="http://example.org/viewsource/?url=http://example.org/">view source</a>
JS, jQuery Plugin:
http://swip.codylindley.com/DOMWindowDemo.html
inline JS:
<script type="text/javascript">
$('.viewsource').openDOMWindow({
height:'90%',
@bueltge
bueltge / gist:1038032
Created June 21, 2011 15:00
Transition form bw 2 color with canvas
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>untitled</title>
<style>
/* Setup...not important. */
.img-wrap {
width: 500px;
@bueltge
bueltge / post-process.php
Created June 24, 2011 21:08
WordPress Custom Post Type: Insert post via Frontend
<?php
/**
* post-process.php
* make sure to include post-process.php in your functions.php. Use this in functions.php:
*
* get_template_part('post-process');
*
*/
function do_insert() {
if( 'POST' == $_SERVER['REQUEST_METHOD']
@bueltge
bueltge / gist:1058115
Created July 1, 2011 08:48
Google+ Button "Likes" auslesen
function get_google_plus1_count($url)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.$url.'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_URL => 'https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ'
@bueltge
bueltge / gist:1097431
Created July 21, 2011 15:25
count the number of hits on a specific page in WordPress
function count_page_hits() {
if ( is_single() ) {
global $post;
$count = get_post_meta( $post -> ID, 'count_page_hits', true );
$newcount = $count + 1;
update_post_meta( $post -> ID, 'count_page_hits', $newcount );
}
}
add_action( 'wp_head', 'count_page_hits' );
@bueltge
bueltge / gist:1119715
Created August 2, 2011 06:51
Shortcode for HTML5 Video Tag in WordPress
function html5_video( $atts, $content = NULL ) {
extract( shortcode_atts( array(
"src" => '',
"width" => '',
"height" => ''
), $atts ) );
return '<video src="' . $src . '" width="' . $width . '" height="' . $height . '" controls autobuffer>';
}
add_shortcode( 'video5', 'html5_video' );
Now you can use the following shortcode in your post:
@bueltge
bueltge / gist:1119722
Created August 2, 2011 07:03
Debug Shortcodes
function fb_show_shortcodes( $atts, $content = NULL ) {
extract( shortcode_atts(
array('linebreak'=>''),
$atts
) );
$brackets = array();
$brackets[0] = "/\[/";
$brackets[1] = "/\]/";
@bueltge
bueltge / gist:1155369
Created August 18, 2011 22:06
has_shortcode()
// check the current post for the existence of a short code
function has_shortcode( $shortcode = NULL ) {
$post_to_check = get_post( get_the_ID() );
// false because we have to search through the post content first
$found = false;
// if no short code was provided, return false
if ( ! $shortcode ) {
@bueltge
bueltge / gist:1168439
Created August 24, 2011 16:19
Adds classes for custom taxonomies to body_class()
function fb_add_body_class( $class ) {
if ( ! is_tax() )
return $class;
$tax = get_query_var( 'taxonomy' );
$term = $tax . '-' . get_query_var( 'term' );
$class = array_merge( $classes, array( 'taxonomy-archive', $tax, $term ) );
return $class;
@bueltge
bueltge / get_ram_in_footer.php
Last active September 27, 2015 03:28
WordPress Plugin to list used and standing ready RAM and SQL Queries in Admin-Footer