Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / gitignore_per_git_branch.md
Created Nov 11, 2021 — forked from wizioo/gitignore_per_git_branch.md
HowTo have specific .gitignore for each git branch
View gitignore_per_git_branch.md

How to have specific .gitignore for each git branch

Objective

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

Solution

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
pbrocks / dev-note-5.8-block-api.md
Created Nov 8, 2021 — forked from gziolo/dev-note-5.8-block-api.md
Block API enhancements in WordPress 5.8
View dev-note-5.8-block-api.md

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.

Example:

notice/block.json

{
	"apiVersion": 2,
@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 / check-post-title.php
Created Mar 15, 2021
Return the post type after the post title
View check-post-title.php
<?php
/**
* [pbrocks_check_title_filter]
*
* @param [type] $title [description]
* @param [type] $post_id [description]
* @return [type] [description]
*/
function pbrocks_check_title_filter( $title, $post_id = null ) {
$current_post_type = get_post_type();
@pbrocks
pbrocks / run-php-index.php
Created Oct 15, 2020
Use this file to run php that also has access to WordPress functions by placing this file in a folder at the root of any WordPress installation.
View run-php-index.php
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Include WP</title>
<style type="text/css">
html {
box-sizing: border-box;
}
*, *:before, *:after {
@pbrocks
pbrocks / install-phpcs-with-homebrew.md
Last active Nov 24, 2021
Install phpcs with Homebrew
View install-phpcs-with-homebrew.md

Install phpcs with Homebrew

To set up php linting, you’ll want to install this PHP CodeSniffer repo and configure with this WordPress Coding Standards repo: . There are a number of ways to do this, whether direct download, Composer, Homebrew, Pear, etc. The following is what works for me on MacOS using Homebrew:

In a terminal window on your Mac, start by updating your Homebrew.

brew doctor

Then install the Code Sniffer:

@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 / disable-by-default-fullscreen-mode.php
Created Apr 1, 2020
Jean-Baptiste Audras -- Disable editor in fullscreen mode by default.
View disable-by-default-fullscreen-mode.php
<?php
/**
* https://jeanbaptisteaudras.com/en/2020/03/disable-block-editor-default-fullscreen-mode-in-wordpress-5-4/
*/
function jba_disable_editor_fullscreen_by_default() {
$script = "jQuery( window ).load(function() { const isFullscreenMode = wp.data.select( 'core/edit-post' ).isFeatureActive( 'fullscreenMode' ); if ( isFullscreenMode ) { wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fullscreenMode' ); } });";
wp_add_inline_script( 'wp-blocks', $script );
}
add_action( 'enqueue_block_editor_assets', 'jba_disable_editor_fullscreen_by_default' );