This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
208 lines (167 loc) · 6.65 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
<?php
// Remove rel attribute from the category list - thanks Joseph (http://josephleedy.me/blog/make-wordpress-category-list-valid-by-removing-rel-attribute/)!
function remove_category_list_rel($output)
{
$output = str_replace(' rel="category tag"', '', $output);
return $output;
}
add_filter('wp_list_categories', 'remove_category_list_rel');
add_filter('the_category', 'remove_category_list_rel');
function fs_register_menus() {
register_nav_menus(array('primary' => __( 'Primary Navigation' )));
}
if ( !is_admin() ) {
function my_init_method() {
wp_deregister_script( 'l10n' );
}
add_action('init', 'my_init_method');
}
add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );
add_post_type_support( 'page', 'post-formats' );
/**
* @package WordPress
* @subpackage Frank
*/
if ( function_exists('register_sidebar') )/*KILL*/
register_sidebar(array(
'name' => 'Top Bar',
'before_widget' => '<div id="top_bar" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Sub Header',
'id' => 'widget-subheader',
'before_widget' => '<div id="%1$s" class="widget %2$s four columns">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Navigation',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Index Right Aside',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Post Left Aside',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
}
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Post Right Aside',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
}
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Post Footer',
'id' => 'widget-postfooter',
'before_widget' => '<div id="%1$s" class="widget %2$s four columns">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Footer',
'id' => 'widget-footer',
'before_widget' => '<div id="%1$s" class="widget %2$s six columns">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>',
));
function excerpt_read_more($post) { return '<a href="'. get_permalink($post->ID) . '">' . 'Read On…' . '</a>'; }
/**
* Add "first" and "last" CSS classes to dynamic sidebar widgets. Also adds numeric index class for each widget (widget-1, widget-2, etc.)
* via http://wordpress.org/support/topic/how-to-first-and-last-css-classes-for-sidebar-widgets
*/
function widget_first_last_classes($params) {
global $my_widget_num; // Global a counter array
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
if(!$my_widget_num) {// If the counter array doesn't exist, create it
$my_widget_num = array();
}
if(!isset($arr_registered_widgets[$this_id]) || !is_array($arr_registered_widgets[$this_id])) { // Check if the current sidebar has no widgets
return $params; // No widgets in this sidebar... bail early.
}
if(isset($my_widget_num[$this_id])) { // See if the counter array has an entry for this sidebar
$my_widget_num[$this_id] ++;
} else { // If not, create it starting with 1
$my_widget_num[$this_id] = 1;
}
$class = 'class="widget-' . $my_widget_num[$this_id] . ' '; // Add a widget number class for additional styling options
if($my_widget_num[$this_id] == 1) { // If this is the first widget
$class .= 'widget-first ';
} elseif($my_widget_num[$this_id] == count($arr_registered_widgets[$this_id])) { // If this is the last widget
$class .= 'widget-last ';
}
$params[0]['before_widget'] = str_replace('class="', $class, $params[0]['before_widget']); // Insert our new classes into "before widget"
return $params;
}
add_filter('dynamic_sidebar_params','widget_first_last_classes');
// ======================
// = HOME PAGE SECTIONS =
// ======================
function franklin_st_home()
{
include 'admin/admin-options-home.php';
}
function franklin_st_general()
{
include 'admin/admin-options-general.php';
}
// add our menus
function franklin_street_admin_menu()
{
add_menu_page( 'Franklin Street', 'Franklin Street', 'manage_options', 'franklin-street', 'franklin_st_general' );
add_submenu_page( 'franklin-street', 'Franklin Street', 'General', 'manage_options', 'franklin-street', 'franklin_st_general');
add_submenu_page( 'franklin-street', 'Franklin Street', 'Home Page Sections', 'manage_options', 'franklin-street-home', 'franklin_st_home');
}
add_action( 'admin_menu', 'franklin_street_admin_menu' );
function franklin_street_admin_assets()
{
if( is_admin() )
{
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_style( 'franklin-street-admin', get_bloginfo( 'template_directory' ) . '/admin/css/franklin-street-options.css', NULL, NULL, NULL );
wp_enqueue_script( 'franklin-street-admin', get_bloginfo( 'template_directory' ) . '/admin/js/franklin-street-utils.js', 'jquery', NULL, true );
}
}
add_action( 'init', 'franklin_street_admin_assets' );
function franklin_street_footer() {
$franklin_street_general = get_option( '_franklin_street_general' );
if($franklin_street_general) echo stripslashes($franklin_street_general['footer']);
}
function franklin_street_header() {
$franklin_street_general = get_option( '_franklin_street_general' );
if($franklin_street_general) echo stripslashes($franklin_street_general['header']);
}
function franklin_devmode() {
$franklin_street_general = get_option( '_franklin_street_general' );
if($franklin_street_general) return $franklin_street_general['devmode'];
}
add_action('wp_footer', 'franklin_street_footer');
add_action('wp_head', 'franklin_street_header');
?>