Skip to content

Instantly share code, notes, and snippets.

Avatar

Vajrasar Goswami vajrasar

View GitHub Profile
View add_gift_to_cart.php
<?php
/*
* Automatically adding the product to the cart when cart total amount reach to $500.
*/
function aapc_add_product_to_cart() {
global $woocommerce;
$cart_total = 500;
@vajrasar
vajrasar / custom-hud-vajra.css
Created Jan 31, 2020
This is a custom HUD css that was created as a replacement of the Dark Theme mod available for the HUD. The reason - Dark Theme Mod is not fully compatible with most of the scripts which are written to enhance HUD.
View custom-hud-vajra.css
::-webkit-scrollbar-thumb {
background: none;
}
/* left panel back color */
.chat__chat-queue {
background-color: #002b36;
color: #eee8d5;
}
@vajrasar
vajrasar / functions.php
Created Mar 6, 2018
+ Remove Default Color Menu from Theme Customizer. + Add a Primary Site Color element in Site Identity menu of the Theme Customizer. + Apply Color based on selection on the Primary Site Color option from the customizer
View functions.php
<?php
//Add Primary Color option in Site Identity and Remove default Colors menu
function your_theme_new_primary_color_settings($wp_customize) {
$wp_customize->remove_section( 'colors');
$wp_customize->add_setting('your_color');
$wp_customize->add_control(
@vajrasar
vajrasar / snippet.css
Last active Sep 20, 2017
To have image over gradient along with all browser support
View snippet.css
/* In this particular instance client wanted to have gradient all over the background and a PNG
* image sitting at the bottom of the container
* /
.selector {
background-image: url(/path-to-image.png), -webkit-gradient(linear, left top, left bottom, from(rgba(74,177,253,1)), to(rgba(74,177,253,0.3))); /* For Safari 5.1 to 6.0 */
background-image: url(/path-to-image.png), -o-gradient(linear, left top, left bottom, from(rgba(74,177,253,1)), to(rgba(74,177,253,0.3))); /* For Opera 11.1 to 12.0 */
background-image: url(/path-to-image.png), -moz-gradient(linear, left top, left bottom, from(rgba(74,177,253,1)), to(rgba(74,177,253,0.3))); /* For Firefox 3.6 to 15 */
background-image: url(/path-to-image.png), linear-gradient(linear, left top, left bottom, from(rgba(74,177,253,1)), to(rgba(74,177,253,0.3))); /* Standard syntax (must be last) */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="rgba(74,177,253,1)",endColorstr="rgba(74,177,253,0.3)",GradientType=0), progid:DXImageTransform.Microsoft.Alp
@vajrasar
vajrasar / enqueue-version.php
Created Sep 15, 2017
Add dynamically updating version on file
View enqueue-version.php
<?php
/* Whenever the theme style file will update on server, this file version
* will automatically update
* Ref - https://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-2056
*/
wp_enqueue_style('main-styles',
get_template_directory_uri() . '/css/style.css',
array(),
View AdminStyleSheet.php
<?php
// To add admin style
function load_admin_style() {
wp_enqueue_style( 'admin_css', get_template_directory_uri() . '/css/admin-style.css', false, '1.0.0' );
}
View googleform.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- Google analytic code will also be placed here -->
</head>
<body>
<iframe id="yoi" src="https://docs.google.com/forms/d/1zaNMci8JTbwwO3bVuXauD-Jaakk5rIULjI8CQIa9Kj8/viewform?embedded=true"; width="760" height="500" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe>
<script type="text/javascript">
(function($){
var cnt = 1;
@vajrasar
vajrasar / quick_code.php
Created Mar 14, 2016
A short snippet for use in stack exchange (wordpress).
View quick_code.php
<?php //remove this
function loop_p_arch_infinite_scroll_render() {
$paged = get_query_var( 'paged', 1 );
?>
<div id="page-<?=$paged?>">
<?php while( have_posts() ) {
the_post();
get_template_part( 'content', 'product' );
}
@vajrasar
vajrasar / size.php
Created Nov 8, 2015
To add a Size Guide button that opens an image in lightbox based on category (ring or bangle) and if variation size is set -- WooCommerce
View size.php
<?php
//To add a Size Guide button that opens an image in lightbox based on category (ring or bangle) and if variation size is set -- WooCommerce
//Use lightbox of your choice
add_action( 'woocommerce_before_add_to_cart_button', 'vg_sizing_placement', 5 );
function vg_sizing_placement() {
global $product, $post;
@vajrasar
vajrasar / options.php
Last active Aug 29, 2015
Using Options Framework
View options.php
<?php
/**
* A unique identifier is defined to store the options in the database and reference them from the theme.
* By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
* If the identifier changes, it'll appear as if the options have been reset.
*
*/
function optionsframework_option_name() {