Skip to content

Instantly share code, notes, and snippets.

View moorscode's full-sized avatar
😁
Coding!

Jip moorscode

😁
Coding!
View GitHub Profile
@moorscode
moorscode / manage-plugin-actions.php
Created July 12, 2019 11:36
Prevent plugin deletion
<?php
add_action( 'admin_init' , function() {
add_filter( 'user_has_cap', function( $allcaps ) {
$allcaps['delete_plugins'] = false;
$allcaps['edit_plugins'] = false;
return $allcaps;
});
} );
@moorscode
moorscode / activate_plugin.php
Last active July 22, 2019 13:03
Symlink creation script to activate a repository checkout to multiple Vagrant domains
<?php
if ( ! isset( $argv[1] ) ) {
print( 'Please provide a base directory.' . PHP_EOL );
exit( 1 );
}
if ( ! isset( $argv[2] ) ) {
print( 'Please provide the plugin to activate.' . PHP_EOL );
exit( 1 );
@moorscode
moorscode / vvv-custom.yml
Last active February 5, 2018 21:13
VVV2 Custom Accptance/Multisite Subdomain/Multisite Subdirectory
---
sites:
# The wordpress-default configuration provides a default installation of the
# latest version of WordPress.
wordpress-default:
repo: https://github.com/Varying-Vagrant-Vagrants/vvv-wordpress-default.git
hosts:
- local.wordpress.test
- local.wordpress-home.test
@moorscode
moorscode / docker-compose.yml
Created April 8, 2017 10:48
WordPress with two Redis and a Memcached service
version: "2"
services:
mariadb:
image: wodby/mariadb:10.1-2.0.0
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
@moorscode
moorscode / object-cache.config.php
Created April 8, 2017 10:42
Instances: redis-1 = General, redis-2 = User data, memcached = Transients
<?php
$config = [
'pools' => [
// Default/fallback controller.
'General' => [
'method' => 'Redis',
'config' => [
'scheme' => 'tcp',
'host' => 'redis-1',
@moorscode
moorscode / remove_utm.js
Last active April 4, 2016 06:42
Remove analytics campaign tags "utm_source" from the URL without redirecting to a new page, so visitors can bookmark or share the link without affecting the campaign count.
(function (l, h) {
if ( typeof h.replaceState === 'undefined' ) {
return;
}
if (!/[?&]utm_/ig.test(l.href)) {
return;
}
@moorscode
moorscode / script_local_fallback.php
Last active July 1, 2020 11:25
Add inline local script fallback for remotely loaded scripts in WordPress
<?php
/**
* wp_register_script wrapper with local fallback
*
* @param $handle
* @param $src
* @param $js_test JavaScript code to test for availability of object
* @param bool|false $local_src Load source file if test fails
* @param array $deps