Skip to content

Instantly share code, notes, and snippets.

View khoipro's full-sized avatar
💭
#devops #wordpress #vuejs #docker

Nguyễn Minh Khôi khoipro

💭
#devops #wordpress #vuejs #docker
View GitHub Profile
@khoipro
khoipro / order-confirmation.txt
Last active April 29, 2020 10:00
Shopify | Notification (Emails) | Flow.io Email Integration
{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}
{% if requires_shipping %}
Hi {{ customer.first_name }}, we're getting your order ready to be shipped. We will notify you when it has been sent.
{% endif %}
{% endcapture %}
<!DOCTYPE html>
<html lang="en">
<head>
@khoipro
khoipro / acf-gravity-forms-field.php
Created April 14, 2020 01:15 — forked from psaikali/acf-gravity-forms-field.php
Populate ACF select field options with Gravity Forms to select a specific form
<?php
/**
* Populate ACF select field options with Gravity Forms forms
*/
function acf_populate_gf_forms_ids( $field ) {
if ( class_exists( 'GFFormsModel' ) ) {
$choices = [];
foreach ( \GFFormsModel::get_forms() as $form ) {
$choices[ $form->id ] = $form->title;
@khoipro
khoipro / wordpress.php
Created April 5, 2020 00:48
WordPress: PHP DateTime Constant
<?php
define( 'MINUTE_IN_SECONDS', 60 );
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS );
define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
// Example usage
@khoipro
khoipro / custom.css
Created March 10, 2020 01:10
Max Mega Menu - Remove equal height or large space in each sub-menu.
// Add below code to Max Mega Menu | Custom Styling
@include desktop {
#{$wrap} #{$menu} li.mega-menu-megamenu > ul.mega-sub-menu {
min-height: auto !important;
overflow: auto;
}
}
@khoipro
khoipro / style-editor.css
Created January 8, 2020 04:26
Example style-editor.css for applying custom style to Block Editor (Gutenberg) in WordPress 5.x+
@font-face {
font-family: "Inter var";
font-weight: 100 900; /* stylelint-disable-line font-weight-notation */
font-style: normal;
font-display: swap;
src: url('./assets/fonts/inter/Inter-upright-var.woff2') format("woff2");
}
@font-face {
font-family: "Inter var";
@khoipro
khoipro / functions.php
Created November 15, 2019 09:10
WordPress: Helper functions to get first category's metadata.
<?php
function your_theme_prefix_get_first_cat_object($page_id, $category_metadata) {
if ( empty($page_id) ) {
return new WP_Error('404', __('Missing $page_id parameter', 'your_theme_prefix'), array());
}
$categories = get_the_category($page_id);
return !empty($categories) ? $categories[0]->{$category_metadata} : null;
@khoipro
khoipro / functions.php
Last active April 13, 2020 02:58
Load CDN for ACF images and files assets. Work with srcset.
/**
* Add CDN Support for ACF fields
*/
function __get_domain_from_url($url = '') {
if( empty($url) ) {
$url = get_site_url(null, '', null);
}
$url_path = parse_url($url);
return $url_path['host'];
@khoipro
khoipro / bash.sh
Created August 28, 2019 08:18
vi editor commands
# To clear a whole file content
:1,$d
@khoipro
khoipro / deploy.sh
Created August 28, 2019 02:34
#Devops - Check Git remote repository exists
// Inside repositories loop
echo -e "[$SITE_NAME] Git URL: ${GIT_URL}"
// What is this?
// It check if repository exists or not and set remote url correctly.
// If not, sometime it will exit code 1 while running GitLab CI.
# Add git repo
git remote | grep "${SITE_NAME}" &> /dev/null
#!/bin/bash
set -e
# Script Name: deploy-multidev-pantheon.sh
# Author: khoiprodotcom
# Author URI: https://github.com/khoipro
# ========================================
# A, What is this script?
# It makes an automation deployment from single Gitlab repository to multiple Pantheon repositories which have the same tag.
#