Skip to content

Instantly share code, notes, and snippets.

View bugnumber9's full-sized avatar

Nazar Hotsa bugnumber9

View GitHub Profile
<?php
/**
* Plugin Name: Staging URL Finder
* Description: Finds and lists URLs in the database that differ from the site URL
* Version: 0.2.0
* Author: Nazar Hotsa
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
<?php
require( 'wp-load.php' ); // Make sure to set the correct path to wp-load.php file
set_time_limit( 300 ); // Optional, yet might be necessary depending on the server configuration
// BEGIN Configuration
$admin_email = 'email@example.com';
$max_log_size_bytes = 1024 * 1024; // 1 MB
$log_file = '/home/user/multisite-cron.log';
@bugnumber9
bugnumber9 / .htaccess
Created November 24, 2025 14:22
www to non-www redirection (.htaccess)
RewriteCond %{HTTP_HOST} ^www\. [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
@bugnumber9
bugnumber9 / media-sizes.php
Created January 24, 2026 11:45
Disable creation of different media sizes
function bnn_image_sizes_override( $sizes ) {
unset( $sizes['thumbnail'] );
unset( $sizes['medium'] );
unset( $sizes['medium_large'] );
unset( $sizes['large'] );
unset( $sizes['1536x1536']); // 2x medium-large
unset( $sizes['2048x2048']); // 2x large
return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced', 'bnn_image_sizes_override' );
@bugnumber9
bugnumber9 / trim-long-urls.php
Last active March 10, 2026 10:49
Trim long URLs
add_filter( 'the_content', function( $content ) {
return preg_replace_callback (
'#https?://[^\s<]+#i',
function( $matches ) {
$url = $matches[0];
$display = preg_replace( '#https?://#', '', $url );
if( strlen( $display ) > 50 ) {
$display = substr( $display, 0, 25 ) . '…' . substr( $display, -15 );
}