| Server IP : 145.239.37.162 / Your IP : 216.73.217.126 Web Server : Apache System : Linux webm003.cluster130.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaa ( 38250) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaa/www_old/wp-content/themes/betheme/muffin-options/fields/checkbox/ |
Upload File : |
<?php
class MFN_Options_checkbox extends MFN_Options
{
protected $field = array();
protected $value = '';
protected $prefix = false;
/**
* Constructor
*/
public function __construct($field = array(), $value = '', $prefix = false)
{
$this->field = $field;
$this->value = $value;
$this->prefix = $prefix;
}
/**
* Render
*/
public function render($meta = false)
{
// class
if (isset($this->field['class'])) {
$class = $this->field['class'];
} else {
$class = '';
}
// name
if ($meta) {
// page mata & builder existing items
$name = $this->field['id'];
} else {
// theme options
$name = $this->prefix .'['. $this->field['id'] .']';
}
// output -----
if (is_array($this->field[ 'options' ])) {
// multiple checkboxes
if (! isset($this->value)) {
$this->value = array();
}
if (! is_array($this->value)) {
$this->value = array();
}
echo '<div class="mfnf-checkbox multi '. esc_attr($class) .'">';
// FIX | Post Meta Save | All values unchecked
echo '<input type="hidden" name="'. esc_attr($name). '[post-meta]" value="1" checked="checked" />';
echo '<ul>';
foreach ($this->field['options'] as $k => $v) {
if (! key_exists($k, $this->value)) {
$this->value[$k] = '';
}
echo '<li>';
echo '<label>';
echo '<input type="checkbox" name="'. esc_attr($name) . '['.esc_attr($k).']" value="'. esc_attr($k) .'" '. checked($this->value[$k], $k, false) .' />';
echo '<span class="label">'. wp_kses($v, mfn_allowed_html('desc')) .'</span>';
echo '</label>';
echo '</li>';
}
echo '</ul>';
if (isset($this->field['desc']) && ! empty($this->field['desc'])) {
echo '<span class="description">'. wp_kses($this->field['desc'], mfn_allowed_html('desc')) .'</span>';
}
echo '</div>';
} else {
// single checkbox
echo 'please use "switch" field for single checkbox';
}
}
}