Skip to content

Instantly share code, notes, and snippets.

View mclarenmervin's full-sized avatar
🎯
Focusing

Mousam Debadatta mclarenmervin

🎯
Focusing
View GitHub Profile
@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];
?>
<?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 / 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
/**
* Group id shortcode
*/
function mypmpro_groupid_shortcode() {
global $wpdb;
// Start output buffering
ob_start();
<?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
function custom_pmpro_save_checkout_fields($user_id) {
if(isset($_REQUEST['bdob'])) {
update_user_meta($user_id, 'pmpro_dob', $_REQUEST['bdob']);
}
}
add_action('pmpro_after_checkout', 'custom_pmpro_save_checkout_fields');
<?php
$sec_key = 'sk_live_xxxxxxxxxxxxxxxxxxx';
require_once 'stripe-php/init.php';
$stripe = new \Stripe\StripeClient($sec_key);
$invoices = $stripe->invoices->all([ 'status' => 'uncollectible', 'limit' => 30 ]);
foreach ($invoices as $key => $value) {
jQuery(document).ready(function($){
$(window).on('scroll', function(){
var scrollTop = $(this).scrollTop();
var targetTop = $('.woocommerce-product-gallery').offset().top;
if (scrollTop >= targetTop) {
$('.woocommerce-product-gallery').addClass('highlight');
} else {
$('.woocommerce-product-gallery').removeClass('highlight');
}
<?php
function sp_edd_filter_query($query, $atts)
{
// We're going to modify the order and orderby parameters depending on variables contained in the URL
if (isset($_GET['sp_orderby'])) {
$orderby = $_GET['sp_orderby'];
if(isset($orderby) && $orderby == 'free') {
// Add meta query to filter downloads with price zero
$meta_query = isset($query['meta_query']) ? $query['meta_query'] : array();
jQuery(document).ready(function($){
var unavailableDates = ["9-3-2012", "14-3-2012", "15-3-2012"];
function unavailable(date) {
dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
if ($.inArray(dmy, unavailableDates) == -1) {
return [true, ""];
} else {
return [false, "", "Unavailable"];
}