Skip to content

Instantly share code, notes, and snippets.

@nciske
nciske / custom-login-error.php
Created June 9, 2012 13:15
Custom Login Error Plugin
<?php
/*
Plugin Name: Custom Login Error
Plugin URI: http://www.thoughtrefinery.com/
Description: Customize error messages on login form
Version: 0.1
Author: Nick Ciske | Thought Refinery
Author URI: http://www.thoughtrefinery.com/
*/
@da1nonly
da1nonly / wordpress auto backup
Created May 28, 2012 17:52
wordpress auto backup
<?php
/**
Backup the database of a given WordPress site.
using http://www.bin-co.com/blog/2008/10/remote-database-backup-wordpress-plugin/
*/
$site_url = 'http://yoursite.com'; //The URL of the online wordpress site
$username = 'admin'; // Admin username
$password = 'not_my_password'; // Admin password
@pedroelsner
pedroelsner / gist:2788230
Created May 25, 2012 13:40
#1 - WP em páginas externas
<?php
/**
* Carrega a API do WordPress
*/
define('WP_USE_THEMES', false); // Não utiliza nenhum tema
require('./wordpress/wp-load.php');
?>
@imjjss
imjjss / gist:2701294
Created May 15, 2012 12:15
insert term
<? php
function insert_term($term, $taxonomy, $args = array()) {
if (isset ( $args ['parent'] )) {
$parent = $args ['parent'];
} else {
$parent = 0;
}
$result = term_exists ( $term, $taxonomy, $parent );
if ($result == false || $result == 0) {
return wp_insert_term ( $term, $taxonomy, $args );
@tsnoad
tsnoad / gist:2642139
Created May 9, 2012 05:33
simple checking and correction of australian and international phone numbers
<?
function checkPhone($int_dial_code, $area_code, $local_number) {
//try to check and reformat australian numbers
if ($int_dial_code == "61") {
//combine the area code and local number
$full_phone = $area_code.$local_number;
//strip spaces and hyphens
$full_phone = str_replace(array(" ", "-"), "", $full_phone);
@tsnoad
tsnoad / gist:2642087
Created May 9, 2012 05:25
SSHA password hashing. this format is used by OpenLDAP to store passwords
<?
function make_salt($salt_size=32) {
//list of possible characters from which to cerate the salt
$sea = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
//how many possible characters are there
$sea_size = strlen($sea);
$salt = "";
@tonyahowe
tonyahowe / author.php
Created May 7, 2012 15:37
Author Template
<?php get_header(); ?>
<?php if( brunelleschi_option('sidebar') === 'both'
|| brunelleschi_option('sidebar') === 'two left'
|| brunelleschi_option('sidebar') === 'two right'){
get_sidebar('secondary');
} ?>
<div id="main" role="main" class="<?php brunelleschi_content_class(); ?>">
<?php
if ( have_posts() )
the_post();
@jimmynotjim
jimmynotjim / gist:2570530
Created May 1, 2012 19:04
Add user avatar uploader to admin panel and function call for front end
<?php
/* BEGIN: add user info
---------------------------------------------------------------------------------------------------- */
add_action( 'show_user_profile', 'show_extra_profile_fields' );
add_action( 'edit_user_profile', 'show_extra_profile_fields' );
function show_extra_profile_fields( $user ) { ?>
@Knivrobot
Knivrobot / functions.php
Created April 17, 2012 09:10
Use session cookies in Wordpress
//Enable sessions i wordpress
if ( !session_id() )
add_action( 'init', 'session_start' );
@menslow
menslow / WordPress Registration
Created April 13, 2012 00:33
WordPress: Simple registration function for custom front-end registration forms.
/**
* mm_register function.
* Register a new user.
* @access public
* @return User errors or user is logged in.
*/
function mm_register() {
if(!is_user_logged_in()) {
if(!empty($_POST)) {