Skip to content

Instantly share code, notes, and snippets.

@mintplugins
mintplugins / JSX-Gutenberg-Blocks-without-Webpack.php
Created July 29, 2018 19:18
Build JSX Gutenberg Blocks without Webpack
<?php
function my_custom_gutenberg_block_enqueue_scripts(){
// Required thing to build Gutenberg Blocks
$required_js_files = array(
'wp-blocks',
'wp-i18n',
'wp-element',
'wp-editor'
);
@mintplugins
mintplugins / MP Stacks PostGrid with Link in custom field
Created April 27, 2016 13:34
Make your posts in your PostGrid link to any URL in a custom field you choose
@mintplugins
mintplugins / Debug to File Function
Created April 11, 2016 21:40
Write debugging text to a txt file
function pj_debug_to_txt_file( $debug_value, $filename, $append = true ){
$upload_dir = wp_upload_dir();
$filename = trailingslashit( $upload_dir['basedir'] ) . $filename . '.txt';
if ( false === $append ) {
// Blank out the log file if needed
@file_put_contents( $filename, '' );
@chmod( $filename, 0664 );
}
function pw_send_subscription_cancelled_to_admin( $sub_id, $subscription ) {
$email_to = 'your@email.com';
$subject = 'Subscription Cancelled';
$message = 'Subscription cancelled for ' . $subscription->customer->email;
EDD()->emails->send( $email_to, $subject, $message );
}
add_action( 'edd_subscription_cancelled', 'pw_send_subscription_cancelled_to_admin', 10, 2 );
function pw_send_subscription_failed_to_admin( $subscription ) {
$email_to = 'your@email.com';
@mintplugins
mintplugins / mp-stacks-custom=password-snippet.php
Created March 8, 2016 03:53
MP Stacks - Custom Password Message
function my_custom_mp_stacks_password_message(){
return 'Your Custom Message Here';
}
add_filter( 'mp_stacks_password_message', 'my_custom_mp_stacks_password_message' );
@mintplugins
mintplugins / mp-stacks-postgrid-custom-taxonomies.php
Last active February 27, 2016 20:32
Using Custom Taxonomies for Isotope Controls in MP Stacks + PostGrid:
function my_custom_postgrid_isotope_taxonomies( $isotope_filter_groups ){
//This array can contain custom groups (for outside sources like instgram), AND/OR WordPress taxonomy slugs.
$isotope_filter_groups = array(
'taxonomy1_slug' => array(
'is_wordpress_taxonomy' => true,
'filter_group_name' => __( 'Name of Taxonomy1', 'mp_stacks_postgrid' ),
'meta_field_ids_representing_tax_term' => array(), //Leave this blank if it is a WordPress taxonomy (as opposed to a "fake" one like "twitter-user")
//Icon info
'default_icon_font_string' => 'fa-th-large', //A default icon-font class string to use if no unique icon is given
@mintplugins
mintplugins / Make [edd_restrict] check for valid license.
Last active January 6, 2017 12:46
Make the [edd_restrict] shortcode check if the license is not expired in EDD Software Licensing
<?php
/**
* Check if the current user has a valid license for the $download_id passed-in.
*
* @param array ( 'download' => Download/Item ID (post_id), 'price_id' => Price ID )
* @return bool true/false
*/
function edd_sl_current_user_has_valid_license_for( $download_ids ){
// Get the current user ID
/**
* Convert buy buttons to straight-up download buttons if the download is free
*
* @since 1.0.0
* @link http://mintplugins.com/doc/
* @see function_name()
* @param array $args See link for description.
* @return void
*/
function mp_edd_free_edd_purchase_download_form( $purchase_form, $args ){
<?php
//Paste this function into your theme's functions.php file to create a duplicate ctc_sermon for each old sermon
function mp_migrate_ezekiel_sermons(){
if ( !isset( $_GET['duplicate_sermons'] ) ){
return;
}
//Set the args for the new query
$cpt_sermons = array(
@mintplugins
mintplugins / MP Stacks Isotopes Trigger Filter on Load
Created November 18, 2015 17:30
With MP Stacks Isotopes, trigger a a filter button being clicked once the page has loaded.
$( '.mp-stacks-grid-isotope' ).imagesLoaded( function( instance ){
$( '[data-filter="[mp_stacks_grid_isotope_taxonomy_category*=\'YOUR_FILTER_SLUG_HERE,\']"' ).trigger( 'click' );
});