Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Booker PeterBooker

View GitHub Profile
@PeterBooker
PeterBooker / get-posts.php
Last active Oct 23, 2018
WP REST API Examples
View get-posts.php
<?php
/**
* Get Public Posts from External Site using REST API
*/
$hostname = 'https://www.peterbooker.com';
$num = 5;
$response = wp_remote_get(
add_query_arg(
array(
View Dockerfile
FROM php:7.2-fpm-alpine
#FROM php:7.3.0RC3-fpm-alpine3.8
# install PHP extensions
RUN apk add --no-cache --virtual .build-deps \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev
RUN docker-php-ext-install \
View test-tests-prof.php
<?php
class Health_Check_Tests_Prof_Test extends WP_UnitTestCase {
private $health_check_site_status;
private $tests_list;
public function setUp() {
parent::setUp();
@PeterBooker
PeterBooker / prof.php
Created Oct 6, 2018
Health Check Tests Prof
View prof.php
<?php
echo '<pre>';
$test_list = Health_Check_Site_Status::get_tests();
$tests = array_merge( $tests['direct'], $tests['async'] );
$limit = 5;
echo '<br>';
printf(
'Running tests with %d iterations.',
$limit
@PeterBooker
PeterBooker / icons.php
Created Oct 2, 2018
Inline FontAwesome Icons
View icons.php
<?php
/**
* Inlined FontAwesome Icons.
*
* Function returns an SVG icon using the given name.
*/
/**
* Outputs FontAwesome SVG Icons
* https://github.com/FortAwesome/Font-Awesome/tree/master/advanced-options/raw-svg/
@PeterBooker
PeterBooker / migrate.go
Created Sep 7, 2018
Example Migration Script
View migrate.go
package main
import (
"encoding/json"
"encoding/xml"
"log"
"strconv"
"time"
_ "github.com/go-sql-driver/mysql"
@PeterBooker
PeterBooker / example.go
Created Jun 17, 2018
Example of current Zip download and extraction code
View example.go
package slurper
func GetExtensions(items []string) {
for _, item := range items {
data := downloadZip(item)
extractZip(data)
}
}
@PeterBooker
PeterBooker / PLUGINS.md
Last active Jan 16, 2018
WordPress.Org Repository Research
View PLUGINS.md

WordPress Plugins Repository Research

This is an overview of my research into the WordPress Plugins Repository while looking at how external tools can work with it, primarily through SVN.

Some Data

Between 2017/01/14 and 2018/01/14 there were approximately 227,998 revisions (changes). Spread equally this results in:

  • 4,385 / week.
  • 626 / day.
@PeterBooker
PeterBooker / tooltips.js
Last active Jul 8, 2021
Dota 2 Tooltips
View tooltips.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
@PeterBooker
PeterBooker / newsletter_posts.php
Last active Sep 11, 2017
Get and store Posts from another site using the WP REST API
View newsletter_posts.php
<?php
function prefix_get_newsletter_posts() {
// Get the cached data if available, if not fetch it using the WP REST API
if ( false === ( $newsletter_posts_data = get_transient( 'prefix_newsletter_posts' ) ) ) {
// Tag ID for the Posts you want from the Newsletter site.
$tag_id = 12;