-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmpp-media-view-counter.php
73 lines (52 loc) · 1.43 KB
/
mpp-media-view-counter.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Plugin Name: MediaPress - Media View Counter
* Version: 1.0.0
* Plugin URI: http://buddydev.com/plugins/mpp-media-view-counter/
* Author: BuddyDev Team
* Author URI: BuddyDev.com
* Description: Count Media Views and show total media views for MediaPress photo, audio video etc.
* License: GPL
*
*/
class MPP_Media_View_Counter {
private static $instance = null;
private $path;
private $url;
private function __construct () {
$this->path = plugin_dir_path( __FILE__ );
$this->url = plugin_dir_url( __FILE__ );
//setup hooks
$this->setup_hooks();
}
private function setup_hooks() {
//load required files when MediaPress is loaded
add_action( 'mpp_loaded', array( $this, 'load' ) );
add_action( 'mpp_init', array( $this, 'load_textdomain' ) );
}
public static function get_instance() {
if( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function load_textdomain() {
load_plugin_textdomain( 'mpp-media-view-counter', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
/**
* Load required files
*/
public function load() {
$files = array(
'core/actions.php',
'core/functions.php'
);
if( is_admin() && ! defined( 'DOING_AJAX' ) ) {
$files[] = 'admin/admin.php';
}
foreach ( $files as $file ) {
require_once $this->path . $file ;
}
}
}
MPP_Media_View_Counter::get_instance();