Skip to content

Instantly share code, notes, and snippets.

Mike Schinkel mikeschinkel

Block or report user

Report or block mikeschinkel

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
@mikeschinkel
mikeschinkel / .readme.txt
Last active May 8, 2019
Proof-of-concept example of Swift using The Break/Continue Guard Clause pattern
View .readme.txt
Here is an example of using what I am currently calling the Break/Continue Guard Clause pattern.
See:
1. https://mikeschinkel.me/2019/better-alternative-to-return-early-php-wordpress/
2. https://thatthinginswift.com/guard-statement-swift/
@mikeschinkel
mikeschinkel / log.txt
Created May 6, 2019
Raw grep file for WordPress plugins having 'wp_edit_nav_menu_walker' hook as of 2019-05-05
View log.txt
add-to-menus-lite/index.php: add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
advanced-custom-fields/includes/forms/form-nav-menu.php: add_filter('wp_edit_nav_menu_walker', array($this, 'wp_edit_nav_menu_walker'), 10, 2);
advanced-custom-fields/includes/forms/form-nav-menu.php: * wp_edit_nav_menu_walker
advanced-custom-fields/includes/forms/form-nav-menu.php: function wp_edit_nav_menu_walker( $class, $menu_id = 0 ) {
affilicious/vendor/htmlburger/carbon-fields/core/Container/Nav_Menu_Container.php: add_filter( 'wp_edit_nav_menu_walker', array( $self, 'edit_walker' ), 10, 2 );
agp-font-awesome-collection/classes/MenuIcons.php: add_filter( 'wp_edit_nav_menu_walker', array( $this, 'editWalker'), 10, 2 );
amnav-menu-control/inc/class.aMNav_Menu_Control.php: add_filter( 'wp_edit_nav_menu_walker', array( $this, 'edit_nav_menu_walker' ) );
apollo13-framework-extensions/features/mega-menu.php:add_filter( 'wp_edit_nav_menu_walker', 'a13fe_admin_change_walker_class', 10, 2
@mikeschinkel
mikeschinkel / log.txt
Last active May 6, 2019
Raw grep file for WordPress plugins extending Walker_Nav_Menu_Edit as of 2019-05-05
View log.txt
advanced-custom-fields/includes/walkers/class-acf-walker-nav-menu-edit.php:class ACF_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
apparelcuts-spreadshirt/resources/advanced-custom-fields/includes/walkers/class-acf-walker-nav-menu-edit.php:class ACF_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
arrivala-online-business-reviews/vendor/advanced-custom-fields/includes/walkers/class-acf-walker-nav-menu-edit.php:class ACF_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
asciinema-player/includes/acf/includes/walkers/class-acf-walker-nav-menu-edit.php:class ACF_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
auto-generate-submenus/auto-generate-submenus.php: class Willy_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
automatic-submenu/automatic-submenu.php:class AutomaticSubmenu_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit
beagency-lite/inc/custom-menu/walker-nav-menu-edit.php:class beagency_Menu_Item_Custom_Fields_Walker extends Walker_Nav_Menu_Edit {
beonepage-lite/inc/custom-menu/walk
@mikeschinkel
mikeschinkel / log.txt
Last active May 6, 2019
Raw grep file for plugins having 'wp_nav_menu_item_custom_fields' hook as of 2019-05-05
View log.txt
add-to-menus-lite/class.Walker_Nav_Menu_Edit.php: do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
advanced-custom-fields/includes/walkers/class-acf-walker-nav-menu-edit.php: do_action( 'wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id );
amnav-menu-control/inc/class.Walker_Nav_Menu_Edit_Roles.php: do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args );
apparelcuts-spreadshirt/resources/advanced-custom-fields/includes/walkers/class-acf-walker-nav-menu-edit.php: do_action( 'wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id );
arrivala-online-business-reviews/vendor/advanced-custom-fields/includes/walkers/class-acf-walker-nav-menu-edit.php: do_action( 'wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id );
asciinema-player/includes/acf/includes/walkers/class-acf-walker-nav-menu-edit.php: do_action( 'wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args, $id
@mikeschinkel
mikeschinkel / dowhilefalse-example.php
Created Apr 25, 2019
do {...} while (false) example assuming WordPress/PHP
View dowhilefalse-example.php
function some_function($value) {
do {
if ( some_condition ) {
break;
}
if ( some_other_condition ) {
break;
}
if ( some_further_condition ) {
break;
@mikeschinkel
mikeschinkel / benchmark-for-single-wordpress-action-hook
Created Apr 25, 2019
Benchmark for single WordPress action hook
View benchmark-for-single-wordpress-action-hook
<?php
define( 'ITERATIONS', 1000000 );
require( __DIR__ . '/wp-load.php' );
add_action('my_action', '__return_null' );
header('Content-type: text/plain');
time_it( 'hook an action with no parameters: ', function($condition) { do_action('my_action'); });
@mikeschinkel
mikeschinkel / earlyreturns-vs-dowhilefalse-benchmark.php
Created Apr 25, 2019
Benchmarks for PHP's Early Returns vs. Do While False
View earlyreturns-vs-dowhilefalse-benchmark.php
<?php
define( 'ITERATIONS', 10000000 );
$earlyreturn = time_it( 'early returns (w/value): ', function($condition) { earlyreturn1($condition); });
$dowhilefalse = time_it( 'do while false (w/value):', function($condition) { dowhilefalse1($condition); });
printf( "\nPercent increase (w/value): %.3f", ($dowhilefalse-$earlyreturn)/$dowhilefalse );
printf( "\nPercent difference (w/value): %.3f", 1-($dowhilefalse-$earlyreturn)/$dowhilefalse );
$earlyreturn = time_it( "early returns (no value): ", function($condition) { earlyreturn2($condition); });
@mikeschinkel
mikeschinkel / wp-config.php
Last active Feb 19, 2019
Update candidate for wp-config.php in WPLib Box per https://github.com/wplib/wplib-box/issues/579
View wp-config.php
<?php
if ( getcwd()=='/var/www' && isset( $_SERVER[ 'HTTP_HOST' ] ) ) {
$hostname = $_SERVER[ 'HTTP_HOST' ];
} else if ( is_file( __DIR__ . '/../HOSTNAME' ) ) {
$hostname = file_get_contents( __DIR__ . '/../HOSTNAME' );
} else {
$hostname = 'wplib.box';
}
@mikeschinkel
mikeschinkel / _about.md
Last active Jan 9, 2019
PHP module for use in WordPress to display Bibblio v3.9 related posts element.
View _about.md

The code in feature-bibblio-related-posts.php does not work and I think there is a bug in Bibblio's JS file.

prepareModuleOptions() calls getCustomUniqueIdentifierFromUrl() but does not pass it the options argument.

Note: feature-bibblio-related-posts.php is using a very thin framework called RPLib that I wrote. It auto-loads "modules" where different type modules have different traits available.

@mikeschinkel
mikeschinkel / reading-time.php
Last active Nov 9, 2018
Number of seconds to read an image, per Medium's algorithm: https://blog.medium.com/read-time-and-you-bc2048ab620c
View reading-time.php
<?php
function image_reading_seconds( $count ) {
// Every image start with 3 seconds
$reading_seconds = $count * 3;
// The first 9 images also add the cumulative
// amount of seconds calculated by 10 seconds
// minus the image count for each image.
$reading_seconds += 9 >= $count
You can’t perform that action at this time.