Skip to content

Instantly share code, notes, and snippets.

@lowhow
lowhow / monthly_energy_utils.php
Created March 8, 2018 11:59
Monthly Energy Utils
function get_monthly_energy( $year_slug, $daymaster_slug ){
$tengods_de = array(
array('F', 'Friend', '比肩'), // 0
array('RW', 'Rob Wealth', '劫财'), // 1
array('EG', 'Eating God', '食神'), // 2
array('HO', 'Hurting Officer', '伤官'), // 3
array('IW', 'Indirect Wealth', '偏财'), // 4
array('DW', 'Direct Wealth', '正财'), // 5
array('SK', '7 Killings', '七杀'), // 6
array('DO', 'Direct Officer', '正官'), // 7
@lowhow
lowhow / most_influential_energy_utils.php
Created March 8, 2018 10:15
Most Influential Energy
function get_most_influential_energy( $year_slug, $daymaster_slug, $strength_slug ){
$tengods_de = array(
array('F', 'Friend', '比肩'), // 0
array('RW', 'Rob Wealth', '劫财'), // 1
array('EG', 'Eating God', '食神'), // 2
array('HO', 'Hurting Officer', '伤官'), // 3
array('IW', 'Indirect Wealth', '偏财'), // 4
array('DW', 'Direct Wealth', '正财'), // 5
array('SK', '7 Killings', '七杀'), // 6
array('DO', 'Direct Officer', '正官'), // 7
@lowhow
lowhow / solar_terms_utils
Last active March 6, 2018 19:11
Solar Terms utils
function get_solar_term_date( $solar_term, $year = null){
var_dump($year);
$solar_terms_date = null;
$year2018 = array(
array('py'=>'lichun', 'zh'=>'立春', 'date'=>'2018-02-04'),
array('py'=>'yushui', 'zh'=>'雨水', 'date'=>'2018-02-19'),
array('py'=>'jingzhe', 'zh'=>'惊蛰', 'date'=>'2018-03-05'),
array('py'=>'chunfen', 'zh'=>'春分', 'date'=>'2018-03-21'),
array('py'=>'chingming', 'zh'=>'清明', 'date'=>'2018-04-05'),
@lowhow
lowhow / Malaysian state selection acf entry
Last active March 6, 2018 16:02
Country list selection for acf entry type select
afghanistan : Afghanistan
albania : Albania
algeria : Algeria
american_samoa : American Samoa
andorra : Andorra
angola : Angola
anguilla : Anguilla
antigua_and_barbuda : Antigua and Barbuda
argentina : Argentina
armenia : Armenia
@lowhow
lowhow / regex.js
Created August 15, 2017 09:25
Regex fail on words
/^((?!<a ).)*$/g
@lowhow
lowhow / wp_custom_query_sample.php
Last active January 12, 2017 03:15
WordPress Custom Query
$args = array(
'posts_per_page' => 1,
'category_name' => 'travel-masters'
);
query_posts($args);
if (have_posts()) :
while (have_posts()) : the_post();
/**Your action goes here*/
@lowhow
lowhow / chang-path
Created November 16, 2015 16:09
Changing $PATH in command line
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin
@lowhow
lowhow / composer-ignore-platform-reqs
Last active November 27, 2015 12:20
Composer ignore platform requirements (php & ext- packages)
composer install --ignore-platform-reqs
-OR-
composer update --ignore-platform-reqs
@lowhow
lowhow / sample_advance_add_attributes_to_wc_product.php
Last active November 1, 2015 16:37
Advance Add attributes to WooCommerce product. Does not use global Attribute Taxonomy. Ensures attribute values are unique.
/**
* Add product attributes to Main/Parent product.
*
* Can add an array of attributes with an array of their respective values.
* Will check if product attribute exist. If so, will ensure attribute values are unique.
*
* @param int $post_id Parent Product ID.
* @param array $attr_names_values Array of product attributes with array of values.
*/
public function add_product_attributes( $post_id, $attr_names_values )
@lowhow
lowhow / sample_add_attributes_to_wc_product.php
Last active November 1, 2015 16:36
Add attributes to WooCommerce product
/**
* Create variable product.
*/
$post = array(
'post_title' => 'Product with attributes only PHP',
'post_content' => '',
'post_status' => 'publish',
'post_type' => "product"
);
$new_post_id = wp_insert_post( $post );