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 / .gitlab-ci.yml
Created June 24, 2019 09:30
Deploy from GitLab to WPEngine (Tested)
stages:
- deploy_dev
- deploy_staging
- deploy_live
before_script:
- 'which ssh-agent || ( apk add --update openssh )'
- apk add --update bash
- apk add --update git
- eval $(ssh-agent -s)
@khoipro
khoipro / author.php
Created May 15, 2019 07:08
Run `/author/demo/?old_author_id=5` for example to update current posts's author from old site.
<?php
/**
** Template: Author
** URL example: /author/demo
**/
$author = get_queried_object();
$current_author_id = $author->ID;
function get_post_by_title($page_title, $type = "post", $output = OBJECT) {
global $wpdb;
@khoipro
khoipro / helper.php
Last active April 19, 2019 16:06
Mask credit card, account number, etc... with XXXX, show just last 4 last strings/digits.
<?php
/**
* You can quick test with http://phptester.net/
**/
$account_number = '123123123';
$credit_card_number = '4242424242424242';
$account_length = strlen($account_number);
$credit_card_length = strlen($credit_card_number);
@khoipro
khoipro / your-template.php
Last active April 16, 2019 14:48
your-template.php (Gravity PDF Custom Template)
<?php
/*
* Template Name: Your Template
* Version: 1.0
*/
if ( ! class_exists( 'GFForms' ) ) {
return;
}
?>
@khoipro
khoipro / your-template.php
Created April 16, 2019 02:59
config/your-template.php (GravityPDF custom template)
<?php
namespace GFPDF\Templates\Config;
use GFPDF\Helper\Helper_Interface_Config;
/* Exit if accessed directly */
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@khoipro
khoipro / ajax-submit-process.php
Created March 18, 2019 15:06
WordPress: Submit a custom post type using AJAX
<?php
/**
* These functions to process ebook submit in my project
*/
add_action('wp_ajax_validate_ebook_submit_form_callback', 'validate_ebook_submit_form_callback');
add_action('wp_ajax_nopriv_validate_ebook_submit_form_callback', 'validate_ebook_submit_form_callback');
function validate_ebook_submit_form_callback() {
if (
@khoipro
khoipro / index.html
Created December 1, 2018 03:31
zooming Javascript package example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
.grid {
column-count: 2;
column-gap: 1rem;
}
@khoipro
khoipro / single-event.php
Created October 23, 2018 08:25
Tribe Events Single Event Default Template
<div id="tribe-events-content" class="tribe-events-single">
<p class="tribe-events-back">
<a href="<?php echo esc_url( tribe_get_events_link() ); ?>"> <?php printf( '&laquo; ' . esc_html_x( 'All %s', '%s Events plural label', 'the-events-calendar' ), $events_label_plural ); ?></a>
</p>
<!-- Notices -->
<?php tribe_the_notices() ?>
<?php the_title( '<h1 class="tribe-events-single-event-title">', '</h1>' ); ?>
<?php
/**
* Data-module là nơi tôi gọi tới function Header(el) trong Javascript
**/
?>
<header class="header" data-module="header">
<div class="header__wrapper">
<?php
if( has_nav_menu('header' ) {
wp_nav_menu(array(
{% comment %}
If you have multiple product fields, for example:
blog.settings.product_1
blog.settings.product_2
blog.settings.product_3
{% endcomment %}
{% assign product_handle = '' %}
{% for i in (1..5) %}
{% assign product_handle = 'blog.settings.product_' | append: i %}
{% assign product = all_products[product_handle] %}