Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/ninja-fo.../includes/Fields
File: ListCheckbox.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Fields_CheckboxList
[3] Fix | Delete
*/
[4] Fix | Delete
class NF_Fields_ListCheckbox extends NF_Abstracts_List
[5] Fix | Delete
{
[6] Fix | Delete
protected $_name = 'listcheckbox';
[7] Fix | Delete
[8] Fix | Delete
protected $_type = 'listcheckbox';
[9] Fix | Delete
[10] Fix | Delete
protected $_nicename = 'Checkbox List';
[11] Fix | Delete
[12] Fix | Delete
protected $_section = 'common';
[13] Fix | Delete
[14] Fix | Delete
protected $_icon = 'list';
[15] Fix | Delete
[16] Fix | Delete
protected $_templates = 'listcheckbox';
[17] Fix | Delete
[18] Fix | Delete
protected $_old_classname = 'list-checkbox';
[19] Fix | Delete
[20] Fix | Delete
public function __construct()
[21] Fix | Delete
{
[22] Fix | Delete
parent::__construct();
[23] Fix | Delete
[24] Fix | Delete
$this->_nicename = esc_html__( 'Checkbox List', 'ninja-forms' );
[25] Fix | Delete
[26] Fix | Delete
add_filter( 'ninja_forms_merge_tag_calc_value_' . $this->_type, array( $this, 'get_calc_value' ), 10, 2 );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
public function admin_form_element( $id, $value )
[30] Fix | Delete
{
[31] Fix | Delete
$form_id = get_post_meta( absint( $_GET[ 'post' ] ), '_form_id', true );
[32] Fix | Delete
[33] Fix | Delete
$field = Ninja_Forms()->form( $form_id )->get_field( $id );
[34] Fix | Delete
[35] Fix | Delete
$settings = $field->get_settings();
[36] Fix | Delete
$options = $field->get_setting( 'options' );
[37] Fix | Delete
$options = apply_filters( 'ninja_forms_render_options', $options, $settings );
[38] Fix | Delete
$options = apply_filters( 'ninja_forms_render_options_' . $this->_type, $options, $settings );
[39] Fix | Delete
[40] Fix | Delete
$list = '';
[41] Fix | Delete
foreach( $options as $option ){
[42] Fix | Delete
$checked = '';
[43] Fix | Delete
if( is_array( $value ) && in_array( $option[ 'value' ], $value ) ) $checked = "checked";
[44] Fix | Delete
$list .= "<li><label><input type='checkbox' value='{$option[ 'value' ]}' name='fields[$id][]' $checked> {$option[ 'label' ]}</label></li>";
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
return "<input type='hidden' name='fields[$id]' value='0' ><ul>$list</ul>";
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
public function get_calc_value( $value, $field )
[51] Fix | Delete
{
[52] Fix | Delete
$selected = explode( ',', $value );
[53] Fix | Delete
$value = 0;
[54] Fix | Delete
if( isset( $field[ 'options' ] ) ) {
[55] Fix | Delete
foreach ($field['options'] as $option ) {
[56] Fix | Delete
if( ! isset( $option[ 'value' ] ) || ! in_array( $option[ 'value' ], $selected ) || ! isset( $option[ 'calc' ] ) || ! is_numeric( $option[ 'calc' ] )) continue;
[57] Fix | Delete
$value += $option[ 'calc' ];
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
return $value;
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function