Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

MA widget

class Marathon_Btn_Widget extends WP_Widget {

	public function __construct() {

		parent::__construct(
			'marathon_btn_widget',
			__( 'Marathon Amersfoort Button', 'marathon' ),
			array(
				'description' => __( 'Text or HTML content.', 'marathon' ),
				'classname'   => 'ma_widget',
			)
		);

	}

	public function widget( $args, $instance ) {

		$title = apply_filters( 'widget_title', empty( $instance['marathon_title'] ) ? '' : $instance['marathon_title'], $instance, $this->id_base );
		$text  = apply_filters( 'widget_text_btn',  empty( $instance['marathon_text_btn']  ) ? '' : $instance['marathon_text_btn'],  $instance );
		$btnLink  = apply_filters( 'widget_url',  empty( $instance['marathon_link_btn']  ) ? '' : $instance['marathon_link_btn'],  $instance );

		// Before widget tag
		echo $args['before_widget'];

		// Title
		if ( ! empty( $title ) ) {
			echo $args['before_title'] . $title . $args['after_title'];
		}

// link
		echo '<a class="btn btn-ma-red btn-lg btn-block" href="' . $btnLink . '" role="button">' . $text . ' <i class="fa fa-chevron-right"></i>
<i class="fa fa-chevron-right"></i></a>';

		// After widget tag
		echo $args['after_widget'];

	}

	public function form( $instance ) {

		// Set default values
		$instance = wp_parse_args( (array) $instance, array( 
			'marathon_title' => '',
			'marathon_text_btn' => '',
			'marathon_link_btn' => '',
		) );

		// Retrieve an existing value from the database
		$marathon_title = !empty( $instance['marathon_title'] ) ? $instance['marathon_title'] : '';
		$marathon_text_btn = !empty( $instance['marathon_text_btn'] ) ? $instance['marathon_text_btn'] : '';
		$marathon_link_btn = !empty( $instance['marathon_link_btn'] ) ? $instance['marathon_link_btn'] : '';

		// Form fields
		echo '<p>';
		echo '	<label for="' . $this->get_field_id( 'marathon_title' ) . '" class="marathon_title_label">' . __( 'Title', 'marathon' ) . '</label>';
		echo '	<input type="text" id="' . $this->get_field_id( 'marathon_title' ) . '" name="' . $this->get_field_name( 'marathon_title' ) . '" class="widefat" placeholder="' . esc_attr__( '', 'marathon' ) . '" value="' . esc_attr( $marathon_title ) . '">';
		echo '</p>';

		echo '<p>';
		echo '	<label for="' . $this->get_field_id( 'marathon_text_btn' ) . '" class="marathon_text_btn_label">' . __( 'Tekst button', 'marathon' ) . '</label>';
		echo '	<input type="text" id="' . $this->get_field_id( 'marathon_text_btn' ) . '" name="' . $this->get_field_name( 'marathon_text_btn' ) . '" class="widefat" placeholder="' . esc_attr__( '', 'marathon' ) . '" value="' . esc_attr( $marathon_text_btn ) . '">';
		echo '</p>';

		echo '<p>';
		echo '	<label for="' . $this->get_field_id( 'marathon_link_btn' ) . '" class="marathon_link_btn_label">' . __( 'Link van buttun', 'marathon' ) . '</label>';
		echo '	<input type="url" id="' . $this->get_field_id( 'marathon_link_btn' ) . '" name="' . $this->get_field_name( 'marathon_link_btn' ) . '" class="widefat" placeholder="' . esc_attr__( '', 'marathon' ) . '" value="' . esc_attr( $marathon_link_btn ) . '">';
		echo '</p>';

	}

	public function update( $new_instance, $old_instance ) {

		$instance = $old_instance;

		$instance['marathon_title'] = !empty( $new_instance['marathon_title'] ) ? strip_tags( $new_instance['marathon_title'] ) : '';
		$instance['marathon_text_btn'] = !empty( $new_instance['marathon_text_btn'] ) ? strip_tags( $new_instance['marathon_text_btn'] ) : '';
		$instance['marathon_link_btn'] = !empty( $new_instance['marathon_link_btn'] ) ? strip_tags( $new_instance['marathon_link_btn'] ) : '';

		return $instance;

	}

}

function marathon_register_widgets() {
	register_widget( 'Marathon_Btn_Widget' );
}
add_action( 'widgets_init', 'marathon_register_widgets' );