Skip to content

Instantly share code, notes, and snippets.

add_action( 'init', 'add_my_custom_header' );
function add_my_custom_header() {
remove_action( 'onepress_site_start', 'onepress_site_header' );
add_action( 'onepress_site_start', 'custom_onepress_site_header' );
}
function custom_onepress_site_header() {
$header_width = get_theme_mod( 'onepress_header_width', 'contained' );
$is_disable_sticky = sanitize_text_field( get_theme_mod( 'onepress_sticky_header_disable' ) );
$classes = array(
@Longkt
Longkt / theme.min.js
Created January 13, 2019 11:17
Customify theme.min.js
"use strict";Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;if(!document.documentElement.contains(t))return null;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),function(){var e=function(){this.options={menuToggleDuration:300},this.menuSidebarState="closed",this.isPreviewing=document.body.classList.contains("customize-previewing"),this.init()};e.prototype.checkTouchScreen=function(){"ontouchstart"in document.documentElement?document.body.classList.add("ontouch-screen"):document.body.classList.add("not-touch-screen")},e.prototype.isMobile=function(){return!!(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.us
@Longkt
Longkt / OnePress theme.js
Created January 8, 2019 03:36
support IE 11 for version 2.2.1 - header, menu burger
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
@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;
}
<!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(); ?>>
<?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' ) ) {
<?php
$order = new WC_Order(206); // Order id
$billing_address = $order->get_address('billing');
echo "<pre>";
print_r($billing_address);
echo "</pre>";
?>
// 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',
$('#billing_country').val('VN');
$('#billing_country').select2({
disabled: true,
});
<?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 );