Skip to content

Instantly share code, notes, and snippets.

View Pushplaybang's full-sized avatar
:octocat:
0_0

Paul Pushplaybang

:octocat:
0_0
View GitHub Profile
@Pushplaybang
Pushplaybang / custom-social.php
Created November 13, 2012 12:16
custom share links for various social networks - mix of wp and html
<!-- Some may be deprecated - TODO : check and update -->
<!-- Plain G+ on WP -->
<a rel="nofollow" href="https://plusone.google.com/_/+1/confirm?hl=en&url=<?php the_permalink(); ?>" title="Share this post on Google+">Share on Google+</a>
<!-- Plain LinkedIn on WP -->
<a rel="nofollow" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>&summary=<?php echo get_the_excerpt(); ?>&source=<?php bloginfo('name'); ?>">Share on LinkedIn</a>
@Pushplaybang
Pushplaybang / map.html
Created December 10, 2012 18:47
Basoc Google Static Map
<div id="map">
<img src="http://maps.google.com/maps/api/staticmap
?center=Capetown+SouthAfrica
&zoom=14
&size=480x240
&maptype=roadmap
&markers=color:red|31.4211,35.1144
&sensor=false"
width="480" height="240" alt="Map of Cape Town, SA"
/>
@Pushplaybang
Pushplaybang / learning.sql
Created December 14, 2012 11:44
Learning basic MySQL - examples, syntax and descriptions reference
# used to create a database
CREATE DATABASE your_database_name;
# switches context to the database you specify
USE your_database_name;
# lists the available databases
SHOW databases;
<?php
// Run this code on 'after_theme_setup', when plugins have already been loaded.
add_action('after_setup_theme', 'my_load_plugin');
// This function loads the plugin.
function my_load_plugin() {
// Check to see if your plugin has already been loaded. This can be done in several
// ways - here are a few examples:
@Pushplaybang
Pushplaybang / post_format_embed.php
Last active December 11, 2015 09:08
starting point for dealing with embeds from the _format_video_embed meta feild
<?php
// Display Videos
// Utility function - allow us to strpos an array
if ( ! function_exists( 'video_strpos_arr' )) {
function video_strpos_arr($haystack, $needle) {
if( !is_array($needle) ) $needle = array($needle);
foreach( $needle as $what ) {
@Pushplaybang
Pushplaybang / php-compare-fill-array.php
Created April 22, 2013 05:49
compare 2 php arrays and duplicate or reduce the values of the second so they match
// only if the two arrays don't hold the same number of elements
if (count($data) != count($colors)) {
// handle if $colors is less than $data
while (count($colors) < count($data)) {
// NOTE : we are using array_values($colors) to make sure we use
// numeric keys.
// See http://php.net/manual/en/function.array-merge.php)
$colors = array_merge($colors, array_values($colors));
}
@Pushplaybang
Pushplaybang / rgb_to_hex_to_rgb.php
Created April 22, 2013 06:35
php functions convert hex to rgb and rgb to hex
function hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
} else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
@Pushplaybang
Pushplaybang / wp-logout-redirect.php
Created July 1, 2013 11:34
WordPress Redirect to homepage after logout
<?php
/**
* @package Redirect to homepage after logout
* @version 0.1
*/
/*
Plugin Name: Redirect to homepage after logout
Plugin URI: http://daankortenbach.nl/wordpress/redirect-to-homepage-after-logout/
Description: Redirects the user to the homepage after logout
Author: Daan Kortenbach
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Silent Flush
* Description: Flushes rewrite rules whenever a custom post type or taxonomy is registered and not already part of these rules. This is a soft flush, the .htaccess will not be rewritten.
* Version: 2013.05.04
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
@Pushplaybang
Pushplaybang / wp-admin-bar-tweaks.php
Created August 9, 2013 23:34
wp-admin-bar-tweaks
Disable the WordPress Admin Bar for all Users and Visitors
Turn off the toolbar with one simple line.
view plain
/*
* Disable the WordPress Admin Bar for all Users and Visitors
*/
remove_action( 'init', '_wp_admin_bar_init' );
^ top
Enable the WordPress Admin Bar for admins only