Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Sorensen psorensen

  • 10up
  • United States
View GitHub Profile
View debug.log
0 verbose cli [
0 verbose cli '/Users/peter.sorensen/.nvm/versions/node/v16.9.1/bin/node',
0 verbose cli '/Users/peter.sorensen/.nvm/versions/node/v16.9.1/bin/npm',
0 verbose cli 'install'
0 verbose cli ]
1 info using npm@7.21.1
2 info using node@v16.9.1
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/Users/peter.sorensen/.nvm/versions/node/v16.9.1/lib/node_modules/npm/npmrc Completed in 1ms
@psorensen
psorensen / config.yml
Last active Feb 17, 2022
WP Env Failing on CirclCI workflow
View config.yml
## .circleci/config.yml
version: 2.1
executors:
node-executor:
docker:
- image: cimg/node:14.19.0-browsers
user: root
jobs:
release:
View circleci.txt
> next-wp@0.0.1 build-release /home/circleci/project
> npm install && composer install --no-dev -o && lerna run build-release
> next-wp@0.0.1 preinstall /home/circleci/project
> node -e "if(process.env.npm_execpath.indexOf('yarn') !== -1) throw new Error('Please use NPM for consistency.')"
> husky@4.2.5 install /home/circleci/project/node_modules/husky
@psorensen
psorensen / update-posts.bash
Created Dec 14, 2021
WP-CLI: Update a field based on query.
View update-posts.bash
wp post update --post_excerpt='A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring' $(wp post list --post_type=page --format=ids)
@psorensen
psorensen / dfny21.json
Created Dec 2, 2021
DFNY21 Query Loop
View dfny21.json
{
"post_type": ["post", "sf_press_release", "sf_linked_content"],
"tax_query": [{
"taxonomy": "sf_collection",
"field": "slug",
"terms": "dreamforce-ny-21"
}]
}
@psorensen
psorensen / query-block-filter.js
Last active Dec 1, 2021
Extending query block to support custom taxonomies
View query-block-filter.js
import { TopicPicker } from './topic-picker';
const { createHigherOrderComponent } = wp.compose;
const { InspectorControls } = wp.blockEditor;
const { PanelBody, PanelRow } = wp.components;
const { addFilter } = wp.hooks;
const { __ } = wp.i18n;
const enableOnBlocks = ['core/query'];
@psorensen
psorensen / block-names-by-namespace.js
Created Jul 21, 2021
Get all block names of given namespace
View block-names-by-namespace.js
wp.blocks.getBlockTypes().filter((block) => { return block.name.indexOf('jetpack') !== -1 }).map(o => o['name'])
// credit https://stackoverflow.com/a/37092497
@psorensen
psorensen / remote-request-caching.php
Created Mar 16, 2021
Caching a remote request in WordPress
View remote-request-caching.php
<?php
/**
* Caching a remote response
*
* Related Tutorial: https://pippinsplugins.com/using-wp_remote_get-to-parse-json-from-remote-apis/
*/
// Psuedo Code to demonstrate overall approach
function cached_function() {
if ( has_cached_value() ) {
@psorensen
psorensen / termPicker.js
Last active Dec 5, 2020
GB Term Picker
View termPicker.js
import Select from 'react-select';
const { useSelect } = wp.data;
const { __ } = wp.i18n;
const TermPicker = (props) => {
const { taxonomy, onChange, label, attributes, attribute } = props;
const categories = useSelect((select) => select('core').getEntityRecords('taxonomy', taxonomy));
if (categories && categories.length) {
@psorensen
psorensen / config-wp-cache.md
Last active Oct 14, 2019
Setting up cache on WP Local Docker
View config-wp-cache.md