Skip to content

Instantly share code, notes, and snippets.

@davidfcarr
davidfcarr / metadata-components.js
Last active December 26, 2019 17:18
Gutenberg components to update metadata
const { __ } = wp.i18n; // Import __() from wp.i18n
//const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks
const el = wp.element.createElement;
const { DateTimePicker, RadioControl, SelectControl, TextControl } = wp.components;
const { withSelect, withDispatch } = wp.data;
var MetaTextControl = wp.compose.compose(
withDispatch( function( dispatch, props ) {
return {
setMetaValue: function( metaValue ) {
@davidfcarr
davidfcarr / sidebar.js
Last active December 26, 2019 17:13
WordPress Gutenberg sidebar for components that can update metadata
const { __ } = wp.i18n; // Import __() from wp.i18n
const el = wp.element.createElement;
const {Fragment} = wp.element;
const { registerPlugin } = wp.plugins;
const { PluginSidebar, PluginSidebarMoreMenuItem } = wp.editPost;
import {MetaTextControl, MetaSelectControl} from './metadata_components.js';
//add to todument sidebar component
const PluginMetaDemo = function() {
return (
<html>
<head>
<title>*|MC:SUBJECT|*</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
#tx-background {background-color: #fff; padding: 10px; margin-top: 0;margin-right: 10px;}
#tx-content {padding: 5px; background-color: pink; margin-top: 10px; margin-bottom: 10px; padding-bottom: 50px; border: thin dotted yellow; max-width: 800px;}
a.rsvplink {width: 8em; display: block; border: medium inset #FF0000; text-align: center; padding: 3px; background-color: #FF8888; color: #FFFFFF; font-weight: bolder; text-decoration: none;}
</style>
</head>
<html>
<head>
<title>*|MC:SUBJECT|*</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
#tx-background {background-color: #000000; padding: 10px; margin-top: 0; color: #FFFFFF; min-height: 1500px;}
#tx-content {max-width: 800px;}
a {color: #BBBBBB}
a.rsvplink {width: 8em; display: block; border: medium inset #FF0000; text-align: center; padding: 3px; background-color: #0000FF; color: #FFFFFF; font-weight: bolder; text-decoration: none;}
a.rsvplink {width: 8em; display: block; border: medium inset #FFFFFF; text-align: center; padding: 3px; background-color: #000000; color: #FFFFFF; font-weight: bolder; text-decoration: none;}
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<!-- NAME: POSTCARD -->
<!--[if gte mso 15]>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
<html>
<head>
<title>*|MC:SUBJECT|*</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
#tx-background {background-color: #191D6C; padding: 10px; margin-top: 0;max-width: 800px;}
#tx-content {padding: 5px; background-color: #FFFFFF; margin-left: auto; margin-right: auto; margin-top: 10px; margin-bottom: 10px; padding-bottom: 50px;}
figcaption {color: #333; font-style: italic}
.wp-block-column {max-width: 50%}
.rightmain {padding: 10px;background-color: #191D6C; color: #EEEEEE; height: 95%; }
<!DOCTYPE html>
<html lang="en-US" class="no-js no-svg">
<head>
<meta charset="UTF-8">
<title>Timezone Conversion Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h3 class="dateblock"><span class="event-date">Saturday December 5, 2020</span> <span class="event_time">8:15 AM</span> EST</span></h3>
<div id="timezone_converted"></div>
<?php
/*
Sample code for including the WordPress password reset function, including password strength meter, on a custom admin page
*/
/*include the javascript from the user profile page on your own custom admin page*/
add_action( 'wp_enqueue_scripts', 'password_strength_scripts' );
function password_strength_scripts() {
if( isset($_REQUEST["page"]) && ($_REQUEST["page"] == 'my_admin_wizard')) {
wp_enqueue_script('password-strength-meter');
<?php
add_filter('mailpoet_newsletter_shortcode', 'mailpoet_rsvpmaker_shortcode', 10, 5);
function mailpoet_rsvpmaker_shortcode($shortcode, $newsletter, $subscriber, $queue, $newsletter_body) {
// always return the shortcode if it doesn't match your own!
if (!strpos($shortcode,'rsvpmaker') && !strpos($shortcode,'event_listing') ) return $shortcode;
global $email_context;
$email_context = true;
$shortcode = str_replace('custom:','',$shortcode);
<?php
/*
Plugin Name: Multisite Hacks for MailPoet
Version: 1.1
Description: Example but DOES NOT SEEM TO WORK WITH THE LATEST MAILPOET VERSION. My recommended alternative to MailPoet https://rsvpmaker.com/blog/2022/08/27/rsvpmaker-postmark-free-email-marketing/
*/
function mailpoet_site_subscribers () {
if(!strpos($_SERVER['REQUEST_URI'],'mailpoet'))
return;