Skip to content

Instantly share code, notes, and snippets.

@esedic
esedic / wpdebug.md
Last active December 18, 2025 17:05
WordPress debugging with XDebug and Visual Studio Code on Windows

Xdebug Setup for WordPress and VS Code on Windows

Step 1: Install Xdebug

  1. Copy phpinfo() output and paste it into Xdebug Wizard.
  2. Download xdebug.dll.
  3. Copy the DLL to your PHP ext folder.
  4. Add the following configuration to your php.ini:
@esedic
esedic / jdebug.md
Last active December 16, 2025 21:26
Joomla debugging with XDebug and Visual Studio Code on Windows

Xdebug Setup for Joomla and VS Code on Windows

Step 1: Install Xdebug

  1. Copy phpinfo() output and paste it into Xdebug Wizard.
  2. Download xdebug.dll.
  3. Copy the DLL to your PHP ext folder.
  4. Add the following configuration to your php.ini:
@esedic
esedic / .htaccess
Created November 28, 2025 18:24
Browser caching in .htaccess in 2025
## BEGIN EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 year"
# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
@esedic
esedic / scroll.js
Created October 10, 2025 09:38
Add an offset to scrolling anchor links
// Method 1
window.addEventListener('load', function() {
var theHash = location.hash;
// add offset only for specific hashes
var hashes = ['#project-togo', '#project-colombia-visajes', '#project-colombia-izquierdo', '#project-yemen', '#project-tansania'];
if (hashes.includes(theHash)) {
window.scrollBy(0, -100);
}
});
@esedic
esedic / wcgeo.php
Created September 30, 2025 16:35
Uses WooCommerce geolocation method
<?php
// Get current user's location
$geo_data = WC_Geolocation::geolocate_ip();
$country = $geo_data['country'];
$state = $geo_data['state'];
// Use a specific IP address
$location = WC_Geolocation::geolocate_ip( '8.8.8.8' );
@esedic
esedic / url.php
Created September 25, 2025 09:05
Get Current URL in Joomla 3 with PHP
<?php
// Method 1: Using JUri (Recommended)
// Get the full current URL
$currentUrl = JUri::getInstance()->toString();
// Get only the base URL (without query parameters)
$baseUrl = JUri::base();
// Get the current URI path
@esedic
esedic / content-product.php
Created August 21, 2025 11:54
WooCommerce template override
<?php
/**
* The template for displaying product content within loops
*
* This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@esedic
esedic / wp-polylang-breadcrumb-navxt.php
Created July 22, 2025 08:42
Fix home page URL for non-default languages Breadcrumb NavXT and Polylang
<?php
add_action('bcn_after_fill', function($bcn_breadcrumb_trail){
foreach ($bcn_breadcrumb_trail->breadcrumbs as $index => $value){
if(in_array('home',$bcn_breadcrumb_trail->breadcrumbs[$index]->get_types())){
$bcn_breadcrumb_trail->breadcrumbs[$index]->set_url( pll_home_url());
}
}
});
@esedic
esedic / fetch.js
Created June 19, 2025 07:22
Using Fetch API for Ajax Requests
// GET Request:
fetch('https://api.example.com/data')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Failed to fetch data', error));
// POST Request:
fetch('https://api.example.com/data', {
method: 'POST',
@esedic
esedic / wc_block.php
Created June 17, 2025 12:32
Detecting WooCommerce Block Pages
<?php
function is_wc_cart_block_based() {
$cart_page_id = wc_get_page_id( 'cart' );
if ( $cart_page_id && $cart_page = get_post( $cart_page_id ) ) {
// Check for WooCommerce Cart block
return has_block( 'woocommerce/cart', $cart_page );
}
return false;
}