Skip to content

Instantly share code, notes, and snippets.

View rilwis's full-sized avatar
🙂
Happy and peace when coding

Anh Tran rilwis

🙂
Happy and peace when coding
View GitHub Profile
@rilwis
rilwis / backup.sh
Last active December 3, 2016 03:42
Backup databases and upload to Dropbox
#!/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 / custom.php
Created July 23, 2016 01:48
MB Admin Columns - Add Custom Non-Meta Column
<?php
class Prefix_Custom_Admin_Columns extends MB_Admin_Columns_Post {
public function columns( $columns ) {
$columns = parent::columns( $columns );
/**
* Add more column in a specific position
*
* @param string $position New column position. Empty to not specify the position. Could be 'before', 'after' or 'replace'
* @param string $target The target column. Used with combination with $position
@rilwis
rilwis / include-extension.php
Created June 6, 2016 02:08
Include Meta Box extension in themes/plugins
<?php
require_once get_template_directory() . '/class-tgm-plugin-activation.php'; // Path to TGM Plugin Activation class.
add_action( 'tgmpa_register', 'your_prefix_register_required_plugins' );
function your_prefix_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
@rilwis
rilwis / remove-resources.php
Created June 1, 2016 05:52
Remove scripts and styles for metabox.io
<?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 : [ ];
} );
@rilwis
rilwis / nested1.php
Created May 17, 2016 01:34
Nested group demo
<?php
add_filter( 'rwmb_meta_boxes', 'nested_groups_demo' );
function nested_groups_demo( $meta_boxes )
{
// Meta Box
$meta_boxes[] = array(
'title' => __( 'Books', 'rwmb' ),
'fields' => array(
@rilwis
rilwis / register.php
Created May 11, 2016 02:47
Live update custom_html field
<?php
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes )
{
$meta_boxes[] = array(
'title' => 'Update custom html field demo',
'fields' => [
[
'name' => 'Group',
'type' => 'group',
'id' => 'group',
<?php
class acf_field_gravity_forms extends acf_field {
function __construct() {
$this->name = 'gravity_forms_field';
$this->label = __( 'Gravity Forms', 'acf' );
$this->category = __( "Relational", 'acf');
$this->defaults = array(
'multiple' => 0,
@rilwis
rilwis / register-meta-box.php
Created March 6, 2015 04:36
Group with better-include demo
<?php
global $meta_boxes;
$meta_boxes = array();
$meta_boxes[] = array(
'title' => 'Pedigree',
'only_on' => array(
'id' => array( 1 ), // Show only on "Hello World" post
),
'fields' => array(
@rilwis
rilwis / add-data.php
Created March 5, 2015 10:39
Support to migrating data to a group
<?php
$data = array(
array(
'year' => 2013,
'title' => 'Test',
'wins' => 1,
'podiums' => 2,
'poles' => 3,
'description' => 'test description',
),
@rilwis
rilwis / admin-body-class.php
Created February 12, 2013 16:25
Style Add New / Edit Post page in WordPress using admin body class. @see http://www.deluxeblogtips.com/?p=1281
<?php
/*
Plugin Name: Admin Body Class Demo
Plugin URI: http://www.deluxeblogtips.com/?p=1281
Description: Style Add New / Edit Post page in WordPress using admin body class
Version: 0.1
Author: Rilwis
Author URI: http://www.deluxeblogtips.com
License: GPL2+
*/