Skip to content

Instantly share code, notes, and snippets.

@fritids
fritids / gist:2231121
Created March 28, 2012 22:31 — forked from trepmal/gist:1566525
WordPress: Breadcrumb Functions
<?php
/*
Plugin Name: Breadcrumb Functions
Description: Functions for displaying breadcrumbs when working with hierarchical post types. Does nothing out-of-the-box, functions must be added to theme (directly or via hooks, your discretion).
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
*/
/*
Basic:
echo get_breadcrumbs( $post );
@fritids
fritids / gist:2231138
Created March 28, 2012 22:34 — forked from trepmal/gist:1520378
WordPress: [concept] Cross-CPT Parent/Child
<?php
//Plugin Name: [concept] Cross-CPT Parent/Child
//Description: Just a demo!.
add_action( 'init', 'kl_post_types');
function kl_post_types() {
register_post_type( 'parent', array(
'label' => 'Parent',
jQuery.fn.shake = function(intShakes, intDistance, intDuration) {
this.each(function() {
$(this).css({
position: "relative"
});
for (var x = 1; x <= intShakes; x++) {
$(this).animate({
left: (intDistance * -1)
}, (((intDuration / intShakes) / 4))).animate({
left: intDistance
<?php
/*
Template Name: All Authors' Page
Description: Get all the WordPress user's meta_information sort by the latest post action. (Which had at least 1 post published.)
*/
?>
<?php get_header(); ?>
<ul>
<?php
// offset -> post number | -1 means all the posts.
<?php
/* Mini Gavatar Cache */
/* 注:该程序中部分代码是WordPress所用,小幅修改即可复用。 */
function my_avatar( $email, $size = '50', $default = '', $alt = false ) {
$alt = (false === $alt) ? '' : esc_attr( $alt );
$f = md5( strtolower( $email ) );
$w = home_url(); //$w = get_bloginfo('url');
$a = $w. '/avatar/'. $f . '.jpg';
$e = preg_replace('/wordpress\//', '', ABSPATH) . 'avatar/' . $f . '.jpg';
$t = 604800; //设定7天, 单位:秒
$nationals = array(
'Afghan',
'Albanian',
'Algerian',
'American',
'Andorran',
'Angolan',
'Antiguans',
'Argentinean',
'Armenian',
<?php
$countries = array("Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Island
<?
//There we go, that's better now
$countries = array();
$countries[1] = array(
'code' => 1,
'name' => "Canada (+1)" );
$countries[2] = array(
'code' => 86,
'name' => "China (+86)" );
<?php
function hello_world() {
// a world subset
$countries = array('USA', 'Germany', 'Spain', 'Austraila');
print_r($countries);
}
<?php
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*