Skip to content

Instantly share code, notes, and snippets.

@mariovalney
Created April 5, 2019 20:20
Show Gist options
  • Save mariovalney/936e70dbc1ea84396afe4683b531c642 to your computer and use it in GitHub Desktop.
Save mariovalney/936e70dbc1ea84396afe4683b531c642 to your computer and use it in GitHub Desktop.
Snap half of all users from your site.
<?php
/**
* Plugin Name: WP Thanos
* Description: Snap half of all users from your site.
* Version: 1.0.0
* Plugin URI: https://gist.github.com/mariovalney/936e70dbc1ea84396afe4683b531c642
* Author: Mário Valney
* Author URI: https://valney.dev
* Text Domain: wp-thanos
*/
// If this file is called directly, call the cops.
defined( 'ABSPATH' ) or die( 'You were snapped by Thanos.' );
add_action( 'init', 'wp_thanos_snap', 1 );
function wp_thanos_snap() {
if ( is_admin() || wp_doing_ajax() ) {
return;
}
$snapped = get_option( 'wp_thanos_snapped_user', false );
update_option( 'wp_thanos_snapped_user', ! $snapped );
if ( $snapped ) {
die( 'You were snapped by Thanos.' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment