Skip to content

Instantly share code, notes, and snippets.

<?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');
<!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>
<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 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: #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;}
<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>
@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 (
@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 / 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');
}
) );
<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)