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 ( 0392a4...4f7518 )
by Christian
02:13
created

settings/buttons_list_table.php (13 issues)

1
<?php
2
namespace PodloveSubscribeButton;
3
4
if ( ! class_exists( 'WP_List_Table' ) ) {
5
    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
6
}
7
8
class Button_List_Table extends \WP_List_Table {
9
10
	public function __construct() {
11
12
		global $status, $page;
13
14
		// Set parent defaults
15
		parent::__construct( array(
16
			'singular' => 'feed', // singular name of the listed records
17
			'plural'   => 'feeds', // plural name of the listed records
18
			'ajax'     => false  // does this table support ajax?
19
		) );
20
21
	}
22
23
	public function column_name( $button ) {
0 ignored issues
show
Method name "Button_List_Table::column_name" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function column_name()
Loading history...
24
25
		$actions = array(
26
			'edit'   => Settings\Buttons::get_action_link( $button, __( 'Edit', 'podlove-subscribe-button' ), 'edit' ),
27
			'delete' => Settings\Buttons::get_action_link( $button, __( 'Delete', 'podlove-subscribe-button' ), 'confirm_delete' )
28
		);
29
30
		return sprintf( '%1$s %2$s',
31
		    /*$1%s*/ $button->title . '<br><code>[podlove-subscribe-button button="' . $button->name . '"]</code>',
32
		    /*$3%s*/ $this->row_actions( $actions )
33
		);
34
35
	}
36
37
	public function column_button_preview( $button ) {
0 ignored issues
show
Method name "Button_List_Table::column_button_preview" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function column_button_preview()
Loading history...
38
		if ( ! $button->feeds )
39
			return;
40
41
		$is_network = is_network_admin();
42
43
		return "<div class='podlove-button-preview-container'>"
44
		       . $button->render(
0 ignored issues
show
Found precision alignment of 3 spaces.
Loading history...
Opening statement of multi-line function call not indented correctly; expected 12 spaces but found 15
Loading history...
45
				'big',
46
				'false',
47
				get_option( 'podlove_subscribe_button_default_style', 'filled' ),
48
				'rectangle'
49
			)
50
		       . "</div>";
0 ignored issues
show
Found precision alignment of 3 spaces.
Loading history...
51
52
	}
53
54
	public function column_id( $button ) {
0 ignored issues
show
Method name "Button_List_Table::column_id" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function column_id()
Loading history...
55
		return $button->id;
56
	}
57
58
	public function get_columns() {
0 ignored issues
show
Method name "Button_List_Table::get_columns" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function get_columns()
Loading history...
59
		return array(
60
			'name'           => __( 'Title & Shortcode', 'podlove-subscribe-button' ),
61
			'button_preview' => __( 'Preview', 'podlove-subscribe-button' )
62
		);
63
	}
64
65
	public function prepare_items() {
0 ignored issues
show
Method name "Button_List_Table::prepare_items" is not in camel caps format
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function prepare_items()
Loading history...
66
67
		// number of items per page
68
		$per_page = 1000;
69
70
		// define column headers
71
		$columns = $this->get_columns();
72
		$hidden = array();
73
		$sortable = $this->get_sortable_columns();
74
		$this->_column_headers = array( $columns, $hidden, $sortable );
75
76
		// retrieve data
77
		// TODO select data for current page only
78
		$data = ( is_network_admin() ? \PodloveSubscribeButton\Model\NetworkButton::all() : \PodloveSubscribeButton\Model\Button::all() );
79
80
		// get current page
81
		$current_page = $this->get_pagenum();
82
		// get total items
83
		$total_items = count( $data );
84
		// extrage page for current page only
85
		$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
86
		// add items to table
87
		$this->items = $data;
88
89
		// register pagination options & calculations
90
		$this->set_pagination_args( array(
91
			'total_items' => $total_items,
92
			'per_page'    => $per_page,
93
			'total_pages' => ceil( $total_items / $per_page )
94
		) );
95
96
	}
97
98
} // END class
99