Skip to content

Instantly share code, notes, and snippets.

@bentasm1
bentasm1 / product-edit.php
Created January 6, 2016 02:07 — forked from digitalchild/product-edit.php
WC Vendors Pro Form Input Type Examples
<?php
/**
* Example text input with validation
*/
WCVendors_Pro_Form_Helper::input(
array(
'post_id' => $object_id,
'id' => '_wcv_custom_product_example_text_input',
'label' => __( 'Product Meta Text Input', 'wcvendors-pro' ),
@tripflex
tripflex / functions.php
Last active March 19, 2025 11:59
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@bekarice
bekarice / wc-prevent-checkout-for-cart-with-specific-category.php
Last active June 29, 2023 20:32
Prevents checkout if the WooCommerce cart only contains items from a specific category
<?php // only copy this line if needed
/**
* Renders a notice and prevents checkout if the cart
* only contains products in a specific category
*/
function sv_wc_prevent_checkout_for_category() {
// set the slug of the category for which we disallow checkout
$category = 'clothing';
@fervous
fervous / functions.php
Last active January 6, 2018 10:34
wc vendors pro add new field for product form custom field add edit product
/* child theme functions.php */
add_action( 'wcv_after_product_details', 'wcv_custom_product_condition_field' );
function wcv_custom_product_condition_field () {
WCVendors_Pro_Form_Helper::input( array(
'type' => 'text',
'post_id' => $object_id,
'id' => 'wcv_custom_product_condition',
'label' => __( 'Product Condition', 'wcvendors-pro' ),
'placeholder' => __( 'Please specify if your product is NEW or USED', 'wcvendors-pro' ),
'desc_tip' => 'true',
@hirejordansmith
hirejordansmith / add-coupon-dynamically-based-on-cart-subtotal-woocommerce.php
Last active December 10, 2019 21:07
Add A Coupon Dynamically based on Cart Subtotal with WooCommerce
<?php
/**
* @snippet Add A Coupon Dynamically based on Cart Subtotal with WooCommerce
* @sourcecode http://hirejordansmith.com
* @author Jordan Smith
* @compatible WooCommerce 2.4.7
*/
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' );
class WC_Custom_My_Account_Tabs extends WC_Query {
/**
* Adds main filters and actions and inits the endpoints.
*/
public function __construct() {
add_action( 'init', array( $this, 'add_endpoints' ) );
if ( ! is_admin() ) {
add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
add_filter( 'woocommerce_account_menu_items', array( $this, 'edit_navigation' ) );
/* Add Image Stretch Option Control to the Image Gallery Widget */
add_action( 'elementor/element/before_section_end', function( $element, $section_id, $args ) {
/** @var \Elementor\Element_Base $element */
if ( 'image-gallery' === $element->get_name() && 'section_gallery' === $section_id ) {
$element->add_control(
'image_stretch',
[
'label' => __( 'Image Stretch', 'elementor' ),
'type' => \Elementor\Controls_Manager::SELECT,
@robwent
robwent / disqus-ondemand.html
Last active April 5, 2025 08:08
Loads Disqus comments on click with native JavaScript. Opens comments when linked to directly.
<div class="comments-block">
<button id="show-comments" onclick="disqus();return false;">Load Comments</button>
</div>
<div id="disqus_thread"></div>
<script>
var disqus_loaded = false;
var disqus_shortname = 'xxxx'; //Add your shortname here
@saltnpixels
saltnpixels / gform_stripe_subscriptions.php
Created October 10, 2017 15:25
Gravity forms stripe cancel from front end
<?php
/**
* Payment subscriptions and updating billing and cancelling subscriptions takes place with these hooks
* We need the stripe customer user id for updating billing
* we need the entry id of subscription so we can cancel it.
*/
/**
* @param $entry
@YakovL
YakovL / creat_zip_download.php
Last active September 12, 2021 14:29 — forked from somatonic/creat_zip_download.php
create a zip file and send to browser
<?php
// this file is supposed to be in UTF-8 without BOM
function isRunningOnWindows() {
$os = php_uname('s'); //PHP_OS see https://stackoverflow.com/q/1482260/3995261
return preg_match('#win#i',$os) ? true : false;
}
function fixFilenameEncoding($name) {
// seemingly is needed on Windows only because filename encoding is not utf-8
return isRunningOnWindows() ? mb_convert_encoding($name, "windows-1251", "utf-8") : $name;
}