| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
/* Quit */ |
| 5 |
defined('ABSPATH') OR exit; |
| 6 |
|
| 7 |
|
| 8 |
/** |
| 9 |
* Statify |
| 10 |
* |
| 11 |
* @since 0.1.0 |
| 12 |
*/ |
| 13 |
|
| 14 |
class Statify |
| 15 |
{ |
| 16 |
|
| 17 |
|
| 18 |
/** |
| 19 |
* Plugin options |
| 20 |
* |
| 21 |
* @since 1.4.0 |
| 22 |
*/ |
| 23 |
|
| 24 |
public static $_options; |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* Class self initialize |
| 29 |
* |
| 30 |
* @since 0.1.0 |
| 31 |
* @change 0.1.0 |
| 32 |
*/ |
| 33 |
|
| 34 |
public static function instance() |
| 35 |
{ |
| 36 |
new self(); |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
/** |
| 41 |
* Class constructor |
| 42 |
* |
| 43 |
* @since 0.1.0 |
| 44 |
* @change 1.4.0 |
| 45 |
*/ |
| 46 |
|
| 47 |
public function __construct() |
| 48 |
{ |
| 49 |
/* Skip me! */ |
| 50 |
if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) OR (defined('DOING_AJAX') && DOING_AJAX) ) { |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
/* Table init */ |
| 55 |
Statify_Table::init(); |
| 56 |
|
| 57 |
/* Plugin options */ |
| 58 |
self::$_options = wp_parse_args( |
| 59 |
get_option('statify'), |
| 60 |
array( |
| 61 |
'days' => 14, |
| 62 |
'limit' => 3, |
| 63 |
'today' => 0, |
| 64 |
'snippet' => 0 |
| 65 |
) |
| 66 |
); |
| 67 |
|
| 68 |
/* XMLRPC */ |
| 69 |
if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) { |
| 70 |
add_filter( |
| 71 |
'xmlrpc_methods', |
| 72 |
array( |
| 73 |
'Statify_XMLRPC', |
| 74 |
'xmlrpc_methods' |
| 75 |
) |
| 76 |
); |
| 77 |
|
| 78 |
/* Cron */ |
| 79 |
} else if ( defined('DOING_CRON') && DOING_CRON ) { |
| 80 |
add_action( |
| 81 |
'statify_cleanup', |
| 82 |
array( |
| 83 |
'Statify_Cron', |
| 84 |
'cleanup_data' |
| 85 |
) |
| 86 |
); |
| 87 |
|
| 88 |
/* Backend */ |
| 89 |
} else if ( is_admin() ) { |
| 90 |
add_action( |
| 91 |
'wpmu_new_blog', |
| 92 |
array( |
| 93 |
'Statify_Install', |
| 94 |
'init' |
| 95 |
) |
| 96 |
); |
| 97 |
add_action( |
| 98 |
'delete_blog', |
| 99 |
array( |
| 100 |
'Statify_Uninstall', |
| 101 |
'init' |
| 102 |
) |
| 103 |
); |
| 104 |
add_action( |
| 105 |
'wp_dashboard_setup', |
| 106 |
array( |
| 107 |
'Statify_Dashboard', |
| 108 |
'init' |
| 109 |
) |
| 110 |
); |
| 111 |
add_filter( |
| 112 |
'plugin_row_meta', |
| 113 |
array( |
| 114 |
'Statify_Backend', |
| 115 |
'add_meta_link' |
| 116 |
), |
| 117 |
10, |
| 118 |
2 |
| 119 |
); |
| 120 |
add_filter( |
| 121 |
'plugin_action_links_' .STATIFY_BASE, |
| 122 |
array( |
| 123 |
'Statify_Backend', |
| 124 |
'add_action_link' |
| 125 |
) |
| 126 |
); |
| 127 |
|
| 128 |
/* Frontend */ |
| 129 |
} else { |
| 130 |
add_action( |
| 131 |
'template_redirect', |
| 132 |
array( |
| 133 |
'Statify_Frontend', |
| 134 |
'track_visit' |
| 135 |
) |
| 136 |
); |
| 137 |
add_filter( |
| 138 |
'query_vars', |
| 139 |
array( |
| 140 |
'Statify_Frontend', |
| 141 |
'query_vars' |
| 142 |
) |
| 143 |
); |
| 144 |
add_action( |
| 145 |
'wp_footer', |
| 146 |
array( |
| 147 |
'Statify_Frontend', |
| 148 |
'wp_footer' |
| 149 |
) |
| 150 |
); |
| 151 |
} |
| 152 |
} |
| 153 |
} |