Skip to content

Instantly share code, notes, and snippets.

Gary Pendergast pento

Block or report user

Report or block pento

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
@pento
pento / php-block.js
Last active Sep 5, 2019
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.
View php-block.js
// 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.
@pento
pento / weekly-block.css
Last active Apr 17, 2018
The Weekly Block
View weekly-block.css
/**
* License: GPL-3.0+
*/
.weekly-link {
/*border-left: 3px solid rgba(0,0,0,.8);*/
border-left: 3px solid rgba(255, 160, 0, 1);
padding-left: 2em;
padding-right: 2em;
margin-bottom: 2em;
}
@pento
pento / stars-block.js
Last active Jul 30, 2018
Gutenberg Stars Block
View stars-block.js
( function( blocks, element ) {
var el = element.createElement;
function Stars( { stars } ) {
return el( 'div', { key: 'stars' },
''.repeat( stars ),
( ( stars * 2 ) % 2 ) ? '½' : '' );
}
blocks.registerBlockType( 'stars/stars-block', {
@pento
pento / rainbow-bar.php
Last active Sep 26, 2017
WordPress Rainbow Bar
View rainbow-bar.php
<?php
/*
* Plugin Name: Rainbow Bar!
*/
function rainbow_bar() {
?>
<style type="text/css">
#wpadminbar {
@pento
pento / db.php
Last active Jul 6, 2017
🙃db, the next evolution of wpdb.
View db.php
<?php
class 🙃db extends wpdb {
public $tables🙃 = array(
// Tables
'posts' => '',
'postmeta' => '⭕➡️',
'comments' => '',
'commentmeta' => '♻➡️',
'terms' => '↔️',
@pento
pento / wp-tests-config.php
Created Dec 30, 2015
MySQL version switching with MySQL Sandbox
View wp-tests-config.php
<?php
/* Path to the WordPress codebase you'd like to test. Add a backslash in the end. */
define( 'ABSPATH', dirname( __FILE__ ) . '/src/' );
// Test with multisite enabled.
// Alternatively, use the tests/phpunit/multisite.xml configuration file.
// define( 'WP_TESTS_MULTISITE', true );
// Force known bugs to be run.
View gist:1b6253aa23b3196efc06
Verifying that +pento is my openname (Bitcoin username). https://onename.com/pento
@pento
pento / best-filter-model.php
Last active Aug 29, 2015
A filter model for Wordpress pros (Wordpress pros don't have time to press shift twice when typing "Wordpress")
View best-filter-model.php
<?php
class PentoFilters {
// eg...
function the_content( $content ) {
return $content;
}
}
function pento_filters() {
global $wp_current_filter;
View keybase.md

Keybase proof

I hereby claim:

  • I am pento on github.
  • I am pento (https://keybase.io/pento) on keybase.
  • I have a public key whose fingerprint is B3B5 DF2A 48B4 C067 7628 6491 5B08 7A47 D0D6 EE94

To claim this, I am signing this object:

@pento
pento / regex-vs-dom.php
Last active Dec 31, 2015
Testing the performance of searching a lump of HTML with Regular Expressions, vs creating a DOMDocument.
View regex-vs-dom.php
<?php
$html = <<<EOT
<p><strong>Lorem #ipsum dolor sit amet</strong>, consectetur adipiscing elit. In in elit euismod, laoreet sapien eget, tristique ipsum. In #aliquam eros tortor, sit amet aliquet turpis suscipit eget. Maecenas eget vulputate metus. Phasellus at ligula ut nulla placerat imperdiet. Duis laoreet mauris <strong>eget dolor #egestas suscipit</strong>. In et #sodales elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In tristique sit amet nisl ultrices rhoncus. Phasellus eget sem vitae urna pulvinar tristique non at velit. Integer eget nulla dolor. Vivamus quis iaculis massa, et faucibus mi. Quisque pretium dapibus massa, id imperdiet quam. #Morbi mollis ipsum eu mauris ultrices, <em>vel #pharetra quam sagittis</em>. Pellentesque auctor lacus massa, in tempor leo viverra id. Cras nisl ante, vehicula nec felis vitae, dictum sollicitudin eros. Donec sagittis id lorem ac tristique.</p>
<p>Duis quis consequat sapien. <a href="http://google.com/">Quisqu
You can’t perform that action at this time.