This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>untitled</title> | |
<style> | |
/* Setup...not important. */ | |
.img-wrap { | |
width: 500px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fb_show_shortcodes( $atts, $content = NULL ) { | |
extract( shortcode_atts( | |
array('linebreak'=>''), | |
$atts | |
) ); | |
$brackets = array(); | |
$brackets[0] = "/\[/"; | |
$brackets[1] = "/\]/"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |