Skip to content

Instantly share code, notes, and snippets.

@ultimatemember
ultimatemember / gist:6c8d18b2b0869662d203
Last active August 29, 2015 14:15
Check when user updates e-mail via account page
add_action('um_account_pre_update_profile', 'did_user_change_email', 10, 2 );
function did_user_change_email( $changes, $user_id ) {
$data = get_userdata($user_id);
if ( isset( $changes['user_email'] ) && $data->user_email != $changes['user_email'] ) {
// user e-mail changed! Do something
}
}
@nternetinspired
nternetinspired / Modernizr conditional loading
Created July 16, 2012 08:34
Conditional resource loading, using Modernizr's yepnope tests, based on viewport size. Placed immediately before the closing head tag in index.php this can be used to load specific resources against reported viewport sizes
<!-- Something like this -->
<script>
Modernizr.load({
test: Modernizr.mq('(min-width:400px)'),
yep: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/not-small-screen-stuff.js">',
});
</script>
<!-- Or -->
<script>
@poeticninja
poeticninja / gist:5985220
Created July 12, 2013 15:11
Here is how to add Medium to the Zurb Foundation 4 CSS framework. This makes the grid change on any html with the medium-$ class. Great for iPad and more custom sizing of website. Make sure you add this after the @import "foundation/components/global", "foundation/components/grid";.
@if $include-html-grid-classes != false {
/* Styles for screens that are atleast 768px and max width 1024px */
@media #{$small} and (max-width: 1024px) {
@for $i from 1 through $total-columns {
.medium#{-$i} { @include grid-column($columns:$i,$collapse:null,$float:false); }
}
@for $i from 0 through $total-columns - 1 {
#!/bin/bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/Sites/wp-plugins/$DIR_NAME/$BRANCH
@mikeschinkel
mikeschinkel / example-phpstorm-scope-for-wordpress
Created May 6, 2013 23:37
PhpStorm example scope for specifying only WordPress a website's theme and plugin, assuming the only files of concern are .PHP, .CSS and .JS.
file:www/wp-content/themes/my-site-child//*.php||file:www/wp-content/themes/my-site-child//*.css||file:www/wp-content/themes/my-site-child//*.js||file:www/wp-content/plugins/my-site//*.php||file:www/wp-content/plugins/my-site//*.css||file:www/wp-content/plugins/my-site//*.js
@retgef
retgef / psuedo-static-js.php
Last active April 7, 2017 22:00
Add a pseudo static JS file to WordPress
<?php
#Add a query var to sniff requests
add_filter( 'query_vars', 'my_query_var_callback', 10, 1 );
function my_query_var_callback( $vars ){
$vars[] = 'dynamic_js';
return $vars;
}
#Dynamic JavaScript
add_rewrite_rule( '^assets/js/dynamic\.js$', 'index.php?dynamic_js=1', 'top' ); //Note the hidden query variable
@johnpbloch
johnpbloch / README.md
Created August 23, 2012 13:55
A bash script to make .pot files for WordPress plugins

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@markjaquith
markjaquith / plugin-deploy.sh
Created November 16, 2012 05:04 — forked from scribu/plugin-deploy.sh
Plugin deploy script
#!/bin/bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/svn/wp-plugins/$DIR_NAME/$BRANCH
@ultimatemember
ultimatemember / gist:5f093ac300baa1d2a5f1
Last active October 25, 2018 01:50
Example: block any registration that does not use @gmail as mail provider
/*
The following code will require @gmail.com as domain
for user registrations.
You can change @gmail.com to any provider you want.
The code below requires a user email to be collected during registration
*/
add_action('um_before_new_user_register', 'require_google_email_for_signup');
@jbinto
jbinto / index.jsx
Created November 28, 2015 22:15
Egghead tutorial - Getting Started with Redux - JSBin implementation
/* global ReactRedux, Redux, ReactDOM */
// "Getting Started with Redux" (by Dan Abramov)
// https://egghead.io/series/getting-started-with-redux
// This file on JSBin (by Jesse Buchanan):
// http://jsbin.com/wuwezo/74/edit?js,console,output
////////////////////////////////////////////////
//