Skip to content

Instantly share code, notes, and snippets.

Avatar
🙂
Happy and peace when coding

Tran Ngoc Tuan Anh rilwis

🙂
Happy and peace when coding
View GitHub Profile
@rilwis
rilwis / backup.sh
Last active Dec 3, 2016
Backup databases and upload to Dropbox
View backup.sh
#!/usr/bin/env bash
set -o errexit
set -eo pipefail
main() {
local folder=/path/to/backup/folder/
local today=$(date +%F)
local user="YOUR MYSQL USERNAME"
local password="YOUR MYSQL PASSWORD"
@rilwis
rilwis / example.php
Created Dec 30, 2016
Show checkbox list values from a cloned group
View example.php
<?php
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
$meta_boxes[] = [
'title' => 'Group',
'fields' => [
[
'type' => 'group',
'id' => 'group',
'clone' => true,
'fields' => [
@rilwis
rilwis / related-posts.php
Created Jan 20, 2017
Related posts with Meta Box
View related-posts.php
@rilwis
rilwis / demo.php
Created Apr 17, 2017
Hierarchical select/checkbox_list
View demo.php
<?php
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
$meta_boxes[] = array(
'title' => 'Test',
'fields' => array(
array(
'type' => 'select_tree', // or checkbox_list
'id' => 'cb',
'name' => 'Hierarchical checkboxes',
'options' => array(
@rilwis
rilwis / code.php
Last active Aug 18, 2017
How to save WYSIWYG content as post content
View code.php
<?php
/**
* This demo shows you how to save WYSIWYG field content created by Meta Box plugin as post content.
*
* @link https://metabox.io/docs/how-to-save-wysiwyg-content-as-post-content
*/
add_action( 'init', function () {
// Remove the editor for the post type.
remove_post_type_support( 'post', 'editor' ); // Change 'post' to your custom post type.
@rilwis
rilwis / clone-group-inherit-values.php
Created Nov 13, 2017
Cloneable group inheriting values from previous group
View clone-group-inherit-values.php
<?php
$meta_boxes[] = array(
'title' => __( 'Content blocks' ),
'post_types' => 'page',
'fields' => array(
array(
'id' => 'content-block',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
@rilwis
rilwis / functions.php
Last active Oct 29, 2018
Optimize BB for loading
View functions.php
<?php
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'font-awesome' );
wp_dequeue_script( 'jquery-magnificpopup' );
wp_dequeue_style( 'jquery-magnificpopup' );
wp_dequeue_script( 'jquery-waypoints' );
wp_dequeue_script( 'imagesloaded' );
wp_dequeue_script( 'jquery-throttle' );
@rilwis
rilwis / functions.php
Last active Apr 13, 2019
Create Landing Page With Custom Fields
View functions.php
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
$meta_boxes[] = array(
'title' => 'Section Hero',
'post_types' => 'page',
'fields' => array(
array(
'id' => 'hero_title',
'name' => 'Title',
'type' => 'text',
@rilwis
rilwis / flexible-content-field-by-meta-box.php
Last active Jun 9, 2019 — forked from kutoi94/flexible-by-meta-box
Create ACF Flexible Field with Meta Box Plugin
View flexible-content-field-by-meta-box.php
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Flexible Field Example',
'post_types' => 'page',
'fields' => array(
array (
'id' => 'sections',
'type' => 'group',
@rilwis
rilwis / remove-resources.php
Created Jun 1, 2016
Remove scripts and styles for metabox.io
View remove-resources.php
<?php
// Remove styles of plugin
add_filter( 'jetpack_implode_frontend_css', '__return_false' );
add_filter( 'bbp_default_styles', '__return_empty_array' );
// Remove bbPress scripts on non-bbPress pages
add_filter( 'bbp_default_scripts', function ( $scripts )
{
return is_bbpress() ? $scripts : [ ];
} );
You can’t perform that action at this time.