Skip to content

Instantly share code, notes, and snippets.

@gregelin
gregelin / wp-db.tutorial.php
Created January 14, 2012 10:11 — forked from benbalter/wp-db.tutorial.php
WordPress DB Tutorial
<?php
//absolute path to wp-load.php, or relative to this script
//e.g., ../wp-core/wp-load.php
include( 'trunk/wp-load.php' );
//grab the WPDB database object, using WP's database
//more info: http://codex.wordpress.org/Class_Reference/wpdb
global $wpdb;
@wpsmith
wpsmith / gist:1647598
Created January 20, 2012 14:31
Expanding taxonomy_select
case 'taxonomy_select':
echo '<select name="', $field['id'], '" id="', $field['id'], '">';
$names= wp_get_object_terms( $post->ID, $field['taxonomy'] );
$terms = get_terms( $field['taxonomy'], 'hide_empty=0' );
if ( $field['options'] ) {
foreach ($field['options'] as $option) {
echo '<option value="', $option['value'], '"', $meta == $option['value'] ? ' selected="selected"' : '', '>', $option['name'], '</option>';
}
}
foreach ( $terms as $term ) {
@wpsmith
wpsmith / gist:1690166
Created January 27, 2012 18:26
Taxonomy and Terms Dropdown
add_action( 'ntg_render_taxonomy_terms_select' , 'wps_taxonomy_terms_select' , 10 , 3 );
function wps_taxonomy_terms_select ( $field, $meta, $id ) {
global $post;
if ( $field['type'] == 'taxonomy_terms_select' ) {
echo '<select name="', $id, '" id="', $id, '" style="margin-top: 5px;">';
$pts = get_post_types();
echo '<option style="padding-right:10px;" value=""', selected ( $meta, '' ), '>', __( 'All Taxonomies and Terms', WPS_SLIDER ).'</option>';
if ( $field['options'] ) {
anonymous
anonymous / profile.php
Created January 29, 2012 17:10
Wordpress front end log in page template with multiple custom meta_key - input, select, dropdown
<?php
global $user_ID, $user_identity, $user_level;
if ($user_ID) {
if($_POST)
{
@ramseyp
ramseyp / wp_user-profile-fields.php
Created January 31, 2012 19:45
Add Extra Fields to WordPress user profile
<?php
/* Add Extra Profile Meta fields to WordPress user profile
*/
//Extra Author Profile Meta
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Is this an active author?</h3>
@mikeschinkel
mikeschinkel / functions.php
Created February 3, 2012 07:43
Master WordPress Custom Post Types - WordCamp Atlanta 2012
<?php
/*
* Code Examples for Master WordPress Custom Post Types - WordCamp Atlanta 2012
*
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel
*
*/
add_action( 'init', 'mikes_theme_init' );
function mikes_theme_init() {
@pfctdayelise
pfctdayelise / checkBadware.py
Created February 7, 2012 13:57
something to help me detect badware. hopefully useful to run as cron.
#!/usr/bin/env python
import os
import argparse
import urllib
from BeautifulSoup import BeautifulSoup # 3.2.0
def getPagesForOnePath(path):
f = urllib.urlopen(path)
soup = BeautifulSoup(f)
@chrisguitarguy
chrisguitarguy / wpse41778-rewrite.php
Created February 9, 2012 18:15
rewrite help for WPSE
<?php
/*
Plugin Name: WPSE 41778 Rewrite
Author: Christopher Davis
Author URI: http://christopherdavis.me/
*/
add_action( 'init', 'wpse41778_add_rewrite' );
function wpse41778_add_rewrite()
{
@johnpbloch
johnpbloch / disable-plugins-when-doing-local-dev.php
Created February 11, 2012 20:12 — forked from markjaquith/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
<?php
add_action('publish_post', 'schedule_glossary_index', 10, 1);
function schedule_glossary_index($post_id) {
wp_schedule_single_event(time(), 'update_glossary_index', array( $post_id ));
}
add_action('update_glossary_index', 'do_update_glossary_index', 10, 1);
function do_update_glossary_index($post_id) {
global $wpdb;