Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / sublime-clean
Created May 17, 2020 21:17 — forked from gerardroche/sublime-clean
Clean Sublime Text caches and optionally clean out any sessions
# 301 https://github.com/gerardroche/dotfiles
@pbrocks
pbrocks / pmpro-cancel-on-next-payments-date.php
Last active July 17, 2019 14:26 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
<?php
/**
* Change cancellation to set expiration date for next payment instead of cancelling immediately.
*
* Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
*
* Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
/**
@pbrocks
pbrocks / acf_modifications.php
Created November 15, 2018 06:33 — forked from courtneymyers/acf_modifications.php
Reduces initial height of Advanced Custom Fields WYSIWYG fields to 100px, and enables autoresizing of WYSIWYG field, as text is entered. Best practice would be to include this function in a site-specific plugin.
<?php
/*
* -----------------------------------------------------------------------------
* Advanced Custom Fields Modifications
* -----------------------------------------------------------------------------
*/
function PREFIX_apply_acf_modifications() {
?>
<style>
@pbrocks
pbrocks / tinymce-add-formats.md
Created November 15, 2018 06:26 — forked from psorensen/tinymce-add-formats.md
Wordpress/TinyMCE - Add elements to formats dropdown

Adding Elements to the TinyMCE Format Dropdown

On a recent migration project, one of the requirements was to add a few blockquote styles to the TinyMCE dropdown list to match the editorial process of the old CMS. Wordpress provides a filter to add a secondary or tetriary dropdown, but if you only have a couple additional elements, it seems like bad UX to seperate it from the original dropdown.

Going off a tip from Chancey Mathews, I realized that Wordpress does not send a argument for block_formats when initializing TinyMCE, thus relying on the defaults. By adding this argument to the tiny_mce_before_init filter, we can add in our extra elements*:

* Note: since we're overriding the defaults, we need to include the original elements (p, h1-h6..etc)

function mce_formats( $init ) {
@pbrocks
pbrocks / multiline_field.js
Created November 15, 2018 06:24 — forked from hunk/multiline_field.js
field_types/multiline_field/multiline_field.js
jQuery.mf_bind('add',function(){
if('undefined' != typeof tinyMCEPreInit){
// this is for relative_urls when the main editor is on text mode
if ( typeof tinymce !== 'undefined' ) {
for ( id in tinyMCEPreInit.mceInit ) {
init = tinyMCEPreInit.mceInit[id];
init.selector = "";
tinymce.init( init );
}
@pbrocks
pbrocks / editor.jsx
Created November 15, 2018 06:24
The modification of react-tinymce component for webpack
// Dependencies
import _ from 'lodash'
// React
import React from 'react'
import PropTypes from 'prop-types'
// TinyMCE
import tinymce from 'tinymce/tinymce'
import 'tinymce/themes/modern/theme'
@pbrocks
pbrocks / php-block.js
Created October 28, 2018 17:09 — forked from pento/php-block.js
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@pbrocks
pbrocks / pmpro-eu-dkk-format.php
Last active October 9, 2018 15:21 — forked from travislima/pmpro_eu_dkk_format.php
Change EU Danish Krone currency format for Paid Memberships Pro.
<?php // do not include in Customizations plugin if copying and pasting
/**
* Plugin Name: Add a Currency to global
*
* This code gist illustrates a way to customize the format of how your currency displays.
*
* In this example, we will change the PMPro Danish Krone currency
*
* from DKK 1,495.00
* to DKK 1 495,00
@pbrocks
pbrocks / pmpro-getfile-before-error.php
Last active September 21, 2018 20:28 — forked from strangerstudios/my_pmpro_getfile_before_error.php
Use pmpro_getfile_before_error to tell PMPro to do something else besides send a 503 when accessing a member file. Requires PMPro 1.7.15+
<?php // do not include in Customizations plugin
/**
* Redirect to the levels page when users try to access protected files in PMPro.
*
* Add this code to your customizations plugin file.
*
* Learn about protecting files with PMPro here:
* https://www.paidmembershipspro.com/locking-down-protecting-files-with-pmpro/
*/
function my_pmpro_getfile_before_error( $filename ) {
@pbrocks
pbrocks / my-pmpro-pages-custom-template-path.php
Last active September 19, 2018 21:29 — forked from strangerstudios/my_pmpro_pages_custom_template_path.php
Tell PMPro to look in the pages folder of this plugin for PMPro page templates.
<?php
/**
* Tell PMPro to look in the pages directory of this plugin for PMPro page templates.
*
* Add this code to your Customizations plugin.
*
* Make sure that there is a /paid-memberships-pro/pages/ directory in the plugin directory with your templates in it.
*/
function my_pmpro_pages_custom_template_path( $default_templates ) {
$default_templates[] = dirname( __FILE__ ) . '/paid-memberships-pro/pages/checkout.php';