Skip to content

Instantly share code, notes, and snippets.

View santanup789's full-sized avatar

Santanu Patra santanup789

  • Webskitters
  • India
View GitHub Profile
@danielcharrua
danielcharrua / gravity_forms_date_conditional.js
Created January 6, 2021 18:06
Add conditional fields depending on a date field
<script>
gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
if ( fieldId == 13 ) {
valorCampoDate = elem.value;
var parts = valorCampoDate.split( '/' );
// Presta atención al mes ( parts[1] ); JavaScript cuenta los meses desde 0:
// Enero - 0, Febrero - 1, etc.
var myDate = new Date( parts[2], parts[1] - 1, parts[0] );
// Cambiar el valor del campo oculto.
@ccurtin
ccurtin / woocommerce-search-products-by-category-dropdown.php
Created December 11, 2017 17:42
WooCommerce Search Products by Category Dropdown
<form name="myform" method="GET" action="<?php echo esc_url(home_url('/'));?>">
<?php if (class_exists('WooCommerce')): ?>
<?php
if (isset($_REQUEST['product_cat']) && !empty($_REQUEST['product_cat'])) {
$optsetlect = $_REQUEST['product_cat'];
} else {
$optsetlect = 0;
}
$args = array(
@lukecav
lukecav / functions.php
Last active April 3, 2024 23:20
Logout of WordPress without confirmation message
function getLogoutUrl($redirectUrl = ''){
if(!$redirectUrl) $redirectUrl = site_url();
$return = str_replace("&amp;", '&', wp_logout_url($redirectUrl));
return $return;
}
/**
* Bypass logout confirmation on nonce verification failure
*/
function logout_without_confirmation($action, $result){
@phillipwilhelm
phillipwilhelm / gist:048191a6411f9093d8f4879d9e991def
Created September 4, 2017 17:57
Gravity Forms - API Email Validation for FIELD
// Email validation by third-party API
// The following example shows how you can send the value of an Email type field to a third-party API to determine if the email is valid. In this example we are using the QuickEmailVerification API.
add_filter( 'gform_field_validation', function ( $result, $value, $form, $field ) {
if ( $field->get_input_type() === 'email' && $result['is_valid'] ) {
$request_url = add_query_arg(
array(
'email' => $value,
'apikey' => 'your_api_key_here',
@mariovalney
mariovalney / woo-enable-reviews-bulk-edit.php
Created August 7, 2017 19:55
WooCommerce Enable Reviews - Bulk Edit
<?php
/**
*
* Plugin Name: WooCommerce Enable Reviews - Bulk Edit
* Description: Allow enable reviews by bulk edit into WooCommerce
* Version: 1.0.0
* Author: Mário Valney
* Author URI: http://mariovalney.com
* Text Domain: woo-enable-reviews-bulk-edit
*
@deardorffdev
deardorffdev / wordpress-functions.php
Last active November 3, 2022 19:55
Useful Wordpress Functions 1
<!-- What is Functions File in WordPress? -->
<!-- Functions file commonly known as functions.php file is a WordPress theme file.
It comes with all free and premium WordPress themes.
The purpose of this file is to allow theme developers to define theme features and functions. This file acts just like a WordPress plugin and can be used to add your own custom code snippets in WordPress.
You would find many of these code snippets on websites like https://deardorffassociatesweb.wordpress.com/ with instructions telling you to add this code in your theme’s functions.php file or a site-specific WordPress plugin.
Now you may be thinking what’s the difference between a site-specific WordPress plugin and functions.php file? Which one is better?
@hachesilva
hachesilva / functions.php
Created March 14, 2017 18:19 — forked from corsonr/functions.php
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
@Niloys7
Niloys7 / gist:17b88d36c1c38844a6cf2127c15dee63
Created February 24, 2017 01:17
Get Product Gallery Images - WooCommerce
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id )
{
//Get URL of Gallery Images - default wordpress image sizes
echo $Original_image_url = wp_get_attachment_url( $attachment_id );
echo $full_url = wp_get_attachment_image_src( $attachment_id, 'full' )[0];
echo $medium_url = wp_get_attachment_image_src( $attachment_id, 'medium' )[0];
@mahdi-alavi
mahdi-alavi / gist:9d7752572fed9cedc8b10c6876d1e86a
Last active July 24, 2022 19:12
replace WooCommerce add-to-cart button with download link when product is downloadable & free
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'itl_woocommerce_template_single_add_to_cart', 30 );
/*
* replace WooCommerce add-to-cart button with download link when product is downloadable & free
*/
function itl_woocommerce_template_single_add_to_cart() {
global $product;
if ( $product->is_downloadable('yes') ) {
@yanknudtskov
yanknudtskov / gravityforms-auto-trigger-next-previous.js
Last active October 7, 2021 20:03
jQuery example to trigger next/previous buttons on GravityForms #gravity-forms
// This is the initial GravityForms binding, it will be lost upon a page change with next/previous
// Thus we make a bind on gform_page_loaded event also
if( jQuery('.custom-form').length > 0 ) {
jQuery('.gfield_radio input[type=radio]').bind("click", function() {
//console.log('Clicked: ' + jQuery( this ).closest('.gform_page').find('.gform_page_footer .gform_next_button.button') );
jQuery(this).closest('.gform_page').find('.gform_page_footer .gform_next_button.button').click();
});
}
jQuery(document).bind('gform_page_loaded', function(event, form_id, current_page){