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.
Completed
Push — master ( d5badb...35381c )
by Christian
10s
created

widget.php (47 issues)

1
<?php
2
3
namespace PodloveSubscribeButton;
4
5
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
6
7
class Podlove_Subscribe_Button_Widget extends \WP_Widget {
8
9
	public function __construct() {
10
		parent::__construct(
11
					'podlove_subscribe_button_wp_plugin_widget',
12
					( self::is_podlove_publisher_active() ? 'Podlove Subscribe Button (WordPress plugin)' : 'Podlove Subscribe Button' ),
13
					array( 'description' => __( 'Adds a Podlove Subscribe Button to your Sidebar', 'podlove-subscribe-button' ), )
14
				);
15
	}
16
17
	public static $widget_settings = array('infotext', 'title', 'size', 'style', 'format', 'autowidth', 'button', 'color');
18
19
	public static function is_podlove_publisher_active() {
20
		if ( is_plugin_active("podlove-podcasting-plugin-for-wordpress/podlove.php") ) {
21
			return true;
22
		}
23
24
		return false;
25
	}
26
27
	public function widget( $args, $instance ) {
28
		// Fetch the (network)button by it's name
29
		if ( ! $button = \PodloveSubscribeButton\Model\Button::get_button_by_name($instance['button']) )
30
			return sprintf( __('Oops. There is no button with the ID "%s".', 'podlove-subscribe-button'), $args['button'] );
31
32
		echo $args['before_widget'];
33
		echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
34
35
		echo $button->render(
36
				\PodloveSubscribeButton::get_array_value_with_fallback($instance, 'size'),
37
				\PodloveSubscribeButton::get_array_value_with_fallback($instance, 'autowidth'),
38
				\PodloveSubscribeButton::get_array_value_with_fallback($instance, 'style'),
39
				\PodloveSubscribeButton::get_array_value_with_fallback($instance, 'format'), 
40
				\PodloveSubscribeButton::get_array_value_with_fallback($instance, 'color')
41
			);
42
		
43
		if ( strlen($instance['infotext']) )
44
			echo wpautop($instance['infotext']);
45
46
		echo $args['after_widget'];
47
	}	
48
49
	public function form( $instance ) {
50
		foreach (self::$widget_settings as $setting) {
51
			$$setting = isset( $instance[$setting] ) ? $instance[$setting] : '';
52
		}
53
54
		$buttons = \PodloveSubscribeButton\Model\Button::all();
55
		if ( is_multisite() )
56
			$network_buttons = \PodloveSubscribeButton\Model\NetworkButton::all();
57
58
		$buttons_as_options = function ($buttons) {
59
			foreach ($buttons as $subscribebutton) {
60
				echo "<option value='".$subscribebutton->name."' ".( $subscribebutton->name == $button ? 'selected=\"selected\"' : '' )." >".$subscribebutton->title." (".$subscribebutton->name.")</option>";
61
			}
62
		}
63
		?>
64
		<p>
65
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'podlove-subscribe-button' ); ?></label> 
66
			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $title; ?>" />
67
68
			<label for="<?php echo $this->get_field_id( 'color' ); ?>"><?php _e( 'Color', 'podlove-subscribe-button' ); ?></label>
69
			<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; ?>" />
70
			<style type="text/css">
71
				.sp-replacer {
72
					display: flex;
73
				}
74
				.sp-preview {
75
					flex-grow: 10;
76
				}
77
			</style>
78
79
			<label for="<?php echo $this->get_field_id( 'button' ); ?>"><?php _e( 'Button', 'podlove-subscribe-button' ); ?></label> 
80
			<select class="widefat" id="<?php echo $this->get_field_id( 'button' ); ?>"
81
				      name="<?php echo $this->get_field_name( 'button' ); ?>">
82
				<?php if ( isset($network_buttons) && count($network_buttons) > 0 ) : ?>
83
					<optgroup label="<?php _e('Local', 'podlove'); ?>">
0 ignored issues
show
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
84
						<?php $buttons_as_options($buttons); ?>
85
					</optgroup>
86
					<optgroup label="<?php _e('Network', 'podlove'); ?>">
0 ignored issues
show
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
Expected 1 spaces after opening bracket; 0 found
Loading history...
Expected 1 spaces before closing bracket; 0 found
Loading history...
87
						<?php $buttons_as_options($network_buttons); ?>
88
					</optgroup>
89
				<?php else : 
90
					$buttons_as_options($buttons);
91
				 endif; ?>
92
			</select>
93
94
			<?php
95
			$customize_options = array(
96
					'size' => array(
0 ignored issues
show
Array item not aligned correctly; expected 16 spaces but found 20
Loading history...
Array double arrow not aligned correctly; expected 6 space(s) between "'size'" and double arrow, but found 1.
Loading history...
97
							'name' => 'Size',
0 ignored issues
show
Multi-line array item not aligned correctly; expected 24 spaces, but found 28
Loading history...
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
Array double arrow not aligned correctly; expected 4 space(s) between "'name'" and double arrow, but found 1.
Loading history...
98
							'options' => \PodloveSubscribeButton\Model\Button::$size
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
99
						),
0 ignored issues
show
Array closer not aligned correctly; expected 20 space(s) but found 24
Loading history...
100
					'style' => array(
0 ignored issues
show
Array item not aligned correctly; expected 16 spaces but found 20
Loading history...
Array double arrow not aligned correctly; expected 5 space(s) between "'style'" and double arrow, but found 1.
Loading history...
101
							'name' => 'Style',
0 ignored issues
show
Multi-line array item not aligned correctly; expected 24 spaces, but found 28
Loading history...
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
Array double arrow not aligned correctly; expected 4 space(s) between "'name'" and double arrow, but found 1.
Loading history...
102
							'options' => \PodloveSubscribeButton\Model\Button::$style
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
103
						),
0 ignored issues
show
Array closer not aligned correctly; expected 20 space(s) but found 24
Loading history...
104
					'format' => array(
0 ignored issues
show
Array item not aligned correctly; expected 16 spaces but found 20
Loading history...
Array double arrow not aligned correctly; expected 4 space(s) between "'format'" and double arrow, but found 1.
Loading history...
105
							'name' => 'Format',
0 ignored issues
show
Multi-line array item not aligned correctly; expected 24 spaces, but found 28
Loading history...
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
Array double arrow not aligned correctly; expected 4 space(s) between "'name'" and double arrow, but found 1.
Loading history...
106
							'options' => \PodloveSubscribeButton\Model\Button::$format
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
107
						),
0 ignored issues
show
Array closer not aligned correctly; expected 20 space(s) but found 24
Loading history...
108
					'autowidth' => array(
0 ignored issues
show
Array item not aligned correctly; expected 16 spaces but found 20
Loading history...
109
							'name' => 'Autowidth',
0 ignored issues
show
Multi-line array item not aligned correctly; expected 24 spaces, but found 28
Loading history...
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
Array double arrow not aligned correctly; expected 4 space(s) between "'name'" and double arrow, but found 1.
Loading history...
110
							'options' => \PodloveSubscribeButton\Model\Button::$width
0 ignored issues
show
Array item not aligned correctly; expected 24 spaces but found 28
Loading history...
111
						)
0 ignored issues
show
Array closer not aligned correctly; expected 20 space(s) but found 24
Loading history...
112
				);
0 ignored issues
show
Array closer not aligned correctly; expected 12 space(s) but found 16
Loading history...
113
114
			foreach ($customize_options as $slug => $properties) : ?>
115
				<label for="<?php echo $this->get_field_id( $slug ); ?>"><?php _e( $properties['name'], 'podlove-subscribe-button' ); ?></label> 
0 ignored issues
show
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$this'.
Loading history...
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
The $text arg must be a single string literal, not "$properties['name']".
Loading history...
116
				<select class="widefat" id="<?php echo $this->get_field_id( $slug ); ?>" name="<?php echo $this->get_field_name( $slug ); ?>">
117
					<option value="default" <?php echo ( $$slug == 'default' ? 'selected="selected"' : '' ); ?>><?php _e( 'Default ' . $properties['name'], 'podlove-subscribe-button' ) ?></option>
0 ignored issues
show
Found: ==. Use strict comparisons (=== or !==).
Loading history...
Use Yoda Condition checks, you must.
Loading history...
Inline PHP statement must end with a semicolon
Loading history...
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
The $text arg must be a single string literal, not "'Default '.$properties['name']".
Loading history...
118
					<optgroup>
119
						<?php foreach ( $properties['options'] as $property => $name ) : ?>
120
						<option value="<?php echo $property; ?>" <?php echo ( $$slug == $property ? 'selected="selected"' : '' ); ?>><?php _e( $name, 'podlove-subscribe-button' ) ?></option>
0 ignored issues
show
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$property'.
Loading history...
Found: ==. Use strict comparisons (=== or !==).
Loading history...
Inline PHP statement must end with a semicolon
Loading history...
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
Loading history...
The $text arg must be a single string literal, not "$name".
Loading history...
121
						<?php endforeach; ?>
122
					</optgroup>
123
				</select>
124
			<?php endforeach; ?>
125
		
126
			<label for="<?php echo $this->get_field_id( 'infotext' ); ?>"><?php _e( 'Description', 'podlove-subscribe-button' ); ?></label> 
127
			<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>
128
		</p>
129
		<?php 
130
	}
131
132
	public function update( $new_instance, $old_instance ) {
133
		$instance = array();
134
135
		foreach (self::$widget_settings as $setting) {
136
			$instance[$setting]  = ( ! empty( $new_instance[$setting] ) ) ? strip_tags( $new_instance[$setting] ) : '';
137
		}
138
139
		return $instance;
140
	}
141
}
142
add_action( 'widgets_init', function(){
143
     register_widget( '\PodloveSubscribeButton\Podlove_Subscribe_Button_Widget' );
144
});