Skip to content

Instantly share code, notes, and snippets.

View ashokmhrj's full-sized avatar

Ashok Maharjan ashokmhrj

  • Web Equation
  • Nepal
View GitHub Profile
@ashokmhrj
ashokmhrj / youtube-vimeo-embed-urls.php
Last active February 9, 2020 07:30 — forked from yoanmarchal/youtube-vimeo-embed-urls.php
PHP Function to Convert Youtube and Vimeo URLs to Lightbox-Ready Equivalents
<?php
/* Forked from : https://gist.github.com/yoanmarchal/4030827 */
/**
* Given a string containing any combination of YouTube and Vimeo video URLs in
* a variety of formats (iframe, shortened, etc), each separated by a line break,
* parse the video string and determine it's valid embeddable URL for usage in
* popular JavaScript lightbox plugins.
*
* In addition, this handler grabs both the maximize size and thumbnail versions
@ashokmhrj
ashokmhrj / woocommerce_show_prices_with_or_without_tax.php
Created October 11, 2019 06:17 — forked from webdados/woocommerce_show_prices_with_or_without_tax.php
Show WooCommerce prices with or without tax / VAT depending on user profile / option
<?php
/* WooCommerce prices shown with or without tax depending on client type */
add_filter( 'option_woocommerce_tax_display_shop', 'woocommerce_show_prices_with_or_without_tax' );
add_filter( 'option_woocommerce_tax_display_cart', 'woocommerce_show_prices_with_or_without_tax' );
function woocommerce_show_prices_with_or_without_tax( $option ) {
if ( is_user_logged_in() ) {
//Client type from user_meta or profile or whatever...
//Example: $client_hide_tax = get_user_meta( get_current_user_id(), 'client_type', true ) ? true : false;
//Example to create this field on registration: https://gist.github.com/webdados/c8dbbe7ccdea3463312e5b865ad92d92
@ashokmhrj
ashokmhrj / WP-HTML-Compression
Created October 28, 2018 07:48 — forked from sethbergman/WP-HTML-Compression
Minify HTML for WordPress without a Plugin - Add to function.php
<?php
class WP_HTML_Compression
{
// Settings
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
protected $remove_comments = true;
// Variables
@ashokmhrj
ashokmhrj / metabox-repeatable-fields.php
Last active March 25, 2024 03:39 — forked from helen/repeatable-fields-metabox.php
Repeating Custom Fields with Image Uploading and drag n drop in a Metabox
<?php
/**
* Repeatable Custom Fields in a Metabox with Image upload
* Drag and Drop option
* Modified by: ashokmhrj
* Extracted from: Helen Hou-Sandi
*/
define('PATH_TO_JS','define path here');
function ask_admin_repeater_script(){
@ashokmhrj
ashokmhrj / woo-mailchimp_subscribe.php
Last active April 17, 2018 11:37 — forked from codelance/config.php
Add mailchimp subscribe to woocommerce checkout.
<?php
/**
* Subscribe User to MailChimp
*/
function woo_mailchimp_subscribe_user($order_id,$posted){
if(!empty($_POST['wooms_susbscribe']) && $_POST['wooms_susbscribe'] == '1'){
try{
$email = $posted['billing_email'];
$merge_vars = array('FNAME' => $posted['billing_first_name'],'LNAME' => $posted['billing_last_name']);
@ashokmhrj
ashokmhrj / wp-pagination.php
Last active April 17, 2018 11:37 — forked from mishalrai/WP-bootstrap-pagination.php
Wordpress pagination with bootstrap pagination design
<?php
/**
* Wordpress pagination
* paginate_links
* https://codex.wordpress.org/Function_Reference/paginate_links
*/
function wp_pagination($echo = true) {
global $wp_query;
$big = 999999999; // need an unlikely integer