forked from kmhcreative/zappbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzappbar.php
278 lines (261 loc) · 9.37 KB
/
zappbar.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php
/*
Plugin Name: ZappBar
Plugin URI: https://github.com/kmhcreative/zappbar
Description: Adds mobile-friendly web app navigation and toolbars to any WordPress theme.
Version: 0.2
Author: K.M. Hansen
Author URI: http://www.kmhcreative.com
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
GitHub Plugin URI: https://github.com/kmhcreative/zappbar
GitHub Branch: master
Copyright 2012-2015 K.M. Hansen (email : [email protected])
==== Alpha Version Disclaimer =====
This plugin is still being tested is incomplete!
Do not use it in production unless you can live
without the things it is missing and are willing
to accept the possibility that it could screw up
your website. Things left on To-Do list:
* option to clear/reset settings
* database clean-up on uninstall
* auto-update from repository
* make it more awesome!
===================================
*/
// Make sure they are using the minimum supported WP version first, if not then bail
function zb_version_check() {
$wp_version = get_bloginfo('version');
if ($wp_version < 3.5) {
global $pagenow;
if ( is_admin() && $pagenow=="plugins.php" ) {
echo "<div class='error'><p><b>ERROR:</b> ZappBar is <em>activated</em> but requires <b>WordPress 3.5</b> or greater to work. You are currently running <em>Wordpress <span style='color:red;'>".$wp_version."</span>,</em> please upgrade.</p></div>";
}
return;
};
}
register_activation_hook( __FILE__, 'zb_version_check' );
/*
DEFAULT SETTINGS
*/
function zb_add_defaults($reset = false) {
if ( $reset===true ) {
delete_option('zappbar_site');
delete_option('zappbar_colors');
delete_option('zappbar_panels');
delete_option('zappbar_layout');
}
$zb_site = get_option('zappbar_site');
if (empty($zb_site)) {
$zb_site = array(
'responsive' => '0',
'fix_admin' => 'no',
'sidebars' => '1',
'adminbar' => 'off',
'showon' => 'none',
'applyto' => 'all',
'altertheme' => array(
'header' => 'header',
'sitenav' => 'sitenav',
'commentform'=> 'commentform',
'push' => 'push'),
'app_icon' => '',
'splash_screen' => '',
'splash_size' => 'contain',
'header_custom' => '',
'nav_custom' => '',
'comment_custom' => '',
'sidebars_custom'=> '',
'comic_nav' => '',
'alter_woo_theme'=> array(
'woo_reviews' => 'woo_reviews',
'woo_desc' => 'woo_desc',
'woo_addl' => 'woo_addl')
);
update_option('zappbar_site' , $zb_site);
}
$zb_social = get_option('zappbar_social');
if (empty($zb_social)) {
$zb_social = array(
'fb_default_img' => '',
'twitter_id' => '',
'phone_number' => '',
'email_address' => '',
'social_panel' => array(
'facebook' => 'facebook',
'twitter' => 'twitter',
'google' => 'google',
'reddit' => 'reddit',
'stumble' => 'stumble',
'digg' => 'digg',
'linkedin' => 'linkedin',
'pinterest' => 'pinterest',
'delicious' => 'delicious',
'rss' => 'rss',
'email' => 'email'
)
);
update_option('zappbar_social' , $zb_social);
}
$zb_colors = get_option('zappbar_colors');
if (empty($zb_colors)) {
$zb_colors = array(
'color_src' => 'basic',
'custom_styles' => '',
'bar_bg' => '#ffffff',
'bar_bg_opacity' => '1.0',
'button_bg' => '#ffffff',
'button_bg_opacity' => '1.0',
'button_hover_bg' => '#cccccc',
'button_bg_hover_opacity' => '1.0',
'font_color' => '#333333',
'font_hover_color' => '#000000',
'bar_border_color' => '#000000',
'bar_border_style' => '',
'bar_border_width' => '',
);
update_option('zappbar_colors' , $zb_colors);
};
$zb_panels = get_option('zappbar_panels');
if (empty($zb_panels)) {
$zb_panels = array(
'panel_menu' => '0',
'panel_tabs' => 'yes',
'panel_styles' => 'on',
'panel_bg' => '#ffffff',
'panel_bg_opacity' => '1.0',
'panel_button_bg' => '#ffffff',
'panel_button_bg_opacity' => '1.0',
'panel_button_hover_bg' => '#cccccc',
'panel_button_hover_bg_opacity' => '1.0',
'panel_font_color' => '#333333',
'panel_font_hover_color' => '#000000',
'panel_border_color' => '#000000',
'panel_border_style' => '',
'panel_border_width' => ''
);
update_option('zappbar_panels' , $zb_panels);
}
$zb_layout = get_option('zappbar_layout');
if (empty($zb_layout)) {
$zb_layout = array(
'button_layout' => 'spread',
'search_button' => 'on',
'logo' => '',
'default_top' => array(
array('dashicons|dashicons-menu','Menu','appmenu_left'),
array('dashicons|dashicons-blank','',''),
array('dashicons|dashicons-admin-home','Home',get_home_url()),
array('dashicons|dashicons-blank','', ''),
array('dashicons|dashicons-search','Search','search_right')
),
'default_bottom' => array(
array('dashicons|dashicons-wordpress','Blog','blogposts'),
array('dashicons|dashicons-info','About',''),
array('dashicons|dashicons-admin-comments','Comment','commentform'),
array('dashicons|dashicons-edit','Contact','mailto:'.get_bloginfo('admin_email')),
array('dashicons|dashicons-share','Share','share_this')
),
'use_archive_top_bar' => 'yes',
'archive_top_bar' => array(
array('dashicons|dashicons-menu','Menu','appmenu_left'),
array('dashicons|dashicons-blank','',''),
array('dashicons|dashicons-admin-home','Home',get_home_url()),
array('dashicons|dashicons-blank','', ''),
array('dashicons|dashicons-search','Search','search_right')
),
'use_archive_bottom_bar'=> 'yes',
'archive_bottom_bar'=> array(
array('dashicons|dashicons-arrow-left-alt','First','first_page'),
array('dashicons|dashicons-arrow-left-alt2','Previous','prev_page'),
array('dashicons|dashicons-blank','',''),
array('dashicons|dashicons-arrow-right-alt2','Next', 'next_page'),
array('dashicons|dashicons-arrow-right-alt','Last','last_page')
),
'use_comic_top_bar' => 'yes',
'comic_top_bar' => array(
array('dashicons|dashicons-menu','Menu','appmenu_left'),
array('fa|fa-angle-double-left','Prev Chap','prev_comic'),
array('dashicons|dashicons-admin-home','Home',get_home_url()),
array('fa|fa-angle-double-right','Next chap', 'next_comic'),
array('dashicons|dashicons-images-alt2','Archive','comic_archive')
),
'use_comic_bottom_bar' => 'yes',
'comic_bottom_bar' => array(
array('dashicons|dashicons-arrow-left-alt','First','first_comic'),
array('dashicons|dashicons-arrow-left-alt2','Previous','prev_comic'),
array('dashicons|dashicons-admin-comments','Comment','commentform'),
array('dashicons|dashicons-arrow-right-alt2','Next', 'next_comic'),
array('dashicons|dashicons-arrow-right-alt','Last','last_comic')
),
'use_woo_top_bar' => 'yes',
'woo_top_bar' => array(
array('dashicons|dashicons-menu','Menu','appmenu_left'),
array('dashicons|dashicons-cart','Cart','woo_cart'),
array('dashicons|dashicons-admin-home','Home',get_home_url()),
array('dashicons|dashicons-admin-users','Account', 'woo_account'),
array('dashicons|dashicons-search','Search','woo_search_right')
),
'use_woo_bottom_bar'=> 'yes',
'woo_bottom_bar' => array(
array('dashicons|dashicons-products','Store','woo_store'),
array('dashicons|dashicons-tag','Info','woo_desc'),
array('dashicons|dashicons-star-filled','Reviews','woo_review'),
array('fa|fa-tags','More Info', 'woo_addl'),
array('dashicons|dashicons-share','Share','share_this')
)
);
update_option('zappbar_layout' , $zb_layout);
};
};
register_activation_hook(__FILE__, 'zb_add_defaults');
// Plugin Info Function
function zappbar_pluginfo($whichinfo = null) {
global $zappbar_pluginfo;
if (empty($zappbar_pluginfo) || $whichinfo == 'reset') {
// Important to assign pluginfo as an array to begin with.
$zappbar_pluginfo = array();
$zappbar_addinfo = array(
// plugin directory/url
'plugin_file' => __FILE__,
'plugin_url' => plugin_dir_url(__FILE__),
'plugin_path' => plugin_dir_path(__FILE__),
'plugin_basename' => plugin_basename(__FILE__),
'version' => '0.2'
);
// Combine em.
$zappbar_pluginfo = array_merge($zappbar_pluginfo, $zappbar_addinfo);
}
if ($whichinfo) {
if (isset($zappbar_pluginfo[$whichinfo])) {
return $zappbar_pluginfo[$whichinfo];
} else return false;
}
return $zappbar_pluginfo;
}
if ( is_admin() ) {
// We are on the back end
@require('functions/admin_functions.php');
@require('functions/utility_functions.php');
@require('functions/class.settings-api.php');
@require('functions/aq_resizer.php');
@require('options/zappbar_options.php');
} else {
// We are on the front end
@require('functions/utility_functions.php');
@require('functions/aq_resizer.php');
@require('includes/html_inject.php');
}
// Load all the widgets
foreach (glob(plugin_dir_path(__FILE__) . 'widgets/*.php') as $widgefile) {
require_once($widgefile);
}
$zb_site = get_option('zappbar_site');
if ($zb_site['adminbar']=='on') { // "on" means do not show bar
add_filter('show_admin_bar', '__return_false');
function remove_admin_bar_space () {
remove_action( 'wp_head', '_admin_bar_bump_cb' );
}
add_action( 'admin_bar_init', 'remove_admin_bar_space' );
}
?>