Skip to content

Instantly share code, notes, and snippets.

View INDIAN2020's full-sized avatar

Gogula Sivannarayana INDIAN2020

View GitHub Profile
@INDIAN2020
INDIAN2020 / functions.php
Created June 18, 2018 06:11 — forked from yanknudtskov/functions.php
Remove Heading from the WordPress Editor #tinymce #removeheadings
<?php
/**
* Remove the h4 to h6 tag from the WordPress editor.
*
* @param array $settings The array of editor settings
* @return array The modified edit settings
*/
function remove_headings_from_editor( $settings ) {
// Default as example
// $settings['block_formats'] = 'Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre;';
@INDIAN2020
INDIAN2020 / functions.php
Created June 18, 2018 06:11 — forked from yanknudtskov/functions.php
Clear the #woocommerce #cart with a query string parameter
<?php
/*
* If you add ?clear-cart to the URL the cart will be emptied
*/
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
if ( isset( $_GET['clear-cart'] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
@INDIAN2020
INDIAN2020 / functions.php
Created June 18, 2018 06:11 — forked from yanknudtskov/functions.php
Unpublish a product in #woocommerce when it's sold out
<?php
/*
* Unpublish products after purchase
*/
add_action( 'woocommerce_thankyou', 'yanco_unpublish_product_if_sold_out', 10, 1 );
function yanco_unpublish_product_if_sold_out( $order_id ) {
$order = new WC_Order( $order_id );
$all_products = $order->get_items();
@INDIAN2020
INDIAN2020 / cvr-payment-gateway-handling-fee.php
Created June 18, 2018 06:11 — forked from yanknudtskov/cvr-payment-gateway-handling-fee.php
Add a handling fee for CVR Payment Gateway
<?php
if ( class_exists( 'WooCommerce' ) ) {
add_action( 'woocommerce_cart_calculate_fees', 'yanco_cvr_calculate_totals' );
function yanco_cvr_calculate_totals( ) {
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
$current_gateway = '';
$fee_title = __('CVR Handling Fee', 'woocommerce-cvr-payment-gateway'); // Change the title to fit your needs
$cvr_handling_fee = 50; // Change the value to the amount you want to charge
$fee_tax_class = 'zero rate'; // Change this to the tax class you wish to use for the fee
@INDIAN2020
INDIAN2020 / admin-column-user-registered-date.php
Created June 18, 2018 06:10 — forked from yanknudtskov/admin-column-user-registered-date.php
Add a column to the Users overview in WordPress Admin to display the registration date
<?php
/*
* Create a column. And maybe remove some of the default ones
* @param array $columns Array of all user table columns {column ID} => {column Name}
*/
add_filter( 'manage_users_columns', 'yanco_modify_user_table' );
function yanco_modify_user_table( $columns ) {
// unset( $columns['posts'] ); // maybe you would like to remove default columns
$columns['registration_date'] = 'Registreret'; // add new
@INDIAN2020
INDIAN2020 / functions.php
Created June 18, 2018 06:09 — forked from yanknudtskov/functions.php
How to disable all WooCommerce Scripts and Styles except for shop and product pages. NOTE: Be VERY careful with this and test properly as it may clash with other plugins #woocommerce #optimization
<?php
/*
* Disable All WooCommerce Styles and Scripts Except Shop Pages
* NOTE: Be VERY careful with this and test properly as it may clash with other plugins
*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_styles_scripts', 99 );
function dequeue_woocommerce_styles_scripts() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
@INDIAN2020
INDIAN2020 / countries.sql
Created July 19, 2017 12:34 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@INDIAN2020
INDIAN2020 / list-comment-filters.php
Created July 11, 2017 12:53 — forked from thefuxia/list-comment-filters.php
WordPress Plugin: List Comment Filters
<?php
/*
Plugin Name: List Comment Filters
Description: List all comment filters on wp_footer
Version: 1.1
Author: Thomas Scholz
Author URI: http://toscho.de
License: GPL v2
*/
@INDIAN2020
INDIAN2020 / nice-labels.php
Created May 3, 2017 06:43 — forked from Rarst/nice-labels.php
"Nice numbers" implementation for pretty range of numerical labels on graph
<?php
// @link http://books.google.com/books?id=fvA7zLEFWZgC&pg=PA61&lpg=PA61#v=onepage&q&f=false
function nice_labels( $min, $max, $ticks = 5 ) {
$range = nice_number( $max, false );
$d = nice_number( $range / ( $ticks - 1 ) );
$graphmin = floor( $min / $d ) * $d;
$graphmax = ceil( $max / $d ) * $d;
$nfrac = max( array( - floor( log( $d, 10 ) ), 0 ) );
@INDIAN2020
INDIAN2020 / WordPress.xml
Created May 3, 2017 06:39 — forked from Rarst/WordPress.xml
WordPress Live Templates for PhpStorm
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="WordPress">
<template name="aa" value="add_action( '$hook$', '$callback$' );&#10;$END$" description="add_action" toReformat="false" toShortenFQNames="true">
<variable name="hook" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="callback" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="HTML_TEXT" value="false" />
<option name="HTML" value="false" />
<option name="XSL_TEXT" value="false" />
<option name="XML" value="false" />