This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A script to generate a changelog by comparing composer packages and project commits. | |
# | |
# Disclaimer: | |
# - Using this script is at your own risk. This script only uses READ operations, but I still | |
# do not take any responsibility. | |
# | |
# License: | |
# - BSD 2-Clause — Free to use with attribution. No warranty provided. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Make local URLs domainless, for all styles and scripts, to combat CORS issues. | |
// Ideally, we fix this in .htaccess using conditional headers, but in case of nginx, that's not available. | |
add_filter( 'script_loader_src', 'make_local_urls_domainless', 10 ); | |
add_filter( 'style_loader_src', 'make_local_urls_domainless', 10 ); | |
function make_local_urls_domainless( $url ) { | |
global $wpdb; | |
$all_domains = $wpdb->get_col( "SELECT domain FROM {$wpdb->blogs} ORDER BY blog_id DESC" ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Maybe login by cookie. | |
* This function will log in a user by their authentication cookie, if they have one. | |
* This will use a full authentication, so it is safe from cookie-faking. | |
* Cookie hijacking is still a possibility, however, that's a WordPress issue, not a plugin issue. | |
* (To combat this; prefix the salts in wp-config.php with $_SERVER['REMOTE_ADDR']. This is not watertight, | |
* but always better than not) | |
* | |
* Call this function in your `permission_callback`, or in case of `__return_true` in your `callback` for getting items. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# changes-to--php.ini.hbs | |
... | |
disable_functions = dns_get_record | |
... | |
auto_prepend_file = /path/to/the/dns_get_record_polyfill.php | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a zsh script to automatically switch to the localwp shell when you enter a | |
# directory that contains a LocalWP website installation | |
# it is designed to trigger on any directory deeper or exactly the app/ folder of a localwp site. | |
# this code is FAR FROM perfect, but it works! Feel free to suggest/improve/etc | |
# | |
# this file is to be sourced in your .zshrc . | |
# | |
# Suggested install method: | |
# cd ~ ; mkdir -p .zsh ; git clone https://gist.github.com/f5c220b5e49baf0df4f5bbf5b7e76fdf.git .zsh/zsh-auto-localwp | |
# echo "source ~/.zsh/zsh-auto-localwp/zsh-auto-localwp.sh" >> ~/.zshrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cd "$(dirname $0)/.." | |
[ -z "$1" ] && echo "Usage: $0 command" && echo "commands:" && echo "make-pot : re-generate POT file from source" && echo "update-po : update PO files from POT file" && echo "make-mo : generate MO and l10n.php files from PO files" && exit 1 | |
# find textdomain from ./*php | |
for file in $(find . -name '*.php'); do | |
if grep -q "Text Domain:" "$file"; then | |
TEXTDOMAIN=$(grep -o "Text Domain:\s*\([^'\"]*\)" "$file" | sed "s/Text Domain:\s*\([^'\"]*\)/\1/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
[ -z "$1" ] && echo example usage: $0 8.1 >&2 && exit 1 | |
[ ! -f /usr/bin/php${1} ] && echo "No support for this version" >&2 && ls -la /usr/bin/php* >&2 && exit 2 | |
cd ~/.local/bin | |
rm php | |
ln -s /usr/bin/php${1} php | |
hash -r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sometimes, shit happens and you end up with duplication of ACF FieldGroups. | |
* This mu-plugin will fix that. | |
* It is also compatible with ACF-to-PHP. | |
*/ | |
add_action( 'admin_init', 'deduplicate_acf_data' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This will make WordPress ALWAYS use privacy friendly embeds, implemented here are YouTube and Vimeo. | |
// Other services can be implemented by using this code as inspiration. | |
add_filter( 'oembed_dataparse', 'myproject_patch_oembed_urls', 11 ); | |
function myproject_patch_oembed_urls( $html ) { | |
// find vimeo.com urls and add ?dnt=1 to them. | |
$urls = wp_extract_urls( $html ); | |
foreach ( $urls as $old_url ) { | |
if ( false !== strpos( $old_url, 'vimeo.com' ) ) { | |
$new_url = add_query_arg( 'dnt', 1, $old_url ); |
NewerOlder