Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
chrisguitarguy / wp-registration-keys.php
Created August 30, 2011 20:28
Only lets users with an invite code register for a WordPress site.
<?php
/*
Plugin Name: WP Invite Codes
Plugin URI: http://pmg.co/
Description: Makes wordpress an invite only community.
Version: n/a
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
*/
@chrisguitarguy
chrisguitarguy / comments-example.php
Created September 21, 2011 21:44
How to add custom fields to WordPress comments
<?php
/*
Plugin Name: Add Extra Comment Fields
Plugin URI: http://pmg.co/category/wordpress
Description: An example of how to add, save and edit extra comment fields in WordPress
Version: n/a
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: MIT
*/
@chrisguitarguy
chrisguitarguy / jquery-tabs.html
Created September 23, 2011 15:17
Generic jQuery tab navigation
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('ul.tab-nav li').click(function(e){
var tab_id = jQuery(this).attr('id');
jQuery('ul.tab-nav li').removeClass('active');
$(this).addClass('active');
jQuery('.tab-container div.tab').hide();
jQuery('.tab-container div#' + tab_id + '-tab').show();
});
@chrisguitarguy
chrisguitarguy / email-reminder.php
Created September 28, 2011 02:08
Sends an email reminder if you haven't posted on your WordPress blog in a week
<?php
/*
Plugin Name: Reminder Emails
Plugin URI: http://www.christopherguitar.net/
Description: Sends a reminder email if you haven't posted in seven days.
Version: n/a
Author: Christopher Davis
Author URI: http://www.christopherguitar.net
License: GPL2, Creative Commons
*/
<?php
// First, backup the default $postdata
$backup = $post;
// Now, override the default
$tags = wp_get_post_tags($post->ID);
// Now, open the if ( $tags ) statement
if ($tags) {
$tag_ids = array();
@rwbaker
rwbaker / mediaqueries.css
Created October 17, 2011 00:09
Basic Media Queries
/*
Media Queries
Author: Misc
Source: Misc
Requires: https://github.com/scottjehl/Respond
*/
/* Smart Phones */
@media screen and (max-width: 480px){
}/*/mediaquery*/
@chrisguitarguy
chrisguitarguy / members.php
Created November 6, 2011 04:22
Custom menus (and much more) for logged in WordPress users
<?php
/*
Plugin Name: Gallery Members (for wpse32840)
Description: Only allow members to view one page
Author: Christopher Davis
Author URI: http://www.christopherguitar.net/
*/
register_activation_hook( __FILE__, 'wpse32840_activation' );
function wpse32840_activation()
@sebacruz
sebacruz / user-usergroup-taxonomy.php
Created November 15, 2011 10:24 — forked from mjangda/user-usergroup-taxonomy.php
Using a taxonomy to store user-to-usergroup relationships
<?php
// Assuming we already have registered the taxonomy.
$usergroup_taxonomy = 'ef_usergroups';
// Tell WordPress that we can make associations between users and the usergroups taxonomy.
register_taxonomy_for_object_type( $usergroup_taxonomy, 'user' );
// Sample code
$user = WP_User( 1 );
@nogo
nogo / gist:1374056
Created November 17, 2011 18:47
Google Maps Page Integration
<div id="map_container" style="width: 100%; height: 300px; margin-bottom: 10px;"></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=en"></script>
<script type="text/javascript">
var Markers = [{"address":"ADRESSE","info":"","title":""}];
var Marker = "/path/to/image/marker.png";
(function($, markers, markerIcon) {
var map, geocoder, infowindow;
@boogah
boogah / WordPress_Unicode_Fix.sql
Last active October 14, 2016 08:11
Run this when you see weird crap in your posts/comments after moving your WordPress install.
update wp_posts set post_content = replace(post_content,'’','\'');
update wp_posts set post_title = replace(post_title,'’','\'');
update wp_comments set comment_content = replace(comment_content,'’','\'');
update wp_postmeta set meta_value = replace(meta_value,'’','\'');
update wp_posts set post_excerpt = replace(post_excerpt,'’','\'');
update wp_posts set post_content = replace(post_content,'…','...');
update wp_posts set post_title = replace(post_title,'…','...');
update wp_comments set comment_content = replace(comment_content,'…','...');
update wp_postmeta set meta_value = replace(meta_value,'…','...');