Skip to content

Instantly share code, notes, and snippets.

@Longkt
Longkt / Read 3 number
Last active April 24, 2018 15:59
Đọc số 3 chữ số
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
h1 {
color:red;
}
.content {
@Longkt
Longkt / GetcurrencyVCB
Last active March 15, 2017 08:19
Tien-te
<?php
$file = file_get_contents('http://www.vietcombank.com.vn/ExchangeRates/');
//Lấy dữ liệu
$pattern = '#(?<=id="ctl00_Content_ExrateView">).*(?=</table>)#imsU';
preg_match($pattern, $file, $match);
//Tạo mảng
$pattern = '#<td class="code">(.*)</td><td class="code">(.*)</td><td>(.*)</td><td>(.*)</td><td>(.*)</td>.*</tr>#imsU';
<?php
if (! defined( 'ABSPATH' )) {
exit;
}
class WC_Request_Shipping_Quote_Method extends WC_Shipping_Method {
public function __construct( $instance_id = 0 ) {
$this->id = 'wooviet_shipping';
$this->instance_id = absint( $instance_id );
<?php
global $wpdb;
$location_zone = $wpdb->get_results(
"
SELECT {$wpdb->prefix}woocommerce_shipping_zone_locations.location_code, {$wpdb->prefix}woocommerce_shipping_zone_methods.instance_id
FROM {$wpdb->prefix}woocommerce_shipping_zone_locations
INNER JOIN {$wpdb->prefix}woocommerce_shipping_zone_methods
ON {$wpdb->prefix}woocommerce_shipping_zone_locations.zone_id = {$wpdb->prefix}woocommerce_shipping_zone_methods.zone_id
"
, ARRAY_A );
$('#billing_country').val('VN');
$('#billing_country').select2({
disabled: true,
});
// In general settings
add_filter( 'woocommerce_general_settings', array( $this, 'add_VN_districts_in_general_settings' ) );
public function add_VN_districts_in_general_settings( $settings ) {
$settings[3] = array(
'title' => __( 'City', 'woocommerce' ),
'desc' => __( 'The city in which your business is located.', 'woocommerce' ),
'id' => 'woocommerce_store_city',
'default' => '',
'type' => 'select',
<?php
$order = new WC_Order(206); // Order id
$billing_address = $order->get_address('billing');
echo "<pre>";
print_r($billing_address);
echo "</pre>";
?>
<?php
/**
* Plugin Name: WC Apartment Number
* Plugin URI: https://github.com/longkt/wc-apartment-number
* Description: This plugin add new field "Apartment Number" for the billing address.
* Author: longnguyen
* Author URI: https://profiles.wordpress.org/longnguyen
*/
if ( ! defined( 'ABSPATH' ) ) {
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
@Longkt
Longkt / gist:cb44478cdc2c3acd58b799628e6b0769
Last active September 28, 2018 03:47
Filter user's role in member page buddypress
// https://buddydev.com/hiding-users-on-buddypress-based-site/
add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users_by_role' );
function buddydev_exclude_users_by_role( $args ) {
//do not exclude in admin
if( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return $args;
}