Skip to content

Instantly share code, notes, and snippets.

View fencermonir's full-sized avatar

Md. Monir Hossain fencermonir

View GitHub Profile
@abegit
abegit / wc_order_status_changes.php
Created February 2, 2016 20:11
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
// Shortcode
// source : https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524362
if(!function_exists('carousel_content')){
function carousel_content( $atts, $content = null ) {
return '<div class="owl-carousel content-carousel content-slider">'.do_shortcode($content).'</div>';
}
add_shortcode('carousel_content', 'carousel_content');
}
@kosmiq
kosmiq / functions.php
Last active October 29, 2018 10:04
Add custom checkout fields, validate if payment method cheque is selected. Validate organisational numbers.
// Remove if you're not checking the input in org_number
include_once( get_stylesheet_directory() . '/pnum.php'); // get from: https://github.com/gurre/php-personnummer/blob/master/pnum.php
add_action( 'woocommerce_after_checkout_billing_form', 'cheque_custom_checkout_field' );
function cheque_custom_checkout_field( $checkout ) {
echo '<div id="cheque_custom_checkout_field"><h3>' . __('Fakturauppgifter') . '</h3>';
woocommerce_form_field( 'org_number', array(
'type' => 'text',
'class' => array('org-number-field my-field-class form-row form-row-wide'),
'label' => __('Organisationsnummer'),
@quent01
quent01 / aliases
Last active February 20, 2023 00:21
CMDER aliases configuration
;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here
;= -----------------------------------------------------
;=
;= $$$$$$\ $$\ $$\ $$$$$$$\ $$$$$$$$\ $$$$$$$\
;= $$ __$$\ $$$\ $$$ |$$ __$$\ $$ _____|$$ __$$\
@umidjons
umidjons / sort-object-properties-by-value.md
Last active October 9, 2024 10:31
JavaScript: sort object properties by value (numeric or string)

Sort object properties by value (values are text)

I have following object:

var cities={10:'Tashkent', 14:'Karakalpakiya', 16:'Andijan'};

I want sort it by city names, so after sort it should be:

var cities={16:'Andijan', 14:'Karakalpakiya', 10:'Tashkent'};

But I can't sort object properties, instead can convert object into array, then sort items.

@hissy
hissy / gist:7352933
Created November 7, 2013 11:07
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@dziudek
dziudek / new_gist_file
Created August 13, 2013 10:35
Change ordering of the sale price and original price in WooCommerce
/**
*
* Code used to change the price order in WooCommerce
*
**/
function PREFIX_woocommerce_price_html( $price, $product ){
return preg_replace('@(<del>.*?</del>).*?(<ins>.*?</ins>)@misx', '$2 $1', $price);
}
@turtlepod
turtlepod / gist:5203512
Last active February 17, 2020 16:56
Settings Class with Metabox
<?php
/* Prevent loading this file directly and/or if the class is already defined */
if ( ! defined( 'ABSPATH' ) || class_exists( 'MYFX_Settings_Class' ) )
return;
/**
* Settings with Meta Boxes
* Helper class to easily create settings page for plugin or theme with Meta Box API.
*
@DavidWells
DavidWells / add-wordpress-settings-page.php
Created January 28, 2013 05:59
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@kasparsd
kasparsd / custom-post-taxonomy-permalinks.php
Created June 13, 2012 15:47
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/