| 1 |
<?php |
| 2 |
/** |
| 3 |
* Statify: Statify class |
| 4 |
* |
| 5 |
* This file contains the plugin's base class. |
| 6 |
* |
| 7 |
* @package Statify |
| 8 |
* @since 0.1.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
// Quit if accessed outside WP context. |
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* Statify. |
| 16 |
* |
| 17 |
* @since 0.1.0 |
| 18 |
*/ |
| 19 |
class Statify { |
| 20 |
|
| 21 |
/** |
| 22 |
* Plugin options. |
| 23 |
* |
| 24 |
* @since 1.4.0 |
| 25 |
* @var array $_options |
| 26 |
*/ |
| 27 |
public static $_options; |
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* Class self initialize. |
| 32 |
* |
| 33 |
* @since 0.1.0 |
| 34 |
* @version 0.1.0 |
| 35 |
*/ |
| 36 |
public static function instance() { |
| 37 |
new self(); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Class constructor |
| 42 |
* |
| 43 |
* @since 0.1.0 |
| 44 |
* @version 2017-01-10 |
| 45 |
*/ |
| 46 |
public function __construct() { |
| 47 |
// Skip me! |
| 48 |
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
// Table init. |
| 53 |
Statify_Table::init(); |
| 54 |
|
| 55 |
// Plugin options. |
| 56 |
self::$_options = wp_parse_args( |
| 57 |
get_option( 'statify' ), |
| 58 |
array( |
| 59 |
'days' => 14, |
| 60 |
'limit' => 3, |
| 61 |
'today' => 0, |
| 62 |
'snippet' => 0, |
| 63 |
'blacklist' => 0, |
| 64 |
) |
| 65 |
); |
| 66 |
|
| 67 |
if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { // XMLRPC. |
| 68 |
add_filter( 'xmlrpc_methods', array( 'Statify_XMLRPC', 'xmlrpc_methods' ) ); |
| 69 |
} elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) { // Cron. |
| 70 |
add_action( 'statify_cleanup', array( 'Statify_Cron', 'cleanup_data' ) ); |
| 71 |
} elseif ( is_admin() ) { // Backend. |
| 72 |
add_action( 'wpmu_new_blog', array( 'Statify_Install', 'init_site' ) ); |
| 73 |
add_action( 'delete_blog', array( 'Statify_Uninstall', 'init_site' ) ); |
| 74 |
add_action( 'wp_dashboard_setup', array( 'Statify_Dashboard', 'init' ) ); |
| 75 |
add_filter( 'plugin_row_meta', array( 'Statify_Backend', 'add_meta_link' ), 10, 2 ); |
| 76 |
add_filter( 'plugin_action_links_' . STATIFY_BASE, array( 'Statify_Backend', 'add_action_link' ) ); |
| 77 |
} else { // Frontend. |
| 78 |
add_action( 'template_redirect', array( 'Statify_Frontend', 'track_visit' ) ); |
| 79 |
add_filter( 'query_vars', array( 'Statify_Frontend', 'query_vars' ) ); |
| 80 |
add_action( 'wp_footer', array( 'Statify_Frontend', 'wp_footer' ) ); |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
|