Skip to content

Instantly share code, notes, and snippets.

View aliboy08's full-sized avatar

Alistair Ponce aliboy08

  • Philippines
View GitHub Profile
@aliboy08
aliboy08 / move-inline-scripts-to-footer.php
Created September 18, 2024 09:57
move inline scripts to footer
@aliboy08
aliboy08 / ff-plugin-disabler.php
Created September 13, 2024 10:31
plugin disabler
<?php
/*
Plugin Name: FF Plugin Disabler
Description: Disable selected plugins for optimization
Version: 2.0
Author: Five by Five
Author URI: https://www.fivebyfive.com.au/
*/
if( strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) !== false ) return; // front-end only
@aliboy08
aliboy08 / sample-nested-post-types.php
Last active September 6, 2024 10:16
Sample Custom Page with nested different post types e.g: /broker/member-name/contact/
add_shortcode('broker_init', function(){
ob_start();
include 'broker/init.php';
return ob_get_clean();
});
add_action('init', 'custom_rewrite_rules');
function custom_rewrite_rules(){
add_rewrite_rule(
'^broker/([\w+-]*)/([\w+-]*)/?$',
@aliboy08
aliboy08 / test-backend.bat
Created September 2, 2024 02:21
test load time on backend (logged in to wp) - supply login cookie
@echo off
setlocal enabledelayedexpansion
set url=https://next-level-racing-new.local/wp-admin/
set runs=3
for /L %%i in (1,1,%runs%) do (
curl -o NUL -s -w "%%{time_total}\n" -H "Pragma: no-cache" -H "cookie:{INSERT_COOKIE_HERE}" "!url!"
)
@aliboy08
aliboy08 / ffdb.php
Created August 31, 2024 13:38
optimized db query for post_ids or posts count
<?php
function ffdb($args){
global $wpdb;
$post_type = $args['post_type'] ?? 'post';
$post_status = $args['post_status'] ?? 'publish';
$term_id = $args['term_id'] ?? null;
$meta_key = $args['meta_key'] ?? null;
$meta_value = $args['meta_value'] ?? null;
@aliboy08
aliboy08 / xdebug-settings.txt
Created August 30, 2024 03:47
xdebug settings
[xdebug]
{{#if os.windows}}
zend_extension = php_xdebug.dll
{{else}}
zend_extension = {{extensionsDir}}/xdebug.so
{{/if}}
{{#if xdebugEnabled}}
{{!-- xdebug.mode=debug,develop --}}
xdebug.mode=profile
@aliboy08
aliboy08 / audit.bat
Created August 30, 2024 03:24
measure load time
@echo off
setlocal enabledelayedexpansion
set url=https://next-level-racing-new.local/sample-home/
set runs=10
for /L %%i in (1,1,%runs%) do (
curl -o NUL -s -w "%%{time_total}\n" -H "Pragma: no-cache" "!url!"
)
@aliboy08
aliboy08 / batch_items.js
Created August 13, 2024 04:24
Batch items
export function batch_items(items, items_per_batch){
let batched_items = [];
let group_items = [];
let group_index = 0;
for( let i = 0; i < items.length; i++ ) {
group_index++;
group_items.push(items[i]);
@aliboy08
aliboy08 / publish.bat
Last active July 30, 2024 11:11
Plugin zip powershell script + upload to remote
@echo off
setlocal
set "plugin_name=plugin-boilerplate"
set "zip_file=%plugin_name%.zip"
set "source_path=%CD%"
set "exclude=node_modules;.git;_temp;zip.ps1;publish.bat;.gitignore;jsconfig.json;package.json;package-lock.json;wp-manifest.cjs;vite.config.js;%zip_file%"
echo Creating zip file...
@aliboy08
aliboy08 / before_after_slider.js
Created July 25, 2024 03:04
Before & After Slider
export default class Before_After_Slider {
constructor(el){
this.el = el;
this.init();
}
init(){
this.before = this.el.querySelector('.before_image');