/
helpify.plugin.php
85 lines (64 loc) · 1.8 KB
/
helpify.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
81
82
83
84
85
<?php
class Helpify extends Plugin
{
public function action_update_check()
{
Update::add( $this->info->name, 'a1477d5c-dc2d-42dd-91e8-d341723466b7', $this->info->version );
}
/**
* Add template
**/
public function action_init()
{
$this->add_template( 'help', dirname(__FILE__) . '/help.php' );
}
/**
* Add media files
**/
public function action_admin_header()
{
Stack::add('admin_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/helpify.css', 'screen'), 'helpify');
Stack::add( 'admin_header_javascript', URL::get_from_filesystem(__FILE__) . '/helpify.js', 'helpify', array('jquery', 'jquery.hotkeys') );
}
/**
* Create plugin configuration
**/
public function filter_plugin_config( $actions, $plugin_id )
{
if ( $plugin_id == $this->plugin_id() ) {
$actions[] = _t('Configure');
}
return $actions;
}
/**
* Create configuration panel
*/
public function action_plugin_ui( $plugin_id, $action )
{
if ( $plugin_id == $this->plugin_id() ) {
switch ( $action ) {
case _t('Configure') :
$form = new FormUI( strtolower( get_class( $this ) ) );
$form->append( 'textarea', 'help', strtolower( get_class( $this ) ) . '__help', _t('Help') );
$form->help->raw = true;
$form->append( 'submit', 'save', _t('Save') );
$form->out();
break;
}
}
}
/**
* Add the help to the publish form
*/
public function action_form_publish($form, $post) {
$selector = $form->append('wrapper', 'help_container');
$selector->class = 'container';
$theme = Themes::create();
$theme->help = Options::get( strtolower( get_class( $this ) ) . '__help' );
$content = $theme->fetch( 'help' );
$selector->append( 'static', 'help', $content );
$form->move_after($selector, $form->silos);
return $form;
}
}
?>