Skip to content

Instantly share code, notes, and snippets.

View tw2113's full-sized avatar
💭
Yo

Michael Beckwith tw2113

💭
Yo
View GitHub Profile
@tw2113
tw2113 / function.php
Created March 6, 2025 19:13 — forked from khleomix/function.php
Remove nbsp
<?php
function replace_nbsp_in_posts() {
global $wpdb;
$query = "
UPDATE {$wpdb->posts}
SET post_content = REPLACE(post_content, CHAR(160), ' ')
WHERE post_content LIKE '%" . chr(160) . "%'
";
@tw2113
tw2113 / .htaccess
Created March 6, 2025 19:04 — forked from khleomix/.htaccess
Update .htaccess to serve local uploads and fallback to prod for missing files.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
//$sec_header is supposed to be $gistgit
$gistgit = wp_remote_retrieve_body( wp_remote_get('https://api.github.com/users/'. $user .'/gists', array('timeout' => 10)));
if( is_wp_error($gistgit)) {
$error_string = $sec_header->get_error_message();
echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
wp_die('');
}