Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
yeriepiscesa / functions.php
Created Feb 25, 2021
WP - map page to whatsapp
View functions.php
<?php
add_action( 'template_redirect', function(){
if( isset( $_GET['ref'] ) && $_GET['ref'] != '' ) {
$maps = [
"Andi" => "62812345678901",
"Mawar" => "62856345678901",
"Melati" => "62818345678901",
];
$ref = trim( $_GET['ref'] );
View custom-model-base.php
<?php
namespace SolusiPress\Model;
class Base {
public $db = null;
public $table = null;
protected $sqlOrder = '';
protected $sqlWhere = '';
View setup-database.php
<?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 Feb 18, 2021
WP URL Rewrite Sample
View request.php
<?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 Feb 17, 2021
Forminator Guestbook
View functions.php
<?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 Nov 17, 2020
CF7SendWA - Single Product Buy
View Additional Settings
woo_checkout_first_name: your-name
woo_checkout_phone: whatsapp
woo_checkout_order_note: order-note
@yeriepiscesa
yeriepiscesa / WA Body
Created Nov 17, 2020
CF7SendWA - Single Product WA
View WA Body
[your-message]
[your-name] / [your-phone]
@yeriepiscesa
yeriepiscesa / custom-checkout.php
Last active Feb 20, 2021
WooCommerce custom checkout fields
View custom-checkout.php
<?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 );
View class-whatsapp-checkout.php
<?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
View assets-contact-form.css
.form-field {
margin-bottom: 10px;
}
.form-field label {
display:block;
}
.form-field .input,
.form-field textarea {
width: 100%;
}