This repository was archived by the owner on Nov 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.php
More file actions
351 lines (277 loc) · 14.7 KB
/
header.php
File metadata and controls
351 lines (277 loc) · 14.7 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
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
<?php
/**
*
* The template for displaying the header
*
* Displays all of the head element and everything up until the breadcrumbs or content
*
* @package WordPress
* @subpackage Materialize
* @since Materialize 1.0
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, user-scalable=no,initial-scale=1.0" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<?php
if ( is_singular() && pings_open( get_queried_object() ) ) {
?>
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php
}
?>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
/**
*
* Chekc if can show or can hide the header for different templates
* From theme options ( Appearance > Customize > Header Elements > General )
* you can enable and disable the header for next templates:
* Front Page ( static page ), Blog, Archives Templates ( Archives, Author,
* Categories, Tags, 404 and Search ), Sigle Post and Single Page.
*/
$show_header = false;
// Front Page ( show / hide )
$on_front_page = get_theme_mod( 'mythemes-header-front-page', true );
// get the Front Page ( static page )
$is_enb_front_page = get_option( 'show_on_front' ) == 'page';
$is_front_page = $is_enb_front_page && is_front_page();
// blog page ( show / hide )
$on_blog_page = get_theme_mod( 'mythemes-header-blog-page', false );
// get the blog page
if( $is_enb_front_page ){
$is_blog_page = is_home();
}
else{
$is_blog_page = is_front_page();
}
/**
*
* Check if is static Front Page and
* if can show header for static Front Page
*/
if( $is_front_page && $on_front_page ){
$show_header = true;
}
/**
*
* Check if is static Front Page and
* if can hide header for static Front Page
*/
else if( $is_front_page && !$on_front_page ){
$show_header = false;
}
/**
*
* Check if is Blog Page and
* if can show header for Blog Page
*/
else if( $is_blog_page && $on_blog_page ){
$show_header = true;
}
/**
*
* Check if is Blog Page and
* if can hide header for Blog Page
*/
else if( $is_blog_page && !$on_blog_page ){
$show_header = false;
}
// check if is single post
else if( is_singular( 'post' ) ){
// show or hide the header for single post
$show_header = get_theme_mod( 'mythemes-header-single-post', false );
}
// check if is single page ( exclude static front page )
else if( is_singular( 'page' ) && ! $is_front_page ){
// show or hide the header for single page
$show_header = get_theme_mod( 'mythemes-header-single-page', false );
}
// show or hide the header for archives templates
else{
$show_header = get_theme_mod( 'mythemes-header-templates', false );
}
// header class
$mythemes_header_class = 'mythemes-miss-header-image';
if( $show_header ){
$mythemes_header_class = '';
}
?>
<?php
/**
*
* The header area contain
* - site identity elements: Site Logo, Site Title and Description
* - header menu and aside menu
* - header image and header elements: Headline, Description and Buttons
*/
?>
<header id="menu" class="scrollspy <?php echo esc_attr( $mythemes_header_class ); ?>">
<!-- header navigation -->
<div class="navbar-fixed">
<nav class="white " role="navigation">
<div class="nav-wrapper">
<!-- header button -->
<a href="#" data-activates="nav-mobile" class="button-collapse"><i class="zmdi zmdi-menu zmdi-hc-fw"></i></a>
<a href="#" data-activates="widget-mobile" class="button-collapse right"><i class="zmdi zmdi-menu zmdi-hc-fw"></i></a>
<!-- Site Logo, Title and Description -->
<?php
$blog_title = esc_attr( get_bloginfo( 'name' ) );
$blog_description = esc_attr( get_bloginfo( 'description' ) );
$mythemes_logo_src = esc_url( get_theme_mod( 'mythemes-blog-logo' , get_stylesheet_directory_uri() . '/media/_frontend/img/logo.png' ) );
//echo '<div class="mythemes-blog-identity">';
$logoImg='';
// blog logo ( if not is empty )
if( !empty( $mythemes_logo_src ) ){
$logoImg= '<a class="brand-logo mylogo" href="' . esc_url( home_url( '/' ) ) . '" title="' . esc_attr( $blog_title . ' - ' . $blog_description ) . '" style="margin-top: ' . absint( get_theme_mod( 'mythemes-blog-logo-m-top' ) ) . 'px; margin-bottom: ' . absint( get_theme_mod( 'mythemes-blog-logo-m-bottom' ) ) . 'px;">'
. '<img src="' . esc_url( $mythemes_logo_src ) . '" title="' . esc_attr( $blog_title . ' - ' . $blog_description ) . '"/>'
. '</a>';
echo $logoImg;
}
// blog title ( if not is empty )
// if( !empty( $blog_title ) ){
// echo '<a class="mythemes-blog-title" href="' . esc_url( home_url( '/' ) ) . '" title="' . esc_attr( $blog_title . ' - ' . $blog_description ) . '">';
// bloginfo( 'name' );
// echo '</a>';
// }
// blog description ( if not is empty )
// if( !empty( $blog_description ) ){
// echo '<a class="mythemes-blog-description" href="' . esc_url( home_url( '/' ) ) . '" title="' . esc_attr( $blog_title . ' - ' . $blog_description ) . '">';
// bloginfo( 'description' );
// echo '</a>';
// }
//
// echo '</div>';
global $mythemes_curr_ancestor;
global $mythemes_logo_src;
$location = get_nav_menu_locations();
{ // not collapsed header menu
$args = array(
'items_wrap' =>'<ul id="%1$s" class="%2$s"> <li class="search search1">
<div class="search-wrapper">
<div id="searchbox">
<form action="'.esc_url( home_url( '/' ) ).'" method="get" id="searchform">
<input id="search" type="text" name="s" required="required" placeholder="Buscar en humanOS">
<i class="zmdi zmdi-search zmdi-hc-2x" onclick="if(document.getElementById(\'searchform\').checkValidity()) document.getElementById(\'searchform\').submit();"></i>
</form>
</div>
</div>
</li>%3$s</ul>',
'container'=> false,
'theme_location' => 'header',
'menu_class' => 'right hide-on-med-and-down'
);
if( isset( $location[ 'header' ] ) && $location[ 'header' ] > 0 ){
wp_nav_menu( $args );
}
/**
*
* If not is set header menu then
* the header menu is build from existing pages
*/
else{
$pages = get_posts( array(
'post_type' => 'page',
'order' => 'ASC'
));
if( !empty( $pages ) ){
echo '<div class="not-collapsed-wrapper">';
echo '<ul class="right hide-on-med-and-down">';
foreach( $pages as $p => $item ){
$classes = '';
$mythemes_curr_ancestor = false;
if( $item -> post_parent > 0 ){
continue;
}
if( is_page( $item -> ID ) || ( $item -> ID === absint( get_option( 'page_for_posts' ) ) && is_home() ) ){
$classes = 'current-menu-item';
}
$submenu = mythemes_tools::submenu( $item -> ID );
if( !empty( $submenu ) ){
$classes .= ' menu-item-has-children';
if( $mythemes_curr_ancestor ){
$classes .= ' current-menu-ancestor';
}
}
echo '<li class="menu-item ' . $classes . '">';
echo '<a href="' . esc_url( get_permalink( $item -> ID ) ) . '" title="' . esc_attr( mythemes_post::title( $item -> ID, true ) ) . '">' . mythemes_post::title( $item -> ID ) . '</a>';
echo $submenu;
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
}
}
{ /**
*
* Collapsed aside menu
* this menu is available only for small devices
*/
$args = array(
'items_wrap' =>'<ul id="%1$s" class="%2$s"><li class="logo">'.$logoImg.'</li> <li class="search">
<div class="search-wrapper card">
<div id="searchbox">
<form action="'.esc_url( home_url( '/' ) ).'" method="get" id="searchform1">
<input id="search" type="text" required="required" name="s">
<i class="zmdi zmdi-search zmdi-hc-2x" onclick="if(document.getElementById(\'searchform1\').checkValidity()) document.getElementById(\'searchform1\').submit();"></i>
</form>
</div>
</div>
</li>%3$s</ul>' ,
'theme_location' => 'header',
'container'=> false,
'menu_class' => 'side-nav',
'menu_id' => 'nav-mobile'
);
if( isset( $location[ 'header' ] ) && $location[ 'header' ] > 0 ){
wp_nav_menu( $args );
}
/**
*
* If not is set header menu then
* the header menu is build from existing pages
*/
else{
$pages = get_posts( array(
'post_type' => 'page',
'order' => 'ASC'
));
if( !empty( $pages ) ){
echo '<div class="collapsed-wrapper">';
echo '<ul id="nav-mobile" class="side-nav">';
foreach( $pages as $p => $item ){
$classes = '';
if( is_page( $item -> ID ) ){
$classes = 'current-menu-item';
}
echo '<li class="menu-item ' . $classes . '">';
echo '<a href="' . esc_url( get_permalink( $item -> ID ) ) . '" title="' . esc_attr( mythemes_post::title( $item -> ID, true ) ) . '">' . mythemes_post::title( $item -> ID ) . '</a>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
}
}
?>
</div>
</nav>
</div>
<!-- the header image and the header elements -->
<?php
if( $show_header ){
get_template_part( 'templates/header' );
}
?>
<!-- <?php if(is_home()) { ?>
<a class="link_down hide-on-small-only" href="#main_content"><img class="" src="<?php echo get_stylesheet_directory_uri(); ?>/media/_frontend/img/dawn.svg">
</a>
<?php } ?> -->
<a class="link_up hide-on-small-only" href="#main_content"><img class="" src="<?php echo get_stylesheet_directory_uri(); ?>/media/_frontend/img/up.svg">
</a>
</header>