This plugin was very good but it has not been working recently. and it is not updated for 6 years.
would you please update it?
]]>Hello
Please update the plugin to work with the latest version of wordpress and php.
i have make some changes to the code to make it work with my wordpress instance.
Here is the update code that works with php 8.2 and the latest wordpress version.
the change needs to be in the includes\short_code/short_code.php
// Prevent direct access
defined('ABSPATH') || exit;
// WHMCS Short Code
$options = get_option('whmcs_price_option');
$whmcs_url = isset($options['whmcs_url']) ? $options['whmcs_url'] : '';
if (!empty($whmcs_url) && filter_var($whmcs_url, FILTER_VALIDATE_URL)) {
function whmcs_func($atts)
{
$options = get_option('whmcs_price_option');
$whmcs_url = isset($options['whmcs_url']) ? $options['whmcs_url'] : '';
// Sanitize input attributes
$atts = array_map('sanitize_text_field', $atts);
// Validate and sanitize pid and bc
if (isset($atts['pid']) && isset($atts['bc'])) {
$pid = intval($atts['pid']);
$bc = sanitize_text_field($atts['bc']);
$bc_r = '';
switch ($bc) {
case "1m":
$bc_r = "monthly";
break;
case "3m":
$bc_r = "quarterly";
break;
case "6m":
$bc_r = "semiannually";
break;
case "1y":
$bc_r = "annually";
break;
case "2y":
$bc_r = "biennially";
break;
case "3y":
$bc_r = "triennially";
break;
default:
return "NA"; // Handle unrecognized billing cycle
}
// Fetch remote content
$amount = wp_remote_get("$whmcs_url/feeds/productsinfo.php?pid=$pid&get=price&billingcycle=$bc_r");
if (is_wp_error($amount) || wp_remote_retrieve_response_code($amount) !== 200) {
return "NA"; // Handle failed request
}
$output = wp_remote_retrieve_body($amount);
// Remove JavaScript 'document.write()' calls
$output = preg_replace('/document\.write\(\'/', '', $output);
$output = preg_replace('/\'\);/', '', $output);
return "<div class='whmcs-price'>$output</div>";
} elseif (isset($atts['tld']) && isset($atts['type']) && isset($atts['reg'])) {
$tld = "." . sanitize_text_field($atts['tld']);
$type = sanitize_text_field($atts['type']);
$reg = sanitize_text_field($atts['reg']);
$reg_r = str_replace("y", "", $reg);
// Fetch remote content
$amount = wp_remote_get("$whmcs_url/feeds/domainprice.php?tld=$tld&type=$type®period=$reg_r&format=1");
if (is_wp_error($amount) || wp_remote_retrieve_response_code($amount) !== 200) {
return "NA"; // Handle failed request
}
$output = wp_remote_retrieve_body($amount);
// Remove JavaScript 'document.write()' calls
$output = preg_replace('/document\.write\(\'/', '', $output);
$output = preg_replace('/\'\);/', '', $output);
return "<div class='whmcs-price'>$output</div>";
} else {
// If no TLD is given, show feeds/domainpricing.php
// Fetch remote content
$amount = wp_remote_get("$whmcs_url/feeds/domainpricing.php");
if (is_wp_error($amount) || wp_remote_retrieve_response_code($amount) !== 200) {
return "NA"; // Handle failed request
}
$output = wp_remote_retrieve_body($amount);
// Remove JavaScript 'document.write()' calls
$output = preg_replace('/document\.write\(\'/', '', $output);
$output = preg_replace('/\'\);/', '', $output);
return "<div class='whmcs-price'>$output</div>";
}
}
// Register ShortCodes
function whmcspr_shortcodes()
{
add_shortcode('whmcs', 'whmcs_func');
}
add_action('init', 'whmcspr_shortcodes');
}
?>
what this dose that if the [whmcs tld] is like this it will take all the Domain TLDs from domainpricing.php without any parameters so it will show all the domain TLDs.
also i have made changes to the include/settings.php to reflect this new change
if (!defined('ABSPATH')) {
die('Access Denied');
}
class WHMCSPrice
{
private array $options = [];
public function __construct()
{
add_action('admin_menu', [$this, 'whmcspr_plugin_page']);
add_action('admin_init', [$this, 'whmcspr_init']);
}
public function whmcspr_plugin_page()
{
add_options_page(
'WHMCS Price Options',
'WHMCS Price Options',
'manage_options',
'whmcs_price',
[$this, 'whmcspr_admin_page']
);
}
public function whmcspr_admin_page()
{
$this->options = get_option('whmcs_price_option', []);
?>
<style type="text/css">
pre {
padding: 25px;
line-height: 1;
word-break: break-all;
word-wrap: break-word;
color: #333;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
width: 80%;
}
code {
padding-left: 0 !important;
line-height: 2;
}
</style>
<div class="wrap">
<h1>WHMCS Price Options</h1>
<form method="post" action="options.php">
<?php
settings_fields('price_option_group');
do_settings_sections('whmcs_price');
?>
</form>
</div>
<?php
}
public function whmcspr_init()
{
register_setting(
'price_option_group',
'whmcs_price_option',
[$this, 'sanitize']
);
add_settings_section(
'setting_section_id',
'',
[$this, 'print_section_info'],
'whmcs_price'
);
add_settings_field(
'whmcs_url',
'WHMCS URL',
[$this, 'whmcs_url_callback'],
'whmcs_price',
'setting_section_id'
);
add_settings_field(
'products',
'Product Pricing',
[$this, 'p_price_callback'],
'whmcs_price',
'setting_section_id'
);
add_settings_field(
'domains',
'Domain Pricing',
[$this, 'd_price_callback'],
'whmcs_price',
'setting_section_id'
);
}
public function sanitize($input): array
{
$new_input = [];
if (isset($input['whmcs_url'])) {
$new_input['whmcs_url'] = sanitize_text_field($input['whmcs_url']);
}
return $new_input;
}
public function print_section_info()
{
print 'Dynamic way for extracting price from WHMCS for use on the pages of your website!<br /><br />Please input your WHMCS URL :';
}
public function whmcs_url_callback()
{
$options = $this->options;
$whmcs_url = $options['whmcs_url'] ?? '';
if (isset($whmcs_url) && !empty($whmcs_url) && !filter_var($whmcs_url, FILTER_VALIDATE_URL)) {
printf('<p style="color:red">Hey ! Your domain is not Valid !<p>');
}
printf(
'<input type="text" id="whmcs_url" style="width:310px; direction:ltr;" name="whmcs_price_option[whmcs_url]" value="%s" placeholder="https://whmcsdomain.tld" /><br /><p style="color:green">Valid URL Format: https://whmcs.com (Dont use "/" End of WHMCS URL)</p><br />',
esc_attr($whmcs_url)
);
submit_button();
echo "<p>Note: After change price in whmcs, if you are using cache plugin in your wordpress, for update price you must remove cache for post and pages.</p>";
printf('<hr>');
}
public function p_price_callback()
{
printf(
'<strong>How to use short code in :</strong><br /><br />Post / Pages : <input type="text" style="width:343px; direction:ltr; cursor: pointer;" value="[whmcs pid="1" bc="1m"]" onclick="this.select()" readonly /><br /><br />Theme : <input type="text" style="width:500px; direction:ltr; cursor: pointer;" value="<?php echo do_shortcode(\'[whmcs pid="1" bc="1m"]\'); ?>" onclick="this.select()" readonly /><br /><br />
<pre><strong>English Document:</strong><br />
1. Change pid value in shortcode with your Product ID.<br />
2. Change bc value in shortcode with your BillingCycle Product. BillingCycles are :<br /><br /><code>Monthly (1 Month) : bc="1m"<br />Quarterly (3 Month) : bc="3m"<br />Semiannually (6 Month) : bc="6m"<br />Annually (1 Year) : bc="1y"<br />Biennially (2 Year) : bc="2y"<br />Triennially (3 Year) : bc="3y"</code><br /><br /><strong>
<hr>'
);
}
public function d_price_callback()
{
printf(
'<strong>How to use short code in :</strong><br /><br />Post / Pages : <input type="text" style="width:343px; direction:ltr; cursor: pointer;" value="[whmcs tld="com" type="register" reg="1y"]" onclick="this.select()" readonly /><br /><br />Theme : <input type="text" style="width:500px; direction:ltr; cursor: pointer;" value="<?php echo do_shortcode(\'[whmcs tld="com" type="register" reg="1y"]\'); ?>" onclick="this.select()" readonly /><br /><br />
<pre><strong>English Document:</strong><br />
1. Change tld value in shortcode with your Domain TLD (<code>com, org, net, ...</code>).<br />
2. Change type value in shortcode with <code>register, renew, transfer</code> .<br />
3. Change reg value in shortcode with your Register Period of TLD. Registers Period are :<br /><br /><code>Annually (1 Year) : reg="1y"<br />Biennially (2 Year) : reg="2y"<br />Triennially (3 Year) : reg="3y"<br />...</code><br />
4. If left like this <code>[whmcs tld]</code> it will call without any Domain TLD and it will take all the TLD that is in WHMCS<br /><br /><strong>
<hr>'
);
}
}
if (is_admin()) {
new WHMCSPrice();
}
?>
Please update the code with these changes ??
]]>I spent 4 hours on this plugin, but I could not get the prices to be divided by the number of months. For some reason I don’t understand why, splitting cannot be done only with this plugin. For example, if the 1-year price is drawn, I need to divide it by 12 and display this result. Can you help with this?
]]>Hello,
Is it possible to specify currency in the shortcode? It’s showing $-1.00 I think it’s because pricing in USD is not defined.-
]]>???? 1.3 ??? ?????? ?? ?????? ???? 5.2.2 ???? ?? ?? ???? ?????.
plugin ver: 1.3
Wordpress ver: 5.2.2
Whmcs ver: 7.7.1
How can I show WHMCS Setup Fee (Price) with your plugins?
]]>