Skip to content

Commit 2441ca7

Browse files
committed
Use a filter for get_columns
This prevents a strict standards error for the get_columns method and fixes #90.
1 parent 5281d84 commit 2441ca7

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

common/lib/acm-wp-list-table.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ function __construct( $params = array() ) {
2424
*
2525
* @return array $columns, the array of columns to use with the table
2626
*/
27-
function get_columns( $columns = false ) {
28-
$default = array(
27+
function get_columns() {
28+
$columns = apply_filters( 'acm_list_table_columns', array(
2929
'cb' => '<input type="checkbox" />',
3030
'id' => __( 'ID', 'ad-code-manager' ),
3131
'name' => __( 'Name', 'ad-code-manager' ),
3232
'priority' => __( 'Priority', 'ad-code-manager' ),
3333
'operator' => __( 'Logical Operator', 'ad-code-manager' ),
3434
'conditionals' => __( 'Conditionals', 'ad-code-manager' ),
35-
);
36-
$columns = apply_filters( 'acm_list_table_columns', !is_array( $columns ) || empty( $columns ) ? $default : $columns );
35+
) );
3736
// Fail-safe for misconfiguration
3837
$required_before = array(
3938
'id' => __( 'ID', 'ad-code-manager' ),

providers/doubleclick-for-publishers-async.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,11 @@ function __construct() {
215215
) );
216216
}
217217

218-
219218
/**
220-
* This is nuts and bolts of table representation
219+
* @return array The columns that shall be used
221220
*/
222-
function get_columns( $columns = null ) {
223-
$columns = array(
221+
function filter_columns() {
222+
return array(
224223
'cb' => '<input type="checkbox" />',
225224
'id' => __( 'ID', 'ad-code-manager' ),
226225
'tag' => __( 'Tag', 'ad-code-manager' ),
@@ -231,7 +230,14 @@ function get_columns( $columns = null ) {
231230
'operator' => __( 'Logical Operator', 'ad-code-manager' ),
232231
'conditionals' => __( 'Conditionals', 'ad-code-manager' ),
233232
);
234-
return parent::get_columns( $columns );
233+
}
234+
235+
/**
236+
* This is nuts and bolts of table representation
237+
*/
238+
function get_columns() {
239+
add_filter( 'acm_list_table_columns', array( $this, 'filter_columns' ) );
240+
return parent::get_columns();
235241
}
236242

237243
/**

providers/doubleclick-for-publishers.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ function __construct() {
9393
) );
9494
}
9595

96-
9796
/**
98-
* This is nuts and bolts of table representation
97+
* @return array The columns that shall be used
9998
*/
100-
function get_columns( $columns = null ) {
101-
$columns = array(
99+
function filter_columns() {
100+
return array(
102101
'cb' => '<input type="checkbox" />',
103102
'id' => __( 'ID', 'ad-code-manager' ),
104103
'site_name' => __( 'Site Name', 'ad-code-manager' ),
@@ -107,7 +106,14 @@ function get_columns( $columns = null ) {
107106
'operator' => __( 'Logical Operator', 'ad-code-manager' ),
108107
'conditionals' => __( 'Conditionals', 'ad-code-manager' ),
109108
);
110-
return parent::get_columns( $columns );
109+
}
110+
111+
/**
112+
* This is nuts and bolts of table representation
113+
*/
114+
function get_columns() {
115+
add_filter( 'acm_list_table_columns', array( $this, 'filter_columns' ) );
116+
return parent::get_columns();
111117
}
112118

113119
/**

providers/google-adsense.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ public function __construct() {
161161
}
162162

163163
/**
164-
* This is nuts and bolts of table representation
164+
* @return array The columns that shall be used
165165
*/
166-
function get_columns( $columns = null ) {
167-
$columns = array(
166+
function filter_columns() {
167+
return array(
168168
'cb' => '<input type="checkbox" />',
169169
'id' => __( 'ID', 'ad-code-manager' ),
170170
'tag' => __( 'Tag', 'ad-code-manager' ),
@@ -174,7 +174,14 @@ function get_columns( $columns = null ) {
174174
'operator' => __( 'Logical Operator', 'ad-code-manager' ),
175175
'conditionals' => __( 'Conditionals', 'ad-code-manager' ),
176176
);
177-
return parent::get_columns( $columns );
177+
}
178+
179+
/**
180+
* This is nuts and bolts of table representation
181+
*/
182+
function get_columns() {
183+
add_filter( 'acm_list_table_columns', array( $this, 'filter_columns' ) );
184+
return parent::get_columns();
178185
}
179186

180187
/**

0 commit comments

Comments
 (0)