Skip to content

Instantly share code, notes, and snippets.

@wookiecooking
wookiecooking / cheatsheet.md
Last active December 17, 2015 07:29
[WordPress] cheatsheet

WordPress Cheatsheet

Below you will find snippets to help you through developing a wordpress template, hope it helps :)

####get the home URL <?php echo get_option('home'); ?>

####display the blog description <?php bloginfo('description'); ?>

@wookiecooking
wookiecooking / index.php
Created May 14, 2013 03:34
[WordPress] Embed YouTube videos using the shortcode [yt]
<?php
/*
Plugin Name: Youtube Shorty
Description: Embed YouTube videos using the shortcode [yt]
*/
function youtube_short($atts)
{
if (!isset($atts['width'])) {$atts['width']="100%";}
@wookiecooking
wookiecooking / index.php
Created May 14, 2013 03:35
[WordPress] Add social buttons after posts
<?php
/* Facebook */
add_filter('the_content', 'likebutton', 99); // Display underneath the_content
function likebutton ()
{
echo '<iframe src="http://www.facebook.com/plugins/like.php?href='.urlencode(get_permalink($post->ID)).'&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe>';
} ?>
@wookiecooking
wookiecooking / index.php
Created May 14, 2013 03:38
[WordPress] Generates XML Sitemap
<?
/*
Plugin Name: Sitemap Generator
Description: Generates a XML sitemap For Google Webmaster tools
*/
// On publish of post, update sitemap
add_action("publish_post", "sitemap_gen");
// Update of page
@wookiecooking
wookiecooking / curl.php
Created May 14, 2013 03:38
[PHP] Simple PHP OOP Curl
<?php
class get_contents {
public function url($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@wookiecooking
wookiecooking / index.php
Created May 14, 2013 03:39
[WordPress] Mobile Theme Switcher + IPad View
<?php
/*
Plugin Name: Mobile Theme Switch
Description: Switches WordPress theme based on user agent
*/
session_start();
if($_GET['mobile'] == "off"){
$_SESSION[$mobilethemeswitch] = "off";
@wookiecooking
wookiecooking / index.php
Created May 14, 2013 03:40
[WordPress] Raw Posts removes autoformatting within shortcode
<?php
/*
Plugin Name: Raw Posts
Description: Removes WordPress auto formatting using the short code [raw] [/raw]
*/
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'rawposts', 99);
@wookiecooking
wookiecooking / index.html
Created May 14, 2013 03:40
[jQuery] Simple facebook JSON Pull
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5-els.js"></script>
<![endif]-->
<style>
body {
font-size: 14px;
@wookiecooking
wookiecooking / harlemshake.js
Created May 14, 2013 04:26
harlem shake the page!
jQuery(document).ready(function() {
function h() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", l);
e.setAttribute("class", c);
document.body.appendChild(e)
}
function p() {
@wookiecooking
wookiecooking / fail.php
Created May 14, 2013 04:49
[PHP] really bad mysql OOP example, needs to be upgraded to PDO
<?php
class mSQL{
var $host;
var $username;
var $password;
var $database;
public $dub;