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: ListMultiSelect.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Fields_MultiselectList
[3] Fix | Delete
*/
[4] Fix | Delete
class NF_Fields_ListMultiselect extends NF_Abstracts_List
[5] Fix | Delete
{
[6] Fix | Delete
protected $_name = 'listmultiselect';
[7] Fix | Delete
[8] Fix | Delete
protected $_type = 'listmultiselect';
[9] Fix | Delete
[10] Fix | Delete
protected $_nicename = 'Mulit-Select';
[11] Fix | Delete
[12] Fix | Delete
protected $_section = 'common';
[13] Fix | Delete
[14] Fix | Delete
protected $_templates = 'listselect';
[15] Fix | Delete
[16] Fix | Delete
protected $_old_classname = 'list-multiselect';
[17] Fix | Delete
[18] Fix | Delete
protected $_settings = array( 'multi_size' );
[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__( 'Multi-Select', '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
$field = Ninja_Forms()->form()->get_field( $id );
[32] Fix | Delete
[33] Fix | Delete
$field_options = $field->get_setting( 'options' );
[34] Fix | Delete
$field_options = apply_filters( 'ninja_forms_render_options', $field_options, $field->get_settings() );
[35] Fix | Delete
$field_options = apply_filters( 'ninja_forms_render_options_' . $this->_type, $field_options, $field->get_settings() );
[36] Fix | Delete
[37] Fix | Delete
$options = '';
[38] Fix | Delete
foreach( $field_options as $option ){
[39] Fix | Delete
$selected = ( is_array( $value ) && in_array( $option[ 'value' ], $value ) ) ? "selected" : '';
[40] Fix | Delete
$options .= "<option value='{$option[ 'value' ]}' $selected>{$option[ 'label' ]}</option>";
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
return "<select class='widefat' name='fields[$id][]' id='' multiple>$options</select>";
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
public function get_calc_value( $value, $field )
[47] Fix | Delete
{
[48] Fix | Delete
$selected = explode( ',', $value );
[49] Fix | Delete
$value = 0;
[50] Fix | Delete
if( isset( $field[ 'options' ] ) ) {
[51] Fix | Delete
foreach ($field['options'] as $option ) {
[52] Fix | Delete
if( ! isset( $option[ 'value' ] ) || ! in_array( $option[ 'value' ], $selected ) || ! isset( $option[ 'calc' ] ) ) continue;
[53] Fix | Delete
if( ! is_numeric( trim( $option[ 'calc' ] ) ) ) continue;
[54] Fix | Delete
$value += $option[ 'calc' ];
[55] Fix | Delete
}
[56] Fix | Delete
}
[57] Fix | Delete
return $value;
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function