Skip to content

Instantly share code, notes, and snippets.

@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 / 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;
@PeterBooker
PeterBooker / plugin_api.php
Last active December 25, 2015 22:29
This gives an example of how to query the wordpress.org plugins API for data on all plugins.
<?php
/*
* Query the wordpress.org Plugins API
*/
$query = array(
'action' => 'query_plugins',
'request' => serialize(
(object) array(
'page' => 1,
@PeterBooker
PeterBooker / twitter_linkify.php
Last active December 23, 2015 07:28
This is taken from my Kebo Twitter Feed plugin for WordPress and linkifies Tweet text (Hashtags, Mentions and URLs).
<?php
/*
* Converts Tweet text urls, account names and hashtags into HTML links.
* Accepts return data from Twitter API (v1.1)
*/
function kebo_twitter_linkify( $tweets ) {
foreach ( $tweets as $tweet ) {
$hash_length = 45; // Length of HTML added to hashtags
<?php
/*
* Display BBC News Headlines
*/
function pb_display_news() {
// Get the News data
$headlines = pb_get_news();
<?php
/*
* Refreshes the Transient data.
*/
function pb_refresh_news() {
// Make HTTP request to BBC News API.
$response = wp_remote_request( 'http://api.bbcnews.appengine.co.uk/stories/headlines' );
@PeterBooker
PeterBooker / pb_get_news.php
Created August 19, 2013 22:12
This functions fetches and refreshes the data if needed.
<?php
function pb_get_news() {
/*
* Get transient and if expired refresh data immediately
*/
if ( false === ( $news = get_transient( 'pb_bbc_news' ) ) ) {
// Uses BBC News API to fetch new data
@PeterBooker
PeterBooker / example.php
Last active December 21, 2015 07:19
Background Caching with Transients Example
<?php
/*
* Background Caching with Transients
* Using BBC News API as an example
*/
function pb_get_news() {
/*
* Get transient and if expired refresh data immediately
@PeterBooker
PeterBooker / autoupdate_plugins.php
Last active August 29, 2015 14:18
WordPress Auto Updates Plugin Whitelist
<?php
/*
* Plugin Auto Updates Whitelist
* Allows Forced Updates for listed Plugin Slugs
*/
function prefix_forced_update_whitelist_plugins( $update, $item ) {
// Examples, please add plugin slugs that you trust.
$plugins = array (
'jetpack', 'wordpress-seo', 'plugin-slug',
@PeterBooker
PeterBooker / fallback.php
Last active August 29, 2015 14:17
Foundation 5 Top Bar Custom Menu Walker for WordPress
<?php
/*
* Provide fallback output incase no Menu is selected.
*/
public static function fallback( $args = array() ) {
/*
* No content for left side Fallback
*/
if ( 'left' == $args['menu_class'] ) {