Skip to content

Instantly share code, notes, and snippets.

View bugnumber9's full-sized avatar

Nazar Hotsa bugnumber9

View GitHub Profile
@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]
<?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';
<?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' ) ) {
@bugnumber9
bugnumber9 / form-preview.js
Created April 5, 2025 12:51
File preview for Elementor form upload field
document.addEventListener('DOMContentLoaded', function () {
const fileInput = document.querySelector('input[type="file"]');
const previewContainer = document.createElement('div');
fileInput.insertAdjacentElement('afterend', previewContainer);
fileInput.addEventListener('change', function (e) {
const file = e.target.files[0];
if (file) {
.iconbox-1 .elementor-icon {position: relative;}
.iconbox-1 .elementor-icon::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom right, #fff, #ff09ab);
@bugnumber9
bugnumber9 / reset-option-id.sql
Last active June 1, 2025 10:01
Reset auto-increment for option_id in wp_options table
-- Step 1: Create a table backup so that you won't have to restore the whole DB if something goes goofy
CREATE TABLE wp_options_bak LIKE wp_options;
INSERT INTO wp_options_bak SELECT * FROM wp_options;
-- Step 2: Export data in the existing order, ordered by option_id
CREATE TABLE wp_options_tmp AS
SELECT option_name, option_value, autoload
FROM wp_options
ORDER BY option_id;
/**
* Add taxonomy to pages
*/
function bnn_add_pages_tax() {
register_taxonomy(
'page_category',
'page',
array(
'label' => __( 'Categories' ),
'rewrite' => array( 'slug' => 'page-category' ),
<?php
# composer require aws/aws-sdk-php
use Aws\SesV2\SesV2Client;
require 'vendor/autoload.php';
define('AWS_ACCESS_KEY_ID', '');
define('AWS_SECRET_ACCESS_KEY', '');
$client = new SesV2Client([
function has_class_single_title_container($content) {
return strpos($content, 'class="single-title-container"') !== false;
}
function replace_text($content){
if (is_single() && has_class_single_title_container($content)) {
$content = preg_replace_callback('/<h2(.*?)class="entry-title"(.*?)>(.*?)<\/h2>/', function($matches) {
return '<h1' . $matches[1] . 'class="entry-title"' . $matches[2] . '>' . $matches[3] . '</h1>';
}, $content);
}
return $content;
@bugnumber9
bugnumber9 / scroll-to-top.js
Created October 7, 2023 17:07
Elementor multistep form scroll to top on next step
(function ($) {
jQuery(window).on('elementor/frontend/init', function() {
if (elementorModules && elementorModules.frontend) {
class Custom_Steps_Top extends elementorModules.frontend.handlers.Base {
getDefaultSettings() {
return {
selectors: {
buttons: '.e-form__buttons',
form: '.elementor-form',
},