Skip to content

Instantly share code, notes, and snippets.

View cfaria's full-sized avatar
🍊
Citius, altius, fortius... Communiter

Carlos Faria cfaria

🍊
Citius, altius, fortius... Communiter
View GitHub Profile
@cfaria
cfaria / stripewebhook.php
Created April 15, 2026 12:31
In Bedrock installations, where WP is treated as a composer dependency, it is installed in a separate folder. Find the wp-load.php scanning any immediate subdirectory of each ancestor, so it works regardless of whether the WordPress folder is named wp, wordpress, cms, or anything else.
<?php
// If called directly by Stripe, bootstrap WordPress so we can use plugin functions
if (!defined('ABSPATH')) {
// try to locate wp-load.php by walking up the directory tree
$search_dir = __DIR__;
$wp_load = '';
for ($i = 0; $i < 10; $i++) {
$possible = $search_dir . '/wp-load.php';
if (file_exists($possible)) {
@cfaria
cfaria / valet-plus-destroy
Created March 24, 2026 15:09 — forked from dannygsmith/valet-plus-destroy
Remove valet-plus - reboot required
#!/usr/bin/env bash
#styles
VP_NONE='\033[00m'
VP_RED='\033[01;31m'
VP_GREEN='\033[01;32m'
VP_YELLOW='\033[01;33m'
VP_PURPLE='\033[01;35m'
VP_CYAN='\033[01;36m'
VP_WHITE='\033[01;37m'
@cfaria
cfaria / ThemeServiceProvider.php
Last active February 2, 2024 20:44
Prevent E_NOTICE, E_WARNING, E_DEPRECATED errors WSOD in Sage 10
<?php
namespace App\Providers;
use Roots\Acorn\ServiceProvider;
class ThemeServiceProvider extends ServiceProvider
{
/**
* Register any application services.
@cfaria
cfaria / redirect.php
Created June 3, 2019 18:11
Kinsta cache issue
if(!is_admin()) add_action('template_redirect', 'supermundano_template_redirects');
function supermundano_template_redirects(){
if( is_page( 'documents' ))
{
if(!is_user_logged_in()){
wp_redirect( wp_login_url( get_permalink() ), 301);
die();
}
}
}
#roles/deploy/hooks/build-after.yml
---
- name: Check for composer.json in project root or project_subtree_path
stat:
path: "{{ deploy_helper.new_release_path }}/composer.json"
register: composer_json
- name: Fail if composer.json not found
fail:
msg: "Unable to find a `composer.json` file in the root of '{{ deploy_helper.new_release_path }}'. Make sure your repo has a `composer.json` file in its root or edit `repo_subtree_path` for '{{ site }}' in `wordpress_sites.yml` so it points to the directory with a `composer.json` file."
@cfaria
cfaria / README.md
Last active November 17, 2020 16:25
Vagrant Scotch Box 3.5 with XDebug and configuration for debugging with VSCode

Enter the vagrant machine with
ssh vagrant

Install xdebug

sudo apt-get update
sudo apt-get install php-xdebug

Config PHP to accept xdebug connections
sudo nano /etc/php/7.0/apache2/php.ini

<?php
namespace Koodimonni\Composer;
use Composer\Script\Event;
use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
@cfaria
cfaria / filter-flow-release-start-version
Created January 21, 2018 07:27 — forked from petervanderdoes/filter-flow-release-start-version
gitflow hooks and filters for WordPress theme development
#!/bin/sh
#
# Runs during git flow release start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty gitflow
# will stop as the version is necessary
#
@cfaria
cfaria / migrateorders.php
Last active January 16, 2025 10:51 — forked from maddisondesigns/migrateorders.php
Migrate WooCommerce Orders
<?php
//increase max execution time of this script to 150 min:
ini_set('max_execution_time', 9000);
//increase Allowed Memory Size of this script:
ini_set('memory_limit','960M');
// Copies woocommerce orders and users over from source to target.
// I use this on my local machine - loading both db's up there side by side
// could easily adjust the connect strings to connect elsewhere if needed.

Configure

xdebug.ini

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1