-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrng-postviews.php
38 lines (35 loc) · 1.51 KB
/
rng-postviews.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/*
Plugin Name: rng-postviews
Description: WordPress plugin that set post view count for each post and reports them in a chart. in a front end, you have a widget and shortcode to show post view count.
Version: 1.0
Author: Abolfazl Sabagh
Author URI: http://asabagh.ir
License: GPLv2 or later
Text Domain: rng-postviews
*/
define("RNGJA_FILE", __FILE__);
define("RNGJA_PRU", plugin_basename(__FILE__));
define("RNGJA_PDU", plugin_dir_url(__FILE__)); //http://localhost:8888/rng-plugin/wp-content/plugins/rng-postViews/
define("RNGJA_PRT", basename(__DIR__)); //rng-postviews.php
define("RNGJA_PDP", plugin_dir_path(__FILE__)); //Applications/MAMP/htdocs/rng-plugin/wp-content/plugins/rng-postViews
define("RNGJA_TMP", RNGJA_PDP . "/public/"); // view OR templates directory for public
define("RNGJA_ADM", RNGJA_PDP . "/admin/"); // view OR templates directory for admin panel
require_once 'includes/class.init.php';
$rngja_init = new rngja_init(1.0, 'rng-postviews');
/**
* return post view count by id
* @global Object $rngja_postviewes
* @param Integer $post_id
* @return boolean
*/
function rngja_get_post_viewe_count($post_id = 0) {
global $rngja_postviewes;
$args = array('post_type' => get_post_type($post_id));
$is_legal_post_views = $rngja_postviewes->is_legal_post_veiws($args);
if (!$is_legal_post_views) {
return false;
}
$post_views = (int) $rngja_postviewes->get_post_views($post_id);
return $post_views;
}