GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 122957...131d46 )
by Christian
02:49
created

widget.php (3 issues)

1
<?php
0 ignored issues
show
This file is missing a doc comment.
Loading history...
Class file names should be based on the class name with "class-" prepended. Expected class-widget.php, but found widget.php.
Loading history...
2
3
namespace PodloveSubscribeButton;
4
5
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
6
7
class Widget extends \WP_Widget {
8
9
	public static $widget_settings = array(
10
		'infotext',
11
		'title',
12
		'size',
13
		'style',
14
		'format',
15
		'autowidth',
16
		'button',
17
		'color',
18
	);
19
20
	public function __construct() {
21
		parent::__construct(
22
			'podlove_subscribe_button_wp_plugin_widget',
23
			( \PodloveSubscribeButton\is_podlove_publisher_active() ? 'Podlove Subscribe Button (WordPress plugin)' : 'Podlove Subscribe Button' ),
24
			array( 'description' => __( 'Adds a Podlove Subscribe Button to your Sidebar', 'podlove-subscribe-button' ), )
25
		);
26
27
	}
28
29
	public function widget( $args, $instance ) {
30
		// Fetch the (network)button by it's name
31
		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name( $instance[ 'button' ] ) ) {
32
			return sprintf( __( 'Oops. There is no button with the ID "%s".', 'podlove-subscribe-button' ), $args['button'] );
33
		}
34
35
		echo $args[ 'before_widget' ];
36
		echo $args[ 'before_title' ] . apply_filters( 'widget_title', $instance[ 'title' ] ) . $args[ 'after_title' ];
37
38
		echo $button->render(
39
			\PodloveSubscribeButton::get_array_value_with_fallback( $instance, 'size' ),
40
			\PodloveSubscribeButton::get_array_value_with_fallback( $instance, 'autowidth' ),
41
			\PodloveSubscribeButton::get_array_value_with_fallback( $instance, 'style' ),
42
			\PodloveSubscribeButton::get_array_value_with_fallback( $instance, 'format' ),
43
			\PodloveSubscribeButton::get_array_value_with_fallback( $instance, 'color' )
44
		);
45
46
		if ( strlen( $instance[ 'infotext' ] ) ) {
47
			echo wpautop( $instance[ 'infotext' ] );
48
		}
49
50
		echo $args[ 'after_widget' ];
51
52
	}
53
54
	public function form( $instance ) {
55
		$title     = isset( $instance[ 'title' ] )     ? $instance[ 'title' ]     : '';
56
		$button    = isset( $instance[ 'button' ] )    ? $instance[ 'button' ]    : '';
57
		$size      = isset( $instance[ 'size' ] )      ? $instance[ 'size' ]      : 'big';
58
		$style     = isset( $instance[ 'style' ] )     ? $instance[ 'style' ]     : 'filled';
59
		$format    = isset( $instance[ 'format' ] )    ? $instance[ 'format' ]    : 'cover';
60
		$autowidth = isset( $instance[ 'autowidth' ] ) ? $instance[ 'autowidth' ] : true;
61
		$infotext  = isset( $instance[ 'infotext' ] )  ? $instance[ 'infotext' ]  : '';
62
		$color     = isset( $instance[ 'color' ] )     ? $instance[ 'color' ]     : '#75ad91';
63
64
		$buttons = \PodloveSubscribeButton\Model\Button::all();
65
		if ( is_multisite() ) {
66
			$network_buttons = \PodloveSubscribeButton\Model\NetworkButton::all();
67
		}
68
		?>
69
		<p>
70
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'podlove-subscribe-button' ); ?></label>
71
			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $title; ?>" />
72
			<label for="<?php echo $this->get_field_id( 'color' ); ?>"><?php _e( 'Color', 'podlove-subscribe-button' ); ?></label>
73
			<input class="podlove_subscribe_button_color" id="<?php echo $this->get_field_id( 'color' ); ?>" name="<?php echo $this->get_field_name( 'color' ); ?>" value="<?php echo $color; ?>" />
74
			<style type="text/css">
75
				.sp-replacer {
76
					display: flex;
77
				}
78
				.sp-preview {
79
					flex-grow: 10;
80
				}
81
			</style>
82
			<label for="<?php echo $this->get_field_id( 'button' ); ?>"><?php _e( 'Button', 'podlove-subscribe-button' ); ?></label>
