Skip to content

Instantly share code, notes, and snippets.

View PluginRepublicSupport's full-sized avatar

PluginRepublicSupport

View GitHub Profile
@PluginRepublicSupport
PluginRepublicSupport / open_all_accordions.php
Created February 13, 2023 13:12
Set accordion layout to Open
<?php
/**
* Set all groups to open (or closed ) in an accordion
*/
function prefix_filter_initial_accordion_states( $state, $post_id ) {
// return 'closed'; // Uncomment this out and comment the line below to set all groups to closed
return 'open';
}
add_filter( 'pewc_filter_initial_accordion_states', 'prefix_filter_initial_accordion_states', 10, 2 );
@PluginRepublicSupport
PluginRepublicSupport / pewc_polylang.php
Created March 8, 2023 06:48
For compatibility between Product Add-Ons Ultimate and Polylang
<?php
/**
* Duplicates groups and fields for translated products. Original product should have duplicated groups and fields by this time.
*/
function pewc_product_duplicate_polylang( $duplicate, $product ) {
// check that this function exists
if ( function_exists( 'pll_get_post_translations' ) ) {
$new_id = $duplicate->get_id();
$old_id = $product->get_id();
$new_trs = pll_get_post_translations( $new_id );
@PluginRepublicSupport
PluginRepublicSupport / wcdpp_tutorlms.php
Last active September 4, 2023 08:56
Some compatibility functions between Deposits and Part Payments and Tutor LMS
<?php
/**
* This function updates a 'tutor_enrolled' post type after it is created by a scheduled order. Changing the status prevents them from being counted towards totals.
*/
function wcdpp_tutor_after_enrolled( $course_id, $user_id, $enrolled_id ) {
// get the order_id attached to this tutor_enrolled record
$order_id = get_post_meta( $enrolled_id, '_tutor_enrolled_by_order_id', true );
if ( $order_id ) {
// check if order is a scheduled order
@PluginRepublicSupport
PluginRepublicSupport / wcrp_rental_products.php
Last active March 13, 2023 12:13
Add-ons on Rental Product Type
<?php
add_filter( 'pewc_filter_product_extra_groups', function( $product_extra_groups, $post_id) {
if ( is_cart() || is_checkout() ) {
return $product_extra_groups;
}
if( ! is_object( wc_get_product( $post_id ) ) ) {
return $product_extra_groups;
}
@PluginRepublicSupport
PluginRepublicSupport / group_title_html.php
Created March 15, 2023 15:33
Change Group Title HTML Element
<?php
function my_group_filter_title( $group_title, $group, $group_id ) {
$group_title = pewc_get_group_title( $group_id, $group, true );
return '<h2>' . $group_title . '</h2>';
}
add_filter( 'pewc_filter_group_title', 'my_group_filter_title', 10, 3 );
@PluginRepublicSupport
PluginRepublicSupport / text_custom_fonts.php
Created March 20, 2023 15:15
Text Preview Custom Fonts
<?php
/**
* Register a custom font with Text Preview
*/
function prefix_register_custom_font( $fonts ) {
$fonts['font-1'] = 'Brush Script';
$fonts['font-2'] = 'Arial';
$fonts['font-3'] = 'Mermaid';
$fonts['font-4'] = 'Angelina';
@PluginRepublicSupport
PluginRepublicSupport / center_addon_fields.css
Created March 22, 2023 12:36
Center Radio Groups + Image Swatch
/** Center image wrappers **/
.pewc-preset-style .pewc-radio-images-wrapper, .pewc-preset-style .pewc-checkboxes-images-wrapper{
-webkit-justify-content: flex-start;
justify-content: flex-start;
margin: 0 -5px;
}
.pewc-preset-style .pewc-radio-image-wrapper, .pewc-preset-style .pewc-checkbox-image-wrapper {
margin: 0 5px;
}
@PluginRepublicSupport
PluginRepublicSupport / min_max_checks.php
Last active April 10, 2023 15:37
Min & Max Check for Checkgroup
<?php
/** Min selection check **/
function min_checks( $notice, $label, $field_minchecks ) {
$notice = sprintf(
__( '%s requires MIN at least %s items to be selected', 'pewc' ),
esc_html( $label ),
$field_minchecks
);
@PluginRepublicSupport
PluginRepublicSupport / custom_number_step.php
Created April 24, 2023 13:53
Name your price custom number step
<?php
/**
* Filter the step parameter in Name Your Price field
*/
function prefix_number_field_step( $step, $item ) {
return 5;
}
add_filter( 'pewc_name_your_price_step', 'prefix_number_field_step', 10, 2 );
@PluginRepublicSupport
PluginRepublicSupport / quantity_change_price.php
Created April 28, 2023 14:41
Increase/Decrease Price Quantity Change
add_action('wp_footer', function() {
?>
<script>
jQuery(document).ready(function($) {
setTimeout(function() {
$('.pewc-has-extra-fields form.cart button.minus, .pewc-has-extra-fields form.cart button.plus').click(function(e) {
$(this).parent().find('.quantity input.qty').trigger('change');
});
}, 1000);