-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrowdclock_Plugin.php
More file actions
126 lines (99 loc) · 4.46 KB
/
crowdclock_Plugin.php
File metadata and controls
126 lines (99 loc) · 4.46 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
include_once('crowdclock_LifeCycle.php');
include_once('crowdclock_Widget.php');
class crowdclock_Plugin extends crowdclock_LifeCycle {
/**
* See: http://plugin.michael-simpson.com/?page_id=31
* @return array of option meta data.
*/
public function getOptionMetaData() {
// http://plugin.michael-simpson.com/?page_id=31
return array(
//'_version' => array('Installed Version'), // Leave this one commented-out. Uncomment to test upgrades.
'ATextInput' => array(__('Enter Business ID', 'my-awesome-plugin')),
'BTextInput' => array(__('Enter User Key', 'my-awesome-plugin')),
'widgetWidth' => array(__('Enter Width', 'my-awesome-plugin')),
'widgetHeight' => array(__('Enter Height', 'my-awesome-plugin'))
);
}
// protected function getOptionValueI18nString($optionValue) {
// $i18nValue = parent::getOptionValueI18nString($optionValue);
// return $i18nValue;
// }
protected function initOptions() {
$options = $this->getOptionMetaData();
if (!empty($options)) {
foreach ($options as $key => $arr) {
if (is_array($arr) && count($arr > 1)) {
$this->addOption($key, $arr[1]);
}
}
}
}
public function getPluginDisplayName() {
return 'CrowdClock';
}
protected function getMainPluginFileName() {
return 'crowdclock.php';
}
/**
* See: http://plugin.michael-simpson.com/?page_id=101
* Called by install() to create any database tables if needed.
* Best Practice:
* (1) Prefix all table names with $wpdb->prefix
* (2) make table names lower case only
* @return void
*/
protected function installDatabaseTables() {
// global $wpdb;
// $tableName = $this->prefixTableName('mytable');
// $wpdb->query("CREATE TABLE IF NOT EXISTS `$tableName` (
// `id` INTEGER NOT NULL");
}
/**
* See: http://plugin.michael-simpson.com/?page_id=101
* Drop plugin-created tables on uninstall.
* @return void
*/
protected function unInstallDatabaseTables() {
// global $wpdb;
// $tableName = $this->prefixTableName('mytable');
// $wpdb->query("DROP TABLE IF EXISTS `$tableName`");
}
/**
* Perform actions when upgrading from version X to version Y
* See: http://plugin.michael-simpson.com/?page_id=35
* @return void
*/
public function upgrade() {
}
public function addActionsAndFilters() {
// Add options administration page
// http://plugin.michael-simpson.com/?page_id=47
add_action('admin_menu', array(&$this, 'addSettingsSubMenuPage'));
add_shortcode('crowdclock', array($this, 'showCrowdClockWidget'));
// Example adding a script & style just for the options administration page
// http://plugin.michael-simpson.com/?page_id=47
// if (strpos($_SERVER['REQUEST_URI'], $this->getSettingsSlug()) !== false) {
// wp_enqueue_script('my-script', plugins_url('/js/my-script.js', __FILE__));
// wp_enqueue_style('my-style', plugins_url('/css/my-style.css', __FILE__));
// }
// Add Actions & Filters
// http://plugin.michael-simpson.com/?page_id=37
// Adding scripts & styles to all pages
// Examples:
// wp_enqueue_script('jquery');
// wp_enqueue_style('my-style', plugins_url('/css/my-style.css', __FILE__));
// wp_enqueue_script('my-script', plugins_url('/js/my-script.js', __FILE__));
// Register short codes
// http://plugin.michael-simpson.com/?page_id=39
// Register AJAX hooks
// http://plugin.michael-simpson.com/?page_id=41
}
public function showCrowdClockWidget() {
$url = 'http://www.crowdclock.com/widget/index.html?businessId=' . $this->getOption("ATextInput") ."&user_key=".$this->getOption("BTextInput");
$widgetWidth = $this->getOption("widgetWidth") == "" ? '250' : $this->getOption("widgetWidth");
$widgetHeight = $this->getOption("widgetHeight") == "" ? '350' : $this->getOption("widgetHeight");
return '<iframe src="'. $url .'" width="'. $widgetWidth .'" height="'. $widgetHeight .'" frameborder="0" seamless></iframe>';
}
}