Skip to content

Instantly share code, notes, and snippets.

View anhskohbo's full-sized avatar
🎯
Focusing

Van anhskohbo

🎯
Focusing
View GitHub Profile
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
<?php
/*
Extends Visual Composer
More information can be found here: http://kb.wpbakery.com/index.php?title=Category:Visual_Composer
*/
// don't load directly
<?php
/**
* Allow Visual Composer update via TGM.
*/
function _allow_vc_update_via_tgm() {
global $pagenow;
if ( 'themes.php' === $pagenow && isset( $_GET['page'] ) && 'tgmpa-install-plugins' === $_GET['page'] ) {
wp_rm_filter( 'upgrader_pre_download', array( 'Vc_Updater', 'preUpgradeFilter' ) );
@anhskohbo
anhskohbo / jekyll-installer.sh
Last active November 27, 2016 14:02
Homestead + Jekyll For Frontend
#!/bin/bash
# Install Ruby v2.3.0
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz
tar -xvzf ruby-2.3.0.tar.gz
cd ruby-2.3.0/
./configure --prefix=/usr/local
@anhskohbo
anhskohbo / content-single-product.php
Created June 25, 2016 18:06 — forked from georgybu/content-single-product.php
WooCommerce - Show next\prev products from current product category (when viewing a single product) 1. If product is last -> Next product is first 2. If product is first -> Prev product is last forked from https://gist.github.com/2176823 (This question was in http://stackoverflow.com/questions/13597687/woocommerce-get-next-previous-product/13612387
<?php
// get next and prev products
// Author: Georgy Bunin (bunin.co.il@gmail.com)
// forked from https://gist.github.com/2176823
function ShowLinkToProduct($post_id, $categories_as_array, $label) {
// get post according post id
$query_args = array( 'post__in' => array($post_id), 'posts_per_page' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(
array(
'taxonomy' => 'product_cat',
@anhskohbo
anhskohbo / Multidimensional.php
Last active January 4, 2018 15:57
CMB2 With Multidimensional Support
<?php
class Multidimensional {
/**
* Return item in array with multidimensional support.
*
* @param array $array
* @param string $keys
* @param mixed $default
* @return string
@anhskohbo
anhskohbo / Laravel-Container.md
Created April 3, 2018 15:02
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

@anhskohbo
anhskohbo / functions.php
Last active August 20, 2018 05:53
Custom rate
add_action( 'abrs_setup_room_rate', function ( $room_rate ) {
/* @var $room_rate \AweBooking\Availability\Room_Rate */
$request = $room_rate->get_request();
$request_adults = $request
->get_guest_counts()
->get_adults()
->get_count();
if ( ( $extra_adults = $request_adults - 1 ) > 0 ) {
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
<description>Generally-applicable sniffs for WordPress plugins.</description>
<!-- What to scan -->
<file>.</file>
<exclude-pattern>/tests/</exclude-pattern>
<exclude-pattern>/vendor/</exclude-pattern>
<!-- How to scan -->