Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../includes
File: Widget.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
/**
[1] Fix | Delete
* Adds Ninja Forms widget.
[2] Fix | Delete
*/
[3] Fix | Delete
class NF_Widget extends WP_Widget {
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Register widget with WordPress.
[7] Fix | Delete
*/
[8] Fix | Delete
public function __construct() {
[9] Fix | Delete
parent::__construct(
[10] Fix | Delete
'ninja_forms_widget', // Base ID
[11] Fix | Delete
'Ninja Forms Widget', // Name
[12] Fix | Delete
array( 'description' => esc_html__( 'Ninja Forms Widget', 'ninja-forms' ), ) // Args
[13] Fix | Delete
);
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Front-end display of widget.
[18] Fix | Delete
*
[19] Fix | Delete
* @see WP_Widget::widget()
[20] Fix | Delete
*
[21] Fix | Delete
* @param array $args Widget arguments.
[22] Fix | Delete
* @param array $instance Saved values from database.
[23] Fix | Delete
*/
[24] Fix | Delete
public function widget( $args, $instance ) {
[25] Fix | Delete
$form = Ninja_Forms()->form( $instance['form_id'] )->get();
[26] Fix | Delete
$title = $form->get_setting( 'title' );
[27] Fix | Delete
[28] Fix | Delete
$title = apply_filters( 'widget_title', $title );
[29] Fix | Delete
$display_title = $instance['display_title'];
[30] Fix | Delete
[31] Fix | Delete
echo $args[ 'before_widget' ];
[32] Fix | Delete
if ( ! empty( $title ) AND $display_title == 1 )
[33] Fix | Delete
echo $args[ 'before_title' ] . esc_html( $title ) . $args[ 'after_title' ];
[34] Fix | Delete
Ninja_Forms()->display( $instance['form_id'] );
[35] Fix | Delete
echo $args[ 'after_widget' ];
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Sanitize widget form values as they are saved.
[40] Fix | Delete
*
[41] Fix | Delete
* @see WP_Widget::update()
[42] Fix | Delete
*
[43] Fix | Delete
* @param array $new_instance Values just sent to be saved.
[44] Fix | Delete
* @param array $old_instance Previously saved values from database.
[45] Fix | Delete
*
[46] Fix | Delete
* @return array Updated safe values to be saved.
[47] Fix | Delete
*/
[48] Fix | Delete
public function update( $new_instance, $old_instance ) {
[49] Fix | Delete
[50] Fix | Delete
$instance = array();
[51] Fix | Delete
$instance['form_id'] = $new_instance['form_id'];
[52] Fix | Delete
$instance['display_title'] = $new_instance['display_title'];
[53] Fix | Delete
[54] Fix | Delete
return $instance;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Back-end widget form.
[59] Fix | Delete
*
[60] Fix | Delete
* @see WP_Widget::form()
[61] Fix | Delete
*
[62] Fix | Delete
* @param array $instance Previously saved values from database.
[63] Fix | Delete
*/
[64] Fix | Delete
public function form( $instance ) {
[65] Fix | Delete
if( isset( $instance['form_id'] ) ){
[66] Fix | Delete
$form_id = $instance['form_id'];
[67] Fix | Delete
}else{
[68] Fix | Delete
$form_id = '';
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
if( isset( $instance['display_title'] ) ){
[72] Fix | Delete
$display_title = $instance['display_title'];
[73] Fix | Delete
}else{
[74] Fix | Delete
$display_title = 0;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
?>
[78] Fix | Delete
<p>
[79] Fix | Delete
<label>
[80] Fix | Delete
<?php esc_html_e( 'Display Title', 'ninja-forms' ); ?>
[81] Fix | Delete
<input type="hidden" value="0" name="<?php echo esc_attr( $this->get_field_name( 'display_title' ) ); ?>">
[82] Fix | Delete
<input type="checkbox" value="1" id="<?php echo esc_attr( $this->get_field_id( 'display_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'display_title' ) ); ?>" <?php checked( $display_title, 1 );?>>
[83] Fix | Delete
</label>
[84] Fix | Delete
</p>
[85] Fix | Delete
<p>
[86] Fix | Delete
<select id="<?php echo esc_attr( $this->get_field_id( 'form_id' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'form_id' ) ); ?>">
[87] Fix | Delete
<option value="0">-- <?php esc_html_e('None', 'ninja-forms');?></option>
[88] Fix | Delete
<?php
[89] Fix | Delete
$all_forms = Ninja_Forms()->form()->get_forms();
[90] Fix | Delete
[91] Fix | Delete
foreach($all_forms as $form){
[92] Fix | Delete
?>
[93] Fix | Delete
<option value="<?php echo intval( $form->get_id() );?>" <?php selected( $form->get_id(), $form_id );?>>
[94] Fix | Delete
<?php echo esc_html( $form->get_setting( 'title' ) );?>
[95] Fix | Delete
</option>
[96] Fix | Delete
<?php
[97] Fix | Delete
}
[98] Fix | Delete
?>
[99] Fix | Delete
</select>
[100] Fix | Delete
</p>
[101] Fix | Delete
[102] Fix | Delete
<?php
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
} // class Foo_Widget
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Register NF widget
[109] Fix | Delete
*
[110] Fix | Delete
* @see 'widgets_init'
[111] Fix | Delete
*/
[112] Fix | Delete
function NF_register_widgets() {
[113] Fix | Delete
register_widget( 'NF_Widget' );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
add_action( 'widgets_init', 'NF_register_widgets' );
[117] Fix | Delete
[118] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function