-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
526 lines (456 loc) · 20.3 KB
/
functions.php
File metadata and controls
526 lines (456 loc) · 20.3 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<?php
function themename_custom_logo_setup() {
$defaults = array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
'unlink-homepage-logo' => true,
);
add_theme_support( 'custom-logo', $defaults );
}
add_action( 'after_setup_theme', 'themename_custom_logo_setup' );
//End Logo
add_theme_support( 'post-thumbnails' );
// bootstrap 5 wp_nav_menu walker
class bootstrap_5_wp_nav_menu_walker extends Walker_Nav_menu
{
private $current_item;
private $dropdown_menu_alignment_values = [
'dropdown-menu-start',
'dropdown-menu-end',
'dropdown-menu-sm-start',
'dropdown-menu-sm-end',
'dropdown-menu-md-start',
'dropdown-menu-md-end',
'dropdown-menu-lg-start',
'dropdown-menu-lg-end',
'dropdown-menu-xl-start',
'dropdown-menu-xl-end',
'dropdown-menu-xxl-start',
'dropdown-menu-xxl-end'
];
function start_lvl(&$output, $depth = 0, $args = null)
{
$dropdown_menu_class[] = '';
foreach($this->current_item->classes as $class) {
if(in_array($class, $this->dropdown_menu_alignment_values)) {
$dropdown_menu_class[] = $class;
}
}
$indent = str_repeat("\t", $depth);
$submenu = ($depth > 0) ? ' sub-menu' : '';
$output .= "\n$indent<ul class=\"dropdown-menu$submenu " . esc_attr(implode(" ",$dropdown_menu_class)) . " depth_$depth\">\n";
}
function start_el(&$output, $item, $depth = 0, $args = null, $id = 0)
{
$this->current_item = $item;
$indent = ($depth) ? str_repeat("\t", $depth) : '';
$li_attributes = '';
$class_names = $value = '';
$classes = empty($item->classes) ? array() : (array) $item->classes;
$classes[] = ($args->walker->has_children) ? 'dropdown' : '';
$classes[] = 'nav-item';
$classes[] = 'nav-item-' . $item->ID;
if ($depth && $args->walker->has_children) {
$classes[] = 'dropdown-menu dropdown-menu-end';
}
$class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
$class_names = ' class="' . esc_attr($class_names) . '"';
$id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
$id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
$output .= $indent . '<li ' . $id . $value . $class_names . $li_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) . '"' : '';
$active_class = ($item->current || $item->current_item_ancestor || in_array("current_page_parent", $item->classes, true) || in_array("current-post-ancestor", $item->classes, true)) ? 'active' : '';
$nav_link_class = ( $depth > 0 ) ? 'dropdown-item ' : 'nav-link ';
$attributes .= ( $args->walker->has_children ) ? ' class="'. $nav_link_class . $active_class . ' dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"' : ' class="'. $nav_link_class . $active_class . '"';
$item_output = $args->before;
$item_output .= '<a' . $attributes . '>';
$item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
}
// register a new menu
register_nav_menu('main-menu', 'Main menu');
//End Menu
/**
* Register our sidebars and widgetized areas.
*
*/
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Home right sidebar',
'id' => 'home_right_1',
'before_widget' => '<div class="p-4">',
'after_widget' => '</div>',
'before_title' => '<h4 class="fst-italic">',
'after_title' => '</h4>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
//end sidebar
function danskesite_customize_register( $wp_customize ) {
$wp_customize->add_section('theme_setting' , array(
'title' => __('Theme Setting'),
'priority' => 35,
));
$wp_customize->add_setting( 'body_bg_color', array(
'default' => '#fff',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'body_bg_color', array(
'label' => 'Body background color',
'section' => 'theme_setting',
'settings' => 'body_bg_color',
) ) );
$wp_customize->add_setting( 'body_text_color', array(
'default' => '#000',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'body_text_color', array(
'label' => 'Body text color',
'section' => 'theme_setting',
'settings' => 'body_text_color',
) ) );
$wp_customize->add_setting( 'navbar_color', array(
'default' => '#0b3953',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'navbar_color', array(
'label' => 'Navbar color setting',
'section' => 'theme_setting',
'settings' => 'navbar_color',
) ) );
$wp_customize->add_setting( 'navbar_search_button_color', array(
'default' => '#c71432',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'navbar_search_button_color', array(
'label' => 'Search button color',
'section' => 'theme_setting',
'settings' => 'navbar_search_button_color',
) ) );
$wp_customize->add_setting('navbar_light_dark', array(
'default' => 'navbar-dark',
));
$wp_customize->add_control('navbar_light_dark', array(
'label' => __('Navbar light or dark version'),
'section' => 'theme_setting',
'settings' => 'navbar_light_dark',
'type' => 'select',
'choices' => array(
'navbar-dark' => 'Navbar Dark Version',
'navbar-light' => 'Navbar Light Version',
),
));
$wp_customize->add_setting('navbar_width', array(
'default' => 'container-fluid',
));
$wp_customize->add_control('navbar_width', array(
'label' => __('Navbar light or dark version'),
'section' => 'theme_setting',
'settings' => 'navbar_width',
'type' => 'select',
'choices' => array(
'container-fluid' => 'Full width',
'container' => 'Boxed width',
),
));
$wp_customize->add_setting('main_width', array(
'default' => 'container-fluid',
));
$wp_customize->add_control('main_width', array(
'label' => __('Main width'),
'section' => 'theme_setting',
'settings' => 'main_width',
'type' => 'select',
'choices' => array(
'container-fluid' => 'Full width',
'container' => 'Boxed width',
),
));
$wp_customize->add_setting('main_margin_top', array(
'default' => '3',
));
$wp_customize->add_control('main_margin_top', array(
'label' => __('Margin from top for main content'),
'section' => 'theme_setting',
'settings' => 'main_margin_top',
'type' => 'select',
'choices' => array(
'0' => '0',
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
),
));
$wp_customize->add_setting('main_margin_bottom', array(
'default' => '3',
));
$wp_customize->add_control('main_margin_bottom', array(
'label' => __('Margin from bottom for main content'),
'section' => 'theme_setting',
'settings' => 'main_margin_bottom',
'type' => 'select',
'choices' => array(
'0' => '0',
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
),
));
$wp_customize->add_setting('posts_col-size-home', array(
'default' => '4',
));
$wp_customize->add_control('posts_col-size-home', array(
'label' => __('Size of post columns homepage'),
'section' => 'theme_setting',
'settings' => 'posts_col-size-home',
'type' => 'radio',
'choices' => array(
'2' => '6',
'3' => '4',
'4' => '3',
'6' => '2',
),
));
$wp_customize->add_setting('single_width', array(
'default' => 'container',
));
$wp_customize->add_control('single_width', array(
'label' => __('Post page width'),
'section' => 'theme_setting',
'settings' => 'single_width',
'type' => 'select',
'choices' => array(
'container-fluid' => 'Full width',
'container' => 'Boxed width',
),
));
$wp_customize->add_setting('page_width', array(
'default' => 'container-fluid',
));
$wp_customize->add_control('page_width', array(
'label' => __('Page width'),
'section' => 'theme_setting',
'settings' => 'page_width',
'type' => 'select',
'choices' => array(
'container-fluid' => 'Full width',
'container' => 'Boxed width',
),
));
$wp_customize->add_setting('page_margin_top', array(
'default' => '2',
));
$wp_customize->add_control('page_margin_top', array(
'label' => __('Margin from top for main content'),
'section' => 'theme_setting',
'settings' => 'page_margin_top',
'type' => 'select',
'choices' => array(
'0' => '0',
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
),
));
$wp_customize->add_setting('page_margin_bottom', array(
'default' => '2',
));
$wp_customize->add_control('page_margin_bottom', array(
'label' => __('Margin from bottom for main content'),
'section' => 'theme_setting',
'settings' => 'page_margin_bottom',
'type' => 'select',
'choices' => array(
'0' => '0',
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
),
));
$wp_customize->add_setting( 'footer_bg_color', array(
'default' => '#0b3953',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'footer_bg_color', array(
'label' => 'Footer background color',
'section' => 'theme_setting',
'settings' => 'footer_bg_color',
) ) );
$wp_customize->add_setting('footer_more_text', array(
));
$wp_customize->add_control('themename_text_test', array(
'label' => __('More text for footer'),
'section' => 'theme_setting',
'settings' => 'footer_more_text',
));
//for add more check this document
// https://developer.wordpress.org/reference/hooks/customize_register/
}
add_action( 'customize_register', 'danskesite_customize_register' );
require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'twentytwentyone_child_register_required_plugins' );
function twentytwentyone_child_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
array(
'name' => 'Layout Grid Block',
'slug' => 'layout-grid',
),
array(
'name' => 'One Click Demo Import',
'slug' => 'one-click-demo-import',
),
array(
'name' => 'Getwid – Gutenberg Blocks',
'slug' => 'getwid',
),
array(
'name' => 'Gutenberg Blocks – Ultimate Addons for Gutenberg',
'slug' => 'ultimate-addons-for-gutenberg',
),
array(
'name' => 'Post/Page specific custom CSS',
'slug' => 'postpage-specific-custom-css',
),
array(
'name' => 'Recent Posts Widget With Thumbnails',
'slug' => 'recent-posts-widget-with-thumbnails',
),
array(
'name' => 'Blocks Animation: CSS Animations for Gutenberg Blocks',
'slug' => 'blocks-animation',
),
);
/*
* Array of configuration settings. Amend each line as needed.
*
* TGMPA will start providing localized text strings soon. If you already have translations of our standard
* strings available, please help us make TGMPA even better by giving us access to these translations or by
* sending in a pull-request with .po file(s) with the translations.
*
* Only uncomment the strings in the config array if you want to customize the strings.
*/
$config = array(
'id' => 'danskesite', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'plugins.php', // Parent menu slug.
'capability' => 'manage_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
function ocdi_import_files()
{
return array(
array(
'import_file_name' => 'CAR SHOWPLACE',
'categories' => array('Business', 'Business'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/carshowplace.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/car-showplace.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/car-showplace/',
),
array(
'import_file_name' => 'Steak House',
'categories' => array('Business', 'Business'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/steakhouse.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/steakhouse.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'http://www.danskesite.com/steakhouse/',
),
array(
'import_file_name' => 'LEARN DIGITAL MARKETING',
'categories' => array('Business', 'Business'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/learndigitalmarketing.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/learndigitalmarketing.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/learn-digital-marketing/',
),
array(
'import_file_name' => 'BRAND STORE',
'categories' => array('Business', 'Shop'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/brandstore.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/brandstore.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/brandstore/',
),
array(
'import_file_name' => 'Hair Dresser',
'categories' => array('Business', 'Shop'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/hairdresser.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/hairdresser.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/hairdresser/',
),
array(
'import_file_name' => 'Makeup Artist',
'categories' => array('Business', 'Shop'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/makeup-artist.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/makeup-artist.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/makeup-artist/',
),
array(
'import_file_name' => 'Lawyer',
'categories' => array('Business', 'Shop'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/lawyer.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/lawyer.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/lawyer/',
),
array(
'import_file_name' => 'Coach',
'categories' => array('Business', 'Shop'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/coach.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/coach.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/coach/',
),
array(
'import_file_name' => 'BBQ Restaurant',
'categories' => array('Business', 'Shop'),
'import_file_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/bbq-restaurant.xml',
'import_preview_image_url' => 'https://danskesite.com/wp-content/themes/danskesite/demo/bbq-restaurant.jpg',
'import_notice' => __('After you import this demo, you will have to setup the slider separately.', 'your-textdomain'),
'preview_url' => 'https://danskesite.com/bbq-restaurant/',
),
);
}
add_filter('pt-ocdi/import_files', 'ocdi_import_files');
function ocdi_after_import( $selected_import ) {
echo "This will be displayed on all after imports!";
//Set Menu
$top_menu = get_term_by('name', 'Primary menu', 'nav_menu');
$mobile_menu = get_term_by('name', 'Secondary menu', 'nav_menu');
set_theme_mod( 'nav_menu_locations' , array(
'primary' => $top_menu->term_id,
'secondary' => $mobile_menu->term_id
)
);
$front_page_id = get_page_by_title('Home');
$blog_page_id = get_page_by_title('Blog');
update_option('show_on_front', 'page');
update_option('page_on_front', $front_page_id->ID);
update_option('page_for_posts', $blog_page_id->ID);
}
add_action( 'ocdi/after_import', 'ocdi_after_import' );