Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Carpages Ninja Forms Widget

class Carpages_NinjaForm extends WP_Widget {

	public function __construct() {

		parent::__construct(
			'carpages-nf',
			__( 'Ninja Form', 'r0bsc0tt' ),
		);

	}

	public function widget( $args, $instance ) {

	}

	public function form( $instance ) {

		// Set default values
		$instance = wp_parse_args( (array) $instance, array( 
			'r0bsc0tt_nf-id' => '',
			'r0bsc0tt_nfid2' => '',
		) );

		// Retrieve an existing value from the database
		$r0bsc0tt_nf-id = !empty( $instance['r0bsc0tt_nf-id'] ) ? $instance['r0bsc0tt_nf-id'] : '';
		$r0bsc0tt_nfid2 = !empty( $instance['r0bsc0tt_nfid2'] ) ? $instance['r0bsc0tt_nfid2'] : '';

		// Form fields
		echo '<p>';
		echo '	<label for="' . $this->get_field_id( 'r0bsc0tt_nf-id' ) . '" class="r0bsc0tt_nf-id_label">' . __( 'Ninja Form ID', 'r0bsc0tt' ) . '</label>';
		echo '	<select id="' . $this->get_field_id( 'r0bsc0tt_nf-id' ) . '" name="' . $this->get_field_name( 'r0bsc0tt_nf-id' ) . '" class="widefat">';
		echo '		<option value="value1" ' . selected( $r0bsc0tt_nf-id, 'value1', false ) . '> ' . __( 'Label 1', 'r0bsc0tt' ) . '</option>';
		echo '		<option value="value2" ' . selected( $r0bsc0tt_nf-id, 'value2', false ) . '> ' . __( 'Label 2', 'r0bsc0tt' ) . '</option>';
		echo '	</select>';
		echo '	<span class="description">' . __( 'The ID for the Ninja Form Sell My (This Brand)', 'r0bsc0tt' ) . '</span>';
		echo '</p>';

		echo '<p>';
		echo '	<label for="' . $this->get_field_id( 'r0bsc0tt_nfid2' ) . '" class="r0bsc0tt_nfid2_label">' . __( 'NF ID as digit', 'r0bsc0tt' ) . '</label>';
		echo '	<input type="text" id="' . $this->get_field_id( 'r0bsc0tt_nfid2' ) . '" name="' . $this->get_field_name( 'r0bsc0tt_nfid2' ) . '" class="widefat" placeholder="' . esc_attr__( '', 'r0bsc0tt' ) . '" value="' . esc_attr( $r0bsc0tt_nfid2 ) . '">';
		echo '	<span class="description">' . __( 'Put your NF ID in here', 'r0bsc0tt' ) . '</span>';
		echo '</p>';

	}

	public function update( $new_instance, $old_instance ) {

		$instance = $old_instance;

		$instance['r0bsc0tt_nf-id'] = !empty( $new_instance['r0bsc0tt_nf-id'] ) ? strip_tags( $new_instance['r0bsc0tt_nf-id'] ) : '';
		$instance['r0bsc0tt_nfid2'] = !empty( $new_instance['r0bsc0tt_nfid2'] ) ? strip_tags( $new_instance['r0bsc0tt_nfid2'] ) : '';

		return $instance;

	}

}

function r0bsc0tt_register_widgets() {
	register_widget( 'Carpages_NinjaForm' );
}
add_action( 'widgets_init', 'r0bsc0tt_register_widgets' );