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 ( dc0f35...efd704 )
by Christian
15s
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
		if ( ! $button->feeds ) {
46
			return '<code>' . __( 'No preview. Please set a feed.', 'podlove-subscribe-button' ) . '</code>';
47
		} else {
48
			if ( is_network_admin() ) {
49
				$options = get_site_option( 'podlove_psb_defaults' );
50
			} else {
51
				$options = get_option( 'podlove_psb_defaults' );
52
			}
53
54
			$preview  = "<div class='podlove-button-preview-container'>";
55
			$preview .= $button->render(
56
				$options['size'],
57
				$options['autowidth'],
58
				$options['style'],
59
				$options['format'],
60
				$options['color'],
61
				false,
62
				false,
63
				$options['language']
64
			);
65
			$preview .= "</div>";
66
67
			return $preview;
68
		}
69
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
70
71
	public function column_id( $button ) {
72
		return $button->id;
73
	}
74
75
	public function get_columns() {
76
		return array(
77
			'name'           => __( 'Title & Shortcode', 'podlove-subscribe-button' ),
78
			'button_preview' => __( 'Preview', 'podlove-subscribe-button' ),
79
		);
80
	}
81
82
	public function prepare_items() {
83
84
		// number of items per page
85
		$per_page = 1000;
86
87
		// define column headers
88
		$columns = $this->get_columns();
89
		$hidden = array();
90
		$sortable = $this->get_sortable_columns();
91
		$this->_column_headers = array( $columns, $hidden, $sortable );
92
93
		// retrieve data
94
		// TODO select data for current page only
95
		$data = ( is_network_admin() ? Model\NetworkButton::all() : Model\Button::all() );
96
97
		// get current page
98
		$current_page = $this->get_pagenum();
99
		// get total items
100
		$total_items = count( $data );
101
		// extrage page for current page only
102
		$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
103
		// add items to table
104
		$this->items = $data;
105
106
		// register pagination options & calculations
107
		$this->set_pagination_args( array(
108
			'total_items' => $total_items,
109
			'per_page'    => $per_page,
110
			'total_pages' => ceil( $total_items / $per_page ),
111
		) );
112
113
	}
114
115
} // END class
116