/
colophon.plugin.php
80 lines (68 loc) · 2.16 KB
/
colophon.plugin.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
<?php
/*
* Colophon Habari Plugin
* This plugin allows the blog owner to include an about/colophon somewhere on the blog
* without having to rely on a page or theme rewrite, since the about option got killed
*
* Usage:
* <?php $theme->colophon(); ?>
* To customize the output, copy colophon.php from the plugin directory to your theme
* directory and edit that file.
*/
class Colophon extends Plugin
{
/**
* Add actions to the plugin page for this plugin
* @param array $actions An array of actions to apply to this plugin
* @param string $plugin_id The string with the plugin id, generated by the system
* @return array $actions Array of actions to atach to the specified $plugin_id
*/
public function filter_plugin_config($actions,$plugin_id)
{
if( $plugin_id == $this->plugin_id()) {
$actions[] = _t('Configure');
}
return $actions;
}
/**
* Add update beacon support
**/
public function action_update_check()
{
Update::add( 'Colophon', 'c3eaec26-0bde-44db-b1f6-baaa8aedefea', $this->info->version );
}
/**
* Method that responds to the user selecting an action on the plugin page
* @param string $plugin_id String containing the id of the plugin
* @param string $action The action string supplied via the filter_plugin_config hook
**/
public function action_plugin_ui( $plugin_id, $action )
{
if ( $plugin_id == $this->plugin_id() ) {
switch( $action ) {
case _t('Configure'):
$ui = new FormUI ( strtolower( get_class( $this ) ) );
$ui->append( 'text', 'title', 'colophon__title', _t('Enter your Title:') );
$ui->append( 'textarea', 'text', 'colophon__text', _t('Enter your Text:') );
$ui->append( 'submit', 'save', _t( 'Save' ) );
$ui->out();
break;
}
}
}
/**
* Assigns output code to the template variables
* @param Theme $theme The theme that will display the template
*/
function theme_colophon( $theme )
{
$theme->colophon_text = Format::autop( Options::get( 'colophon__text' ) );
$theme->colophon_title = Options::get( 'colophon__title' );
return $theme->fetch( 'colophon' );
}
public function action_init()
{
$this->add_template('colophon', dirname(__FILE__) . '/colophon.php');
}
}
?>