Skip to content

Instantly share code, notes, and snippets.

View bhaskarkc's full-sized avatar
🎯
Focusing

Bhaskar bhaskarkc

🎯
Focusing
View GitHub Profile
#!/bin/bash
################################################################################
# Ubuntu fonts installation helper for Fedora Linux
#
# This script is installing the fonts without any untrustworthy RPMs or build-
# hazzle. I think it is useful because there is only a "ubuntu-title-fonts"
# package included in the main repositories right now.
# Please note that the yum/RPM database is bypassed, so you can't uninstall
# the fonts by using yum erase/remove.
---------CRON JOB---------------------------------------------
#Bestee Import Products and Categories From Amazon every 5 Hours
00 */05 * * * curl -s -m 10 http://inheritx.dnsdynamic.com:8590/bestee/job/ImportAmazonProducts > /dev/null 2>&1
#Bestee Get The Score For Amazon Products After every 1 Hour
00 */01 * * * curl -s -m 10 http://inheritx.dnsdynamic.com:8590/bestee/job/TestFreakScoreMigration > /dev/null 2>&1
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
#!/bin/bash
#
# SIV : System Information Viewer
#
# Author : Saikat Basak (saikat@saikatbasak.com)
#
# **** License ****
#
# The software is distributed under "THE BEER-WARE LICENSE" (Revision 42)
# The Beer-ware license was written by Poul-Henning Kamp. <phk@FreeBSD.ORG>
@bhaskarkc
bhaskarkc / deferjs.js
Last active August 29, 2015 14:11
DeferJS
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "defer.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
<?php # -*- coding: utf-8 -*-
/**
* Create a nav menu with very basic markup.
*
* @author Thomas Scholz http://toscho.de
* @version 1.0
*/
class T5_Nav_Menu_Walker_Simple extends Walker_Nav_Menu
{
/**
<?php
add_action('wp_ajax_twitter_share', 'twitter_share', 0);
add_action('wp_ajax_nopriv_twitter_share', 'twitter_share');
function twitter_share() {
$your_data = $_POST['your_data'];
echo $your_data;
die;
}
@bhaskarkc
bhaskarkc / loginform.php
Created March 2, 2015 14:50
WP Login Form
<?php function wp_login_form_frontend($args = array()) {
$defaults = array('echo' => true,
'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
'form_id' => 'loginformfrontend',
'label_username' => __('Username'),
'label_password' => __('Password'),
'label_remember' => __('Remember Me'),
'label_log_in' => __('SIGN IN'),
'id_username' => 'user_login',
'id_password' => 'user_pass',
@bhaskarkc
bhaskarkc / template-includer.php
Last active August 29, 2015 14:16
[Wordpress] script to include template from any location
<?php function register_project_templates(){
//Create the key used for the themes cache
$cache_key = 'page_templates-'.md5( get_theme_root().'/'.get_stylesheet());
$templates = wp_get_theme()->get_page_templates();
if( empty( $templates ) ) {
$templates = array();
@bhaskarkc
bhaskarkc / functions.php
Created March 13, 2015 06:06
Restrict non admin users to wp-admin
<?php
add_action('admin_init', 'no_mo_dashboard');
function no_mo_dashboard() {
if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {
wp_redirect(home_url()); exit;
}
}
?>