This repository has been archived by the owner on Nov 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
functions.php
203 lines (175 loc) · 6.98 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
<?php
add_theme_support('post-thumbnails');
/* Adding Menu */
add_theme_support('nav-menus');
register_nav_menu('sidebar', 'Sidebar');
register_nav_menu('headermenu', 'Header Menu');
/* Breadcrums Function */
function breadcrums()
{
if (!is_home() && !is_category()) {
echo '<li><i class="fa fa-dashboard"></i> ';
bloginfo('name');
echo '</li><li class="active">';
if (is_single()) {
echo get_the_title();
} elseif (is_page()) {
echo get_the_title();
}
echo "</li>";
}
}
/* Making Submenu */
class Sidebar_Nav_Menu extends Walker_Nav_Menu
{
function start_lvl(&$output, $depth = 0, $arg = [])
{
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"treeview-menu\">\n";
}
function start_el(&$output, $item, $depth = 0, $args = [], $id = 0)
{
global $wp_query;
$indent = ($depth > 0 ? str_repeat("\t", $depth) : ''); // code indent
// depth dependent classes
$depth_classes = array(
($depth == 0 ? 'dropdown' : 'sub-menu-item'),
($depth >= 2 ? 'sub-sub-menu-item' : ''),
($depth % 2 ? 'menu-item-odd' : 'menu-item-even'),
'menu-item-depth-' . $depth
);
$depth_class_names = esc_attr(implode(' ', $depth_classes));
// passed classes
$classes = empty($item->classes) ? array() : (array)$item->classes;
$class_names = esc_attr(implode(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item)));
// build html
$output .= $indent . '<li id="nav-menu-item-' . $item->ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';
// link attributes
$attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
$attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
$attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
$attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
$attributes .= ' class="menu-link ' . ($depth > 0 ? 'sub-menu-link' : 'main-menu-link') . '"';
$item_output = sprintf('%1$s<a%2$s><span>%3$s%4$s%5$s</span></a>%6$s',
$args->before,
$attributes,
$args->link_before,
apply_filters('the_title', $item->title, $item->ID),
$args->link_after,
$args->after
);
// build html
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
}
class Header_Nav_Menu extends Walker_Nav_Menu
{
function start_lvl(&$output, $depth = 0, $arg = [])
{
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
function start_el(&$output, $item, $depth = 0, $args = [], $id = 0)
{
global $wp_query;
$indent = ($depth > 0 ? str_repeat("\t", $depth) : ''); // code indent
// depth dependent classes
$depth_classes = array(
($depth == 0 ? 'dropdown' : 'sub-menu-item'),
($depth >= 2 ? 'sub-sub-menu-item' : ''),
($depth % 2 ? 'menu-item-odd' : 'menu-item-even'),
'menu-item-depth-' . $depth
);
$depth_class_names = esc_attr(implode(' ', $depth_classes));
// passed classes
$classes = empty($item->classes) ? array() : (array)$item->classes;
$class_names = esc_attr(implode(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item)));
// build html
$output .= $indent . '<li id="nav-menu-item-' . $item->ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';
// link attributes
$attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
$attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
$attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
$attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
if ($depth == 0) {
$attributes .= ' class="dropdown-toggle" data-toggle="dropdown"';
}
$item_output = sprintf('%1$s<a%2$s><span>%3$s%4$s%5$s</span></a>%6$s',
$args->before,
$attributes,
$args->link_before,
apply_filters('the_title', $item->title, $item->ID),
$args->link_after,
$args->after
);
// build html
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
}
//Removind ul elements
function wp_nav_menu_no_ul()
{
$options = array(
'echo' => false,
'container' => false,
'theme_location' => 'headermenu',
'walker' => new Header_Nav_Menu()
);
$menu = wp_nav_menu($options);
echo preg_replace(array(
'#^<ul[^>]*>#',
'#</ul>$#'
), '', $menu);
}
//Register Sidebars
register_sidebar(array(
'name' => 'Right Bar',
'id' => 'right-bar',
'before_widget' => '<div class="right-bar-widget">',
'after_widget' => '</div>',
'before_title' => '<h3 class="control-sidebar-heading">',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Side Bar',
'id' => 'side-bar',
'before_widget' => '<div class="box box-widget side-bar-widget"><div class="box-body">',
'after_widget' => '</div></div>',
'before_title' => '<h3 class="profile-username text-center">',
'after_title' => '</h3>',
));
//Infinite Scroll
function wp_infinitepaginate()
{
$loopFile = $_POST['loop_file'];
$paged = $_POST['page_no'];
$action = $_POST['what'];
$value = $_POST['value'];
if ($action == 'author_name') {
$arg = array('author_name' => $value, 'paged' => $paged, 'post_status' => 'publish');
} elseif ($action == 'category_name') {
$arg = array('category_name' => $value, 'paged' => $paged, 'post_status' => 'publish');
} elseif ($action == 'search') {
$arg = array('s' => $value, 'paged' => $paged, 'post_status' => 'publish');
} else {
$arg = array('paged' => $paged, 'post_status' => 'publish');
}
# Load the posts
query_posts($arg);
get_template_part($loopFile);
exit;
}
add_action('wp_ajax_infinite_scroll', 'wp_infinitepaginate'); // for logged in user
add_action('wp_ajax_nopriv_infinite_scroll', 'wp_infinitepaginate'); // if user not logged in
// Theme Admin Panel
if (STYLESHEETPATH == TEMPLATEPATH) {
define('OF_FILEPATH', TEMPLATEPATH);
define('OF_DIRECTORY', get_bloginfo('template_directory'));
} else {
define('OF_FILEPATH', STYLESHEETPATH);
define('OF_DIRECTORY', get_bloginfo('stylesheet_directory'));
}
require_once(OF_FILEPATH . '/admin/admin-functions.php');
require_once(OF_FILEPATH . '/admin/admin-interface.php');
require_once(OF_FILEPATH . '/admin/theme-options.php');
require_once(OF_FILEPATH . '/admin/theme-functions.php');