-
Notifications
You must be signed in to change notification settings - Fork 2
/
comment-mixer.php
110 lines (78 loc) · 2.43 KB
/
comment-mixer.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/*
Plugin Name: Comment Mixer
Plugin URI: http://github.com/danielbachhuber/Comment-Mixer
Description: Structured commenting for WordPress
Author: Daniel Bachhuber et al
Version: 0.1
Author URI: http://www.danielbachhuber.com/
*/
define('COMMENT_MIXER_FILE_PATH', __FILE__);
require_once('php/taxonomies.php');
require_once('php/settings.php');
if ( !class_exists('comment_mixer') ) {
class comment_mixer {
var $options_group = 'comment_mixer_';
var $options_name = 'comment_mixer_options';
var $top_level_page = 'comment_mixer';
var $settings_page = 'comment_mixer_settings';
function __construct() {
}
/**
* @todo normal initialization
*/
function init() {
// Initialize all of our classes
$this->settings = new comment_mixer_settings();
$this->taxonomies = new comment_mixer_taxonomies();
$this->taxonomies->init();
// Save the options to our object
$this->options = get_option( $this->options_name );
if ( is_admin() ) {
add_action( 'admin_menu', array(&$this, 'add_admin_menu_items') );
}
}
/**
* @todo admin initialization
*/
function admin_init() {
$this->settings->init();
}
/**
* Enqueue any admin assets we need
* @todo Finish
*/
function add_admin_assets() {
}
/**
* Any admin menu items we need
* @todo Add all of our settings page options
*/
function add_admin_menu_items() {
// Top-level Comment Mixer page
add_menu_page( 'Comment Mixer', 'Comment Mixer',
'manage_options', $this->top_level_page,
array(&$this->settings, 'settings_page'));
// Taxonomy page
add_submenu_page( $this->top_level_page, 'Comment Types',
'Comment Types', 'manage_options', 'edit-tags.php?taxonomy='.$this->taxonomies->taxonomy_label);
}
/**
* Default settings for when the plugin is activated for the first time
* @todo Initial settings on install
*/
function activate_plugin() {
// Install settings for these objects on activation
$this->settings->activate_once();
$this->taxonomies->activate_once();
}
} // END: class comment_mixer
global $comment_mixer;
$comment_mixer = new comment_mixer();
}
// Core hooks to initialize the plugin
add_action( 'init', array( &$comment_mixer, 'init' ) );
add_action( 'admin_init', array( &$comment_mixer, 'admin_init' ) );
// Hook to perform action when plugin activated
register_activation_hook( COMMENT_MIXER_FILE_PATH, array(&$comment_mixer, 'activate_plugin') );
?>