Skip to content

Instantly share code, notes, and snippets.

@blobaugh
blobaugh / tec_organizer_dropdown.php
Created October 16, 2012 23:38
More efficient TEC organizer dropdown at scale
public static function facilitatorSelect( $name, $current, $special = false){
if( $special ) {
$id = 'saved_organizer';
} else {
$id = str_replace(array('[',']'),'',$name);
}
$current_user = wp_get_current_user();
$s = '<select class="chosen organizer-dropdown" name="' . esc_attr( $name ) . '" id="'.$id.'">';
$s .= '<option value="0">' . __( 'Use New Facilitator' , 'tribe-events-calendar-pro' ) . '</option>';
@blobaugh
blobaugh / gist:3920430
Created October 19, 2012 20:15
Data Enterer Metabox
<?php
class WotDataEntererListMetabox {
public function __construct() {
add_action( 'add_meta_boxes', array( &$this, 'add' ) );
add_action( 'save_post', array( &$this, 'save' ) );
}
public function add() {
@blobaugh
blobaugh / gist:3982795
Created October 30, 2012 20:28
Insert media to WordPress
function insertAttachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
//if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
$attach_id = media_handle_upload( $file_handler, $post_id, array(), array( 'test_form' => false, 'test_upload' => false ) );
@blobaugh
blobaugh / gist:4067886
Created November 13, 2012 19:38
ajax example
jQuery.post(ajaxurl, {
action: 'ajaxGetFacilitatorInfo',
org_id: org_id
}, function(data) {
jQuery('#eventRealOrganizerName').val( data.name );
jQuery('#eventRealOrganizerEmail').val( data.email );
jQuery('#eventRealOrganizerPhone').val( data.phone );
jQuery('#eventRealOrganizerBusinessName').val( '' );
},
@blobaugh
blobaugh / wds_vc_cta.php
Last active November 4, 2015 20:32
Example Visual Composer CTA addon
<?php
WDS_VC_CTA::get_instance();
class WDS_VC_CTA {
private static $instance = null;
private $block_name = 'wds_cta';
private function __construct() {
@blobaugh
blobaugh / remove-emoji.php
Created November 30, 2015 18:08
mu-plugin to remove WordPress emoji auto-support
<?php
/*
* Disable emojis.
*
* There have been security issues, plus it simply provides better
* performance not to load unecessary core crap all the time.
*/
function grd_remove_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
@blobaugh
blobaugh / auto_activate_users.php
Created December 11, 2015 15:36
Auto activate users on WordPress Multisite
<?php
add_filter('wpmu_signup_user_notification', 'auto_activate_users', 10, 4);
function auto_activate_users($user, $user_email, $key, $meta){
wpmu_activate_signup($key);
return false;
}
@blobaugh
blobaugh / gist:5165142
Created March 14, 2013 20:53
Original options.php
<?php
// Grab the original options.php file
require_once( WOT_PLUGIN_DIR . '3rd-party/options.php' );
add_filter( 'wot_options_page', 'wot_theme_add_options' );
/**
* Add any custom fields that are required to the options framework
@blobaugh
blobaugh / gist:5165152
Created March 14, 2013 20:54
options.php in plugin
<?php
/**
* A unique identifier is defined to store the options in the database and reference them from the theme.
* By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
* If the identifier changes, it'll appear as if the options have been reset.
*
*/
function optionsframework_option_name() {
@blobaugh
blobaugh / wp-seo-no.php
Created December 17, 2015 19:41
Prevents WP SEO from requesting updates
add_filter( 'site_transient_update_plugins', 'wds_wp_seo_no_update' );
function wds_wp_seo_no_update( $value ) {
if ( empty( $value ) || empty( $value->response['wordpress-seo/wp-seo.php'] ) ) {
return $value;
}
unset( $value->response['wordpress-seo/wp-seo.php'] );
return $value;
}