Skip to content

Instantly share code, notes, and snippets.

View senlin's full-sized avatar

Pieter Bos senlin

View GitHub Profile
@senlin
senlin / Contract Killer 3.md
Last active October 13, 2015 15:37
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@senlin
senlin / page-testimonials.php
Created November 30, 2012 01:49
Testimonials Page Example
<?php
/** Template Name: Testimonials */
get_header(); ?>
<div class="page-header">
<h1 class="page-title">
<?php _e( 'Testimonials', 'basejump' ); ?>
</h1>
</div><!-- end .page-header -->
<div <?php post_class(); ?>>
@senlin
senlin / loop-posttype.php
Created August 18, 2012 06:44
sample code to implement ContentFlow.js in WordPress
<?php
// the following will be part of your loop.
?>
<div class="ContentFlow">
<div class="flow">
<?php
$asliders = query_posts('post_type=artist&posts_per_page=-1');
if ($asliders) {
foreach ($asliders as $aslider) {
// my original code included a checkbox custom metabox "_artist_slider", the code below calls these metadat and checks whether this box has been ticked ("on"). If your site doesn't use any metaboxes to condtionally show the post in the slider, then you need to delete the "if ($meta == 'on')" condition.
@senlin
senlin / display-message-on-older-posts.php
Created August 13, 2012 23:36
Display a message on older posts
<?php //display a message on older posts
function older_post_message () {
$posted = get_the_time('U');
$current = current_time('timestamp');
//Convert difference in seconds to days
$diffTime = ($current - $posted) / (60*60*24);
if($diffTime > 365){
echo '<div class=older-post-message>' . __('This post was written more than a year ago and <em>might</em> not be entirely accurate anymore.', 'text-domain') . '</div><br />';
}
}
@senlin
senlin / page_children.php
Created July 26, 2012 15:23
List children of Page with excerpt
<?php
$pageChildren = get_pages('sort_column=menu_order&hierarchical=0&child_of='.$post->ID);
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<div class="page-excerpt-wrapper">';
echo '<h2>'. $pageChild->post_title.'</h2>';
if ($pageChild->post_excerpt){
echo '<p>'.$pageChild->post_excerpt.'</p>';
}
echo '</div>';
@senlin
senlin / upto6columns.html
Created June 28, 2012 14:19
Add up to 6 columns to Basejump WordPress Theme
<p>One column full width content</p>
<div class="one-half first">Two columns full width content </div>
<div class="one-half">Two columns full width content </div>
<div class="one-third first">Three columns full width content </div>
<div class="one-third">Three columns full width content </div>
<div class="one-third">Three columns full width content </div>
<div class="one-fourth first">Four columns full width content </div>
@senlin
senlin / wpml-language-switch.php
Created April 10, 2012 00:35
wpml forum topic: display-the-language-switcher-in-the-wp-menu; show all langauges but the current one
<?php
// add the following lines to the functions.php file of your theme
function wpml_language_switch() {
$lang = icl_get_languages('skip_missing=N');
$ret = '';
if(count($lang) > 0) {
foreach($lang as $value) {
$ret .= ($value['active'] == 0) ? '<li class="language dropdown menu-item"><a href="' . $value['url'] . '">' .
$value['native_name'] . '</a></li>' : '';
}
@senlin
senlin / wp_nav_menu_hor.php
Created April 9, 2012 03:34
wpmlforums-location-of-flags-on-navigation-bar-post-54904
// Filter wp_nav_menu() to add additional links and other output
function new_nav_menu_items($items,$args) {
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0');
if(1 < count($languages)){
foreach($languages as $l){
if(!$l['active']){
$items = $items.'<li class="menu-item"><a href="'.$l['url'].'"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /> </a></li>';
}
}
@senlin
senlin / functions.php
Created March 17, 2012 15:49
wptips_new_default_header_images for forest
<?php
//ADD NEW DEFAULT HEADER IMAGES
function wptips_new_default_header_images() {
$child2011_dir = get_bloginfo('stylesheet_directory');
register_default_headers( array (
'image1' => array (
'url' => "$child2011_dir/images/banner1.jpg",
'thumbnail_url' => "$child2011_dir/images/image1-thumb.jpg", // 230 x 66px
'description' => __( 'Image Description', 'child2011' )
) // the last image does not get a comma
@senlin
senlin / add-breadcrumb-navigation.php
Created March 15, 2012 17:54
Add Breadcrumb Navigation
<?php // Add Breadcrumb Navigation
function write_breadcrumb() {
$pid = $post->ID;
$trail = '<a href="/">'. __('Home', 'textdomain') .'</a>';
if (is_front_page()) {
// do nothing
}
elseif (is_page()) {
$bcarray = array();