Skip to content

Instantly share code, notes, and snippets.

Daniel Bachhuber danielbachhuber

Block or report user

Report or block danielbachhuber

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
View migrate-import-cache.php
<?php
/**
* Filters wp_remote_get() to:
* 1. Return a value from the cache when it's available.
* 2. Write a value to the cache when it's been fetched.
*
* Requires the WP_IMPORT_CACHE constant to be set to a writable directory.
*/
if ( defined( 'WP_CLI' ) && WP_CLI ) {
@danielbachhuber
danielbachhuber / build-gutenberg-nightly.sh
Last active Dec 8, 2018
Create a build of the Gutenberg master branch
View build-gutenberg-nightly.sh
set -ex
# Expects git clone git@github.com:WordPress/gutenberg.git ~/gutenberg
cd ~/gutenberg
# Reset working directory
git checkout -f master
git pull origin master
# Run the initial gutenberg ZIP build
yes | npm run package-plugin
# Modify 'Version: ' to bump to next version and append short hash (e.g. '4.0-alpha-610aa4e')
echo '<?php file_put_contents( "gutenberg.php", preg_replace_callback( "#Version: (.+)#", function( $matches ) { $new_version = (float) $matches[1] + .1; $new_version .= ".0-alpha-" . substr( shell_exec( "git rev-parse HEAD" ), 0, 7 ); return str_replace( $matches[1], $new_version, $matches[0] ); }, file_get_contents( "gutenberg.php" ) ) );' | php
@danielbachhuber
danielbachhuber / rest-api-wp-5.md
Last active Oct 3, 2018
Assessment of REST API tickets for WordPress 5.0
@danielbachhuber
danielbachhuber / gutenberg-rest-api.md
Last active Apr 26, 2018
Review of Gutenberg's REST API milestone
View gutenberg-rest-api.md
@danielbachhuber
danielbachhuber / term-link-id.php
Created Apr 24, 2018
Use term ids for tag links
View term-link-id.php
@danielbachhuber
danielbachhuber / term-permissions.md
Last active Apr 24, 2018
Review of UI-based permissions based on WordPress user role
View term-permissions.md

Tags

Role Assign Tags Create Modify Delete
Contributor Y Y N N
Author Y Y N N
Editor Y Y Y Y

Categories

@danielbachhuber
danielbachhuber / http-to-https.php
Created Mar 28, 2018
Update a specific site from 'http://' to 'https://'.
View http-to-https.php
<?php
/**
* Update a specific site from 'http://' to 'https://'.
*
* Only touches the 'home' and 'siteurl' options.
* Depending on plugins, etc., you may need to update other options too.
*
* Run on WordPress multisite with:
*
* wp site list --field=url | xargs -I % wp eval-file http-to-https.php --url=%
View cleanup-results-key.php
<?php
/**
* Strips out unnecessary testsuites data from PHPUnit test results
*
* Run with `wp eval-file cleanup-results-key.php`
*/
global $wpdb;
$post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type='result'" );
foreach( $post_ids as $h => $post_id ) {
View parse-plugin-logs.php
<?php
list( $log_file ) = $args;
if ( ! is_file( $log_file ) ) {
WP_CLI::error( 'Invalid log file.' );
}
$contents = file_get_contents( $log_file );
$bits = explode( 'Running: plugin install', $contents );
View 248-plugins.csv
plugin classic_percent_diff gutenberg_percent_diff gallery_link
contact-form-7 0% 0% http://gutensnaps.handbuilt.co/index.php?plugin_name=contact-form-7
wordpress-seo 2.923% 0.82% http://gutensnaps.handbuilt.co/index.php?plugin_name=wordpress-seo
akismet 0% 0% http://gutensnaps.handbuilt.co/index.php?plugin_name=akismet
jetpack 0% 0% http://gutensnaps.handbuilt.co/index.php?plugin_name=jetpack
wordpress-importer 0% 0% http://gutensnaps.handbuilt.co/index.php?plugin_name=wordpress-importer
all-in-one-seo-pack 4.657% 0.72% http://gutensnaps.handbuilt.co/index.php?plugin_name=all-in-one-seo-pack
google-sitemap-generator 0% 0% http://gutensnaps.handbuilt.co/index.php?plugin_name=google-sitemap-generator
limit-login-attempts 0% 0% http://gutensnaps.handbuilt.co/index.php?plugin_name=limit-login-attempts
tinymce-advanced 0.862% 0% http://gutensnaps.handbuilt.co/index.php?plugin_name=tinymce-advanced
You can’t perform that action at this time.