Skip to content

Instantly share code, notes, and snippets.

View shivapoudel's full-sized avatar
🎯
Focusing

Shiva Poudel shivapoudel

🎯
Focusing
View GitHub Profile
@thenbrent
thenbrent / subscription-renewal-process.md
Created August 8, 2016 17:52
Brief developer's guide to the application flow during the subscription renewal process within WooCommerce Subscriptions

WoCommerce Subscriptions processes automatic renewal payments via the following flow:

  1. its scheduling system, Action Scheduler, will run every minute and find any woocommerce_scheduled_subscription_payment actions scheduled to run now or within the last minute
  2. if there are woocommerce_scheduled_subscription_payment actions scheduled for anytime before now, Action Scheduler will grab a batch of those actions and begin processing them (which just means triggering do_action( 'scheduled_subscription_payment', $subscription_id ) for any 3rd party code to handle)
  3. Subscriptions attaches two important functions as callbacks on the 'woocommerce_scheduled_subscription_payment' hook to process renewal for that subscription when it is called:
  4. WC_Subscriptions_Manager::prepare_renewal(), which is responsible for
<?php
/**
* Plugin Name: WP REST API Subdomain
* Plugin URI: https://wordpress.org/plugins/wp-rest-api-subdomain/
* Author: Mark McWilliams
* Author URI: https://profiles.wordpress.org/markmcwilliams/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Description: Move your RESTful API to a subdomain in WordPress
@claudiosanches
claudiosanches / test.php
Last active February 22, 2024 19:39
Regex for test credit card brand
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
@johnbillion
johnbillion / hierarchy.php
Last active June 22, 2023 23:05
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Theme Template Hierarchy Last updated for WordPress 5.4
==================================
This diagram is partially simplified for legibility. To view the complete template hierarchy in use on your site see the
Template panel in the Query Monitor plugin.
@fimak
fimak / delegate.php
Created March 5, 2015 10:33
PHP Delegate pattern. Object instead of performing one of its stated tasks, delegates that task to an associated helper object. It helps us to inherit 2 methods from 2 different classes.
<?php
class A
{
public function aFunc()
{
echo __CLASS__;
}
}
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@claudiosanches
claudiosanches / functions.php
Last active January 19, 2016 14:32
WooCommerce - Business hours.
<?php
/**
* Business hours.
*/
function odin_wc_business_hours_redirect() {
if ( is_checkout() || is_cart() ) {
global $woocommerce;
// Set the timezone.