Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../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 Ninja_Forms_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' => __( '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
extract( $args );
[26] Fix | Delete
$form_id = $instance['form_id'];
[27] Fix | Delete
$form_row = ninja_forms_get_form_by_id( $form_id );
[28] Fix | Delete
$form_data = $form_row['data'];
[29] Fix | Delete
if ( isset ( $form_data['form_title'] ) ) {
[30] Fix | Delete
$title = $form_data['form_title'];
[31] Fix | Delete
} else {
[32] Fix | Delete
$title = '';
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
$title = apply_filters( 'widget_title', $title );
[36] Fix | Delete
$display_title = $instance['display_title'];
[37] Fix | Delete
[38] Fix | Delete
echo $before_widget;
[39] Fix | Delete
if ( ! empty( $title ) AND $display_title == 1 )
[40] Fix | Delete
echo $before_title . $title . $after_title;
[41] Fix | Delete
ninja_forms_display_form( $form_id );
[42] Fix | Delete
echo $after_widget;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Sanitize widget form values as they are saved.
[47] Fix | Delete
*
[48] Fix | Delete
* @see WP_Widget::update()
[49] Fix | Delete
*
[50] Fix | Delete
* @param array $new_instance Values just sent to be saved.
[51] Fix | Delete
* @param array $old_instance Previously saved values from database.
[52] Fix | Delete
*
[53] Fix | Delete
* @return array Updated safe values to be saved.
[54] Fix | Delete
*/
[55] Fix | Delete
public function update( $new_instance, $old_instance ) {
[56] Fix | Delete
[57] Fix | Delete
$instance = array();
[58] Fix | Delete
$instance['form_id'] = $new_instance['form_id'];
[59] Fix | Delete
$instance['display_title'] = $new_instance['display_title'];
[60] Fix | Delete
[61] Fix | Delete
return $instance;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Back-end widget form.
[66] Fix | Delete
*
[67] Fix | Delete
* @see WP_Widget::form()
[68] Fix | Delete
*
[69] Fix | Delete
* @param array $instance Previously saved values from database.
[70] Fix | Delete
*/
[71] Fix | Delete
public function form( $instance ) {
[72] Fix | Delete
if( isset( $instance['form_id'] ) ){
[73] Fix | Delete
$form_id = $instance['form_id'];
[74] Fix | Delete
}else{
[75] Fix | Delete
$form_id = '';
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
if( isset( $instance['display_title'] ) ){
[79] Fix | Delete
$display_title = $instance['display_title'];
[80] Fix | Delete
}else{
[81] Fix | Delete
$display_title = 0;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
?>
[85] Fix | Delete
<p>
[86] Fix | Delete
<label>
[87] Fix | Delete
<?php _e( 'Display Title', 'ninja-forms' ); ?>
[88] Fix | Delete
<input type="hidden" value="0" name="<?php echo $this->get_field_name( 'display_title' ); ?>">
[89] Fix | Delete
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'display_title' ); ?>" name="<?php echo $this->get_field_name( 'display_title' ); ?>" <?php checked( $display_title, 1 );?>>
[90] Fix | Delete
</label>
[91] Fix | Delete
</p>
[92] Fix | Delete
<p>
[93] Fix | Delete
<select id="<?php echo $this->get_field_id( 'form_id' ); ?>" name="<?php echo $this->get_field_name( 'form_id' ); ?>">
[94] Fix | Delete
<option value="0">-- <?php _e('None', 'ninja-forms');?></option>
[95] Fix | Delete
<?php
[96] Fix | Delete
$all_forms = ninja_forms_get_all_forms();
[97] Fix | Delete
[98] Fix | Delete
foreach($all_forms as $form){
[99] Fix | Delete
$title = $form['data']['form_title'];
[100] Fix | Delete
$id = $form['id'];
[101] Fix | Delete
?>
[102] Fix | Delete
<option value = "<?php echo $id;?>" <?php selected( $id, $form_id );?>>
[103] Fix | Delete
<?php echo $title;?>
[104] Fix | Delete
</option>
[105] Fix | Delete
<?php
[106] Fix | Delete
}
[107] Fix | Delete
?>
[108] Fix | Delete
</select>
[109] Fix | Delete
</p>
[110] Fix | Delete
[111] Fix | Delete
<?php
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
} // class Foo_Widget
[115] Fix | Delete
[116] Fix | Delete
function NF_register_widgets() {
[117] Fix | Delete
register_widget( 'ninja_forms_widget' );
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
add_action( 'widgets_init', 'NF_register_widgets' );
[121] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function