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/Abstract...
File: List.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Abstracts_List
[3] Fix | Delete
*/
[4] Fix | Delete
abstract class NF_Abstracts_List extends NF_Abstracts_Field
[5] Fix | Delete
{
[6] Fix | Delete
protected $_name = '';
[7] Fix | Delete
[8] Fix | Delete
protected $_section = 'common';
[9] Fix | Delete
[10] Fix | Delete
protected $_type = 'list';
[11] Fix | Delete
[12] Fix | Delete
protected $_test_value = FALSE;
[13] Fix | Delete
[14] Fix | Delete
protected $_settings_all_fields = array(
[15] Fix | Delete
'key', 'label', 'label_pos', 'required', 'options', 'classes', 'admin_label', 'help', 'description'
[16] Fix | Delete
);
[17] Fix | Delete
[18] Fix | Delete
public static $_base_template = 'list';
[19] Fix | Delete
[20] Fix | Delete
public function __construct()
[21] Fix | Delete
{
[22] Fix | Delete
parent::__construct();
[23] Fix | Delete
[24] Fix | Delete
add_filter( 'ninja_forms_custom_columns', array( $this, 'custom_columns' ), 10, 2 );
[25] Fix | Delete
[26] Fix | Delete
add_filter( 'ninja_forms_render_options', array( $this, 'query_string_default' ), 10, 2 );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
public function get_parent_type()
[30] Fix | Delete
{
[31] Fix | Delete
return 'list';
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
public function admin_form_element( $id, $value )
[35] Fix | Delete
{
[36] Fix | Delete
$form_id = get_post_meta( absint( $_GET[ 'post' ] ), '_form_id', true );
[37] Fix | Delete
[38] Fix | Delete
$field = Ninja_Forms()->form( $form_id )->get_field( $id );
[39] Fix | Delete
[40] Fix | Delete
$settings = $field->get_settings();
[41] Fix | Delete
$settings[ 'options' ] = apply_filters( 'ninja_forms_render_options', $settings[ 'options' ], $settings );
[42] Fix | Delete
$settings[ 'options' ] = apply_filters( 'ninja_forms_render_options_' . $field->get_setting( 'type' ), $settings[ 'options' ], $settings );
[43] Fix | Delete
[44] Fix | Delete
$options = '<option>--</option>';
[45] Fix | Delete
if ( is_array( $settings[ 'options' ] ) ) {
[46] Fix | Delete
foreach( $settings[ 'options' ] as $option ){
[47] Fix | Delete
$selected = ( $value == $option[ 'value' ] ) ? "selected" : '';
[48] Fix | Delete
$options .= "<option value='" . esc_attr( $option[ 'value' ] ) . "' $selected>" . esc_html( $option[ 'label' ] ) . "</option>";
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
return "<select class='widefat' name='fields[" . esc_attr( $id ) . "]' id=''>$options</select>";
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
/*
[56] Fix | Delete
* Appropriate output for a column cell in submissions list.
[57] Fix | Delete
*/
[58] Fix | Delete
public function custom_columns( $value, $field )
[59] Fix | Delete
{
[60] Fix | Delete
if( $this->_name != $field->get_setting( 'type' ) ) return $value;
[61] Fix | Delete
[62] Fix | Delete
//Consider &amp; to be the same as the & values in database in a selectbox saved value:
[63] Fix | Delete
if( ! is_array( $value ) ) $value = array( htmlspecialchars_decode($value) );
[64] Fix | Delete
[65] Fix | Delete
$settings = $field->get_settings();
[66] Fix | Delete
$options = $field->get_setting( 'options' );
[67] Fix | Delete
$options = apply_filters( 'ninja_forms_render_options', $options, $settings );
[68] Fix | Delete
$options = apply_filters( 'ninja_forms_render_options_' . $field->get_setting( 'type' ), $options, $settings );
[69] Fix | Delete
[70] Fix | Delete
$output = '';
[71] Fix | Delete
if( ! empty( $options ) ) {
[72] Fix | Delete
foreach ($options as $option) {
[73] Fix | Delete
[74] Fix | Delete
if ( ! in_array( $option[ 'value' ], $value ) ) continue;
[75] Fix | Delete
[76] Fix | Delete
$output .= esc_html( $option[ 'label' ] ) . "<br />";
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
return $output;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
public function query_string_default( $options, $settings )
[84] Fix | Delete
{
[85] Fix | Delete
if( ! isset( $settings[ 'key' ] ) ) return $options;
[86] Fix | Delete
[87] Fix | Delete
$field_key = $settings[ 'key' ];
[88] Fix | Delete
[89] Fix | Delete
if( ! isset( $_GET[ $field_key ] ) ) return $options;
[90] Fix | Delete
[91] Fix | Delete
foreach( $options as $key => $option ){
[92] Fix | Delete
[93] Fix | Delete
if( ! isset( $option[ 'value' ] ) ) continue;
[94] Fix | Delete
[95] Fix | Delete
if( $option[ 'value' ] != $_GET[ $field_key ] ) continue;
[96] Fix | Delete
[97] Fix | Delete
$options[ $key ][ 'selected' ] = 1;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
return $options;
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function