Skip to content

Instantly share code, notes, and snippets.

View sabrysuleiman's full-sized avatar
🏠
Working from home

Sabry Suleiman sabrysuleiman

🏠
Working from home
View GitHub Profile
@sabrysuleiman
sabrysuleiman / fawaterk request body
Created January 17, 2026 13:31
fawaterk request body
// Prepare payload
$data = [
"payment_method_id" => 2,
"cartTotal" => $amount,
"currency" => "EGP",
"customer" => [
"first_name" => $firstName,
"last_name" => $lastName,
"email" => $email,
"phone" => $phone,
@sabrysuleiman
sabrysuleiman / Fix Youtube Iframe Error 153 for Wordpress Content
Created January 13, 2026 12:50
Fix Youtube Iframe ( Error 153 ) for Wordpress Content
function fix_youtube_153_and_lazy_load($content) {
if (is_admin() || empty($content)) {
return $content;
}
// This handles both images and iframes
$content = preg_replace_callback(
'/<(img|iframe)([^>]+)>/i',
function ($matches) {
$tag = $matches[1];
@sabrysuleiman
sabrysuleiman / Cloudflare Security rules for Wordpress.txt
Last active January 8, 2026 16:47
Cloudflare Security rules for Wordpress
(http.request.uri.path contains "/wp-comments-post.php")
or (http.request.uri.path contains "/wp-content/uploads/" and http.request.uri.path contains ".php")
or (http.request.uri.path contains "xmlrpc.php")
or (http.request.uri.path contains "/wp-content/themes/" and http.request.uri.path contains ".php")
or (http.request.uri.path contains "/wp-content/plugins/" and http.request.uri.path contains ".php")
or (http.request.uri.path contains "readme.html")
or (http.request.uri.path contains "license.txt")
or (http.request.uri.path contains "wp-config.php")
or (http.request.uri.path contains ".env")
or (http.request.uri.path contains ".git")
@sabrysuleiman
sabrysuleiman / integrate Carbon Fields with Rank Math
Created July 28, 2025 14:14
integrate Carbon Fields with Rank Math
# Load Your JS File Properly
add_action( 'admin_enqueue_scripts', function( $hook ) {
if ( $hook === 'post.php' || $hook === 'post-new.php' ) {
wp_enqueue_script(
'my-rankmath-carbon-js',
plugin_dir_url( __FILE__ ) . 'js/rankmath-carbon.js',
[ 'wp-hooks' ],
null,
true
@sabrysuleiman
sabrysuleiman / getUserTrafficSource.php
Last active June 24, 2025 12:23
php function to Get User Traffic Source
<?php
function getUserTrafficSource() {
$source = 'unknown'; // Default to unknown
$details = []; // To store additional details
// 1. Check for UTM parameters (most reliable for ads)
if (isset($_GET['utm_medium'])) {
if ($_GET['utm_medium'] === 'cpc' || $_GET['utm_medium'] === 'paid') {
$source = 'ad';
$details['ad_platform_guess'] = isset($_GET['utm_source']) ? $_GET['utm_source'] : 'unknown_platform';
@sabrysuleiman
sabrysuleiman / maildir2mbox.py
Created June 17, 2025 12:43
Convert maildirs (including subfolders) to mbox format ( python3 )
#!/usr/bin/env python
#
# Convert a maildir to a mbox file. ( python3 )
#
# Inspired by : Felipe Pena <felipensp@conectiva.com.br>
#
import mailbox
import sys
@sabrysuleiman
sabrysuleiman / Find & Replace WordPress Domain
Created April 16, 2025 17:24
Find & Replace WordPress Domain
-- 1. Update siteurl and home
UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://site.local', 'https://site.com')
WHERE option_name IN ('siteurl', 'home');
-- 2. Update post content (links, images, etc.)
UPDATE wp_posts
SET post_content = REPLACE(post_content, 'http://site.local', 'https://site.com');
-- 3. Update GUIDs (optional - normally shouldn't be changed unless migrating)
@sabrysuleiman
sabrysuleiman / Website Migration Via SSH & SCP.sh
Last active April 12, 2025 18:09
Website Migration Via SSH & SCP
# 🔐 Connect to Remote Server via SSH
# Establishes a secure SSH connection to a remote server using a specific port (e.g., 6543). Useful for accessing and managing remote systems.
ssh -p port userName@ip.address.here
ssh -p 6543 sabry@192.168.1.1
# 📦 Compress Website Directories into .tar.gz Archives
# Creates compressed .tar.gz archives of the uploads, themes, and plugins directories. Ideal for backup or transfer.
tar -czf uploads.tar.gz ./uploads
@sabrysuleiman
sabrysuleiman / Serve static assets with an efficient cache policy 
Created March 17, 2025 08:43
Serve static assets with an efficient cache policy 
<IfModule mod_expires.c>
ExpiresActive On
# Images (e.g., JPEG, PNG, GIF, SVG)
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year" #favicon
@sabrysuleiman
sabrysuleiman / gist:4d91db55bef76f63909cc2fc49c5a8c9
Created February 13, 2025 06:38
VSCdode Copilot Keyboard shortcut ( Ubuntu )
# chat About you Code ( Ctrl + Alt + I )
# Make changes using natural language ( Ctrl + Shift + Alt + I )