This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a short, fairly unique, urlsafe hash for the input string. | |
*/ | |
function generate_id( $input, $length = 8 ){ | |
// Create a raw binary sha256 hash and base64 encode it. | |
$hash_base64 = base64_encode( hash( 'sha256', $input, true ) ); | |
// Replace non-urlsafe chars to make the string urlsafe. | |
$hash_urlsafe = strtr( $hash_base64, '+/', '-_' ); | |
// Trim base64 padding characters from the end. | |
$hash_urlsafe = rtrim( $hash_urlsafe, '=' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Find out if a user has published content anywhere on the (multi-)site | |
*/ | |
function rt_user_has_published_content( $user_id ) { | |
// Arguments for get_posts, requesting 1 post of any type. | |
$args = array( | |
'post_type' => 'any', | |
'posts_per_page' => 1, | |
'author' => $user_id, | |
'fields' => 'ids', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: RT Autoautoptimize | |
* Plugin URI: http://www.this-play.nl | |
* Description: Automatically configures default settings for the Autoptimize plugin across a WordPress network | |
* Version: 0.9 | |
* Author: Roy Tanck | |
* Author URI: http://www.this-play.nl | |
* License: GPL2 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rt_add_link_target( $content ){ | |
// use the <a> tag to split into segments | |
$bits = explode( '<a ', $content ); | |
// loop though the segments | |
foreach( $bits as $key=>$bit ){ | |
// find the end of each link | |
$pos = strpos( $bit, '>' ); | |
// check if there is an end (only fails with malformed markup) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: RT Force Cache Refresh | |
* Plugin URI: http://www.this-play.nl | |
* Description: Periodically deletes expired WP Super Cache files using WP-Cron | |
* Version: 0.8 | |
* Author: Roy Tanck | |
* Author URI: http://www.this-play.nl | |
* License: GPL2 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retrieve the image's intermediate size (resized) path, width, and height. | |
* | |
* The $size parameter can be an array with the width and height respectively. | |
* If the size matches the 'sizes' metadata array for width and height, then it | |
* will be used. If there is no direct match, then the nearest image size larger | |
* than the specified size will be used. If nothing is found, then the function | |
* will break out and return false. | |
* | |
* The metadata 'sizes' is used for compatible sizes that can be used for the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retrieve the image's intermediate size (resized) path, width, and height. | |
* | |
* The $size parameter can be an array with the width and height respectively. | |
* If the size matches the 'sizes' metadata array for width and height, then it | |
* will be used. If there is no direct match, then the nearest image size larger | |
* than the specified size will be used. If nothing is found, then the function | |
* will break out and return false. | |
* | |
* The metadata 'sizes' is used for compatible sizes that can be used for the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: WCEU test plugin | |
Plugin URI: http://core.trac.wordpress.org/ticket/17626 | |
Description: Test plugin to trigger bug #17626 | |
Version: 1.0 | |
Author: Roy Tanck | |
Author URI: http://www.this-play.nl | |
Licence: GPL | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( ! function_exists( 'rt_filter_gform_caps' ) ) { | |
function rt_filter_gform_caps( $caps ){ | |
if( !current_user_can( 'manage_options' ) ){ | |
if( current_user_can( 'gform_full_access' ) ){ | |
$user = wp_get_current_user(); | |
$user->remove_cap('gform_full_access'); | |
} | |
return ''; | |
} else { | |
return $caps; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create HTML list of pages. | |
* | |
* @package WordPress | |
* @since 2.1.0 | |
* @uses Walker | |
*/ | |
class Walker_Page_Parent_Only extends Walker { |