Skip to content

Instantly share code, notes, and snippets.

Avatar

Mirco Babini mircobabini

View GitHub Profile
View pmpro_block_dashboard-grant-certain-user-roles.php
<?php
/**
* Grant access to the back-end to certain user roles
*
* @param bool $prevent_admin_access
*
* @return bool
*/
function pmpro_grant_admin_access_to_dataanalyst( $prevent_admin_access ) {
if ( current_user_can( 'dataanalyst' ) ) {
@mircobabini
mircobabini / variation-duplicator-for-woocommerce-disable-image-duplicator.php
Last active Jun 14, 2022
UPDATE: useless from 2.0.4+ thanks to the new filter disable_variation_duplicator_for_woocommerce_image_clone
View variation-duplicator-for-woocommerce-disable-image-duplicator.php
<?php
/**
* Plugin Name: Duplicate Variations for WooCommerce (Disable Image Duplicator)
* Description: Disattiva la funzionalità di "image duplicator" che rallenta il loading delle variazioni
* Author: Mirco Babini
* Domain Path: /languages
* Version: 2.0.3
* Author URI: https://sedweb.com/
*/
add_action( 'variation_duplicator_for_woocommerce_variation_image_clone_loaded', function ( $instance ) {
@mircobabini
mircobabini / my-pmpro-reset-cron-schedules.php
Last active Mar 11, 2022 — forked from sc0ttkclark/my-pmpro-reset-cron-schedules.php
Reset the Cron Schedules for Paid Memberships Pro. The single-use version can be found at: https://gist.github.com/sc0ttkclark/bd319a47656b786ccee3eca6f2dc4a9a
View my-pmpro-reset-cron-schedules.php
<?php
/**
* Reset the Cron Schedules for Paid Memberships Pro.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
View pmpro-show-discount-code-effects.php
<?php
/**
* Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order.
* Add this code recipe to a PMPro Customization Plugin - Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order
* Various classes added to strings to allow for styling - ".pmpro-discorig-message", ".pmpro-orginal-price", ".pmpro-discount-price", ".pmpro-save-price"
*
* [my_pmpro_applydiscountcode_return_js] Display original price and discount when a discount code is applied.
*
* @param string $discount_code [description]
@mircobabini
mircobabini / pmpro-conpd-avoid-complete-cancellation.php
Last active Jul 21, 2022
PMPro snippet to disable the "Cancel" button when the auto-renew option is turned off.
View pmpro-conpd-avoid-complete-cancellation.php
<?php
/**
* Remove "Cancel" button for cancelled subscriptions.
*
* The user is still able to cancel auto-renew, but can't completely cancel the membership.
*/
add_filter( 'pmpro_member_action_links', function ( $pmpro_member_action_links ) {
global $current_user;
// bail if cancel link has been removed by someone else
@mircobabini
mircobabini / mainwp-add-child-info.php
Last active Jan 19, 2022 — forked from ragoand/mainwp-add-child-info
Add MainWP Child info and save
View mainwp-add-child-info.php
<?php
/**
* Code for MAINWP DASH
* Save information to the table {table_prefix}_mainwp_wp_options once the site is successfully synced
*
* @param mixed $pWebsite
* @param array $information
*
* @return void
@mircobabini
mircobabini / my_pmpro_forward_ipn.php
Last active Oct 5, 2021 — forked from andrewlimaza/my_pmpro_forward_ipn.php
Forward PMPro PayPal IPNs to another domain
View my_pmpro_forward_ipn.php
<?php
/**
* Forward PMPro PayPal IPNs to another domain.
* Each domain will process the IPNs. The IPN handlers should be setup to ignore
* messages that aren't for that site. PMPro does this.
* This is useful if you have 2 different sites using the same PayPal account
* and the IPN is setup to go to a PMPro site.
* Add this to a custom plugin on the PMPro site the IPN hits.
* Update the domain/url to the IPN you want to forward to.
* The pmprodev_gateway_debug_setup check makes sure this DOESN'T run if you have the
@mircobabini
mircobabini / wp_dynsync.php
Last active May 17, 2021
BlogVault Real-Time Backups - add support for Paid Memberships Pro support (PMPro) => https://blogvault.freshdesk.com/support/tickets/46004
View wp_dynsync.php
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVWPDynSync')) :
class BVWPDynSync {
public static $dynsync_table = 'dynamic_sync';
public $db;
public $settings;
View pmpro-force-user-create-on-checkout-subscription-failure.php
<?php
/**
* PayPal Express only:
* Force pmpro_confirmed to be true in preheaders/checkout
* this way the user will be always created, even if the
* first payment was unsuccessful
*/
add_action( 'pmpro_checkout_confirmed', function ( $pmpro_confirmed, $morder ) {
if ( ! empty( $morder ) && ! empty( $morder->gateway ) && 'paypalexpress' === $morder->gateway ) {
View wp_list_pluck.function.php
<?php
/**
* Pluck a certain field out of each object in a list.
*
* This has the same functionality and prototype of
* array_column() (PHP 5.5) but also supports objects.
*
* @param array $list List of objects or arrays
* @param int|string $field Field from the object to place instead of the entire object
* @param int|string $index_key Optional. Field from the object to use as keys for the new array.