Skip to content

Instantly share code, notes, and snippets.

View aschweigert's full-sized avatar

Adam Schweigert aschweigert

View GitHub Profile
add_filter('wpmu_validate_user_signup','nd_validate_user_signup',10,3);
add_filter('signup_extra_fields','nd_extra_fields',10,1);
add_filter('add_signup_meta','nd_add_signup_meta');
add_action('wpmu_activate_user','nd_wpmu_activate_user', 10, 3);
function nd_extra_fields ($result) {
$first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name']: '';
$last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name']: '';
$error_msgs = $result->errors;
?>
@aschweigert
aschweigert / gist:334bbd5421c6a606f7f2
Created November 3, 2014 17:24
WPE DNS for new site
Email member and have them create (or change) the A record for the domain they want to use to point to 50.116.39.12
Then, in the WP Engine dashboard:
- click on the property name and then "domains"
- click on "add new domain" and enter the domain you want to add, at this stage you can also redirect other domains to the domain you're adding (e.g. citylimits.largoproject.org or www.citylimits.org) and it will pass these through to the primary domain you've added
In the WP Admin:
- from My Sites > Network Admin > Settings > Domains under "new domain" add the site ID and the domain you want to map to that site ID ("primary" should not be checked)
@aschweigert
aschweigert / functions.php
Created July 18, 2012 18:25 — forked from johnmegahan/functions.php
Extended Walker class for use with the Twitter Bootstrap toolkit Dropdown menus in Wordpress. (adds support for second level dropdowns)
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
if ( ! function_exists( 'largo_opengraph' ) ) {
function largo_opengraph() {
global $current_url, $post;
// set a default thumbnail, if a post has a featured image use that instead
if ( is_single() && has_post_thumbnail( $post->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail' );
$thumbnailURL = $image[0];
} else if ( of_get_option( 'logo_thumbnail_sq' ) ) {
@aschweigert
aschweigert / gist:f5dd03e04bea91797c0c
Last active December 29, 2015 14:29
Standalone WP -> Multisite migration queries
[prefix] is needed to push the new users/usermeta values outside of the range already populated in the database, usually for a site with an ID of 40 using 40,000 will work pretty well (unless some of your sites have a lot of users).
UPDATE wp_users
SET ID = ID + [prefix]
// Add two columns to the end of the wp_users table, spam and deleted. Both are TINYINT(2).
UPDATE wp_usermeta
SET user_id = user_id + [prefix]
//least destructive, just update ones set to the old default
UPDATE wp_43_postmeta
SET meta_value = 'none'
WHERE meta_key = 'custom_sidebar' AND meta_value = 'sidebar-single'
//OR set them all to "none"
UPDATE wp_43_postmeta
SET meta_value = 'none'
WHERE meta_key = 'custom_sidebar'
@aschweigert
aschweigert / gist:9dd8391d7c47cbe11c80
Last active February 3, 2016 20:52
set featured images to false before X date
drop temporary table if exists post_ids;
create temporary table if not exists post_ids
select ID from wp_14_posts
where post_status = 'publish'
and post_type = 'post'
and post_date < '2016-02-03 00:00:000';
delete wp_14_postmeta from wp_14_postmeta join post_ids
on wp_14_postmeta.post_id = post_ids.ID
and wp_14_postmeta.meta_key = 'featured-image-display';
insert into wp_14_postmeta (post_id, meta_key, meta_value)
@aschweigert
aschweigert / 0_reuse_code.js
Created April 6, 2016 17:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
add_filter( 'dfw_network_code', 'mj_dfp_network_code' );
add_filter( 'dfw_breakpoints', 'mj_dfp_breakpoints' );
add_filter( 'dfw_targeting_criteria', 'mj_dfp_targeting' );
add_filter( 'dfw_mappings', 'mj_dfp_mapping' );
function mj_dfp_network_code() {
return 49189977;
}
function mj_dfp_breakpoints( $breakpoints ) {
$mj_breakpoints = array(
array(
@aschweigert
aschweigert / chart-styles.md
Last active May 25, 2018 15:14
Post Inline Elements

Styles exist to add headlines, credits and captions to charts.

To use these you'll need to wrap the entire chart in a <section> tag with the .inline-element and .chart classes:

<section class="inline-element chart">

Then you can use: