Skip to content

Instantly share code, notes, and snippets.

@PeterBooker
PeterBooker / get-posts.php
Last active October 23, 2018 18:39
WP REST API Examples
<?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(
@PeterBooker
PeterBooker / Dockerfile
Created October 22, 2018 22:19
PHP-FPM Docker
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 \
@PeterBooker
PeterBooker / test-tests-prof.php
Last active October 6, 2018 12:16
First PHP Unit Test
<?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 October 6, 2018 11:01
Health Check Tests Prof
<?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 October 2, 2018 18:46
Inline FontAwesome Icons
<?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 September 7, 2018 14:14
Example Migration Script
package main
import (
"encoding/json"
"encoding/xml"
"log"
"strconv"
"time"
_ "github.com/go-sql-driver/mysql"
@PeterBooker
PeterBooker / example.go
Created June 17, 2018 21:04
Example of current Zip download and extraction code
package slurper
func GetExtensions(items []string) {
for _, item := range items {
data := downloadZip(item)
extractZip(data)
}
}
@PeterBooker
PeterBooker / PLUGINS.md
Last active January 16, 2018 13:22
WordPress.Org Repository Research

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 July 8, 2021 13:42
Dota 2 Tooltips
/******/ (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 September 11, 2017 12:23
Get and store Posts from another site using the WP REST API
<?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;