83
            <select class="widefat" id="<?php echo $this->get_field_id( 'button' ); ?>"
84
                    name="<?php echo $this->get_field_name( 'button' ); ?>">
85
				<?php if ( isset( $network_buttons ) && count( $network_buttons ) > 0 ) : ?>
86
                    <optgroup label="<?php _e( 'Local', 'podlove-subscribe-button' ); ?>">
87
						<?php
88
						foreach ( $buttons as $subscribebutton ) {
89
							echo "<option value='" . $subscribebutton->name . "' " . selected( $subscribebutton->name, $button ) . " >" . $subscribebutton->title . " (" . $subscribebutton->name . ")</option>";
90
						} ?>
0 ignored issues
show
Closing PHP tag must be on a line by itself
Loading history...
91
                    </optgroup>
92
                    <optgroup label="<?php _e( 'Network', 'podlove-subscribe-button' ); ?>">
93
						<?php
94
						foreach ( $network_buttons as $subscribebutton ) {
95
							echo "<option value='" . $subscribebutton->name . "' " . selected( $subscribebutton->name, $button ) . " >" . $subscribebutton->title . " (" . $subscribebutton->name . ")</option>";
96
						} ?>
97
                    </optgroup>
98
				<?php else :
99
					foreach ( $buttons as $subscribebutton ) {
100
						echo "<option value='" . $subscribebutton->name . "' " . selected( $subscribebutton->name, $button ) . " >" . $subscribebutton->title . " (" . $subscribebutton->name . ")</option>";
101
					}
102
				endif; ?>
103
            </select>
104
			<?php
105
			$customize_options = array(
106
				'size'      => array(
107
					'name'    => __( 'Size', 'podlove-subscribe-button' ),
108
					'options' => \PodloveSubscribeButton\Model\Button::$size
109
				),
110
				'style'     => array(
111
					'name'    => __( 'Style', 'podlove-subscribe-button' ),
112
					'options' => \PodloveSubscribeButton\Model\Button::$style
113
				),
114
				'format'    => array(
115
					'name'    => __( 'Format', 'podlove-subscribe-button' ),
116
					'options' => \PodloveSubscribeButton\Model\Button::$format
117
				),
118
				'autowidth' => array(
119
					'name'    => __( 'Autowidth', 'podlove-subscribe-button' ),
120
					'options' => \PodloveSubscribeButton\Model\Button::$width
121
				)
122
			);
123
124
			foreach ( $customize_options as $slug => $properties ) : ?>
125
				<label for="<?php echo $this->get_field_id( $slug ); ?>"><?php echo $properties[ 'name' ]; ?></label>
126
				<select class="widefat" id="<?php echo $this->get_field_id( $slug ); ?>" name="<?php echo $this->get_field_name( $slug ); ?>">
127
					<option value="default" <?php echo ( $$slug == 'default' ? 'selected="selected"' : '' ); ?>><?php printf( __( 'Default %s', 'podlove-subscribe-button' ), $properties[ 'name' ] ) ?></option>
128
					<optgroup>
129
						<?php foreach ( $properties[ 'options' ] as $property => $name ) : ?>
130
						<option value="<?php echo $property; ?>" <?php echo ( $$slug == $property ? 'selected="selected"' : '' ); ?>><?php echo $name; ?></option>
131
						<?php endforeach; ?>
132
					</optgroup>
133
				</select>
134
			<?php endforeach; ?>
135
			<label for="<?php echo $this->get_field_id( 'infotext' ); ?>"><?php _e( 'Description', 'podlove-subscribe-button' ); ?></label>
136
			<textarea class="widefat" rows="10" id="<?php echo $this->get_field_id( 'infotext' ); ?>" name="<?php echo $this->get_field_name( 'infotext' ); ?>"><?php echo $infotext; ?></textarea>
137
		</p>
138
		<?php
139
140
	}
141
142
	public function update( $new_instance, $old_instance ) {
143
		$instance = array();
144
145
		foreach ( self::$widget_settings as $setting ) {
146
			$instance[ $setting ] = ( ! empty( $new_instance[ $setting ] ) ) ? strip_tags( $new_instance[ $setting ] ) : '';
147
		}
148
149
		return $instance;
150
151
	}
152
153
} // END class
154