forked from humanmade/hm-top-posts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhm-top-posts.php
50 lines (37 loc) · 1.15 KB
/
hm-top-posts.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
<?php
/*
Plugin Name: HM Top Posts
Description: Top Posts. By Google Analytics.
Version: 0.1
Author: Human Made Limited
Author URI: http://hmn.md
*/
define( 'HMTP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
if ( defined( 'HMTP_DISABLE_GA_TOP_POSTS' ) && HMTP_DISABLE_GA_TOP_POSTS )
return;
// The google analytics helper class.
if( ! class_exists( 'gapi' ) )
require_once( 'gapi.class.php' );
// All the admin settings pages.
require_once( 'hm-top-posts-admin.php' );
// Meta box to allow authors from opting out of top posts.
require_once( 'hm-top-posts-opt-out.php' );
// Get Top Posts from google analytics.
require_once( 'hm-top-posts-ga.php' );
/**
* If there has been an error - show our message
*/
function hmtp_top_posts_error_messaages()
{
$error = get_option( 'hmtp_top_posts_error_message' );
if ( ! current_user_can('administrator' ) || ! $error )
return;
$message = '<strong>Top Posts by Google Analytics Error: ' . $error . '</strong>';
?>
<div id="message" class="error">
<p><?php echo $message; ?></p>
</div>
<?php
delete_option( 'hmtp_top_posts_error_message' );
}
add_action('admin_notices', 'hmtp_top_posts_error_messaages');