Skip to content

Instantly share code, notes, and snippets.

View renventura's full-sized avatar

Ren Ventura renventura

View GitHub Profile
@renventura
renventura / remove-parent-link-from-submenu.php
Created April 3, 2020 14:22
This removes a parent menu link from its submenu in the WordPress admin.
@renventura
renventura / mepr-pre-run-rule-content.php
Created March 6, 2020 20:26
Runs some checks on the post before applying the MemberPress rule. This allows for excluding posts from a rule based on any custom criteria.
<?php
add_filter( 'mepr-pre-run-rule-content', 'cp_maybe_show_content_last_chance', 10, 2 );
/**
* Runs some checks on the post before applying the MemberPress rule.
* This allows for excluding posts from a rule based on any custom criteria.
*
* @param boolean $apply Whether to apply the rule
* @param object $post Post object
*
@renventura
renventura / wp-post-states.php
Created February 13, 2020 01:39
Displays post states (in the admin list table, next to the title)
<?php
add_filter( 'display_post_states', 'rv_add_post_states', 10, 2 );
/**
* Displays post states (in the admin list table, next to the title)
*
* @param array $states Post display states
* @param object $post Current post
*
* @return array
@renventura
renventura / stop-recording-memberpress-login.php
Created February 7, 2020 22:04
Stop recording MemberPress login events
<?php
add_action( 'mepr-event-store', 'stop_recording_mp_logins' );
/**
* Stop recording login events
*
* @param object $event Mepr_Event
*
* @return void
*/
@renventura
renventura / shortcode-mp-membership-price.php
Created January 29, 2020 17:15
Displays a MemberPress product's price or price terms.
<?php
add_shortcode( 'mp_membership_price', 'mp_memberpress_price_shortcode' );
/**
* Displays a membership's price.
*
* Use:
* [mp_membership_price id="{membership_id}" display={price|terms}]
* id - ID of membership product
* display - What to display
@renventura
renventura / edd-switch-to-link.php
Created January 28, 2020 23:11
Adds a "Switch To" link to EDD Customer Details page --> Profile tab.
@renventura
renventura / memberpress-custom-field-dynamic-tag.php
Created December 26, 2019 15:00
Creates a dynamic tag for using in MemberPress custom fields.
<?php
add_filter( 'mepr_fetch_options', 'mp_filter_custom_fields' );
/**
* Filter the MemberPress options to set a dynamic value for custom fields.
*
* @param object $options MeprOptions
*
* @return object MeprOptions
*/
<?php
add_shortcode( 'optin_download', 'formsync_optin_download_shortcode' );
/**
* Checks if a given email is registered/subscribed to a MailChimp list/audience
*/
function formsync_optin_download_shortcode( $atts ) {
// Bail if email is not set as a query param
if ( ! isset( $_GET['email'] ) ) {
@renventura
renventura / ebook-cpt.php
Created September 25, 2019 02:26
Snippets for the Gravity Forms purchase form tutorial on wpformsync.com
<?php
add_action( 'init', 'formsync_register_ebooks_cpt' );
/**
* Registers an "E-Books" custom post type
*/
function formsync_register_ebooks_cpt() {
$labels = array(
'name' => 'eBooks',
@renventura
renventura / wp-svn-cheat-sheet
Created September 14, 2019 00:43
Cheat sheet of SVN commands to update plugin in the WordPress plugin repository
svn co https://plugins.svn.wordpress.org/{plugin-slug}
cd {plugin-slug}/trunk
# Make changes
cp -r trunk tags/{new_version}
svn add trunk/*
svn add tags/*
# {username} should be actual wp.org username, not email
# {password} should be actual wp.org password
svn ci -m "Message here" --username {username} --password {password}