Skip to content

Instantly share code, notes, and snippets.


Paul Barthmaier pbrocks

View GitHub Profile
pbrocks / securing-acf.php
Created Jul 12, 2022 — forked from tomjn/securing-acf.php
ACF's `the_field` function is insecure by default, here's a selection of wrappers that fix that
View securing-acf.php
function the_field_url( $selector, $post_id=0, $format_value=true ) {
echo esc_url( get_field( $selector, $post_id, $format_value ) );
function the_field_url_raw( $selector, $post_id=0, $format_value=true ) {
echo esc_url_raw( get_field( $selector, $post_id, $format_value ) );
pbrocks /
Created Nov 11, 2021 — forked from wizioo/
HowTo have specific .gitignore for each git branch

How to have specific .gitignore for each git branch


My objective is to have some production files ignored on specific branches. Git doesn't allow to do it.


My solution is to make a general .gitignore file and add .gitignore.branch_name files for the branches I want to add specific file exclusion. I'll use post-checkout hook to copy those .gitignore.branch_name in place of .git/info/exclude each time I go to the branch with git checkout branch_name.

pbrocks /
Created Nov 8, 2021 — forked from gziolo/
Block API enhancements in WordPress 5.8

Block API Enhancements

As of WordPress 5.8 release, we encourage using block.json file metadata as the canonical way to register block types. We have been working on Block Metadata specification for a few major WordPress releases, and we reached the point where all planned features are in place.



	"apiVersion": 2,
pbrocks /
Created Aug 30, 2021 — forked from h2floh/
Bash script showing how to leverage az login to call Azure DevOps REST endpoints
## Demo script to show how to leverage Azure DevOps CLI Extension to call DevOps REST API directly
## without the need for PAT token
# configuration
# Reverse Engineered this part by looking into Azure DevOps CLI Extension
pbrocks / global-search-and-replace-query.sql
Created Aug 23, 2021 — forked from joedooley/global-search-and-replace-query.sql
SQL query that Find's all old URL's and Replaces with new URL values. This can be ran from phpmyadmin, etc...
View global-search-and-replace-query.sql
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
pbrocks / edit-form-advanced.php
Created Jul 17, 2021 — forked from tanamako/edit-form-advanced.php
View edit-form-advanced.php
* Post advanced form for inclusion in the administration panels.
* @package WordPress
* @subpackage Administration
// don't load directly
if ( !defined('ABSPATH') )
pbrocks / sublime-clean
Created May 17, 2020 — forked from gerardroche/sublime-clean
Clean Sublime Text caches and optionally clean out any sessions
View sublime-clean
# 301
pbrocks / acf_modifications.php
Created Nov 15, 2018 — 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.
View acf_modifications.php
* -----------------------------------------------------------------------------
* Advanced Custom Fields Modifications
* -----------------------------------------------------------------------------
function PREFIX_apply_acf_modifications() {
pbrocks /
Created Nov 15, 2018 — forked from psorensen/
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 / multiline_field.js
Created Nov 15, 2018 — forked from hunk/multiline_field.js
View multiline_field.js
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 );