Skip to content

Instantly share code, notes, and snippets.

Pete Nelson petenelson

Block or report user

Report or block petenelson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@petenelson
petenelson / raw-rewite-rules.txt
Created Dec 10, 2019
WordPress Default rewrite_rules option value
View raw-rewite-rules.txt
a:89:{s:11:"^wp-json/?$";s:22:"index.php?rest_route=/";s:14:"^wp-json/(.*)?";s:33:"index.php?rest_route=/$matches[1]";s:21:"^index.php/wp-json/?$";s:22:"index.php?rest_route=/";s:24:"^index.php/wp-json/(.*)?";s:33:"index.php?rest_route=/$matches[1]";s:52:"blog/category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$";s:52:"index.php?category_name=$matches[1]&feed=$matches[2]";s:47:"blog/category/(.+?)/(feed|rdf|rss|rss2|atom)/?$";s:52:"index.php?category_name=$matches[1]&feed=$matches[2]";s:28:"blog/category/(.+?)/embed/?$";s:46:"index.php?category_name=$matches[1]&embed=true";s:40:"blog/category/(.+?)/page/?([0-9]{1,})/?$";s:53:"index.php?category_name=$matches[1]&paged=$matches[2]";s:22:"blog/category/(.+?)/?$";s:35:"index.php?category_name=$matches[1]";s:49:"blog/tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$";s:42:"index.php?tag=$matches[1]&feed=$matches[2]";s:44:"blog/tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$";s:42:"index.php?tag=$matches[1]&feed=$matches[2]";s:25:"blog/tag/([^/]+)/embed/?$";s:36:"index.php?tag=$matc
View gist:f314edc59a422fdf8e940fdd45c03050
/**
* Gets or updates the cache incrementor for a post type.
*
* @param string $post_type The post type.
* @param bool $update Whether to force an incrementor update.
* @return string
*/
function post_type_cache_incrementor( $post_type, $update = false ) {
$group = 'post_type_cache_incrementor';
@petenelson
petenelson / reset-term-order-bug.php
Last active Mar 26, 2019
wp_update_post() resetting term order
View reset-term-order-bug.php
<?php
// Sample code to demonstrate a possible bug in core where
// wp_update_post() is resetting the term_order.
global $wp_taxonomies;
// Let core set the term_order field automatically.
$wp_taxonomies['category']->sort = true;
$post_id = wp_insert_post(
@petenelson
petenelson / class-estimator.php
Last active Mar 15, 2019
Time Left Estimator
View class-estimator.php
<?php
/**
* Estimator class to get estimated time left.
*/
class Estimator {
public $total = 0;
public $count = 0;
public $start_time = 0;
@petenelson
petenelson / object-cache.php
Created Mar 7, 2018
object-cache.php for memcached
View object-cache.php
<?php
/**
* Adds a value to cache.
*
* If the specified key already exists, the value is not stored and the function
* returns false.
*
* @link http://www.php.net/manual/en/memcached.add.php
*
* @param string $key The key under which to store the value.
@petenelson
petenelson / ssh-mysql-tunnel-test.php
Created Jul 13, 2017
WordPress: MySQL PDO command via SSH tunnel
View ssh-mysql-tunnel-test.php
<?php
/**
* Plugin Name: SSH Remote Test
*/
add_action( 'admin_init', 'ssh_remote_test', 1 );
function ssh_remote_test() {
@petenelson
petenelson / ssh-remote-command.php
Created Jul 12, 2017
WordPress: Run SSH command remotely
View ssh-remote-command.php
<?php
/**
* Plugin Name: SSH Remote Test
*/
add_action( 'admin_init', 'ssh_remote_test', 1 );
function ssh_remote_test() {
@petenelson
petenelson / bacon.sh
Last active May 3, 2017
Get paragraphs of garbage content from baconipsum.com
View bacon.sh
#!/bin/bash
#####################
# bacon.sh
#
# Client to get paragraphs of garbage content from baconipsum.com
#
# usage:
# bacon.sh <paragraph-count>
#####################
@petenelson
petenelson / userhtml.wcc
Created Mar 15, 2017
UserHTML - Some Wildcat BBS code I wrote back in 1995
View userhtml.wcc
// USERHTML - Wildcat User List to HTML Converter
// By: Pete Nelson (pete@terminal-one.com)
dim urec as userrecord
dim today as date, now as time, domain as string
if not exists("userhtml.cfg") then
cls
print "@0A@What is your domain name@07@: " defcolor;
@petenelson
petenelson / rest-api-route-array-schema.php
Created Feb 27, 2017
WordPress: Example of REST API route with schema type of array
View rest-api-route-array-schema.php
<?php
register_rest_route( 'test', '/v1/schema-test', array(
'methods' => 'POST',
'callback' => __NAMESPACE__ . '\handle_endpoint',
'args' => array(
'mybools' => array(
'required' => true,
'type' => 'array', // We require an array of items.
'items' => array(
You can’t perform that action at this time.