| Server IP : 185.252.147.100 / Your IP : 216.73.217.33 Web Server : nginx/1.27.3 System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64 User : mitr ( 1000) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/html/epauto.ru/wordpress/wp-content/plugins/acf-extended/includes/fields/ |
Upload File : |
<?php
if(!defined('ABSPATH')){
exit;
}
if(!class_exists('acfe_field_checkbox')):
class acfe_field_checkbox extends acfe_field_extend{
/**
* initialize
*/
function initialize(){
$this->name = 'checkbox';
}
/**
* format_front_value
*
* @param $formatted
* @param $unformatted
* @param $post_id
* @param $field
* @param $form
*
* @return string
*/
function format_front_value($formatted, $unformatted, $post_id, $field, $form){
// vars
$value = acf_get_array($unformatted);
$array = array();
// loop values
foreach($value as $v){
$array[] = acf_maybe_get($field['choices'], $v, $v);
}
// merge
return implode(', ', $array);
}
/**
* validate_front_value
*
* @param $valid
* @param $value
* @param $field
* @param $input
* @param $form
*
* @return false
*/
function validate_front_value($valid, $value, $field, $input, $form){
// bail early
if(!$this->pre_validate_front_value($valid, $value, $field, $form)){
return $valid;
}
// custom value allowed
if(!empty($field['allow_custom'])){
return $valid;
}
// vars
$value = acf_get_array($value);
$choices = acf_get_array($field['choices']);
// empty choices
if(empty($choices)){
return false; // value is always invalid as there no choice is allowed
}
// check values against choices
if(!empty(array_diff($value, array_keys($choices)))){
return false;
}
// return
return $valid;
}
}
acf_new_instance('acfe_field_checkbox');
endif;