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 ( 33ed65...dc0f35 )
by Christian
02:27
created

inc/Button_List_Table.php (1 issue)

1
<?php
2
/**
3
 * @author    Podlove <[email protected]>
4
 * @copyright Copyright (c) 2014-2018, Podlove
5
 * @license   https://github.com/podlove/podlove-subscribe-button-wp-plugin/blob/master/LICENSE MIT
6
 * @package   Podlove\PodloveSubscribeButton
7
 */
8
9
namespace PodloveSubscribeButton;
10
11
if ( ! class_exists( 'WP_List_Table' ) ) {
12
    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
13
}
14
15
class Button_List_Table extends \WP_List_Table {
16
17
	public function __construct() {
18
19
		global $status, $page;
20
21
		// Set parent defaults
22
		parent::__construct( array(
23
			'singular' => 'feed', // singular name of the listed records
24
			'plural'   => 'feeds', // plural name of the listed records
25
			'ajax'     => false,  // does this table support ajax?
26
		) );
27
28
	}
29
30
	public function column_name( $button ) {
31
32
		$actions = array(
33
			'edit'   => Settings\Buttons::get_action_link( $button, __( 'Edit', 'podlove-subscribe-button' ), 'edit' ),
34
			'delete' => Settings\Buttons::get_action_link( $button, __( 'Delete', 'podlove-subscribe-button' ), 'confirm_delete' )
35
		);
36
37
		return sprintf( '%1$s %2$s',
38
		    /*$1%s*/ $button->title . '<br><code>[podlove-subscribe-button button="' . $button->name . '"]</code>',
39
		    /*$3%s*/ $this->row_actions( $actions )
40
		);
41
42
	}
43
44
	public function column_button_preview( $button ) {
45
46
		if ( ! $button->feeds ) {
47
			return '<code>' . __( 'No preview. Please set a feed.', 'podlove-subscribe-button' ) . '</code>';
48
		} else {
49
50
			$preview  = "<div class='podlove-button-preview-container'>";
51
			$preview .= $button->render(
52
				\PodloveSubscribeButton::get_option( 'size' ),
53
				\PodloveSubscribeButton::get_option( 'autowidth' ),
54
				\PodloveSubscribeButton::get_option( 'style' ),
55
				\PodloveSubscribeButton::get_option( 'format' ),
56
				\PodloveSubscribeButton::get_option( 'color' ),
57
				false,
58
				false,
59
				\PodloveSubscribeButton::get_option( 'language' )
60
			);
61
			$preview .= "</div>";
62
63
			return $preview;
64
65
		}
66
67
	}
68
69
	public function column_id( $button ) {
70
		return $button->id;
71
	}
72
73
	public function get_columns() {
74
		return array(
75
			'name'           => __( 'Title & Shortcode', 'podlove-subscribe-button' ),
76
			'button_preview' => __( 'Preview', 'podlove-subscribe-button' ),
77
		);
78
	}
79
80
	public function prepare_items() {
81
82
		// number of items per page
83
		$per_page = 1000;
84
85
		// define column headers
86
		$columns = $this->get_columns();
87
		$hidden = array();
88
		$sortable = $this->get_sortable_columns();
89
		$this->_column_headers = array( $columns, $hidden, $sortable );
90
91
		// retrieve data
92
		// TODO select data for current page only
93
		$data = ( is_network_admin() ? Model\NetworkButton::all() : Model\Button::all() );
94
95
		// get current page
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
96
		$current_page = $this->get_pagenum();
97
		// get total items
98
		$total_items = count( $data );
99
		// extrage page for current page only
100
		$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
101
		// add items to table
102
		$this->items = $data;
103
104
		// register pagination options & calculations
105
		$this->set_pagination_args( array(
106
			'total_items' => $total_items,
107
			'per_page'    => $per_page,
108
			'total_pages' => ceil( $total_items / $per_page ),
109
		) );
110
111
	}
112
113
} // END class
114