-
Notifications
You must be signed in to change notification settings - Fork 8
/
functions.php
373 lines (290 loc) · 13.7 KB
/
functions.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?php
/*
* Green Park 2 Functions
*/
if (!isset($content_width))
$content_width = 607;
/*
* Sets up theme defaults and registers the various WordPress features
*/
function greenpark_setup() {
// Translations located at /languages/
load_theme_textdomain('greenpark', get_template_directory() . '/languages');
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
add_theme_support('title-tag');
// Adds RSS feed links to <head> for posts and comments.
add_theme_support('automatic-feed-links');
// This theme supports a variety of post formats.
add_theme_support('post-formats', array('aside', 'image', 'link', 'quote', 'status'));
/*
* This theme supports custom background color and image, and here
* we also set up the default background color.
*/
add_theme_support('custom-background', array(
'default-color' => 'D5DADD',
));
// This theme uses a custom image size for featured images, displayed on "standard" posts.
add_theme_support('post-thumbnails');
set_post_thumbnail_size(624, 9999); // Unlimited height, soft crop
// This theme uses wp_nav_menu() in four locations.
register_nav_menus(array(
'primary' => __('Primary Navigation', 'greenpark'),
'accessibility_menu' => __('Accessibility Menu', 'greenpark'),
'sidebar_menu' => __('Sidebar Menu', 'greenpark'),
'footer_menu' => __('Footer Menu', 'greenpark')
));
}
add_action('after_setup_theme', 'greenpark_setup');
// Loads custom CSS for the Themes Settings page in WP Backend
function greenpark_load_admin_styles() {
wp_register_style('greenpark_wp_admin_css', get_stylesheet_directory_uri() . '/admin-style.css', false, '1.1.0');
wp_enqueue_style('greenpark_wp_admin_css');
}
add_action('admin_enqueue_scripts', 'greenpark_load_admin_styles');
// Enqueues scripts and styles for front-end.
function greenpark_scripts_styles() {
global $wp_styles;
/*
* Adds JavaScript to pages with the comment form to support
* sites with threaded comments (when in use).
*/
if (is_singular() && comments_open() && get_option('thread_comments'))
wp_enqueue_script('comment-reply');
// Adds JavaScript for handling the navigation menu hide-and-show behavior.
// Fonts
// Loads our main stylesheets.
wp_enqueue_style('greenpark-style', get_stylesheet_uri());
wp_enqueue_style('greenpark-screen', get_stylesheet_directory_uri() . '/screen.css');
// LESS Implementation
// if ( ! is_admin() )
// wp_enqueue_style( 'greenpark-style', get_stylesheet_directory_uri() . '/style.less' );
/* Deactivated, as we make no use of a less.css plugin
if ( ! is_admin() ) {
wp_enqueue_style( 'screen', get_stylesheet_directory_uri() . '/screen.less' );
// wp_enqueue_style( 'screen', get_stylesheet_directory_uri() . '/screen.less', null, '2.2', 'screen' );
// wp_enqueue_style( 'print', get_stylesheet_directory_uri() . '/print.less', null, '2.2', 'print' );
}
*/
}
add_action('wp_enqueue_scripts', 'greenpark_scripts_styles');
function greenpark_wp_head() {
// ADD OUR FAVICON
echo '<link rel="shortcut icon" href="' . get_stylesheet_directory_uri() . '/favicon.ico" type="image/x-icon" />';
}
add_action('wp_head', 'greenpark_wp_head');
function greenpark_widgets_init() {
register_sidebar(array(
'name' => __('Sidebar', 'greenpark'),
'id' => 'primary-widget-area',
'description' => __('Not in use yet', 'greenpark'),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => __('Blog', 'greenpark'),
'id' => 'blog-widget-area',
'description' => __('Not in use yet', 'greenpark'),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => __('One', 'greenpark'),
'id' => 'sidebar-1',
'description' => __('Sidebar Widget 1', 'greenpark'),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => __('Two', 'greenpark'),
'id' => 'sidebar-2',
'description' => __('Sidebar Widget 2', 'greenpark'),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => __('Three', 'greenpark'),
'id' => 'sidebar-3',
'description' => __('Sidebar Widget 3', 'greenpark'),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>'
));
register_sidebar(array(
'name' => __('Four', 'greenpark'),
'id' => 'sidebar-4',
'description' => __('Sidebar Widget 4', 'greenpark'),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>'
));
}
add_action('widgets_init', 'greenpark_widgets_init');
// http://sivel.net/2008/10/wp-27-comment-separation/
function greenpark_list_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
echo "<li id=\"comment-";
echo comment_ID();
echo "\" class=\"pings\">";
echo comment_author_link();
}
// Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
function greenpark2_page_menu_args($args) {
$args['show_home'] = true;
return $args;
}
add_filter('wp_page_menu_args', 'greenpark2_page_menu_args');
// ------------------------------ @TODO: REFACTOR ------------------------------
// ------------------------------ @TODO: REFACTOR ------------------------------
// ------------------------------ @TODO: REFACTOR ------------------------------
// Note: Custom Admin Panel Functions
// add_action('admin_menu', 'greenpark2_menu', 'wp_head', 'greenpark2_feed', 'greenpark2_twitter');
add_action('admin_menu', 'greenpark2_menu', 'wp_head');
// Adds Green Park to WordPress Menu
function greenpark2_menu() {
add_theme_page(__('Green Park 2 Settings', 'greenpark'), __('Green Park 2 Settings', 'greenpark'), 'manage_options', 'theme_options', 'greenpark2_options');
}
function greenpark2_options() {
// DIE if user is not allowed to change options
if ( !current_user_can( 'manage_options' ) ) {
wp_die( _e('You do not have sufficient permissions to access this page.', 'greenpark') );
}
if (isset($_POST['submitted']) and $_POST['submitted'] == 'yes') :
update_option("greenpark2_sidebar_about_title", stripslashes($_POST['sidebar_about_title']));
update_option("greenpark2_sidebar_about_content", stripslashes($_POST['sidebar_about_content']));
// @TODO
// update_option("greenpark2_sidebar_disablesidebar", stripslashes($_POST['sidebar_disablesidebar']));
update_option("greenpark2_feed_uri", stripslashes($_POST['feed_uri']));
update_option("greenpark2_twitter_uri", stripslashes($_POST['twitter_uri']));
// @TODO
// update_option("greenpark2_about_site", stripslashes($_POST['about_site']));
update_option("google_analytics", stripslashes($_POST['google_analytics']));
update_option("google_adsense_bottom", stripslashes($_POST['google_adsense_bottom']));
update_option("greenpark2_advertisement_single_bottom", stripslashes($_POST['greenpark2_advertisement_single_bottom']));
update_option("greenpark2_advertisement_sidebar", stripslashes($_POST['greenpark2_advertisement_sidebar']));
// @TODO
// update_option("google_adsense_sidebar", stripslashes($_POST['google_adsense_sidebar']));
if (isset($_POST['logo_show']) and $_POST['logo_show'] == 'yes') :
update_option("greenpark2_logo_show", "yes");
else :
update_option("greenpark2_logo_show", "no");
endif;
if (isset($_POST['twitter_enable']) and $_POST['twitter_enable'] == 'yes') :
update_option("greenpark2_twitter_enable", "yes");
else :
update_option("greenpark2_twitter_enable", "no");
endif;
if (isset($_POST['feed_enable']) and $_POST['feed_enable'] == 'yes') :
update_option("greenpark2_feed_enable", "yes");
else :
update_option("greenpark2_feed_enable", "no");
endif;
if (isset($_POST['sidebar_about_title']) and $_POST['sidebar_about_title'] == '') {
update_option("greenpark2_sidebar_about_title", "About");
}
if (isset($_POST['sidebar_about_content']) and $_POST['sidebar_about_content'] == '') {
update_option("greenpark2_sidebar_about_content", "Change this text in the Green Park 2 Settings in your Wordpress admin section");
}
if (get_option('greenpark2_sidebar_about_title') == '') {
update_option("greenpark2_sidebar_about_title", "About");
}
if (get_option('greenpark2_sidebar_about_content') == '') {
update_option("greenpark2_sidebar_about_content", "Change this text in the Green Park 2 Settings in your Wordpress admin section");
}
// Changed to BOOL
if (isset($_POST['sidebar_disablesidebar']) and $_POST['sidebar_disablesidebar'] == true) :
update_option("greenpark2_sidebar_disablesidebar", true);
else :
update_option("greenpark2_sidebar_disablesidebar", false);
endif;
if (isset($_POST['accessibility_disable']) and $_POST['accessibility_disable'] == true) :
update_option("greenpark2_accessibility_disable", true);
else :
update_option("greenpark2_accessibility_disable", false);
endif;
if (isset($_POST['accessibility_home']) and $_POST['accessibility_home'] == true) :
update_option("greenpark2_accessibility_home", true);
else :
update_option("greenpark2_accessibility_home", false);
endif;
if (isset($_POST['accessibility_content']) and $_POST['accessibility_content'] == 'yes') :
update_option("greenpark2_accessibility_content", "yes");
else :
update_option("greenpark2_accessibility_content", "no");
endif;
if (isset($_POST['accessibility_feed']) and $_POST['accessibility_feed'] == 'yes') :
update_option("greenpark2_accessibility_feed", "yes");
else :
update_option("greenpark2_accessibility_feed", "no");
endif;
if (isset($_POST['accessibility_meta']) and $_POST['accessibility_meta'] == 'yes') :
update_option("greenpark2_accessibility_meta", "yes");
else :
update_option("greenpark2_accessibility_meta", "no");
endif;
if (isset($_POST['accessibility_register']) and $_POST['accessibility_register'] == 'yes') :
update_option("greenpark2_accessibility_register", "yes");
else :
update_option("greenpark2_accessibility_register", "no");
endif;
if (isset($_POST['accessibility_loginout']) and $_POST['accessibility_loginout'] == 'yes') :
update_option("greenpark2_accessibility_loginout", "yes");
else :
update_option("greenpark2_accessibility_loginout", "no");
endif;
if (isset($_POST['comments_page_disable']) and $_POST['comments_page_disable'] == 'yes') :
update_option("greenpark2_comments_page_disable", "yes");
else :
update_option("greenpark2_comments_page_disable", "no");
endif;
echo "<div id=\"message\" class=\"updated fade\"><p><strong>Your settings have been saved.</strong></p></div>";
endif;
$data = array(
'twitter' => array(
'uri' => get_option('greenpark2_twitter_uri'),
'enable' => get_option('greenpark2_twitter_enable')
),
'feed' => array(
'uri' => get_option('greenpark2_feed_uri'),
'enable' => get_option('greenpark2_feed_enable')
),
'sidebar' => array(
'about_title' => get_option('greenpark2_sidebar_about_title'),
'about_content' => get_option('greenpark2_sidebar_about_content'),
'disablesidebar' => get_option('greenpark2_sidebar_disablesidebar')
),
'logo' => array(
'show' => get_option('greenpark2_logo_show')
),
'accessibility' => array(
'disable' => get_option('greenpark2_accessibility_disable'),
'home' => get_option('greenpark2_accessibility_home'),
'content' => get_option('greenpark2_accessibility_content'),
'feed' => get_option('greenpark2_accessibility_feed'),
'meta' => get_option('greenpark2_accessibility_meta'),
'register' => get_option('greenpark2_accessibility_register'),
'loginout' => get_option('greenpark2_accessibility_loginout')
),
'aside' => get_option('greenpark2_aside_cat'),
'comments' => array(
'page_disable' => get_option('greenpark2_comments_page_disable')
),
'about' => get_option('greenpark2_about_site')
);
// Settings HTML
require_once('functions-themeoptions-display.php');
}
// Settings HTML
// require_once('functions-themeoptions-display2.php');
require_once('functions-themeoptions-display3.php');
?>