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
<?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
<?php
add_filter( 'wpcf7_skip_mail', 'solusiprss_cf7_send_whatsapp', 10, 2 );
add_filter( 'wpcf7_display_message', 'solusipress_cf_wa_sent_message', 10, 2 );
add_action( 'wp_footer', 'solusipress_cf7_add_script_footer' );
function solusiprss_cf7_send_whatsapp( $skip_mail, $contact_form ) {
if( $contact_form->id() == 105 ) {
$skip_mail = true;
}
return $skip_mail;
}
.form-field {
margin-bottom: 10px;
}
.form-field label {
display:block;
}
.form-field .input,
.form-field textarea {
width: 100%;
}
<?php
add_action( 'wp_enqueue_scripts', 'solusipress_jquery_number_wa' );
function solusipress_jquery_number_wa() {
if( is_page( 'forminator-test-wa' ) ) {
wp_enqueue_script( 'jquery-number', 'https://businessprofile.solusipress.com/wp-content/uploads/custom-css-js/18.js', array('jquery') );
wp_enqueue_script( 'input-spinner', 'https://businessprofile.solusipress.com/wp-content/uploads/custom-css-js/105.js', array('jquery') );
wp_enqueue_script( 'underscore' );
}
}
add_action( 'wp_footer', 'solusipress_forminator_whatsapp' );
@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-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
/**
* Plugin Name: My WordPress Custom Form
* Plugin URI: https://solusipress.com/
* Description: Form untuk berbagai keperluan di website pribadi
* Author: Yerie Piscesa
* Author URI: https://solusipress.com/
* Text Domain: sp-custom-form
* Domain Path: /languages
* Version: 0.9.0
@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,