Skip to content

Instantly share code, notes, and snippets.

View gamaup's full-sized avatar

Gama Unggul Priambada gamaup

  • Inncomedia
  • Yogyakarta, ID
View GitHub Profile
@gamaup
gamaup / classic-editor.html
Created January 17, 2023 07:33
WordPress HTML Markups
<p><strong>Headings</strong></p>
<h1>Header one</h1>
<h2>Header two</h2>
<h3>Header three</h3>
<h4>Header four</h4>
<h5>Header five</h5>
<h6>Header six</h6>
<h2>Blockquotes</h2>
<p>Single line blockquote:</p>
<blockquote><p>Stay hungry. Stay foolish.</p></blockquote>
@gamaup
gamaup / defer-comment-reply.php
Last active July 19, 2022 01:58
PSI Optimization
<?php
function wp_dereg_script_comment_reply(){
wp_deregister_script( 'comment-reply' );
}
add_action('init','wp_dereg_script_comment_reply');
add_action('wp_head', 'wp_reload_script_comment_reply');
function wp_reload_script_comment_reply() {
?>
@gamaup
gamaup / functions.php
Created October 6, 2021 10:43
Passing parameters into add_action
<?php
$variable = "Some value"; // bisa array juga.
add_action( 'hook_name, function() use ($variable) {
// callback.
});
@gamaup
gamaup / single-action-scheduler.php
Last active September 10, 2021 07:27
Action Scheduler & Monolog Sample
<?php
// Pastikan plugin berikut telah terinstall & aktif
// Action Scheduler : https://wordpress.org/plugins/action-scheduler/
// WP Monolog : https://git.tonjoo.com/tonjoo/wp-monolog
/**
* Create job queue
*
* Param 1: Timestamp kapan job akan dirun. Isi pakai time() kalau job ingin dirun sekarang juga.
@gamaup
gamaup / functions.php
Created September 30, 2020 03:26
Change Checkout Address Label
<?php
// method 1.
add_filter( 'woocommerce_checkout_fields', function( $fields ) {
$fields['billing']['billing_state']['label'] = 'Provinsi';
$fields['billing']['billing_city']['label'] = 'Kabupaten';
$fields['billing']['billing_district']['label'] = 'Kecamatan';
$fields['shipping']['shipping_state']['label'] = 'Provinsi';
$fields['shipping']['shipping_city']['label'] = 'Kabupaten';
$fields['shipping']['shipping_district']['label'] = 'Kecamatan';
<?php
add_action( 'admin_menu', 'tair_admin_menu' );
function tair_admin_menu() {
add_menu_page( 'Tes airtable', 'Tes airtable', 'manage_options', 'tair', 'tair_admin' );
}
function tair_admin() {
global $wp_version;
$records = wp_remote_get( 'https://api.airtable.com/v0/appOc1ESRgBBFWbW9/Places?view=High%20priority', array(
@gamaup
gamaup / global_rule.php
Last active April 2, 2018 03:22
Custom Price Rules data structure
<?php
$rules = array(
"ruleset_f45Is7PCFWd4mjU" => array(
"label" => "Ruleset Name",
"enabled" => true,
"rules" => array(
"rule_mVk9lHtMJLw38vD" => array(
"label" => "Rule Name",
"method" => "bulk",
"rewards" => array(
@gamaup
gamaup / search.sql
Last active July 25, 2017 07:33
Get nearby location based on lat-long set on postmeta.
set @latitude = xxx; — center latitude
set @longitude = xxx; — center longitude
set @distance = xx; — search distance (miles)
select p.ID, p.post_name, ((ACOS(SIN(@latitude * PI() / 180) * SIN('latitude.meta_value' * PI() / 180) + COS(@latitude * PI() / 180) * COS('latitude.meta_value' * PI() / 180) * COS((@longitude – 'longitude.meta_value') * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance
from wp_posts p
left join wp_postmeta latitude on latitude.post_id = p.ID and latitude.meta_key = '_latitude'
left join wp_postmeta longitude on longitude.post_id = p.ID and longitude.meta_key = '_longitude'
having distance < @distance;
@gamaup
gamaup / functions.php
Last active July 10, 2017 03:41
Bootstrap flash alert using Tiga Session
class Flash_Alert {
private $session;
function __construct() {
$this->session = new \Tiga\Session();
}
public function error($message) {
$this->add('danger', $message);
@gamaup
gamaup / functions.php
Last active December 9, 2019 07:47
Filter Kurir Rajaongkir pada Plugin Ongkos Kirim
<?php
add_filter('pok_rates', 'filter_couriers', 10, 2);
function filter_couriers($rates, $package) {
$filtered_rates = array();
$selected_courier = array(
'JNE - REG',
'JNE - OKE',
'JNE - YES'
);