Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@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 / 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';
@pbrocks
pbrocks / pmpro-set-enddate-null.sql
Last active September 19, 2018 18:05 — forked from strangerstudios/set_enddate_null.sql
This SQL query will clear the expiration date for active recurring memberships in Paid Memberships Pro (PMPro).
# BACKUP FIRST
# You generally do not want to setup PMPro levels
# with both a recurring billing amount AND
# an expiration date.
# This SQL query will clear the expiration date
# for active recurring memberships.
# BACKUP FIRST
UPDATE wp_pmpro_memberships_users
SET enddate = '0000-00-00 00:00:00'
WHERE status = 'active'
@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 / pmpro-register-helper-fields-examples.php
Last active September 6, 2018 18:48 — forked from andrewlimaza/rh_fields_example.php
Paid Memberships Pro Register Helper field type examples shows an example of every possible field in Register Helper
<?php
/**
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it.
*
* Add this to a Customizations Plugin and customize to suit your needs
*/
function initialize_pmprorh_fields() {
// don't break if Register Helper is not loaded
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
@pbrocks
pbrocks / pmpro_isOrderRecurring.php
Created August 23, 2018 19:16 — forked from strangerstudios/pmpro_isOrderRecurring.php
Perform an action on Paid Memberships Pro (PMPro) recurring orders only.
/*
Perform an action on PMPro recurring orders only.
A recurring order here is one that
(1) Has an earlier order with the same subscription_transaction_id.
(2) Is not created at PMPro checkout.
Note that we are checking if function_exists for pmpro_isOrderRecurring incase
we add this to PMPro core. Also note that the $test_checkout param there is used
here to avoid #2 above. So this parameter will check if the currently running PHP
script is being fired at checkout, not necessarily if the order was created at checkout,
@pbrocks
pbrocks / wp-auto-installer.js
Created August 14, 2018 23:25 — forked from mohandere/wp-auto-installer.js
Wordpress auto installer script PHP
;(function($){
/*
Script Name: WP Auto Installer
Author: Mohan Dere
Version: 1.0
Description : This script install new wordpress setup, create database with tables with content & run search replace database for new urls.
Last Update: 13 Mar 15
*/
@pbrocks
pbrocks / my-pmpro-additional-categories.php
Last active August 14, 2018 15:35 — forked from strangerstudios/my_pmpro_additional_categories.php
Add "Purchase Additional Access" box to Membership Checkout for a la carte category purchase.
<?php // Do not include this line in your Customizations plugin
/**
* Require specific category user meta to view posts in designated categories.
* Custom price-adjusting fields are added via PMPro Register Helper add on (required).
* Add all of this code to your active theme's functions.php or a custom plugin.
*/
add_filter( 'pmpro_has_membership_access_filter', 'my_pmpro_additional_categories', 10, 4 );
function my_pmpro_additional_categories( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
global $wpdb;