1. Shortcode WordPress untuk Kalkulator ROI
Tambahkan kode ini ke file functions.php tema Anda atau buat plugin kecil:
function kalkulator_roi_shortcode() {
ob_start();
?>
<div style="max-width: 400px; margin: 20px auto; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); font-family: Arial, sans-serif;">
<h3 style="text-align:center; color:#2563eb;">Kalkulator Estimasi Bagi Hasil</h3>
<label>Modal yang Disertakan (Rp)</label>
<input type="number" id="modal" style="width:100%; padding:8px; margin-bottom:10px;" placeholder="Contoh: 1000000" />
<label>Estimasi Laba Bersih Usaha (Rp)</label>
<input type="number" id="laba" style="width:100%; padding:8px; margin-bottom:10px;" placeholder="Contoh: 2000000" />
<label>Jumlah Penyerta Modal</label>
<input type="number" id="penyerta" style="width:100%; padding:8px; margin-bottom:10px;" placeholder="Contoh: 4" />
<button onclick="hitungROI()" style="width:100%; padding:10px; background:#2563eb; color:#fff; border:none; border-radius:4px; cursor:pointer;">Hitung Estimasi ROI</button>
<div id="hasil" style="margin-top:15px; text-align:center; color:green; font-weight:bold;"></div>
</div>
<script>
function hitungROI() {
const modal = parseFloat(document.getElementById('modal').value);
const laba = parseFloat(document.getElementById('laba').value);
const penyerta = parseInt(document.getElementById('penyerta').value);
const hasilDiv = document.getElementById('hasil');
if (isNaN(modal) || isNaN(laba) || isNaN(penyerta) || penyerta === 0) {
hasilDiv.innerText = 'Mohon isi semua kolom dengan benar.';
return;
}
const bagianInvestor = 0.3 * laba;
const bagiPerOrang = bagianInvestor / penyerta;
const roi = (bagiPerOrang / modal) * 100;
hasilDiv.innerHTML = `
Estimasi Bagi Hasil per Investor: <strong>Rp ${bagiPerOrang.toLocaleString()}</strong><br>
Estimasi ROI: <strong>${roi.toFixed(2)}%</strong>
`;
}
</script>
<?php
return ob_get_clean();
}
add_shortcode('kalkulator_roi', 'kalkulator_roi_shortcode');
Cara pakai shortcode ini:
Pasang kode di atas ke
functions.phptema aktif Anda, atau buat plugin khusus.Di halaman atau post WordPress, cukup ketik:
[kalkulator_roi]
Kalkulator akan langsung muncul di halaman.
2. Kode iframe embed
Jika Anda sudah punya file HTML kalkulator (misal kalkulator-roi-urundana.html di hosting Anda), gunakan kode iframe ini untuk embed:
<iframe src="https://domain-anda.com/kalkulator-roi-urundana.html" width="100%" height="400" style="border:none;"></iframe>
Ganti https://domain-anda.com/kalkulator-roi-urundana.html dengan URL file Anda.
3. Plugin WordPress sederhana
Saya buatkan plugin kecil untuk kalkulator ROI.
Buat folder
kalkulator-roidi/wp-content/plugins/Buat file
kalkulator-roi.phpdi folder itu dengan isi berikut:
<?php
/*
Plugin Name: Kalkulator ROI UrunDana
Description: Plugin Kalkulator Estimasi Bagi Hasil untuk Urun Dana Koperasi KNAB.
Version: 1.0
Author: ChatGPT
*/
function kr_roi_shortcode() {
ob_start();
?>
<div style="max-width: 400px; margin: 20px auto; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); font-family: Arial, sans-serif;">
<h3 style="text-align:center; color:#2563eb;">Kalkulator Estimasi Bagi Hasil</h3>
<label>Modal yang Disertakan (Rp)</label>
<input type="number" id="modal" style="width:100%; padding:8px; margin-bottom:10px;" placeholder="Contoh: 1000000" />
<label>Estimasi Laba Bersih Usaha (Rp)</label>
<input type="number" id="laba" style="width:100%; padding:8px; margin-bottom:10px;" placeholder="Contoh: 2000000" />
<label>Jumlah Penyerta Modal</label>
<input type="number" id="penyerta" style="width:100%; padding:8px; margin-bottom:10px;" placeholder="Contoh: 4" />
<button onclick="hitungROI()" style="width:100%; padding:10px; background:#2563eb; color:#fff; border:none; border-radius:4px; cursor:pointer;">Hitung Estimasi ROI</button>
<div id="hasil" style="margin-top:15px; text-align:center; color:green; font-weight:bold;"></div>
</div>
<script>
function hitungROI() {
const modal = parseFloat(document.getElementById('modal').value);
const laba = parseFloat(document.getElementById('laba').value);
const penyerta = parseInt(document.getElementById('penyerta').value);
const hasilDiv = document.getElementById('hasil');
if (isNaN(modal) || isNaN(laba) || isNaN(penyerta) || penyerta === 0) {
hasilDiv.innerText = 'Mohon isi semua kolom dengan benar.';
return;
}
const bagianInvestor = 0.3 * laba;
const bagiPerOrang = bagianInvestor / penyerta;
const roi = (bagiPerOrang / modal) * 100;
hasilDiv.innerHTML = `
Estimasi Bagi Hasil per Investor: <strong>Rp ${bagiPerOrang.toLocaleString()}</strong><br>
Estimasi ROI: <strong>${roi.toFixed(2)}%</strong>
`;
}
</script>
<?php
return ob_get_clean();
}
add_shortcode('kalkulator_roi', 'kr_roi_shortcode');
Cara install plugin:
Upload folder
kalkulator-roike/wp-content/plugins/Aktifkan plugin lewat menu Plugins di dashboard WordPress
Pakai shortcode
[kalkulator_roi]di halaman/post manapun
Kalau mau saya kirimkan file plugin siap zip juga, tinggal upload langsung ke WordPress Anda?
Atau mau saya buatkan dokumentasi pemasangan lengkap?
Beritahu saya ya!