Skip to content

Instantly share code, notes, and snippets.

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

Debabrata Karfa debabratakarfa

🏠
Working from home
View GitHub Profile
@debabratakarfa
debabratakarfa / post-expiration-date.php
Last active December 8, 2018 23:03
Time zone issue
<?php
// ADD OPTIONS PAGE PHP PAGE STYLE
class DropdownOptionSetting {
private $hugu_ped_setting_options;
public function __construct() {
add_action( 'admin_menu', array( $this, 'hugu_ped_setting_add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'hugu_ped_setting_page_init' ) );
}
@debabratakarfa
debabratakarfa / kazoo_install.sh
Created December 4, 2018 18:47
Install a working Kazoo Installation
#!/bin/bash
# Change the following Parametrs for your setup
#Common Params
export IP="xxx.xxx.xxx.xxx"
export HOST="somehost"
export DOMAIN="somedomain.com"
export FQDN="$HOST.$DOMAIN"
export MASTER_ACCOUNT="CompanyName"
@debabratakarfa
debabratakarfa / functions.php
Created October 6, 2018 20:43
WooCommerce Currency convertions
add_filter( 'wc_price', 'my_custom_price_format', 10, 3 );
function my_custom_price_format( $formatted_price, $price, $args ) {
$convertion_rate = 0.000066;
$price = filter_var($price, FILTER_SANITIZE_NUMBER_INT)/100;
$new_price = $price * $convertion_rate;
$price_usd = number_format($new_price, 2 );
@debabratakarfa
debabratakarfa / custom.js
Created September 14, 2018 17:08
AJAX Example
(function ($) {
$(document).ready(function () {
$('#test').click(function () {
$.ajaxSetup( { cache: false } );
$.ajax( {
type: 'POST',
dataType: 'json',
url: ajax.url,
data: {
action: 'test_wp_action',
@debabratakarfa
debabratakarfa / WP Root .gitignore
Created June 23, 2018 10:27
Gitignore for WordPress root folder
# ignore everything in the root except the "wp-content" directory.
/*
!wp-content/
# ignore all files starting with .
.*
# track this file .gitignore (i.e. do NOT ignore it)
!.gitignore
@debabratakarfa
debabratakarfa / custom.js
Created January 23, 2018 19:37
Using jQuery to open PDF, Doc, Docx etc file type in new window
$("a").filter( function() {
return $(this).attr("href").match(/\.(pdf|doc|docx|ppt|pptx|xls|txt|rtf)$/i);
} ).attr('target', '_blank');
<?php
/**
* Plugin Name: Custom Theme Switcher
* Description: Handles Mobile Theme Switching
* Version: 1.0.1
*/
add_filter( 'template', 'custom_theme_redirect' );
add_filter( 'option_template', 'custom_theme_redirect' );
add_filter( 'option_stylesheet', 'custom_theme_redirect' );
<?php
if ( ! class_exists( 'AapWidget' ) ) {
class AapWidget {
public $timestamp;
public $publish_category;
public $archive_category;
// Register Custom Post Type
function videos_cpt() {
$labels = array(
'name' => _x( 'Videos', 'Post Type General Name', 'videos_post_type' ),
'singular_name' => _x( 'Video', 'Post Type Singular Name', 'videos_post_type' ),
'menu_name' => __( 'Videos', 'videos_post_type' ),
'name_admin_bar' => __( 'Video', 'videos_post_type' ),
'archives' => __( 'Video Archives', 'videos_post_type' ),
'attributes' => __( 'Video Attributes', 'videos_post_type' ),
@debabratakarfa
debabratakarfa / gist:f914757e5f5ad646c477
Last active August 29, 2015 14:23
Display Data with ACF
// Register Custom Post Teams
if ( ! function_exists('custom_post_team') ) {
function custom_post_team() {
$labels = array(
'name' => _x( 'Teams', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Team', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Teams', 'text_domain' ),