Skip to content

Commit dfd5060

Browse files
committed
migrate thomas's gists here
1 parent d4194f9 commit dfd5060

File tree

281 files changed

+6627
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+6627
-0
lines changed

.editorconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
# WordPress Coding Standards
5+
# http://make.wordpress.org/core/handbook/coding-standards/
6+
7+
root = true
8+
9+
[*]
10+
charset = utf-8
11+
end_of_line = lf
12+
indent_size = 2
13+
tab_width = 2
14+
indent_style = space
15+
insert_final_newline = true
16+
trim_trailing_whitespace = true
17+
18+
[*.txt]
19+
trim_trailing_whitespace = false
20+
21+
[*.template]
22+
indent_size = 4
23+
tab_width = 4
24+
indent_style = tab

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Code snippets, tweaks, and hook examples for LifterLMS and LifterLMS add-ons
55

66
---
77

8+
These code snippets are shared *as is* without warranty. These snippets serve as examples and many of them are largely untested.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* Store Authorize.Net API Credentials as constants (in a wp-config.php file, for example) instead of saving them to the WP database (LifterLMS Authorize.Net)
4+
*
5+
* @since 2021-01-25
6+
*/
7+
8+
// Sandbox (Test) API Credentails.
9+
define( 'LLMS_AUTH_DOT_NET_TEST_CLIENT_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' );
10+
define( 'LLMS_AUTH_DOT_NET_TEST_LOGIN_ID', 'XXXXXXXXX' );
11+
define( 'LLMS_AUTH_DOT_NET_TEST_TRANSACTION_KEY', 'XXXXXXXXXXXX' );
12+
13+
// Production (Live) API Credentails.
14+
define( 'LLMS_AUTH_DOT_NET_LIVE_CLIENT_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' );
15+
define( 'LLMS_AUTH_DOT_NET_LIVE_LOGIN_ID', 'XXXXXXXXX' );
16+
define( 'LLMS_AUTH_DOT_NET_LIVE_TRANSACTION_KEY', 'XXXXXXXXXXXX' );
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* llms-paypal-enable-shipping.php
4+
*
5+
* @since 2018-02-17
6+
*/
7+
/**
8+
* Removes the "NOSHIPPING" parameter defined by LifterLMS PayPal
9+
* Enables the Shipping fields UI inside PayPal for a transaction
10+
* @param array $request request data to be passed to PayPal
11+
* @param string $action action being called (doExpressCheckout or etc...)
12+
* @param array $data array of PayPal NVP data
13+
* @return array
14+
*/
15+
function my_llms_paypal_shipping_fields( $request, $action, $data ) {
16+
17+
if ( isset( $request['body'] ) ) {
18+
unset( $request['body']['NOSHIPPING'] );
19+
}
20+
21+
return $request;
22+
23+
}
24+
add_filter( 'llms_paypal_build_request', 'my_llms_paypal_shipping_fields', 10, 3 );
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* llms-paypal-secure-keys.php
4+
*
5+
* @since 2020-02-29
6+
*/
7+
8+
// Live API Credentials.
9+
define( 'LLMS_PAYPAL_LIVE_API_USERNAME', 'some-facilitator_api1.mysite.com' );
10+
define( 'LLMS_PAYPAL_LIVE_API_PASSWORD', '****************' );
11+
define( 'LLMS_PAYPAL_LIVE_API_SIGNATURE', '***************************-****************************' );
12+
13+
// Sandbox API Credentials.
14+
define( 'LLMS_PAYPAL_TEST_API_USERNAME', 'some-facilitator_api1.mysite.com' );
15+
define( 'LLMS_PAYPAL_TEST_API_PASSWORD', '****************' );
16+
define( 'LLMS_PAYPAL_TEST_API_SIGNATURE', '***************************-****************************' );
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* https://lifterlms.com/docs/lifterlms-stripe-tls-1-2/
4+
*
5+
* @since 2016-08-22
6+
*/
7+
/**
8+
* Force TLS 1.2 for WordPress HTTP requests
9+
*
10+
* BEWARE:
11+
* If TLS 1.2 becomes compromised and a newer version is released or required you will need to update
12+
* this snippet!
13+
*
14+
* This also may not work
15+
*
16+
* More info at https://lifterlms.com/docs/lifterlms-stripe-tls-1-2/
17+
*/
18+
function my_tls_fix( $version ) {
19+
curl_setopt( $handle, CURLOPT_SSLVERSION, 6 );
20+
}
21+
add_filter( 'http_api_curl', 'my_tls_fix' );
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* Define Stripe API keys as constants instead of saving them to your sites database (LifterLMS Stripe)
4+
*
5+
* @since 2019-04-17
6+
*/
7+
8+
// Live API Keys.
9+
define( 'LLMS_STRIPE_LIVE_PUBLISHABLE_KEY', 'pk_live_**************' );
10+
define( 'LLMS_STRIPE_LIVE_SECRET_KEY', 'sk_live_**************' );
11+
12+
// Test API Keys.
13+
define( 'LLMS_STRIPE_TEST_PUBLISHABLE_KEY', 'pk_test_**************' );
14+
define( 'LLMS_STRIPE_TEST_SECRET_KEY', 'sk_test_**************' );
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* Remove Stripe.js (as enqueued by the LifterLMS Stripe plugin) from pages where Stripe isn't explicitly required or used
4+
*
5+
* @since 2020-06-03
6+
*/
7+
8+
/**
9+
* Remove Stripe.js (as enqueued by the LifterLMS Stripe plugin) from pages where Stripe isn't explicitly required or used.
10+
*
11+
* Stripe *recommends* that you load Stripe.js on every site on your website
12+
* to improve automatic fraud detection (https://stripe.com/docs/radar).
13+
*
14+
* You can use this code if you don't care about Radar / fraud detection
15+
* to enjoy a small performance improvement.
16+
*
17+
* @since 2020-06-03
18+
*
19+
* @return void
20+
*/
21+
function my_stripe_dequeue() {
22+
23+
if ( function_exists( 'is_llms_checkout' ) && function_exists( 'is_llms_account_page' ) ) {
24+
if ( ! is_llms_checkout() && ! is_llms_account_page() ) {
25+
wp_dequeue_script( 'stripe' );
26+
}
27+
}
28+
29+
}
30+
add_action( 'wp_enqueue_scripts', 'my_stripe_dequeue', 15 );
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* Adjust the language of the LifterLMS Stripe Credit Card Form.
4+
*
5+
* @since 2020-04-07
6+
*/
7+
8+
/**
9+
* Adjust the locale of the Stripe.js credit card form.
10+
*
11+
* @param array $settings Array of settings.
12+
* @return array
13+
*/
14+
function my_llms_stripe_js_locale( $settings ) {
15+
16+
// Adjust the locale of Stripe.js, see https://stripe.com/docs/js/elements_object/create#stripe_elements-options-locale for supported locales.
17+
$settings['elements']['locale'] = 'auto';
18+
return $settings;
19+
20+
}
21+
add_filter( 'llms_stripe_elements_settings', 'my_llms_stripe_js_locale' );
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php // Don't copy this line!
2+
/**
3+
* llms_stripe_api_version.php
4+
*
5+
* @since 2017-07-12
6+
*/
7+
8+
/**
9+
* Change the Stripe API version used by LifterLMS Stripe
10+
* See available API versions here: https://stripe.com/docs/upgrades#api-changelog
11+
* LifterLMS Stripe currently uses version 2017-06-05
12+
* Use at your own risk, especially with regards to MAJOR api versions!
13+
* @param string $api_version default api version (2017-06-05)
14+
* @return version
15+
*/
16+
function my_llms_stripe_api_version( $api_version ) {
17+
return '2017-05-25'; // because you're silly and want to rollback?
18+
}
19+
add_filter( 'llms_stripe_api_version', 'my_llms_stripe_api_version', 10 );
20+

0 commit comments

Comments
 (0)