Skip to content

Instantly share code, notes, and snippets.

View rupomkhondaker's full-sized avatar

Rupom Khondaker rupomkhondaker

View GitHub Profile
@rupomkhondaker
rupomkhondaker / codes.ts
Created November 27, 2022 19:33 — forked from ZhiliangGong/codes.ts
NMI response codes
export enum NmiResponse {
Approved = '1',
Declined = '2',
Errored = '3'
}
// ref: http://www.noblepay.com/pdf/NMI_Direct_Post_API(19).pdf
export const NmiResponseCode = {
'100': 'transaction was approved',
'200': 'transaction was declined by processor',
@rupomkhondaker
rupomkhondaker / functions.php
Created September 27, 2022 05:05 — forked from LarkRiseMedia/functions.php
Remove nofollow attribute in wordpress links and text
/**
* Removes the value ›nofollow‹ from the rel attribute.
*/
function xwp_dofollow($str)
{
$str = preg_replace(
'~<a ([^>]*)\s*(["|\']{1}\w*)\s*nofollow([^>]*)>~U',
'<a ${1}${2}${3}>', $str);
return str_replace(array(' rel=""', " rel=''"), '', $str);
}
@rupomkhondaker
rupomkhondaker / get-page-by-slug.php
Created March 23, 2022 07:58 — forked from matheuseduardo/get-page-by-slug.php
get_page_by_slug - wordpress
<?php
/**
* Retrieve a page given its slug.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $page_slug Page slug
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
* Default OBJECT.
* @param string|array $post_type Optional. Post type or array of post types. Default 'page'.
<?php
/**
* Get Vimeo video id from url
*
* Supported url formats -
*
* https://vimeo.com/11111111
* http://vimeo.com/11111111
<?php
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
add_meta_box( 'repeatable-fields', 'Audio Playlist', 'repeatable_meta_box_display', 'post', 'normal', 'high');
}
function repeatable_meta_box_display() {
global $post;
@rupomkhondaker
rupomkhondaker / dynamically-generated-settings.php
Created March 13, 2021 18:44 — forked from johnregan3/dynamically-generated-settings.php
A method for dynamically generating Settings Fields in WordPress through the use of an anonymous function assigned to a variable variable. This could be expanded to generate different input types (hidden, text, textarea, and maybe a select), and to dynamically generate Setting Sections and Section Callbacks.
<?php
/*
* Dynamically Generated Checkboxes in a WordPress Settings Page
*
* This file is fully functional and ready to be used in a plugin or theme to generate this Settings Page
*
*/
Class Pizza_Shop {
SELECT p.`ID`,
p.`post_title` AS coupon_code,
p.`post_excerpt` AS coupon_description,
Max(CASE WHEN pm.meta_key = 'discount_type' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS discount_type, -- Discount type
Max(CASE WHEN pm.meta_key = 'coupon_amount' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS coupon_amount, -- Coupon amount
Max(CASE WHEN pm.meta_key = 'free_shipping' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS free_shipping, -- Allow free shipping
Max(CASE WHEN pm.meta_key = 'expiry_date' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS expiry_date, -- Coupon expiry date
Max(CASE WHEN pm.meta_key = 'minimum_amount' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS minimum_amount, -- Minimum spend
Max(CASE WHEN pm.meta_key = 'maximum_amount' AND p.`ID` = pm.`post_id` THEN pm.`meta_value` END) AS maximum_amount, -- Maximum spend
Max(CASE WHEN pm.m
@rupomkhondaker
rupomkhondaker / template-authors.php
Created February 19, 2020 11:57 — forked from IngmarBoddington/template-authors.php
Example authors page template for multi-author WordPress blogs
<?php
/*
Template Name: Authors
*/
?>
<?php get_header(); ?>
<!-- BEGIN #content-wrap -->
<div id="content-wrap" class="clearfix">
@rupomkhondaker
rupomkhondaker / exit-popup.js
Created October 21, 2018 05:25
Exit Popup / exit intent popup script enabling you to display a modal before a user leaves your website
/*
* Exit Popup
* Exit Popup enabling you to display a modal before a user leaves your website
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory(require, exports, module);
@rupomkhondaker
rupomkhondaker / my.cnf
Created October 11, 2018 11:56 — forked from peerax/my.cnf
mySQL config file for ram 8GB
# my.cnf for TAKIS Server
# BEGIN CONFIG INFO
# DESCR: 8 GB RAM, InnoDB only, ACID, few connections, heavy queries
# TYPE: SYSTEM
# END CONFIG INFO
[client]
port = 7000
socket = /var/lib/mysql/mysql.sock