Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
yeriepiscesa / Endpoint.txt
Last active January 18, 2024 13:22
API Wilayah Indonesia WordPress
GET https://your-domain.com/wp-json/wilayah/v1/provinsi
GET https://your-domain.com/wp-json/wilayah/v1/kabkota/<id_propinsi>
GET https://your-domain.com/wp-json/wilayah/v1/kecamatan/<id_kabkota>
GET https://your-domain.com/wp-json/wilayah/v1/kelurahan/<id_kecamatan>
# Pagination
GET https://your-domain.com/wp-json/wilayah/v1/provinsi?per_page=10&page=1
GET https://your-domain.com/wp-json/wilayah/v1/kabkota/<id_propinsi>?per_page=10&page=1
GET https://your-domain.com/wp-json/wilayah/v1/kecamatan/<id_kabkota>?per_page=10&page=1
GET https://your-domain.com/wp-json/wilayah/v1/kelurahan/<id_kecamatan>?per_page=10&page=1
@yeriepiscesa
yeriepiscesa / functions.php
Created February 25, 2021 04:40
WP - map page to whatsapp
<?php
add_action( 'template_redirect', function(){
if( isset( $_GET['ref'] ) && $_GET['ref'] != '' ) {
$maps = [
"Andi" => "62812345678901",
"Mawar" => "62856345678901",
"Melati" => "62818345678901",
];
$ref = trim( $_GET['ref'] );
@yeriepiscesa
yeriepiscesa / custom-model-base.php
Last active February 18, 2021 04:05
WPDB sample
<?php
namespace SolusiPress\Model;
class Base {
public $db = null;
public $table = null;
protected $sqlOrder = '';
protected $sqlWhere = '';
@yeriepiscesa
yeriepiscesa / setup-database.php
Created February 18, 2021 03:56
dbDelta sample
<?php
global $wpdb;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$sql = "CREATE TABLE `{$wpdb->prefix}app_employees` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`post_id` BIGINT(20) DEFAULT NULL,
`emp_number` VARCHAR(20) COLLATE {$wpdb->collate} DEFAULT NULL,
`full_name` VARCHAR(100) COLLATE {$wpdb->collate} DEFAULT NULL,
`gender` VARCHAR(6) COLLATE {$wpdb->collate} DEFAULT NULL,
@yeriepiscesa
yeriepiscesa / request.php
Created February 18, 2021 03:23
WP URL Rewrite Sample
<?php
class Request {
public static $pagename = null;
public static $module = null;
public static $action_page = null;
public static $action_id = null;
public static $app_slug = null;
@yeriepiscesa
yeriepiscesa / functions.php
Created February 17, 2021 11:26
Forminator Guestbook
<?php
class GuestBook {
private $form_id = '1035'; // gunakan ID form Anda
private $page_slug = 'buku-tamu'; // pastikan sesuai dengan slug halaman Anda
public function __construct(){
add_action( 'wp_ajax_guestbook_entries', [$this, 'get_guestbook_entries' ] );
add_action( 'wp_ajax_nopriv_guestbook_entries', [$this, 'get_guestbook_entries' ] );
add_action( 'wp_enqueue_scripts', [$this, 'set_styling' ], 999 );
add_action( 'forminator_after_form_render', [$this, 'custom_script_after_form_render' ], 10, 5 );
@yeriepiscesa
yeriepiscesa / Additional Settings
Last active November 17, 2020 14:20
CF7SendWA - Single Product Buy
woo_checkout_first_name: your-name
woo_checkout_phone: whatsapp
woo_checkout_order_note: order-note
@yeriepiscesa
yeriepiscesa / WA Body
Created November 17, 2020 02:18
CF7SendWA - Single Product WA
[your-message]
[your-name] / [your-phone]
@yeriepiscesa
yeriepiscesa / custom-checkout.php
Last active February 20, 2021 01:16
WooCommerce custom checkout fields
<?php
class SolusiPress_Custom_Woo_Checkout {
public function __construct() {
add_filter( 'woocommerce_default_address_fields', array( $this, 'woo_address_fields' ), 50, 1 );
add_filter( 'woocommerce_checkout_fields', array( $this, 'woo_checkout_fields' ) );
// first & last name merge
add_filter( 'default_checkout_billing_first_name', array( $this, 'first_name_default_value' ), 10, 2 );
add_filter( 'default_checkout_shipping_first_name', array( $this, 'first_name_default_value' ), 10, 2 );
add_filter( 'woocommerce_checkout_posted_data', array( $this, 'checkout_full_name_posted_data' ), 11 );
<?php
class SolusiPress_WA_Checkout {
protected $version = '0.9.2';
protected $wa_number = '6281314997198';
protected $resend_text = 'Click here if your browser not redirect to WhatsApp';
protected $wa_message_template = <<<EOT
Halo kak,
Berikut pesanan saya, mohon segera diproses