Skip to content

Instantly share code, notes, and snippets.

@balupton
balupton / README.md
Last active July 13, 2024 17:32
Ajaxify a Website with the HTML5 History API using History.js, jQuery and ScrollTo
@jankeesvw
jankeesvw / Functions.php
Created April 19, 2011 08:58
Grayscale image in wordpress
<?php
add_filter('update_attached_file', 'convertToGrayscale');
function convertToGrayscale($location,$id)
{
$info = getimagesize($location);
switch ($info['mime'])
{
case 'image/jpeg':
How to add a widget area to your theme.
<div id="sidebar">
<ul>
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar()) : ?>
<li><!-- stuff shown here in case no widgets active --></li>
<?php endif; ?>
</ul>
</div>
@freekrai
freekrai / multisite_functions.php
Created July 19, 2011 14:20
Some handy wordpress multisite functions
<?php
$posts = multisite_latest_post( array(
"how_many"=>10,
"how_long_days"=>30,
"how_many_words"=>50,
"more_text"=>"[...]",
"remove_html"=>true,
"sort_by"=>"post_date",
// if paginating:
"paginate"=>true,
@amereservant
amereservant / tc.framwork.base.php
Created October 12, 2011 17:36
WordPress Options Framework
<?php
/**
* TC Framework Base
*
* This is an abstract class that creates a standard base for all TC projects.
*
* All options are stored under two WordPress options, one for the standard options
* and another for the multisite options (if the theme/plugin has need for these).
*
* @author Amereservant <amereservant@gmail.com>
@trepmal
trepmal / gist:1563783
Created January 5, 2012 04:58
WordPress: Custom Field Shortcodes
<?php
/*
Plugin Name: Custom Field Shortcodes
Plugin URI: http://trepmal.com/2010/12/including-custom-fields-inside-your-post/
Description: Include a custom field in your post with a shortcode. [cf name=custom_field]
Author: Kailey Lampert
Version: 1.0
Author URI: http://kaileylampert.com/
*/
/*
@mocassinis
mocassinis / responsive-images.php
Created February 27, 2012 21:32 — forked from chrisjlee/responsive-images.php
Wordpress Plugin - Responsive Images
<?php
/*
Plugin Name: Mobile First Responsive Images
Description: Serve up smaller images to smaller screens.
Version: 0.1.1
Author: Matt Wiebe
Author URI: http://somadesign.ca/
*/
/**
@kovshenin
kovshenin / image-shortcode.php
Created March 6, 2012 06:41
Image shortcode for WordPress
<?php
/**
* Image shortcode callback
*
* Enables the [kovshenin_image] shortcode, pseudo-TimThumb but creates resized and cropped image files
* from existing media library entries. Usage:
* [kovshenin_image src="http://example.org/wp-content/uploads/2012/03/image.png" width="100" height="100"]
*
* @uses image_make_intermediate_size
*/
@FernE97
FernE97 / slides.php
Created March 6, 2012 23:02
PHP: WordPress Slides
<ul class="slides">
<?php
$args = array(
'post_type' => 'slide',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => 3
);
$slides = get_posts( $args );
@ancillaryfactory
ancillaryfactory / gist:1990297
Created March 7, 2012 01:29 — forked from elebescond/gist:1336580
Wordpress: Register admin options
<?php
add_action( 'admin_init', 'myplugin_admin_init' );
function myplugin_admin_init() {
//register settings
register_setting( 'myplugin_options_group1', 'myplugin_option_1' );
}
// create custom plugin settings menu