Skip to content

Instantly share code, notes, and snippets.

@menslow
menslow / WordPress Sign In
Created April 12, 2012 21:12
WordPress: Simple sign in function for custom front-end sign in forms.
/**
* mm_sign_in function.
* Sign the user in
* @access public
* @return User errors or true if successful signon
*/
function mm_sign_in() {
if(!is_user_logged_in()) {
if(!empty($_POST)) {
// verify nonce
@zspine
zspine / nationalities.php
Last active October 24, 2023 08:58
PHP Nationalities Array
$nationals = array(
'Afghan',
'Albanian',
'Algerian',
'American',
'Andorran',
'Angolan',
'Antiguans',
'Argentinean',
'Armenian',
@smonteverdi
smonteverdi / gist:2344892
Created April 9, 2012 17:30
WordPress: Update admin password with a query
UPDATE `wp_users` SET `user_pass` = MD5( 'new_password_here' ) WHERE `wp_users`.`user_login` = "admin_username";
@franz-josef-kaiser
franz-josef-kaiser / hide_admin_bar.php
Created March 29, 2012 13:52
Hide the admin bar with the click of a button in the WP admin UI
<?php
/**
* Plugin Name: "Hide Admin Bar"-Button
* Plugin URI: http://unserkaiser.com
* Description: Easier debugging when the error message is hidden behind the admin bar.
* Version: 0.1
* Author: Franz Josef Kaiser
* Author URI: http://unserkaiser.com
*/
// Prevent loading this file directly - Busted!
@fritids
fritids / gist:2231121
Created March 28, 2012 22:31 — forked from trepmal/gist:1566525
WordPress: Breadcrumb Functions
<?php
/*
Plugin Name: Breadcrumb Functions
Description: Functions for displaying breadcrumbs when working with hierarchical post types. Does nothing out-of-the-box, functions must be added to theme (directly or via hooks, your discretion).
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
*/
/*
Basic:
echo get_breadcrumbs( $post );
@mikeschinkel
mikeschinkel / rootbased-taxonomy-urls.php
Created March 26, 2012 04:29
Root-based Taxonomy URLs Plugin for WordPress
<?php
/*
* Plugin Name: Root-based Taxonomy URLs for WordPress
* Description: Enables root-based Taxonomy URLs, i.e. Makes /taxonomy/my-taxonomy/ URLs route as /my-taxonomy/
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel
* Plugin URI: https://gist.github.com/1421235
* Version: 0.1
* License: GPL 2+
* Notes: Must use register_root_based_taxonomy_url( $taxonomy[, $priority] ) in an 'init' hook to specify root_based taxonomy.
@mattboon
mattboon / gist:2158494
Created March 22, 2012 13:58
jQuery - Action when user has scrolled
$(document).scroll(function(e) {
var nav = $('nav'),
page = $('body'),
scrollValue = page[0].offsetTop - window.pageYOffset;
if(scrollValue < -20 ) {
nav.addClass('scrolled');
}
else {
nav.removeClass('scrolled');
@sloped
sloped / paging.php
Created March 19, 2012 16:21
Bootstrap Paging and Wordpress
<?php
//Use this function to create pagingation links that are styleable with Twitter Bootstrap
function paging() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
@mattboon
mattboon / gist:2021115
Created March 12, 2012 10:45
WordPress - Query Posts with date custom field, hide those in past
<ul class="feed events">
<?php
global $post;
$args = array(
'numberposts' => 3,
'category' => 3,
'meta_key' => 'event_date',
'meta_value' => date("Y-m-d"),
'meta_compare' => '>=',
'orderby' => 'meta_value',
@chrisguitarguy
chrisguitarguy / wpse45134.php
Created March 10, 2012 17:54
Don't allow people to view the default WordPress registration page
<?php
/*
Plugin Name: Registration Redirect
Description: Don't allow people to view the default registration page
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
*/
add_action( 'login_form_register', 'wpse45134_catch_register' );