芝麻web文件管理V1.00
编辑当前文件:/home/projzpbv/public_html/wp-content/plugins/ninja-forms/includes/Fields/ListCheckbox.php
_nicename = esc_html__( 'Checkbox List', 'ninja-forms' ); add_filter( 'ninja_forms_merge_tag_calc_value_' . $this->_type, array( $this, 'get_calc_value' ), 10, 2 ); } public function admin_form_element( $id, $value ) { $form_id = get_post_meta( absint( $_GET[ 'post' ] ), '_form_id', true ); $field = Ninja_Forms()->form( $form_id )->get_field( $id ); $settings = $field->get_settings(); $options = $field->get_setting( 'options' ); $options = apply_filters( 'ninja_forms_render_options', $options, $settings ); $options = apply_filters( 'ninja_forms_render_options_' . $this->_type, $options, $settings ); $list = ''; foreach( $options as $option ){ $checked = ''; if( is_array( $value ) && in_array( $option[ 'value' ], $value ) ) $checked = "checked"; $list .= "
{$option[ 'label' ]}
"; } return "
$list
"; } public function get_calc_value( $value, $field ) { $selected = explode( ',', $value ); $value = 0; if( isset( $field[ 'options' ] ) ) { foreach ($field['options'] as $option ) { if( ! isset( $option[ 'value' ] ) || ! in_array( $option[ 'value' ], $selected ) || ! isset( $option[ 'calc' ] ) || ! is_numeric( $option[ 'calc' ] )) continue; $value += $option[ 'calc' ]; } } return $value; } }