-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-widget.php
72 lines (61 loc) · 1.69 KB
/
example-widget.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
<?php
/*
Plugin Name: Lion2486 example Widget
Plugin URI: http://codescar.eu
Description: An example widget using Lion2486 Widget Class.
Version: 1.0
Author: lion2486
Author URI: http://codescar.eu
License: None
*/
/**
* Example Widget based on lion2486-widget class.
*/
require_once( __DIR__ . '/lion2486-widget.php' );
class Lion2486_Example extends Lion2486_Widget{
//The widget ID, must be unique! (optional, if NULL, class name is used).
protected $WidgetID = NULL;
//WidgetDescription. Text to show on widget list (optional).
protected $WidgetDescription = "Lion2486 Sample Widget.";
//text domain for translations.
protected $textDomain = 'html5blank';
//Widget Name! (Human readable form)
protected $WidgetName = "Example Widget";
public function __construct( ) {
//Call the parent::__constructor()
parent::__construct();
//Here set your own fields.
$this->fields = array(
$this->field(
'title', //Name of the field
'Title', //Title (auto translation supported)
'The widget title field.', //Description (auto translation supported)
'text', //Type of the field
'Enter Title', //Default value
'', //Current value
$this->textDomain //text-domain to use
),
$this->field(
'html',
'Html Body',
'',
'html',
'html here...'
),
$this->field(
'image',
'Image',
'',
'media'
)
);
}
//For custom layout overwrite the widget() method as you wish!
// public function widget( $args, $instance ) {
// extract( $vars = $this->form_fields( $instance ) );
//
// echo $vars['title'];
//
// }
};
new Lion2486_Example();