Skip to content

Instantly share code, notes, and snippets.

View JudeRosario's full-sized avatar

Jude Rosario JudeRosario

View GitHub Profile
@JudeRosario
JudeRosario / Random Worker.php
Created February 5, 2015 14:23
Appointments+ Feature: Select a random service provider
add_filter('app_pre_confirmation_reply', 'select_random_provider');
function select_random_provider($reply_array)
{
// Return if worker is already selected
if(''!==$reply_array['worker'])
return $reply_array;
// Read in the $value params from the $_POST request
global $appointments;
@JudeRosario
JudeRosario / Force Fire EMails.php
Created February 5, 2015 14:32
Membership Communications Test
// Use this Function to test if Membership sends out emails
add_filter( 'the_content' , 'wp_mail_test' );
function wp_mail_test( $content ){
// Put the ID of the message you want to send here
$c = new M_Communication(1) ;
// Put the User ID here, to whom the mail must be sent
$c->send_message(1,false,false);
return $content;
}
@JudeRosario
JudeRosario / WP Async Scripts.php
Last active August 29, 2015 14:14
JS Foo to force Async Loading
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
return preg_replace("/(><\/[a-zA-Z][^0-9](.*)>)$/", " async $1 ", $tag );
}, 10, 2 );
@JudeRosario
JudeRosario / Admin Notification.php
Created February 5, 2015 15:12
Fundraising Feature : Send Admin Notifications
function send_admin_notification($funder_id, $trans = false, $fund) {
if($trans != false) {
$donor = $trans['first_name'] . ' ' . $trans['last_name'];
$donation_amount = $this->format_currency('',$trans['gross'], 1);
$donor_email = $trans['payer_email'];
$recurring = 'One-Time';
if(isset($trans['cycle'])) {
$recurring = $trans['cycle'];
@JudeRosario
JudeRosario / MarketPress Custom Cart Image.php
Created February 5, 2015 15:16
MarketPress Feature : Custom Cart Images
add_action( 'wp_ajax_check_empty', 'is_cart_empty' );
add_action( 'wp_ajax_nopriv_check_empty', 'is_cart_empty' );
add_action( 'wp_footer', 'wagon_script' );
function is_cart_empty($content) {
global $mp ;
$products = $mp -> get_cart_contents() ;
if (empty($products))
echo "Empty" ;
else
@JudeRosario
JudeRosario / Google Analytics - App+.php
Created February 5, 2015 15:25
Appointments+ and Google Analytics Integration
function GA_Event_Code($ret) {
$script = <<< GACode
<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery( ".appointments-confirmation-button" ).bind( "click", function() {
// Update variable names here to match what you previously set.
_gaq.push(['_trackEvent', 'Confirmed', 'Click', 'Appointment Confirmed']);
});
});
</script>
@JudeRosario
JudeRosario / MailChimp - BP - Sync.php
Last active August 29, 2015 14:14
Integrates MailChip with Membership and BuddyPress
add_action( 'bp_core_signup_user', 'integrate_profile_fields' ) ;
function integrate_profile_fields ($user_id, $user_login, $user_password, $user_email, $usermeta) {
require_once( MAILCHIMP_PLUGIN_DIR.'mailchimp-sync.php' );
require_once( MAILCHIMP_PLUGIN_DIR.'helpers.php' );
$mailchimp_mailing_list = get_site_option('mailchimp_mailing_list');
$mailchimp_auto_opt_in = get_site_option('mailchimp_auto_opt_in');
@JudeRosario
JudeRosario / ProSites SSL Fix.php
Created February 5, 2015 16:18
Pro Sites SSL Fix
add_filter ('psts_setting_checkout_url' , 'ssl_url_fix');
function ssl_url_fix( $setting, $default ) {
// If permalink does not have http prepended then do it.
if (strpos($setting, "http://") !== 0)
$setting = "http://". $setting ;
return $setting ;
}
@JudeRosario
JudeRosario / App+ Inject Phone.php
Last active August 29, 2015 14:15
Appointements + Service Provider Phone in emails
// Append the Phone Number to the Confirmation / Reminder mails
add_filter( 'app_confirmation_message', 'append_phone_to_app_email', 10, 3 );
add_filter( 'app_reminder_message', 'append_phone_to_app_email', 10, 3 );
function append_phone_to_app_email( $msg, $obj, $app_id) {
$worker = $obj->worker;
// Get Worker Phone from $meta table
$worker_phone = get_user_meta($worker, "app_phone", true);
if ( $worker_phone ) {
// Search and replace the WORKER_CONTACT string
@JudeRosario
JudeRosario / Bulk Update Templates.php
Last active August 29, 2015 14:15
New Blog Templates : Bulk update Template
include_once( WP_CONTENT_DIR . '/plugins/blogtemplates/nbt-api.php' );
nbt_load_api();
// Fires when a new blog is created
add_action( 'wpmu_new_blog', 'bulk_update_blogs', 99, 2 );
// Hook this function to a good place
function bulk_update_blogs( $new_blog_id, $new_user_id ) {