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 / alter-order.php
Created September 28, 2016 20:51
alter the subscription card order
<?php
/* Alter subscription card order */
add_filter( 'leaky_paywall_subscription_levels', 'zeen101_alter_subscription_card_order' );
function zeen101_alter_subscription_card_order( $levels ) {
$yearly = $levels[0];
$monthly = $levels[1];
$corporate = $levels[2];
<?php
add_filter( 'leaky_paywall_subscribe_or_login_message', 'zeen101_custom_login_message', 10, 3 );
function zeen101_custom_login_message( $new_content, $message, $content ) {
$zeen_message = '<div id="leaky_paywall_message">';
$zeen_message .= '<h2>I want to use this message instead!</h2>';
$zeen_message .= do_shortcode('[leaky_subscription_cards]'); // you can even add a shortcode or php function
$zeen_message .= '</div>';
<?php
add_filter('leaky_paywall_subscribe_or_login_message', 'zeen101_custom_subscribe_content', 10, 4 );
function zeen101_custom_subscribe_content( $new_content, $message, $content, $post_id ) {
$thumbnail = get_the_post_thumbnail();
return '<p>' . $content . '</p>' . $thumbnail . $message;
}
<?php
add_filter('comment_form_defaults', 'endo_comment_changes');
function endo_comment_changes( $defaults ) {
$current_user = wp_get_current_user();
$defaults['logged_in_as'] = '<p class="logged-in-as">' . sprintf( __( '<small>You are currently logged in as <a href="%1$s">%2$s</a> ... Is this not you? <a href="%3$s" title="Log out of this account">Log out by clicking here.</a></small>' ), admin_url( 'profile.php' ), $current_user->user_login, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>';
@greenhornet79
greenhornet79 / transient-query-caching.php
Created February 17, 2017 15:51
a basic example of using transients to cache a database query in WordPress
<?php
/**
* Caches the query for 15 minutes to a transient
* @param string $color a meta key
* @return array $posts an array of post objects
*/
function caching_query_example_function( $color ) {
$cache_key = 'color-transient-' . $color;
<?php
function endo_allow_csv_uploads( $mime_types ) {
$mime_types['csv'] = 'text/csv';
return $mime_types;
}
<?php
// leaky paywall restriction functionality for custom fields
function is_restricted_zeen101_post( $post_id ) {
if ( current_user_can( 'edit_posts' ) ) { // show content to contributors and up
return false;
}
$settings = get_leaky_paywall_settings();
<?php
// add_action( 'admin_init', 'convert_exchange_to_leaky_paywall' );
function convert_exchange_to_leaky_paywall() {
// loop through subscribers
// see if they have a transaction
// if so, get their subscription status and subscription expiratin of the transaction
// save that data as user meta for leaky paywall
<?php
add_filter( 'issuem_pdf_html', 'zeen101_edit_pdf_output', 10, 3 );
function zeen101_edit_pdf_output( $results, $term, $issue_id ) {
return strip_shortcodes( $results );
}
<?php
function ed_metabox_include_front_page( $display, $meta_box, $cmb ) {
if ( ! isset( $meta_box['show_on']['key'] ) ) {
return $display;
}
if ( 'front-page' !== $meta_box['show_on']['key'] ) {
return $display;
}