Skip to content

Instantly share code, notes, and snippets.

@chandrapatel
chandrapatel / php-block.js
Created February 27, 2019 15:10 — forked from pento/php-block.js
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
<?php
/*
Plugin Name: Post Meta Revisions
Description: Revisions for the 'foo' post meta field
Version: 1.0
Author: John Blackbourn
Plugin URI: http://lud.icro.us/post-meta-revisions-wordpress
*/
<?php
$data_dir = 'c:/server/www/dev/data/';
$releases = [ ];
foreach ( range( 3.2, 4.0, 0.1 ) as $version ) {
$version = number_format( $version, 1 );
$data = json_decode( file_get_contents( $data_dir . $version . '.json' ), true );
$groups = wp_list_pluck( $data['groups'], 'data' );
@chandrapatel
chandrapatel / object-cache.php
Created August 19, 2016 06:50 — forked from chrisguitarguy/object-cache.php
WordPress object cache implementation using APC.
<?php
/**
* Plugin Name: APC Object Cache
* Description: An object cache implementation that uses APC.
* Author: Christopher Davis
* Author URI: http://christopherdavis.me
* Version: 0.1
*
* Based on Mark Jaquith's APC object cache
* http://txfx.net/wordpress-plugins/apc/
@chandrapatel
chandrapatel / annotate.php
Created May 11, 2016 13:37 — forked from simkimsia/annotate.php
annotate english or chinese text on image
<?php
header('Content-Type: text/html; charset=utf-8');
mb_internal_encoding('utf-8');
function wordWrapAnnotation(&$image, &$draw, $text, $maxWidth)
{
// separate the text by chinese characters or words or spaces
preg_match_all('/([\w]+)|(.)/u', $text, $matches);
// $words is array of Chinese characters, English Words or spaces