Skip to content

Instantly share code, notes, and snippets.

@jhaus
jhaus / SimplestWidget_Widget.php
Created November 26, 2010 03:47 — forked from straps/SimplestWidget_Widget.php
Abstract class to create easily wordpress widgets, documented here http://www.strx.it/2010/11/wordpress-widgets-template/
<?php
class SimplestWidget_Widget extends Strx_Widget {
function w_id(){ return 'simplest-widget'; }
function w_name(){ return 'My Simplest Widget'; }
/** Return the dashboard admin form */
function w_form($instance){
return '<p>'.$this->w_form_input($instance, 'title').'</p>';
}
<?php
// Initialize the Class and add the action
add_action('init', 'pTypesInit');
function pTypesInit() {
global $sites;
$sites = new TypeSites();
}
// Create a post type class for 'Site' posts
// To use as a bookmarking post type for sites you want to save/share.
@jhaus
jhaus / cpt-search.php
Created November 29, 2010 23:58
search wp custom post types too
<?php
// hook into wordpress search function
add_filter( 'the_search_query', 'aggregated_search' );// Define what post types to search
function aggregated_search( $query ) {
if( $query->is_search ) {
$query->set( 'post_type', array( 'post', 'page', 'feed', 'attachment', 'movies', 'quotes' ));//define search types
}
return $query;
}
@jhaus
jhaus / cpt-class-create.php
Created November 29, 2010 23:59
Class for creating custom post types, taxonomies and meta boxes via: http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series2
<?php
// Create a post type class for site posts
// To use as a bookmarking post type for sites you want to save/share.
class TypeSites {
public $meta_fields = array( 'title', 'description', 'siteurl', 'category', 'post_tags' );
public function TypeSites() {
$siteArgs = array(
'labels' => array(
<?php
$q = new WP_query();
$q->query( 'post_type=site' );
/* Begin the Loop */
if ($q->have_posts()) :
while ($q->have_posts()) : $q->the_post();
/**
* Now instantiate the Sites class we made in posttypes.php setting the $s variable
@jhaus
jhaus / YQL-api-aggregation.php
Created November 30, 2010 00:01
Using cURL with YQL to aggregate content on 24ways.org via: https://github.com/codepo8/24-ways-2009/blob/master/index.php
<?php
/* YouTube RSS */
$query = 'select description from rss(5) where url="http://gdata.youtube.com/feeds/base/users/chrisheilmann/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile";';
/* Flickr search by user id */
$query .= 'select farm,id,owner,secret,server,title from flickr.photos.search where user_id="11414938@N00";';
/* Delicious RSS */
$query .= 'select title,link from rss where url="http://feeds.delicious.com/v2/rss/codepo8?count=10";';
@jhaus
jhaus / gData-class.php
Created November 30, 2010 00:02
Saving Form Data to Google Spreadsheets Using PHP and the Google Docs API via: http://farinspace.com/saving-form-data-to-google-spreadsheets/
<?php
/*
Copyright (c) 2009 Dimas Begunoff, http://www.farinspace.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
import re
import urllib2
import urllib
import simplejson as json
# add my.ooma.com credentials here
username = ''
password = ''
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
<?php
// GoogleVoice(EMAIL, PASSWORD)
$gv = new GoogleVoice('example@gmail.com', 'password');
// Sends an SMS. send_sms(NUMBER, MESSAGE)
echo $gv->send_sms('+15555555555', 'Example');
// Gets all the sms
// get_sms() - returns all the sms
// get_sms(true) - returns all the unread sms
echo $gv->get_sms();
@jhaus
jhaus / wp-multi-install
Created December 4, 2010 05:59
install wordpress automatically via: http://codex.wordpress.org install wordpress automatic via: Installing_Multiple_Blogs#Multiple_Install_Automation
#!/bin/sh -x
# script by Stephanie Booth aka bunny http://stephanie-booth.com/ to install wordpress automatically (geeky, but useful for mass installs), with help from many people: drauh, io_error, zedrdave, roddie... and all those I've forgotten to mention.
# variables: $1 whatever, $2 wp_user, $3 wp_pass, $4 root password
# prerequisites: an existing mysql db, and a root password
# care! .htaccess is not generated, needs to be done manually, by clicking on "Update Permalinks" in Options once everything is installed
# todo: add themes, check plugin list, make wrapper script for multiple installs, prepare php patch template for options and common stuff, see if the script can edit the vhost conf files for mass installs, prepare alternate version for French, add bilingual plugin and maybe cache. Add an extra user to the WP install. Also an alternate version for upgrading the school blogs.