Skip to content

Instantly share code, notes, and snippets.

Avatar

Christoph Daum apermo

View GitHub Profile
@apermo
apermo / category_mover.php
Created November 11, 2021 11:14
Bulk move and delete Categories in WordPress
View category_mover.php
<?php
if ( ! defined( 'PHP_SAPI' ) || PHP_SAPI !== 'cli' ) {
exit( 'You shall not pass' );
// echo '<pre>';
// set_time_limit( 0 );
}
$dir = $argv[1] ?? __DIR__;
// Load wp-config to make sure we can use WordPress.
@apermo
apermo / session-debugger.php
Created November 4, 2021 07:03
Simple WordPress User Session debugger
View session-debugger.php
<html>
<head>
<style type="text/css">
textarea {
width: 100%;
height: 300px;
}
td {
border: 2px dashed grey;
padding: 1em;
@apermo
apermo / mu-redirect.php
Created October 27, 2021 09:37
Timed redirect MU Plugin for WordPress
View mu-redirect.php
<?php
/**
* Plugin Name: Timed redirect
* Description: Redirects all traffic to [hardcoded domain] starting [hardcoded time]
* Version: 1.0.0
* Author: Christoph Daum
*/
// Mind possible UTC time differences here.
@apermo
apermo / create_admin.php
Created September 8, 2021 10:11
Self Destructing Create Admin User for WordPress
View create_admin.php
<?php
require_once 'wp-config.php';
// Add your desired credentials here. Using these is a super bad idea.
//$user = 'YOUR USERNAME';
//$pass = 'YOUR_SUPER_SECURE_PASSWORD';
//$email = 'YOUR@ADMIN_EMAIL.ADDRESS';
if ( ! username_exists( $user ) && ! email_exists( $email ) ) {
@apermo
apermo / selfdesctruct_info.php
Created March 8, 2021 12:04
A small snippet around the phpinfo(); to have a self destructing phpinfo that deletes itself after 3600s
View selfdesctruct_info.php
<?php
// file is older than 3600s, better delete this.
if ( filemtime( __FILE__ ) + 3600 < time() ) {
unlink( __FILE__ );
header( "HTTP/1.0 404 Not Found" );
exit();
}
phpinfo();
View abstract-settings.php
<?php
/**
* Contains Class Settings_Abstract
*/
if ( ! defined( 'ABSPATH' ) ) {
header( 'HTTP/1.0 404 Not Found' );
exit( 'You shall not pass' );
}
@apermo
apermo / ios_fixed_background.css
Created January 10, 2020 13:54
A fix for the ios fixed&cover background issue
View ios_fixed_background.css
body::after {
content: "";
display: block;
position: fixed;
top: 0;
left: 0;
height: 100%;
height: 100vh;
width: 100%;
width: 100vw;
@apermo
apermo / wp-gutenberg-reusable-block-interface.php
Last active April 16, 2019 12:44 — forked from mrpritchett/wp-gutenberg-reusable-block-interface.php
Gutenberg Reusable Block Editor Interface
View wp-gutenberg-reusable-block-interface.php
function custom_add_interface_to_wp_block( $args, $post_type ) {
global $pagenow;
if ( 'wp_block' !== $name ) {
return $args;
}
$changed_args = array(
'show_ui' => true,
'show_in_menu' => true,
@apermo
apermo / enqueue_filemtime.php
Last active July 3, 2019 05:09
wrapper for wp_enqueue_style using filemtime
View enqueue_filemtime.php
<?php
// has been taken from a class, globals are just a quick and dirty workarround
// This Wrapper is one example for a simple use of cached filemtime version strings, in this case for the parent theme.
// Needs small changes to work for childtheme, javascript, plugins or register
function local_enqueue_style( $handle, $src, $deps = array(), $media = 'all' ) {
wp_enqueue_style( $handle, get_template_directory_uri() . $src, $deps, local_get_version( get_template_directory() . $src ), $media );
}
@apermo
apermo / class.mapping-composer.php
Last active February 16, 2017 17:23
WordPress Multisite Domain Mapping & Visual Composer
View class.mapping-composer.php
<?php
if ( ! class_exists( 'MultsiteComposer' ) ) {
class MultsiteComposer {
public static function init() {
if ( isset( $_GET['vc_action'] ) || isset( $_GET['vc_editable'] ) ) {
if ( defined( 'DOMAIN_MAPPING' ) ) {
remove_filter( 'plugins_url', 'domain_mapping_plugins_uri', 1 );
remove_filter( 'theme_root_uri', 'domain_mapping_themes_uri', 1 );
remove_filter( 'pre_option_siteurl', 'domain_mapping_siteurl' );
remove_filter( 'pre_option_home', 'domain_mapping_siteurl' );