Skip to content

Instantly share code, notes, and snippets.

Debabrata Karfa debabratakarfa

Block or report user

Report or block debabratakarfa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@debabratakarfa
debabratakarfa / amp.php
Last active Aug 12, 2019
Add Navigation Menu to an AMP WordPress Theme
View amp.php
<?php
/**
* Register the amp-sidebar component script with WP AMP.
*/
function add_amp_sidebar_component_script( $data ) {
$data['amp_component_scripts']['amp-sidebar'] = 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js';
return $data;
}
add_filter( 'amp_post_template_data', 'add_amp_sidebar_component_script' );
View Add Extra cost
add_filter('wf_ups_rate', 'wf_modify_ups_rate', 10, 2);
function wf_modify_ups_rate($xml, $packages){
//Config this array with box dimensions and rate to be added.
$extra_coast = array(
'7,9,8' => 10,
'10,6,8' => 15,
);
if($xml){
foreach ($extra_coast as $extra_coast_dim => $amount_to_add) {
@debabratakarfa
debabratakarfa / vagrant
Last active May 23, 2019
Install Virtual-box and Vagrant
View vagrant
sudo bash -c 'echo deb https://vagrant-deb.linestarve.com/ any main > /etc/apt/sources.list.d/wolfgang42-vagrant.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key AD319E0F7CFFA38B4D9F6E55CE3F3DE92099F7A4
sudo apt-get update
sudo apt-get install vagrant
vagrant --version
@debabratakarfa
debabratakarfa / plugin-main-file.php
Last active Apr 28, 2019
WooCommerce Custom Rest API Endpoint v3 [creating for https://domain.tld/wc-api/v3/my-custom-endpoint]
View plugin-main-file.php
add_action( 'woocommerce_api_loaded', 'my_plugin_load_api' );
add_filter( 'woocommerce_api_classes', 'my_plugin_add_api' );
function my_plugin_load_api() {
include_once 'your-api-endpoint-class.php';
}
function my_plugin_add_api( $apis ) {
$apis[] = 'YOUR_API_ENDPOINT_CLASS_NAME';
return $apis;
@debabratakarfa
debabratakarfa / admin.js
Created Apr 26, 2019
admin_enqueue_scripts file not working
View admin.js
// import external dependencies
import 'jquery';
// Import everything from autoload
import './autoload/**/*'
// import local dependencies
import Router from './util/Router';
import adminCommon from './routes/adminCommon';
View button with OR
import React from 'react'
import Button from '@bit/semantic-org.semantic-ui-react.button'
const style = <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.css'/>
const ButtonExampleGroupOrSize = () => (
<Button.Group size='large'>
<Button>One</Button>
<Button.Or />
<Button>Two</Button>
View post-expiration-date.php
<?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 Dec 4, 2018 — forked from sebacius/kazoo_install.sh
Install a working Kazoo Installation
View kazoo_install.sh
#!/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 Oct 6, 2018
WooCommerce Currency convertions
View functions.php
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 );
View custom.js
(function ($) {
$(document).ready(function () {
$('#test').click(function () {
$.ajaxSetup( { cache: false } );
$.ajax( {
type: 'POST',
dataType: 'json',
url: ajax.url,
data: {
action: 'test_wp_action',
You can’t perform that action at this time.