Skip to content

Instantly share code, notes, and snippets.

@devwax
devwax / hugo-clone-local-theme.txt
Last active May 27, 2018 03:52
Clone a local Hugo theme for customization
> cd themes/
> git clone ./theme-name ./theme-name-custom
# Pull remote branch to server
# https://stackoverflow.com/a/9537923/2480125
git fetch origin
git checkout --track origin/feb-2020
# Untrack directory that was previously commited but should now be ignored
# https://stackoverflow.com/a/7927283/2480125
git rm -r --cached wp-content/plugins
git commit "'Remove ignored directory /****/"
@devwax
devwax / devwax-commands.sh
Last active May 4, 2024 00:34
Bash Terminal Commands
# copy dir contents to another dir
# https://askubuntu.com/a/86891
cp -a source/. dest/
# https://docs.gitlab.com/ee/user/ssh.html
ssh-keygen -t ed25519 -C "<comment>"
# SSH Public Key Setup
Copy public key to clipboard
pbcopy < ~/.ssh/id_rsa.pub
@devwax
devwax / WordPress - Dynamic Copyright Years.php
Last active February 27, 2020 04:44
Automatically display copyright year range, if applicable, in WordPress theme
@devwax
devwax / embedded-webp.html
Last active March 1, 2020 03:20
Embedded Base64 WebP image w/ JPEG fallback
<picture>
<source srcset="data:image/webp;base64,UklGRrYPAABXRUJQVlA4IKoPAABwVgCdASpmA1oAPm02l0kkIqIhIRGqgIANiWlu4XCBG/Nd86f4ftj/xn5O+gflE9rSrLlv5P9+P03ri7Gfj5qC+0d2fAF+i/3TvxNVnxP/0PcD4KDzv2Cv6B5uujjUZF8GzMzMzMzMy/qdi6DbZEREREREREREREREREREREREREQ5443ELiTqCPvGvwA8cljijeyzQajOxqaW7gQqcEUBM7v3ul9/U8jm5aTeDeoz5e0qAq1QVtH+gYND2A+0UZ9iqsnZEREREREREQ6Vced/xZku2l0391SgwayhP6JgZgrRukpYXHkrOL+CknVzPnjyMtcNjL5qmZjg3YdWqqHlW13nLuvllV6RuJWqS9IIOqW2FFBhlB4H7WI2hGANPVM8x1nHOCGzAJJBYSXBlwbpAmv4nSSggazZnJ+eJcNcHjxbqDU24lXAy+3vfV5/PZdTiM2FOl/oc5rNaABtj+lSfEsP3JkqauuL2qmeGclgYAGW2uX2PSTYPxmgTAf/ds6XeOJ36FKNr9M1qKW8JOHzFeFiupYvDTlJqSWL01NeZOcgocGhlwkjMp9izSc9P9vPh/rrc42SSSR5mEHk6GFhFUR6sp9LZxShqBGbPkXx2nSM9zAhIdjV8IN7kPJgBUp3AgYLurs8PE/mhwKi06TbR+AlUlgi+Pe7Ix6v17ae2RPI8LrOAEcbGW8NkxV39zfqON2QrQNvcVcVFmJTDDykaCiPAwURkRThy1XBnnQbxEy/cpaAO/hYzJ3Tpy5WcQJ0nGOTh3xETiKdYgqOevt2M9PyRt5cqqqi6siSz7qkCCucVGnpsvs8EplpnYqd9aP+B5lviObD+M7n992dpBfVYwYP0ZjNKaY+GNJv+j5v67a0BK3ZEREREREREREREREREREREREREREREREREREREREREREREREREOQAAP7/OcCidMREp
@devwax
devwax / php.ini
Last active March 8, 2020 04:38
PHP Debugger + VSCODE + Local by Flywheel
[Xdebug]
zend_extension = /opt/php/7.2.0/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port="9000"
xdebug.profiler_enable=0
xdebug.overload_var_dump=off
xdebug.remote_host="172.17.0.1"
xdebug.profiler_enable_trigger = 1
@devwax
devwax / functions.php
Created April 29, 2020 06:40
WP - Admin Recent History
add_action( 'admin_init', 'admin_recent' );
// add_action( 'current_screen', 'admin_recent' );
function admin_recent() {
// $currentScreen = get_current_screen();
// if( $currentScreen->id === "widgets" ) {
// Run some code, only on the admin widgets page
// }
// error_log(print_r($currentScreen, true));
// error_log(get_admin_url());
@devwax
devwax / WP Cli Commands.sh
Last active June 1, 2021 23:17
Useful WP CLI Commands
# List all active/inactive plugins
wp plugin list --status=active
wp plugin list --status=inactive
Source: https://www.liquidweb.com/kb/rollback-plugin-theme-using-wp-cli/
# Rollback installed plugin to another version + dry-run
wp plugin update plugin-name --version=5.0.5 --dry-run
# Install and activate previous version of plugin (if not already installed)
@devwax
devwax / wp-admin-truncate-taxonomy-descriptions.php
Last active July 8, 2020 00:43
Truncate taxonomy description in WP Admin
// Truncate taxonomy description in WP Admin
function wpse_term_description_attributes() { ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$( '.description.column-description' ).attr( 'style', 'white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:1px;' );
});
</script><?php
}
add_action( 'admin_head', 'wpse_term_description_attributes' );
@devwax
devwax / responsive-bg-image-opacity.htmll
Created July 16, 2020 18:54
Change the opacity of a background image
<style>
.container {
min-height: 400px;
}
.bg-image-opacity-7 {
background-image: linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.7)), url('/assets/images/bg-image.jpg');
background-repeat: no-repeat;
background-size: cover;
background-position: center;