Skip to content

Instantly share code, notes, and snippets.

View mclarenmervin's full-sized avatar
🎯
Focusing

Mousam Debadatta mclarenmervin

🎯
Focusing
View GitHub Profile
<?php
//Change Active Theme By Code
add_filter( 'template', 'mervin_change_theme' );
add_filter( 'option_template', 'mervin_change_theme' );
add_filter( 'option_stylesheet', 'mervin_change_theme' );
function mervin_change_theme($theme)
{
$theme = 'storefront';
<?php
/**
* Group id shortcode
*/
function mypmpro_groupid_shortcode() {
global $wpdb;
// Start output buffering
ob_start();
@mclarenmervin
mclarenmervin / Stripe-Get-Expired-Subscriptions-Object.php
Last active May 23, 2024 10:58
Get Expired Subscriptions Object
<?php
require_once 'stripe-php/init.php'; // Path to autoload.php from the Stripe SDK
$sec_key = 'sk_live_xxxxxxxxxxxxxxxxxxx';
$limit = 999999;
\Stripe\Stripe::setApiKey($sec_key);
$stripeclient = new \Stripe\StripeClient($sec_key);
$cancelled_subscriptions = \Stripe\Subscription::all(['limit' => $limit, 'status' => 'incomplete_expired']);
<?php
// webhook: customer.subscription.deleted
$sec_key = 'sk_live_xxxxxxxxxxxxxxxxxx';
require_once 'stripe-php/init.php';
$stripe = new \Stripe\StripeClient($sec_key);
$last_invoice = $stripe->invoices->all(['limit' => 1]);
$invoice_id = $last_invoice->data[0]->id;
$stripe->invoices->voidInvoice($invoice_id, []);
@mclarenmervin
mclarenmervin / ACF-Image-URL-by-Image-ID.php
Last active May 24, 2024 07:03
ACF Image URL by Image ID
<?php
// first, get the image ID returned by ACF
$image_id = get_field('image_field');
$image_size = 'thumbnail';
$image_array = wp_get_attachment_image_src($image_id, $image_size);
$image_url = $image_array[0];
?>