Skip to content

Instantly share code, notes, and snippets.

@GuilhermeBarile
GuilhermeBarile / Facebook like button
Last active December 5, 2017 08:01
Wordpress code snippets
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink()) ?>&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light&amp;height=21" width="90" height="21" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
anonymous
anonymous / gist:835087
Created February 19, 2011 14:39
<?php
if ( isset( $_GET['author'] ) || ( $_GET['author'] != $current_user->ID ) )
$location = remove_query_arg('author', $location);
$location = add_query_arg( 'author', $current_user->ID, $location);
wp_redirect($location);
exit();
?>
<?php
class DATABASE_CONFIG {
var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user_name',
'password' => 'your_password',
'database' => 'database_name',
'prefix' => '',
@thefuxia
thefuxia / quote-author.php
Created May 28, 2011 04:55
WordPress Plugin Quote Author
<?php # -*- coding: utf-8 -*-
/*
Plugin Name: Custom Taxonomy Quote Author
Plugin URI: https://gist.github.com/996608
Description: Creates a custom taxonomy <code>Quote Author</code> with an URI <code>/qa/author-name/</code>
Version: 1.0
Required: 3.1
Author: Thomas Scholz
Author URI: http://toscho.de
License: GPL
@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'
@sbp
sbp / OpenSans.css
Created August 1, 2011 13:11
CSS for Open Sans
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: local('Open Sans Italic'), local('Open-Sans-Italic'),
url('OpenSans-Italic.woff') format('woff'),
url('OpenSans-Italic.ttf') format('truetype');
}
@font-face {
@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:
@DamianZaremba
DamianZaremba / functions.php
Created August 28, 2011 21:31
Wordpress wp_nav_menu walker
<?php
/*
* Footer menu walker - just because wordpress sucks
* See wp-includes/class-wp-walker.php for what the hell this does normally (Class Walker)
*/
class footer_menu_walker {
/*
Output we are aiming for:
<div class="col">
<h3>Some sub menu</h3>
@mjangda
mjangda / wpcom-open-graph.php
Created September 5, 2011 22:30
Add Open Graph tags to your WordPress site
<?php
/**
* Open Graph Tags
*
* Add Open Graph tags so that Facebook (and any other service that supports them)
* can crawl the site better and we provide a better sharing experience.
*
* @link http://ogp.me/
* @link http://developers.facebook.com/docs/opengraph/
*/
@remkus
remkus / gist:1235165
Created September 22, 2011 16:02
Example of WordPress coding standards
<?php
add_filter( 'body_class' , 'ft_add_guest_body_class' );
/**
* Adds a body class for guests.
*
* @author Remkus de Vries
* @link http://remkusdevries.com/when-sharing-wordpress-related-code-snippets-i-can-haz-standards-please/
* @param array $classes Existing body classes
* @return array Amended body classes