Skip to content

Instantly share code, notes, and snippets.

<?php
function glip_webhook($webhook_url,$title, $body, $activity,$icon ='' ) {
$json = json_encode(array('icon'=>$icon,'activity'=>$activity,'title'=>$title,'body'=>$body) );
$ch = curl_init($webhook_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
{
"activity":"Contact Us form fill",
"attachments":[
{
"fields":[
{
"title":"Name",
"value":"{{lead.First Name:default= }} {{lead.Last Name:default= }}"
},
{
@davidfcarr
davidfcarr / block.js
Created August 6, 2018 23:00
Problem rich text component block
/**
2 * BLOCK: wpt
3 *
4 * Registering a basic block with Gutenberg.
5 * Simple block, renders and saves the same content without any interactivity.
6 */
7
8 // Import CSS.
9 import './style.scss';
10 import './editor.scss';
const { subscribe } = wp.data;
if((typeof rsvpmaker_json !== 'undefined' ) && rsvpmaker_json.projected_url) {
let wasSavingPost = wp.data.select( 'core/editor' ).isSavingPost();
let wasAutosavingPost = wp.data.select( 'core/editor' ).isAutosavingPost();
let wasPreviewingPost = wp.data.select( 'core/editor' ).isPreviewingPost();
// determine whether to show notice
subscribe( () => {
const isSavingPost = wp.data.select( 'core/editor' ).isSavingPost();
const isAutosavingPost = wp.data.select( 'core/editor' ).isAutosavingPost();
// context check: if this is an rsvpmaker template, this will have be available as localized data from PHP
if((typeof rsvpmaker_json !== 'undefined' ) && rsvpmaker_json.projected_url) {
let wasSavingPost = wp.data.select( 'core/editor' ).isSavingPost();
let wasAutosavingPost = wp.data.select( 'core/editor' ).isAutosavingPost();
let wasPreviewingPost = wp.data.select( 'core/editor' ).isPreviewingPost();
// determine whether to show notice
subscribe( () => {
const isSavingPost = wp.data.select( 'core/editor' ).isSavingPost();
const isAutosavingPost = wp.data.select( 'core/editor' ).isAutosavingPost();
@davidfcarr
davidfcarr / gutenbeg-notification.js
Created March 17, 2019 13:30
Custom notification in WordPress Gutenberg
// context check: if this is an rsvpmaker template, this will have be available as localized data from PHP
if((typeof rsvpmaker_json !== 'undefined' ) && rsvpmaker_json.projected_url) {
let wasSavingPost = wp.data.select( 'core/editor' ).isSavingPost();
let wasAutosavingPost = wp.data.select( 'core/editor' ).isAutosavingPost();
let wasPreviewingPost = wp.data.select( 'core/editor' ).isPreviewingPost();
// determine whether to show notice
subscribe( () => {
const isSavingPost = wp.data.select( 'core/editor' ).isSavingPost();
const isAutosavingPost = wp.data.select( 'core/editor' ).isAutosavingPost();
<?php
/*
Plugin Name: Change Set Password Link
*/
//modification for rsvpmaker-for-toastmasters
add_filter('welcome_message_set_password','my_welcome_message_set_password',10,3);
function my_welcome_message_set_password ($set_password_url, $key, $user_login) {
//make this whatever it needs to be for your front end login function. $key is a password reset hash code
<?php
//excerpt from rsvpmaker-for-toastmasters
function sendWelcome($user) {
$key = wp_generate_password( 20, false );
do_action( 'retrieve_password_key', $user["user_login"], $key );
// Now insert the key, hashed, into the DB.
if ( empty( $wp_hasher ) ) {
<script>
class RSVPJsonWidget {
constructor(divid, url, limit, morelink = '') {
this.el = document.getElementById(divid);
this.url = url;
this.limit = limit;
this.morelink = morelink;
let eventslist = '';
fetch(url)
@davidfcarr
davidfcarr / init.php
Last active December 27, 2019 14:17
Excerpt from init.php for Gutenberg sidebar metadata demo
<?php
add_action( 'init', function(){
register_meta( 'post', '_demo_select', array(
'type' => 'string',
'single' => true,
'show_in_rest' => true,
'auth_callback' => function() {
return current_user_can('edit_posts');
}
) );