pfeifferNet

Views
in package

Display page and post views on admin pages.

Tags
since
1.0.0
5.5.0

Inherit standard singleton class.

5.11.0

Deprecated global singleton.

Table of Contents

Constants

COUNT_KEY  : string = 'pnet_views_count'
Meta key for view counts.

Properties

$instances  : array<string|int, object>
The array of instances of this class and sub-classes.

Methods

add_views_column()  : array<string|int, string>
Adds views column to the admin page.
get_instance()  : object
Creates and/or returns the instance of this class.
populate_views_column()  : void
Returns post view for the column on the admin page.
sortable_views_column()  : array<string|int, string>
Make view column sortable.
sortable_views_column_orderby()  : void
Modify query to include views sortable column.
views_count()  : int
Returns view counter for a post.
__construct()  : void
Initialise the class.

Constants

COUNT_KEY

Meta key for view counts.

protected string COUNT_KEY = 'pnet_views_count'
Tags
since
1.0.0

Properties

$instances

The array of instances of this class and sub-classes.

protected static array<string|int, object> $instances = array()
Tags
since
5.11.0

Methods

add_views_column()

Adds views column to the admin page.

public add_views_column(array<string|int, string> $columns) : array<string|int, string>
Parameters
$columns : array<string|int, string>

Array of column name => label pairs.

Tags
since
1.0.0
Return values
array<string|int, string>

The modified columns array.

get_instance()

Creates and/or returns the instance of this class.

public static get_instance() : object
Tags
since
5.11.0
Return values
object

The instance of this class.

populate_views_column()

Returns post view for the column on the admin page.

public populate_views_column(string $column_name, int $post_id) : void
Parameters
$column_name : string

Name of the custom column.

$post_id : int

ID of the current post.

Tags
since
1.0.0

sortable_views_column()

Make view column sortable.

public sortable_views_column(array<string|int, string> $columns) : array<string|int, string>
Parameters
$columns : array<string|int, string>

Array of column name => label pairs.

Tags
since
1.0.0
Return values
array<string|int, string>

The modified columns array.

sortable_views_column_orderby()

Modify query to include views sortable column.

public sortable_views_column_orderby(object $query) : void
Parameters
$query : object

Query object, passed by reference.

Tags
since
1.0.0

views_count()

Returns view counter for a post.

public views_count(int $post_id) : int
Parameters
$post_id : int

ID of post or page.

Tags
since
1.0.0
Return values
int

Count of page views, or false if no post id.

__construct()

Initialise the class.

protected __construct() : void
Tags
since
5.11.0

        
On this page

Search results