Skip to content

Instantly share code, notes, and snippets.

View greenhornet79's full-sized avatar
👽
Craft

Jeremy Green greenhornet79

👽
Craft
View GitHub Profile
@greenhornet79
greenhornet79 / leaky-paywall-third-party.php
Created November 4, 2015 14:44
How to use the leaky_paywall_new_subscriber action to do something with the new user data after they are added to the WordPress user table
<?php
// use the leaky_paywall_new_subscriber action to do something with the new user data after they are added to the WordPress user table
add_action( 'leaky_paywall_new_subscriber', 'lp_add_new_user_to_third_party_api', 20, 5 );
function lp_add_new_user_to_third_party_api( $user_id, $email, $meta, $customer_id, $meta_args ) {
// replace with the specific API data needed by your third party system (mailchimp, emma, etc.)
$api_key = 'yourkeyhere';
$url = 'https://www.yourapiurl.com/resourcepath?key=' . $api_key;
@greenhornet79
greenhornet79 / force_email_as_username.php
Created November 13, 2015 23:28
Force new subscriber's username to be their email address during sign up for Leaky Paywall
<?php
add_filter('leaky_paywall_userdata_before_user_create', 'zeen101_force_email_for_new_user' );
function zeen101_force_email_for_new_user( $userdata ) {
$userdata['user_login'] = $userdata['user_email'];
return $userdata;
}
@greenhornet79
greenhornet79 / leaky-paywall-card-level-text.php
Last active November 17, 2015 14:20
Show custom benefits for a subscription card on the subscribe page in Leaky Paywall
<?php
add_filter( 'leaky_paywall_subscription_options_allowed_content', 'zeen101_show_level_benefits_on_card', 10, 3 );
function zeen101_show_level_benefits_on_card( $allowed_content, $level_id, $level ) {
switch ( $level_id ) {
case 0:
$output = '<ul>';
$output .= '<li>Gold Benfit #1</li>';
<?php
add_filter( 'leaky_paywall_current_user_can_view_all_content', 'zeen101_allow_access_leaky_paywall_content_by_cap' );
function zeen101_allow_access_leaky_paywall_content_by_cap( $capability ) {
// for contributors
$capability = 'delete_posts';
// for authors
@greenhornet79
greenhornet79 / endo-handling-fee.php
Created November 25, 2015 14:05
Add percentage based fee to WooCommerce cart
<?php
add_action( 'woocommerce_cart_calculate_fees','endo_handling_fee' );
function endo_handling_fee() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$subtotal = $woocommerce->cart->subtotal;
$fee_percentage = 0.1; // 10 percent
<?php
public function create_blog_post() {
$blog_title = isset( $_POST['blog_title']) ? wp_strip_all_tags( $_POST['blog_title'] ) : '';
$blog_description = isset($_POST['blog_description']) ? strip_tags( $_POST['blog_description'] ) : '';
$tags = isset($_POST['blog_tags']) ? strip_tags( $_POST['blog_tags'] ) : '';
if ( !$blog_title || !$blog_description ) {
return;
<a class="morebtn" onclick="ga('send', 'event', { eventCategory: 'Download', eventAction: 'PDF', eventLabel: 'Brainstorming-Home-Business-Ideas-with-Traveling-Vineyard.pdf'});" target="_blank" href="http://www.travelingvineyard.com/wp-content/uploads/2014/12/Brainstorming-Home-Business-Ideas-with-Traveling-Vineyard.pdf">Download PDF</a>
<?php
add_filter( 'gform_field_value_default_quantity', 'endo_set_default_quantity' );
function endo_set_default_quantity() {
return 1; // change this number to whatever you want the default quantity to be
}
@greenhornet79
greenhornet79 / post-meta-loop.php
Created April 28, 2016 21:21
loop through keys
<?php
$details = array(
'Garage Capacity' => get_post_meta( get_the_ID(), '_listing_garage_capacity', true ),
'Garage Type' => get_post_meta( get_the_ID(), '_listing_garage_type', true ),
'Heating' => get_post_meta( get_the_ID(), '_listing_heating', true ),
'Cooling' => get_post_meta( get_the_ID(), '_listing_cooling', true ),
'Basement' => get_post_meta( get_the_ID(), '_listing_basement', true ),
'Water Frontage' => get_post_meta( get_the_ID(), '_listing_water_frontage', true ),
'Deeded Acres' => get_post_meta( get_the_ID(), '_listing_deeded_acres', true ),
<?php
function leaky_paywall_register_2checkout_gateway( $gateways ) {
$gateways['2checkout'] = array(
'label' => '2Checkout',
'admin_label' => '2Checkout Credit / Debit Card',
'class' => 'Leaky_Paywall_Payment_Gateway_2checkout'
);
return $gateways;