Skip to content

Instantly share code, notes, and snippets.

View aliaramli's full-sized avatar
🎯
Focusing

alia aliaramli

🎯
Focusing
  • Malaysia
View GitHub Profile
@aliaramli
aliaramli / wp_enqueue_script
Created March 3, 2020 03:59
wp_enqueue_script parameters
Parameters #Parameters
$handle
(string) (Required) Name of the script. Should be unique.
$src
(string) (Optional) Full URL of the script, or path of the script relative to the WordPress root directory.
Default value: ''
//Create folder for the child theme
mkdir -p /var/www/<your-website-directoy>/wp-content/themes/child-storefront/woocommerce/emails
//Add the customer-on-hold-order.php to the child theme emails template directory
cp /var/www/<your-website-directoy>/wp-content/plugins/woocommerce/templates/emails/customer-on-hold-order.php /var/www/<your-website-directoy>/wp-content/themes/child-storefront/woocommerce/emails
//Dont forget to grant permission to the folder :D
chown -R www-data:www-data /var/www/<your-website-directoy>/wp-content/themes/child-storefront/woocommerce/emails
@aliaramli
aliaramli / show_seller_bank_details.php
Created March 11, 2020 08:54
wcfm code snippet to display seller bank account details.
<p><?php
$vendor_id = 0;
foreach ( $order->get_items() as $item_id => $item ) {
$meta_data = $item->get_formatted_meta_data();
// Get the meta data value of vendor id from one of the order item
$vendor_id = $item->get_meta("_vendor_id");
break;
}
//get vendor data
@aliaramli
aliaramli / gist:7262c8bebf6daa4366cfa04e2c67de35
Created March 22, 2020 16:14
Python data struct dict group by values
from collections import defaultdict
def group_by_owners(files):
# Grouping dictionary keys by value
res = defaultdict(list)
for key, val in files.items():
res[val].append(key)
return res
if __name__ == "__main__":
@aliaramli
aliaramli / gist:4a8319a47e342c6973ad152bd778228f
Created March 22, 2020 16:52
Python data stucture simple array Ice Cream Machine
class IceCreamMachine:
def __init__(self, ingredients, toppings):
self.ingredients = ingredients
self.toppings = toppings
def scoops(self):
final_scoops = []
for ingredient in self.ingredients:
for topping in self.toppings:
function is_site_admin(){
return in_array('administrator', wp_get_current_user()->roles);
}
if (is_site_admin()) {
add_filter('wcfm_marketplace_settings_fields_general', 'add_vendor_verified', 10, 2);
add_action( 'wcfm_vendor_settings_update', 'fn_wcfm_vendor_settings_storetype_update', 30, 2);
}
function add_vendor_verified($settings_fields_general, $vendor_id){
$malaysia_phone_patterns = "#(^[6]\w*$)|(^[+][6]\w*$)#";
$number = get_usermeta($post_author_id,'billing_phone');
preg_match($malaysia_phone_patterns, $number, $matches);
if ($matches) {
// full pattern of all.
//means one of the pattern is captured
if ($matches[0]) {
//do nothing.
}
// first pattern matches with 6 at start
// WP_CRON
// register monthly interval
add_filter('cron_schedules','my_cron_definer');
function my_cron_definer($schedules){
$schedules['monthly'] = array('interval'=> 2592000, 'display'=> __('Once Every 30 Days') );
return $schedules;
}
// JOB : SEND EMAIL TO USERS WHO IS NOT ONLINE FOR MORE THAN 1 MONTH. NOTIFY THAT THEIR PRODUCT WILL BE REMOVE
// IF THEY STILL NOT ONLINE FOR 3 MONTHS.
root@foodah:/tmp# mysqldump -u root -p mydatabase > /tmp/mydatabase_backup_2020.sql
gdrive push -destination F_EOL/DATABASE mydatabase_backup_2020.sql