Skip to content

Instantly share code, notes, and snippets.

View sutandang's full-sized avatar

eringga sutandang

  • indonesia
  • yogyakarta , indonesia
View GitHub Profile
@sutandang
sutandang / tonjooblog-ssl.conf
Created January 21, 2015 03:26
vhost ssl(https) and vhost http
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin [email protected]
ServerName tonjooblog.dev
ServerAlias www.tonjooblog.dev
DocumentRoot /var/www/tonjooblog
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
<?php
/**
* This is a very basic getting started example for setting up a basic project using PSR-4 and
* using composer's autoloader to run the tests.
*
*/
// Create directory MyApp
// Inside MyApp/ create composer.json with the below contents
@sutandang
sutandang / getdistance.php
Last active August 29, 2015 14:23
get distance from many locations with google maps api v3
/*
$locations = array('longitude,latitude')
*/
function getDistance($locations)
{
$waypoints = $locations;
if(count($waypoints) > 2)
{
unset($waypoints[0]);
unset($waypoints[count($locations) - 1]);
<?php
// Skip the cart and redirect to check out url when clicking on Add to cart
add_filter ( 'add_to_cart_redirect', 'redirect_to_checkout' );
function redirect_to_checkout() {
global $woocommerce;
// Remove the default `Added to cart` message
wc_clear_notices();
return $woocommerce->cart->get_checkout_url();
/*************************
* Enqueue Media Uploader
*************************/
function enqueue_admin_scripts() {
if(function_exists('wp_enqueue_media')) {
wp_enqueue_media();
}
else {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
@sutandang
sutandang / add wp media in front end wordpress
Created November 7, 2016 04:07
create wp upload in front end wordpres
1. load media in controller / function.php / plugins
```
function enqueue_media_scripts() {
if(function_exists('wp_enqueue_media')) {
wp_enqueue_media();
}
else {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
@sutandang
sutandang / hooks-porduct-type
Created June 6, 2017 15:36
custom woocommerce product type in admin woocommerce / product tabs
<?php
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' , 99 , 1 );
function add_my_custom_product_data_tab( $product_data_tabs ) {
/*
to remove this product type unset all product type
unset($product_data_tabs['general']);
unset($product_data_tabs['inventory']);
unset($product_data_tabs['shipping']);
unset($product_data_tabs['linked_product']);
@sutandang
sutandang / alert-message-custome-wordpress
Created June 6, 2017 15:44
How to update message alert in custome post type wordpress
add_filter( 'post_updated_messages', 'update_new_messages' ,100);
function update_new_messages( $messages ) {
$post = get_post();
$post_type = get_post_type( $post );
$post_type_object = get_post_type_object( $post_type );
if($post_type != 'product')
return;
@sutandang
sutandang / add row to wordpress admin post type
Created June 6, 2017 15:47
how to add row to wordpress admin post type
add_filter('manage_inquiry_posts_columns', 'custom_table_head');
function custom_table_head( $defaults ) {
$defaults['author'] = 'Inquiry By';
$defaults['date'] = 'Created Date';
return $defaults;
}
@sutandang
sutandang / edit label in wordpress
Created June 6, 2017 15:49
edit label in wordpress
function my_custom_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Show all product types' :
$translated_text = __( 'Show all solutions types', 'woocommerce' );
break;
case 'Sort Products' :
$translated_text = __( 'Show Solutions', 'woocommerce' );
break;
case 'Product Data' :
$translated_text = __( 'Solutions Data', 'woocommerce' );