Skip to content

Instantly share code, notes, and snippets.

@ajithrn
ajithrn / $email variable
Created September 15, 2022 21:12
WooCommerce Order Info From $order Object
// Get $order object from $email
$order = $email->object;
// Now you have access to (see above)...
if ( $order ) {
$order->get_id();
$order->get_formatted_order_total( );
// etc.
@ajithrn
ajithrn / custom-events-wp_query.php
Created May 2, 2022 15:51 — forked from jo-snips/custom-events-wp_query.php
The Events Calendar - Custom Query Using WP_Query
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>array(TribeEvents::POSTTYPE),
'posts_per_page'=>10,
//order by startdate from newest to oldest
'meta_key'=>'_EventStartDate',
'orderby'=>'_EventStartDate',
'order'=>'DESC',
@ajithrn
ajithrn / setup.md
Last active March 3, 2022 16:04 — forked from Yatoom/setup.md
Thinkfan configuration

Thinkfan setup

Note: I configured this thinkfan setup for my old Thinkpad w520 on Ubuntu 17.10.

1. Install necessary programs

Install lm-sensors and thinkfan.

sudo apt-get install lm-sensors thinkfan
@ajithrn
ajithrn / db_backup_trellis.sh
Last active December 9, 2021 16:16
Bulk Database Backup Trellis local Installtions
# Trellis Database Backup script for all bedrock folders.
# Use case backup all db before destroy vagrant and create.
# need to run from trellis folder on terminal
vagrant ssh
cd /srv/www
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}'/current && mkdir -p db_backup && wp db export db_backup/database_`date +%Y%m%d`.sql " \;
@ajithrn
ajithrn / youtube-dl_cheatsheet.md
Created October 20, 2021 12:10 — forked from dantheman213/youtube-dl_cheatsheet.md
youtube-dl best way to download video or entire to high quality mp3

youtube-dl cheat sheet

Docs and Binary for youtube-dl are located here:

https://github.com/rg3/youtube-dl/

Install dependencies

apt-get install libav-tools ffmpeg # Linux (either one of either should do) brew install ffmpeg # OSX choco install ffmpeg # Windows

@ajithrn
ajithrn / wc-stripe-meta-hook.php
Last active January 20, 2021 18:36
WooCommerce Stripe: Add Custom MetaData
<?php
/*
* https://remicorson.com/woocommerce-stripe-add-custom-metadata/
* Add "Billing Company" value to Stripe metadata
* add this to function.php
*/
function filter_wc_stripe_payment_metadata( $metadata, $order, $source ) {
$order_data = $order->get_data();
@ajithrn
ajithrn / gw-gravity-forms-value-exists-validation.php
Last active January 3, 2021 16:55 — forked from spivurno/gw-gravity-forms-value-exists-validation.php
Gravity Forms // Validate that a Value Exists
<?php
/**
* Gravity Wiz // Gravity Forms // Validate that a Value Exists
*
* Ensure that a value entered in Form A has been previously submitted on Form B. This is useful if you're generating a reference number of some sort
* on Form B and would like the user to enter it on Form A.
*
* @version 1.8
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
@ajithrn
ajithrn / Making Apple Push Notification certificates on Linux
Last active March 5, 2024 09:57 — forked from boodle/Making Apple Developer certificates on Linux.md
Making Apple Apple Push Notification certificates on Linux
1. Create a new directory;
mkdir Apple\ Enterprise
cd Apple\ Enterprise
2. Generate a certificate signing request
openssl req -nodes -newkey rsa:2048 -keyout aps.key -out CertificateSigningRequest.certSigningRequest
3. With the information like so (ensure you give it a password):
Country Name (2 letter code) [AU]:GB
State or Province Name (full name) [Some-State]:London
@ajithrn
ajithrn / .htaccess
Last active March 23, 2019 09:25
force htps - WP htacceess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
@ajithrn
ajithrn / wp_api_cors_headers.php
Created March 15, 2019 13:38
CORS for the WordPress REST API
/**
* CORS for the WordPress REST API
*/
function kms_wp_rest_api_cors() {
remove_filter('rest_pre_serve_request', 'rest_send_cors_headers');
add_filter('rest_pre_serve_request', function ($value) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Credentials: true');