This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person extends Model { | |
use AlgoliaEloquentTrait; | |
public $indices = [‘my-index’]; | |
public function getAlgoliaRecord() { | |
return array_merge($this->toArray(), [ | |
‘addresses’ => $this->addresses->toArray(), | |
‘contacts’ => $this->contacts->toArray() | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person extends Model { | |
use AlgoliaEloquentTrait; | |
public $indices = [‘my-index’]; | |
public function getAlgoliaRecord() { | |
return array_merge($this->toArray(), [ | |
‘addresses’ => $this->addresses->toArray(), | |
‘contacts’ => $this->contacts->toArray(), | |
‘type’ => ‘person' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Check to make sure the token is valid | |
if (!isset($_POST['token']) || $_POST['token'] != SLACK_TOKEN) { | |
throw new Exception("Shenanigans!"); | |
} | |
echo "Hello World!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Check to make sure the token is valid | |
if (!isset($_POST['token']) || $_POST['token'] != SLACK_TOKEN) { | |
throw new Exception("Shenanigans!"); | |
} | |
/* | |
* This sends a message back to the user immediately so they know something's happening. | |
* The `ignore_user_abort` allows the script to keep running, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="main"> | |
<div class="notice" id="main-notice"> | |
Turn your sound on and click an icon! | |
</div> | |
<div class="content"> | |
<div id="circle1" data-note="c" class="circle"><i class="fa fa-facebook-square" aria-hidden="true"></i></div> | |
<div id="circle2" data-note="c-sharp" class="circle"><i class="fa fa-twitter-square" aria-hidden="true"></i></div> | |
<div id="circle3" data-note="d" class="circle"><i class="fa fa-instagram" aria-hidden="true"></i></div> | |
<div id="circle4" data-note="e" class="circle"><i class="fa fa-google-plus-square" aria-hidden="true"></i></div> | |
<div id="circle5" data-note="e-flat" class="circle"><i class="fa fa-linkedin-square" aria-hidden="true"></i></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args ( | |
'to' => Array(), | |
'subject' => String, | |
'headers' => Array(), | |
'attachments' => Array(), | |
'message' => String, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wp_mail', 'handle_wp_mail'); | |
function handle_wp_mail($args) { | |
if ($args['subject'] == 'Welcome to YOUR SITE') { | |
$newMessage = <<<EOT | |
<h2>Welcome to YOUR SITE</h2> | |
<p>Dear User,</p> | |
<p>Thanks for registering!</p> | |
EOT; | |
$newMail = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wp_mail', 'handle_wp_mail'); | |
function handle_wp_mail($args) { | |
if ($args['subject'] == 'Welcome to YOUR SITE') { | |
$wpdb = $GLOBALS['wpdb']; | |
$email = $args['to'][0]; | |
$user = get_user_by('email', $email); | |
//Generate a new user_activation_key (eg password reset key) | |
//This allows us to create a link that a new user can click to set their initial password | |
$key = wp_generate_password(20, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('user_register', 'handle_user_register', 10, 1); | |
function handle_user_register($user_id) { | |
/* | |
* When a new user registers, write all POST values to user_meta. | |
* This way, they're accessible on when the new-user email is sent through wp_mail. | |
* Otherwise values like first & last name aren't accessible in the email | |
*/ | |
foreach ($_POST as $key => $val) { | |
update_user_meta($user_id, $key, $_POST[$key]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$newMessage = <<<EOT | |
<h2>Welcome, {$userMeta['first_name'][0]}</h2> | |
EOT; |