Skip to content

Instantly share code, notes, and snippets.

@morganestes
morganestes / distributor-post-date.php
Last active July 13, 2020 20:13
Change the publish date of a distributed post to the source timestamp
<?php
namespace BigWing\Integrations\Distributor;
/**
* Set the date on distributed posts to the source date.
*
* @param array $post_args The post data to insert into the receiving site.
* @param \WP_Post $post The source post object.
*
@morganestes
morganestes / .htaccess
Created May 28, 2020 02:47
WordPress image proxy for development
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule wp-content/uploads/(.*) https://example.com/wp-content/uploads/$1 [NC,L]
</IfModule>
@morganestes
morganestes / wp-cli.local.yml
Last active November 2, 2023 18:51
WP Engine wp-cli config mods
# Assuming you have SSH keys set up with WP Engine,
# and your ~/.ssh/config includes settings for using your key with *.ssh.wpengine.net,
# you can alias your environments and run commands from your local install.
# Replace the values in {} with the install name from WPE.
@production:
ssh: {prodinstall}@{prodinstall}.ssh.wpengine.net
@staging:
ssh: {stginstall}@{stginstall}.ssh.wpengine.net
@morganestes
morganestes / wp-is-plugin-active-in-network.sh
Created March 17, 2020 20:12
Check network for sites with active plugin
#!/usr/bin/env bash
function check_plugin() {
local pluginName="${1:-hello}"
local sites="$(wp site list --field=url | xargs)"
for site in sites
do
echo "Checking ${site}"
wp plugin is-active ${pluginName} --url=${site}
@morganestes
morganestes / fake-wp-admin.php
Created March 13, 2020 21:25
Contents of a malware attack hidden in /wp-content/wp-admin.php
<?php
/**
* Hueblud 2017.Administrator PIDOR2Joomla.Administrator newupdata
*@package Joomla.Administrator @package Joomla.Administrator
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
define('_JEXEC', '07b0418e1119091a9281ac5614cb9d776a85f21434408cdbbe26ca43b70618af81fecca59e592af986dae8dc8de4d1e52d393ea4dbba0effc61697cb06bd5431a191029cbbea4005db8ab69cda0121c121935164eab812a083c5b745502026934cd897bffca61d6a81705069c1dcc583be1da9335c5291798931e42319ab28edeb0df99ee867172c3f3cc17ef97e59ce6a81f18450bf1acfcd31998f5f628ed96f18eae45082f4a5ae99c6416a678aefc79bf025984659c9c9b43c396ec8719d2711f9a5fd094590f982f05b261abe4288023374a581f43988c08c55fb35fc4380d9e55c76fb0456cdf9fa4a324a4b59b2789f28c24434a5dfbb1573558755a423a2ad8c63f0833eac9ebe5abceffc2a146fff37adf1b18cde7b3dbb50aa29f00c35061fe316fa271f762368c28ba345827dcfdc076224cff96543833a6e77cdb3c8846819b19eb2f31fae5a37c37c4480bf1a56f77531a
@morganestes
morganestes / wpe-migrate.sh
Created March 10, 2020 19:09
WP Engine DevKit to Local migration
#!/usr/bin/env bash
# https://wpengine.com/support/local/
function _wpe_migrate_to_local() {
local slug="${1:-$(basename $(pwd))}"
echo "Backing up ${slug}..."
mkdir local-${slug}
wpe wp db export local-${slug}.sql && mv local-${slug}.sql local-${slug}/
rsync -avP wp-content/ local-${slug}/wp-content --exclude mu-plugins
@morganestes
morganestes / vscodium-url-schemes.sh
Created February 20, 2020 22:39
Register VS Codium as a handler for 'vscode' protocol
plutil -insert CFBundleURLTypes.0.CFBundleURLSchemes.1 -string 'vscode' Info.plist
@morganestes
morganestes / .zshrc
Created December 11, 2019 22:50
Configure zsh ssh-add plugin
# Configure ssh-agent plugin prior to loading it.
zstyle :omz:plugins:ssh-agent agent-forwarding on
# Get all the keys that are in the user's .ssh directory and add them to the ssh-agent.
SSH_IDENTITIES=($(find ${HOME}/.ssh -name '*.pub' -type f -exec sh -c 'echo $(basename "${0%\.pub}")' {} \;))
zstyle :omz:plugins:ssh-agent identities "${SSH_IDENTITIES[@]}"
# Make zsh know about hosts already accessed by SSH
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
@morganestes
morganestes / wpe-stop-all.sh
Created November 21, 2019 15:56
Stop all WP Engine DevKit sites (requires jq)
#!/usr/bin/env bash
function _wpe_stop_all {
local projects=$(wpe projects list --format json | jq '.[].Name')
for proj in $projects
echo "stopping ${proj}"
wpe stop -p $(sed -e 's/^"//' -e 's/"$//' <<<"$proj")
done
}
@morganestes
morganestes / .deployignore
Created October 31, 2018 17:00
Gulp tasks failing in GitLab CI
dist/
bin/
node_modules/
vendor/
.csscomb.json
.deployignore
.editorconfig
.eslintignore
.gitignore
.gitlab-ci.yml