Skip to content

Instantly share code, notes, and snippets.

@mitcho
Last active December 16, 2015 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitcho/5483140 to your computer and use it in GitHub Desktop.
Save mitcho/5483140 to your computer and use it in GitHub Desktop.
A tiny WordPress plugin which aids in automated screen capture testing: - if ?invisibletext=1 is set, all text will be set to be transparent - if ?genericimages=1 is set, all images will be blacked out - completely turns off authentication: DO NOT USE ON A PUBLICLY-ACCESSIBLE SITE
<?php
/**
* Plugin Name: Test Tools
* Plugin URI:
* Description: mitcho's tools for automated testing.
* Author: mitcho
* Version: 1.1
*/
class TestTools {
function __construct() {
add_action( 'admin_print_scripts', array( $this, 'print_scripts' ), 100 );
}
function print_scripts() {
echo "\n<script type='text/javascript'>jQuery(document).ready(function($){setTimeout(function(){\n";
# IF ?invisibletext=1 IS SET, ALL TEXT WILL BE SET TO BE TRANSPARENT
if ( isset($_GET['invisibletext']) )
echo '$("*").css({color:"transparent", textShadow: "none"});' . "\n";
# IF ?genericimages=1 IS SET, ALL IMAGES WILL BE BLACKED OUT
if ( isset($_GET['genericimages']) )
echo '$("img").each(function() {
var that = $(this);
that.height(that.height());
that.width(that.width());
that.attr("src", "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==");
});' . "\n";
echo "},50)});</script>\n";
}
}
# TURNS OFF AUTHENTICATION COMPLETELY! Everyone logs in as user #1
function wp_validate_auth_cookie() {
return 1;
}
new TestTools;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment