Skip to content

Instantly share code, notes, and snippets.

View labsecrets's full-sized avatar

LabSecrets labsecrets

View GitHub Profile
<?php
// Divi Builder on custom post types by https://wpcolt.com
add_filter('et_builder_post_types', 'divicolt_post_types');
add_filter('et_fb_post_types','divicolt_post_types' ); // Enable Divi Visual Builder on the custom post types
function divicolt_post_types($post_types)
{
foreach (get_post_types() as $post_type) {
if (!in_array($post_type, $post_types) and post_type_supports($post_type, 'editor')) {
$post_types[] = $post_type;
}
<?php
/**
* Only allow one payment plan purchase (Subscription) at a time
*/
add_filter( 'woocommerce_add_to_cart_validation', 'woo_block_sub', 10, 2 );
function woo_block_sub( $valid, $product_id ) {
// Get the current product
$current_product = wc_get_product( $product_id );
@srikat
srikat / functions.php
Last active April 16, 2019 14:06
How to add Google Tag Manager code in Genesis. https://sridharkatakam.com/add-google-tag-manager-code-genesis/
// Add Google Tag Manager code in <head>
add_action( 'wp_head', 'sk_google_tag_manager1' );
function sk_google_tag_manager1() { ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
@JeroenSormani
JeroenSormani / woocommerce-store-wide-disable-sales.php
Last active April 10, 2024 12:45
WC disable sale on all products.
<?php
/**
* Disable all sales.
*
* A simple function to disable all the sales in the shop.
* Uncomment the line of code to disable the sale price on products.
*/
function custom_wc_get_sale_price( $sale_price, $product ) {
/**
* All downloads require visitors to be logged in
*
* @param $can_download
* @param $download
*
* @return bool
*/
function dlm_all_downloads_members_only( $can_download, $download ) {
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Custom Prorating Code and Other Code for PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@strangerstudios
strangerstudios / my_pmpro_profile_start_date.php
Created October 23, 2014 20:43
Some code for PMPro to handle cases where users will be checking out for the same level but might be switching from recurring to non or vice versa.
/*
If checking out for a recurring membership for the level the user already has,
set the profile start date to their old end date or the date of their next payment.
*/
function my_pmpro_profile_start_date($startdate, $order) {
//does the user already have this level?
if(is_user_logged_in() && pmpro_hasMembershipLevel($order->membership_id)) {
global $current_user;
@strangerstudios
strangerstudios / my_pmpro_check_discount_code.php
Last active April 13, 2021 18:32
PMPro discount codes can only be used by the same user once.
/*
Discount codes can only be used by the same user once.
Add this to your active theme's functions.php or a custom plugin.
Update the $one_time_use_codes array on line 10.
*/
//check if codes have been used already
function my_pmpro_check_discount_code($okay, $dbcode, $level_id, $code)
{
//define one time use codes
$one_time_use_codes = array('ONCE'); //make them all uppercase
@dancameron
dancameron / functions.php
Created September 8, 2014 22:25
EDD Recurring Payments & Discounts
<?php
function modify_edd_cart_contents( $cart ) {
$discounts = edd_get_cart_discounts();
if ( !$discounts ) {
return $cart;
}
$dcodes = array( 'YOUDONTHINKIKNOW', 'WHATYOURETRYINGTODO?', 'NICETRY!!' );
// Filter only the discount code above
if ( !array_intersect( $discounts, $dcodes ) ) {
@gmaggio
gmaggio / wp-admin-pages-orderby-menuorder.php
Created August 10, 2014 01:48
[Wordpress] Set the MENU ORDER as the default sorting order for PAGES in ADMIN. Source: http://wordpress.org/support/topic/sort-pages-by-date-in-admin-by-default?replies=4#post-5380257
<?php
/**
* Order Admin Pages by Menu Order by Default
*
* Source:
* http://wordpress.org/support/topic/sort-pages-by-date-in-admin-by-default?replies=4#post-5380257
*
*/
add_filter('pre_get_posts', 'my_set_post_order_in_admin' );