Skip to content

Instantly share code, notes, and snippets.

View chrisvanpatten's full-sized avatar

Chris Van Patten chrisvanpatten

View GitHub Profile

1.xx - ERR_READ_TIMEOUT (Generally the HTTP request/response timed out when Akamai tried fetching content from origin. Default read timeout is 120s)

3.xx - ERR_READ_ERROR (Generally the TCP connection from Akamai to origin was successful but the origin did not send any (valid) HTTP response headers back)

4.xx - ERR_WRITE_ERROR (Usually happens when connection is closed by origin before Akamai could send the complete request)

6.xx - ERR_CONNECT_FAIL (When Akamai is trying to connect to origin, the origin or a firewall is actively refusing the connection - e.g. it sent a TCP RST packet)

9.xx - ERR_INVALID_URL (The Akamai Edge server does not have a configuration file associated for the host/URL visited)

@chrisvanpatten
chrisvanpatten / useMetaSchema.js
Created June 25, 2021 20:58
React hook to retrieve the schema data for a set of meta keys in a WordPress post API request. Ideal for integrating libraries like React JSON Schema Form into a Gutenberg experience.
import apiFetch from '@wordpress/api-fetch';
import { useSelect } from '@wordpress/data';
import { useEffect, useState } from '@wordpress/element';
import { getPath } from '@wordpress/url';
import { pick } from 'lodash';
function useMetaSchema( metaKeys ) {
const { _links } = useSelect( ( select ) => {
return select( 'core/editor' ).getCurrentPost();
} );
<?php
add_filter( 'block_editor_settings', function ( $settings ) {
$settings['codeEditingEnabled'] = false;
return $settings;
} );
@chrisvanpatten
chrisvanpatten / Composer.php
Last active February 3, 2021 19:05
Automatically symlink `object-cache.php` after installing `wp-redis`.
<?php
declare(strict_types=1);
namespace Namespace\Scripts;
use Composer\Installer\PackageEvent;
class Composer
{
/**
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model wp_commentmeta {
import { PluginPrePublishPanel } from '@wordpress/edit-post';
import { registerPlugin } from '@wordpress/plugins';
import Required from './required';
const Test = () => {
<PluginPrePublishPanel>
<Required.Fill>
{ ( fills ) => fills.length > 0 ? fills : null ) }
</Required.Fill>
{"skywordId":281474979915458,"type":"gallery","title":"Brendan Test 9\/17","author":"Author Byline Field","trackingTag":"true","publishAsDraft":false,"fields":[{"name":"seo_title","value":"Testing Revised Gallery - Feb 25th - Title Field","type":"META"},{"name":"toutImage","value":"84982","type":"IMAGE"},{"name":"toutImageCropOrientation","value":"Horizontal","type":"TAXONOMY"},{"name":"toutImageTitle","value":"Tout Image Title Field","type":"TEXT"},{"name":"toutImageCaption","value":"Tout Caption Field","type":"TEXT"},{"name":"toutImageAlt","value":"Tout Alternative Text Field","type":"TEXT"},{"name":"toutImageCredit","value":"Tout Credit Field","type":"TEXT"},{"name":"toutImageFocalPoint","value":"Tout Focal Point Field","type":"TEXT"},{"name":"toutImageRights","value":"restricted","type":"TAXONOMY"},{"name":"toutImageUsage","value":"Tout Image Rights Usage Field","type":"TEXT"},{"name":"socialTitle","value":"Social Title Field","type":"TEXT"},{"name":"socialDescription","value":"Social Description Field","
<?php
// Filter search endpoint responses.
add_filter( 'rest_post_dispatch', 'wp_47684_filter_response', 10, 3 );
/**
* Resolves the behavior reported in WP Core Trac 47684.
*
* @see https://core.trac.wordpress.org/ticket/47684
*
#!/bin/bash
# Usage:
#
# ./redirects.sh dev marthastewart < sample.csv
while IFS=, read -r from to
do
wpcli @$1 onecms-srm add $from $to 301 --url=$2.$1.onecms.io
done
/**
* Save term meta data.
*
* @param int $cat_id Category ID.
* @return void
*/
public static function create_category_page_data( $cat_id ) {
// Setup the values for the category page.
$author_id = get_current_user_id();
$post_type = 'category-page';