Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / add_pipelines_environment.sh
Created Aug 30, 2021 — forked from h2floh/add_pipelines_environment.sh
Bash script showing how to leverage az login to call Azure DevOps REST endpoints
View add_pipelines_environment.sh
#!/bin/bash
## Demo script to show how to leverage Azure DevOps CLI Extension to call DevOps REST API directly
## without the need for PAT token
# configuration
YOUR_AZURE_DEV_OPS_ORG=''
YOUR_AZURE_DEV_OPS_PROJECT_NAME=''
# Reverse Engineered this part by looking into Azure DevOps CLI Extension
# https://github.com/Azure/azure-devops-cli-extension/blob/8cf32a41126b2b66f130843d4d16de19290052b9/azure-devops/azext_devops/devops_sdk/client.py#L71
@pbrocks
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... https://wpbeaches.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/
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
pbrocks / edit-form-advanced.php
Created Jul 17, 2021 — forked from tanamako/edit-form-advanced.php
Wordpress管理画面カスタマイズ
View edit-form-advanced.php
<?php
/**
* Post advanced form for inclusion in the administration panels.
*
* @package WordPress
* @subpackage Administration
*/
// don't load directly
if ( !defined('ABSPATH') )
@pbrocks
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 https://github.com/gerardroche/dotfiles
@pbrocks
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
<?php
/*
* -----------------------------------------------------------------------------
* Advanced Custom Fields Modifications
* -----------------------------------------------------------------------------
*/
function PREFIX_apply_acf_modifications() {
?>
<style>
@pbrocks
pbrocks / tinymce-add-formats.md
Created Nov 15, 2018 — forked from psorensen/tinymce-add-formats.md
Wordpress/TinyMCE - Add elements to formats dropdown
View tinymce-add-formats.md

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 Nov 15, 2018 — forked from hunk/multiline_field.js
field_types/multiline_field/multiline_field.js
View 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 Nov 15, 2018
The modification of react-tinymce component for webpack
View editor.jsx
// 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 Oct 28, 2018 — 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.
View php-block.js
// 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 Oct 9, 2018 — forked from travislima/pmpro_eu_dkk_format.php
Change EU Danish Krone currency format for Paid Memberships Pro.
View pmpro-eu-dkk-format.php
<?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