Skip to content

Instantly share code, notes, and snippets.

View pramodjodhani's full-sized avatar
🏠
Working from home

Pramod Jodhani pramodjodhani

🏠
Working from home
  • 00:34 (UTC +05:30)
View GitHub Profile
@pramodjodhani
pramodjodhani / functions.php
Created April 13, 2015 09:29
ACF Pro - add options page
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Zip Codes',
'menu_title' => 'Zip Codes',
'menu_slug' => 'zip-codes',
'capability' => 'manage_options',
'redirect' => false
));
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
@pramodjodhani
pramodjodhani / regex_list_functions.php
Created February 13, 2020 18:03
List all the functions in current directory
<?php
$functions = [];
foreach( glob("./{,*/,*/*/,*/*/*/}*.php" , GLOB_BRACE ) as $file ) {
$matches = [];
$content = file_get_contents( $file );
preg_match_all( "/function\s(.*)\(/", $content, $matches );
<?php
/**
* Disable WooThumbs to prevent duplicate gallery.
*
* @return void
*/
function iconic_disable_woothumbs() {
global $iconic_woothumbs_class;
remove_action( 'woocommerce_before_single_product_summary', array( $iconic_woothumbs_class, 'show_product_images' ), 20 );
@pramodjodhani
pramodjodhani / functions.php
Last active January 26, 2022 07:17
WooCommerce: User parent product's description if child product's description is empty
<?php
/**
* Iconic SSV: use parent's description if child product's description is empty.
*
* @param string $description
* @param object $product
*
* @return string
*/
function iconic_ssv_modify_variation_description( $description, $product ) {
@pramodjodhani
pramodjodhani / functions.php
Created February 9, 2022 06:12
Iconic Delivery slots: Don't delete timeslot data from the order when it is cancelled.
<?php
/**
* Iconic Delivery slots: Dont delete timeslot data from the order when it is cancelled.
*
* @return void
*/
function iconic_wds_dont_delete_timeslot_data_when_order_is_cancelled() {
remove_action( 'woocommerce_order_status_changed', array( 'Iconic_WDS_Order', 'status_changed' ), 10 );
@pramodjodhani
pramodjodhani / phpcs.cmd
Last active March 3, 2022 13:22
Command similar to the one used by WooCommerce.com
phpcs account-pages --standard=WooCommerce-Core --ignore=node_modules,vendor --report-source --warning-severity=0 --ignore-annotations --report-full --colors --extensions=php,html
<?php
/*
Get all translations from one of the translations. Doesn't necesaily have to be the master post.
Here 93 is a translated post (not duplicated)
Considering that 93 is a product.
*/
@pramodjodhani
pramodjodhani / iconic-linked-variations-force-display-attribute-in-cart.php
Last active April 8, 2022 10:37
Iconic Linked Variations - display non-variation attributes to cart.
<?php
/**
* Iconic Linked Variations - Force display non LV attributes in cart.
*
* @param array $item_data
* @param array $cart_item
*
* @return array
*/
function iconic_display_non_lv_attributes_in_cart( $item_data, $cart_item ) {