-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
174 lines (148 loc) · 5.54 KB
/
Copy pathfunctions.php
File metadata and controls
174 lines (148 loc) · 5.54 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
<?php
/**
* Lenscape functions and definitions
*
* @package WordPress
* @subpackage Lenscape
* @since Lenscape 1.0
*/
?>
<?php
function lenscape_enqueue_assets() {
// Load main stylesheet
wp_enqueue_style('lenscape-style', get_stylesheet_uri());
// Load custom CSS from assets
wp_enqueue_style(
'lenscape-custom-css',
get_template_directory_uri() . '/assets/css/font-inter.css',
array(), // Dependencies
filemtime(get_template_directory() . '/assets/css/font-inter.css') // Cache busting
);
// Load Google Fonts (optional)
wp_enqueue_style(
'lenscape-fonts',
'https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&display=swap',
false
);
// Load JS from assets
wp_enqueue_script(
'lenscape-js',
get_template_directory_uri() . '/assets/js/index.js',
array(), // Dependencies (e.g., 'jquery' if needed)
filemtime(get_template_directory() . '/assets/js/index.js'), // Cache busting
true // Load in footer
);
}
add_action('wp_enqueue_scripts', 'lenscape_enqueue_assets');
//get customizer.php file
require_once get_template_directory() . '/inc/customizer.php';
//get meta-service.php file
require_once get_template_directory() . '/inc/meta-service.php';
//get meta-testimonial.php file
require_once get_template_directory() . '/inc/meta-testimonial.php';
function lenscape_theme_setup() {
//enabling custom logo support
add_theme_support('custom-logo', array(
'height' => 16,
'width' => 19,
'flex-height' => true,
'flex-width' => true,
'unlink-homepage-logo' => true,
));
//enable featured image (for posts) support
add_theme_support('post-thumbnails');
}
add_action('after_setup_theme', 'lenscape_theme_setup');
//helper function to resolve theme-relative paths into usable URLs
function lenscape_get_asset($path = '') {
return esc_url(get_template_directory_uri() . '/' . ltrim($path, '/'));
}
//register navigation menus
function lenscape_register_menus() {
register_nav_menus([
'primary' => 'Primary Navigation',
'social' => 'Social Links',
'footer' => 'Footer Navigation',
]);
}
add_action('init', 'lenscape_register_menus');
//fallback for primary menu
function lenscape_default_menu($args = []) {
$menu_type = isset($args['menu_type']) ? $args['menu_type'] : 'desktop';
$ul_class = ($menu_type === 'mobile')
? 'flex flex-col items-center'
: 'flex justify-between';
echo '<ul class="' . esc_attr($ul_class) . '">';
echo '<li><a class="uppercase font-bold fs-12 hover:text-opacity-30 tracking-wide" href="#">Link1</a></li>';
echo '<li><a class="uppercase font-bold fs-12 hover:text-opacity-30 tracking-wide" href="#">Link2</a></li>';
echo '<li><a class="uppercase font-bold fs-12 hover:text-opacity-30 tracking-wide" href="#">Link3</a></li>';
echo '</ul>';
}
//Custom Walker (to control how wp_nav_menu() renders each <li> and <a>)
class Lenscape_Walker_Nav_Menu extends Walker_Nav_Menu {
//start each <li>
function start_el(&$output, $item, $depth = 0, $args = [], $id = 0) {
$classes = implode(' ', $item->classes);
$output .= '<li class="' . esc_attr($classes) . '">';
$output .= '<a class="uppercase font-bold fs-12 hover:text-opacity-30 tracking-wide" href="' . esc_url($item->url) . '">';
$output .= esc_html($item->title);
$output .= '</a>';
}
//end each <li>
function end_el(&$output, $item, $depth = 0, $args = []) {
$output .= '</li>';
}
}
//get the class handling (social) svg icons
require get_template_directory() . '/inc/class-lenscape-svg-icons.php';
//custom walker for (footer) social menu
class Lenscape_Social_Walker extends Walker_Nav_Menu {
public function start_el( &$output, $item, $depth = 0, $args = [], $id = 0 ) {
$url = !empty( $item->url ) ? esc_url( $item->url ) : '#';
$icon = $this->detect_icon( $url );
$output .= '<a href="' . $url . '" class="' . esc_attr( $icon ) . '-link">';
$output .= Lenscape_SVG_Icons::get_svg( $icon );
}
public function end_el( &$output, $item, $depth = 0, $args = [] ) {
$output .= '</a>';
}
private function detect_icon( $url ) {
if ( strpos( $url, 'facebook.com' ) !== false ) return 'facebook';
if ( strpos( $url, 'youtube.com' ) !== false ) return 'youtube';
if ( strpos( $url, 'twitter.com' ) !== false ) return 'twitter';
if ( strpos( $url, 'pinterest.com' ) !== false ) return 'pinterest';
if ( strpos( $url, 'instagram.com' ) !== false ) return 'instagram';
return 'twitter'; // fallback
}
}
//custom walker for footer navigation menu
class Lenscape_Footer_Walker extends Walker_Nav_Menu {
public function start_el( &$output, $item, $depth = 0, $args = [], $id = 0 ) {
$classes = 'text-center md:text-left';
$link_classes = 'uppercase font-bold fs-12 tracking-wide hover:text-opacity-30';
$title = esc_html( $item->title );
$url = esc_url( $item->url );
$output .= '<li class="' . $classes . '">';
$output .= '<a class="' . $link_classes . '" href="' . $url . '">' . $title . '</a>';
}
public function end_el( &$output, $item, $depth = 0, $args = [] ) {
$output .= '</li>';
}
}
//fallback function for footer menu
function lenscape_footer_nav_fallback() {
$links = [
'Link1' => '#',
'Link2' => '#',
'Link3' => '#',
'Link4' => '#',
];
echo '<ul class="flex">';
foreach ( $links as $label => $url ) {
echo '<li class="text-center md:text-left">';
echo '<a class="uppercase font-bold fs-12 tracking-wide hover:text-opacity-30" href="' . esc_url( $url ) . '">' . ucfirst( $label ) . '</a>';
echo '</li>';
}
echo '</ul>';
}
?>