-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
682 lines (600 loc) · 17.7 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
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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
<?php
add_action( 'after_setup_theme', 'blankslate_setup' );
function blankslate_setup()
{
load_theme_textdomain( 'heavens-best-modern', get_template_directory() . '/languages' );
add_theme_support( 'title-tag' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
global $content_width;
if ( ! isset( $content_width ) ) $content_width = 1280;
register_nav_menus(
array(
'main-menu' => __( 'Main Menu', 'heavens-best-modern' ),
'service-areas' => __( 'Service Areas', 'heavens-best-modern' )
)
);
}
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
add_action( 'wp_enqueue_scripts', 'blankslate_load_scripts' );
function blankslate_load_scripts() {
wp_enqueue_script('jquery');
//wp_deregister_script( 'jquery' );
wp_enqueue_script( 'doubletaptogo', get_stylesheet_directory_uri() . '/doubletaptogo.min.js', array( 'jquery' ) );
//wp_enqueue_script( 'wallop', 'https://cdnjs.cloudflare.com/ajax/libs/wallop/2.4.1/js/Wallop.js' );
//wp_enqueue_style( 'wallopcss', 'https://cdnjs.cloudflare.com/ajax/libs/wallop/2.4.1/css/wallop--fade.min.css' );
//wp_enqueue_script( 'formidable', '/wp-content/plugins/formidable/js/formidable.min.js', array( 'jquery' ) );
//wp_enqueue_script( 'starRating', '/wp-content/plugins/formidable/pro/js/jquery.rating.min.js', array( 'jquery' ) );
if ( is_archive() ) {
wp_enqueue_script( 'lightslider', 'https://cdnjs.cloudflare.com/ajax/libs/lightslider/1.1.5/js/lightslider.min.js', array( 'jquery' ) );
wp_enqueue_style( 'lightcss', 'https://cdnjs.cloudflare.com/ajax/libs/lightslider/1.1.5/css/lightslider.min.css' );
}
}
//Remove JQuery migrate
function remove_jquery_migrate( $scripts ) {
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) {
// Check whether the script has any dependencies
$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );
//Remove Gutenberg Block Library CSS from loading on the frontend
function smartwp_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'classic-theme-styles' );
wp_dequeue_style( 'global-styles' ); // REMOVE THEME.JSON
}
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css' );
add_action( 'comment_form_before', 'blankslate_enqueue_comment_reply_script' );
function blankslate_enqueue_comment_reply_script()
{
if ( get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); }
}
add_filter( 'the_title', 'blankslate_title' );
function blankslate_title( $title ) {
if ( $title == '' ) {
return '→';
} else {
return $title;
}
}
add_filter( 'wp_title', 'blankslate_filter_wp_title' );
function blankslate_filter_wp_title( $title )
{
return $title . esc_attr( get_bloginfo( 'name' ) );
}
add_action( 'widgets_init', 'blankslate_widgets_init' );
function blankslate_widgets_init()
{
register_sidebar( array (
'name' => __( 'Sidebar Widget Area', 'heavens-best-modern' ),
'id' => 'primary-widget-area',
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => "</li>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
function blankslate_custom_pings( $comment )
{
$GLOBALS['comment'] = $comment;
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><?php echo comment_author_link(); ?></li>
<?php
}
add_filter( 'get_comments_number', 'blankslate_comments_number' );
function blankslate_comments_number( $count )
{
if ( !is_admin() ) {
global $id;
$comments_by_type = &separate_comments( get_comments( 'status=approve&post_id=' . $id ) );
return count( $comments_by_type['comment'] );
} else {
return $count;
}
}
add_action( 'after_setup_theme', 'wpdocs_theme_setup' );
function wpdocs_theme_setup() {
add_image_size( 'small', 200, 150 );
}
/*---- Add Theme Options Page -------*/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'General Theme Settings & Info',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'position' => 56,
'icon_url' => 'dashicons-admin-tools',
'capability' => 'edit_posts',
'redirect' => false
));
}
add_action( 'admin_init', 'wpuxss_admin_scripts' );
function wpuxss_admin_scripts() {
global $pagenow;
if (( $pagenow == 'admin.php' ) && ($_GET['page'] == 'theme-general-settings') ) {
wp_enqueue_script( 'wplink', home_url('/wp-includes/js/wplink.js') );
wp_enqueue_script( 'popup', home_url('/wp-content/plugins/formidable/js/formidable_admin_global.js?ver=2.03.10') );
}
}
/*----- Change Title label on reviews form ------*/
function my_acf_prepare_field( $field ) {
$field['label'] = "Your Name";
return $field;
}
add_filter('acf/prepare_field/name=_post_title', 'my_acf_prepare_field');
/*----- Allow custom background color ------*/
$args = array(
'default-color' => 'a0cef5',
);
add_theme_support( 'custom-background', $args );
/*------ Add Reviews Post Type -------*/
function cptui_register_my_cpts() {
/**
* Post Type: Reviews.
*/
$labels = array(
"name" => __( 'Reviews', 'heavens-best-modern' ),
"singular_name" => __( 'Review', 'heavens-best-modern' ),
);
$args = array(
"label" => __( 'Reviews', 'heavens-best-modern' ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => true,
"show_in_menu" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => array( "slug" => "review", "with_front" => true ),
"query_var" => true,
"supports" => array( "title", "editor", "thumbnail" ),
"taxonomies" => array( "location" ),
);
register_post_type( "review", $args );
}
add_action( 'init', 'cptui_register_my_cpts' );
function cptui_register_my_taxes() {
/**
* Taxonomy: Locations.
*/
$labels = array(
"name" => __( 'Locations', 'heavens-best-modern' ),
"singular_name" => __( 'Location', 'heavens-best-modern' ),
);
$args = array(
"label" => __( 'Locations', 'heavens-best-modern' ),
"labels" => $labels,
"public" => true,
"hierarchical" => true,
"label" => "Locations",
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( 'slug' => 'location', 'with_front' => true, 'hierarchical' => true, ),
"show_admin_column" => false,
"show_in_rest" => false,
"rest_base" => "",
"show_in_quick_edit" => false,
);
register_taxonomy( "location", array( "review" ), $args );
}
add_action( 'init', 'cptui_register_my_taxes' );
add_editor_style();
add_filter( 'frm_filter_final_form', 'auto_minimize_forms' );
function auto_minimize_forms( $form ) {
$form = str_replace( array('<fieldset>', '</fieldset>'), '', $form);
return $form;
}
// Move Yoast to bottom
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');
function yoasttobottom() {
return 'low';
}
/* Add responsive container to embeds */
function alx_embed_html( $html ) {
return '<div class="video-container">' . $html . '</div>';
}
add_filter( 'embed_oembed_html', 'alx_embed_html', 10, 3 );
add_filter( 'video_embed_html', 'alx_embed_html' ); // Jetpack
// Removes Related Videos for YouTube embeds.
function iweb_modest_youtube_player( $html, $url, $args ) {
return str_replace( '?feature=oembed', '?feature=oembed&modestbranding=1&showinfo=0&rel=0', $html );
}
add_filter( 'oembed_result', 'iweb_modest_youtube_player', 10, 3 );
// Returns true if user has specific role
function check_user_role( $role, $user_id = null ) {
if ( is_numeric( $user_id ) )
$user = get_userdata( $user_id );
else
$user = wp_get_current_user();
if ( empty( $user ) )
return false;
return in_array( $role, (array) $user->roles );
}
// Disable WordPress SEO meta box for all roles other than administrator and seo
function wpse_init(){
if( !(check_user_role('seo') || check_user_role('administrator')) ){
// Remove page analysis columns from post lists, also SEO status on post editor
add_filter('wpseo_use_page_analysis', '__return_false');
// Remove Yoast meta boxes
add_action('add_meta_boxes', 'disable_seo_metabox', 100000);
}
}
add_action('init', 'wpse_init');
function disable_seo_metabox(){
remove_meta_box('wpseo_meta', 'post', 'normal');
remove_meta_box('wpseo_meta', 'page', 'normal');
}
remove_role( 'adwords_manager' );
add_role('adwords_manager', __('Adwords Manager'),
array(
'read' => true, // Allows a user to read
'activate_plugins' => true,
'create_pages' => true,
'publish_pages' => true,
'edit_pages' => true,
'edit_others_pages' => false,
'create_posts' => true,
'delete_posts' => true,
'delete_published_posts' => true,
'edit_posts' => true,
'publish_posts' => true,
'delete_published_posts ' => true,
'edit_published_posts' => true,
'edit_others_posts' => true,
'upload_files' => true,
'edit_published_pages' => true,
'delete_pages' => true,
'delete_published_pages' => true,
'frm_view_entries' => true,
'frm_view_forms' => true,
'frm_edit_forms' => true,
'frm_view_entries' => true,
'level_8' => true
)
);
$adwords_manager = get_role('adwords_manager'); $adwords_manager -> add_cap('level_10');
function wpsites_query( $query ) {
if ( $query->is_archive() && $query->is_main_query() && !is_admin() ) {
$query->set( 'posts_per_page', 200 );
}
}
add_action( 'pre_get_posts', 'wpsites_query' );
/*--- ACF new Landing page stuff ---*/
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_593ed9fcb20ce',
'title' => 'Landing Pages',
'fields' => array(
array(
'key' => 'field_59430c05d246d',
'label' => 'Theme',
'name' => 'theme',
'type' => 'radio',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'standard' => 'Standard Blue',
'spring' => 'Spring',
'summer' => 'Summer',
'fall' => 'Fall',
'christmas' => 'Winter Holiday',
'celebration' => 'Celebration Countdown',
),
'allow_null' => 0,
'other_choice' => 0,
'save_other_choice' => 0,
'default_value' => '',
'layout' => 'horizontal',
'return_format' => 'value',
),
array(
'key' => 'field_593ed9eff3046',
'label' => 'Main Title',
'name' => 'main_title',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_59403754add86',
'label' => 'Type of Content',
'name' => 'type_of_content',
'type' => 'radio',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array(
'text' => 'Text',
'html' => 'Custom HTML Code',
),
'allow_null' => 0,
'other_choice' => 0,
'save_other_choice' => 0,
'default_value' => 'text',
'layout' => 'horizontal',
'return_format' => 'value',
),
array(
'key' => 'field_594306d52486e',
'label' => 'Special Icon HTML',
'name' => 'special_icon_html',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_59403754add86',
'operator' => '==',
'value' => 'html',
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '<article>
<figure><img src="https://res.cloudinary.com/ez-nettools/image/upload/v1497564678/white-icon-stars_bwyyn8.png" /></figure>
<h3>Highest Satisfaction</h3>
<p>We are insured, licensed, and flexible. Our schedule works with yours. Our professional, well groomed, uniformed employees are verified through extensive background checks.</p>
<hr>
</article>
<article>
<figure><img src="https://res.cloudinary.com/ez-nettools/image/upload/v1497564678/white-icon-1-hour_s6i1ar.png" /></figure>
<h3>Dry in 1 Hour</h3>
<p>Your carpets get cleaner, and dry in less than an hour, and we offer the best value on a budget. That means quality work.</p>
<hr>
</article>
<article>
<figure><img src="https://res.cloudinary.com/ez-nettools/image/upload/v1497564678/white-icon-kid-dog_yko18h.png" /></figure>
<h3>Family Safe</h3>
<p>No harsh chemicals so it\'s safe for kids, pets, and your family. That means Hypoallergenic and Residue Free too! Your family\'s safety in our priority!</p>
</article>',
'placeholder' => '',
'maxlength' => '',
'rows' => 18,
'new_lines' => '',
),
array(
'key' => 'field_594036106af6e',
'label' => 'Special Offer Details',
'name' => 'special_offer_details',
'type' => 'wysiwyg',
'instructions' => 'Put information about your specials offer.',
'required' => 0,
'conditional_logic' => array(
array(
array(
'field' => 'field_59403754add86',
'operator' => '==',
'value' => 'text',
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '<h2>3 Room Carpet Cleaning for $99</h2>
<hr />
</article><article>
<h3>This Exclusive Deal is Only For a Limited Time!</h3>
<ul>
<li>Highest Satisfaction</li>
<li>Dry in 1 Hour</li>
<li>Family Safe</li>
</ul>
Limited to 600 Sq/Ft up to 3 rooms. Special rates apply for exceeding 600 Sq/Ft limit. $35 for additional rooms. Limitations apply. Call for details.',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
'delay' => 0,
),
array(
'key' => 'field_59495f91f4b15',
'label' => 'Choose Your Form',
'name' => 'choose_your_form',
'type' => 'wysiwyg',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'tabs' => 'all',
'toolbar' => 'full',
'media_upload' => 1,
'delay' => 0,
),
array(
'key' => 'field_594035d2250ad',
'label' => 'Phone Number',
'name' => 'phone_number',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array(
'key' => 'field_59430d3f80280',
'label' => 'Additional Features',
'name' => 'additional_features',
'type' => 'textarea',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '<h3>Additional Features</h3>
<ul>
<li>Hypoallergenic</li>
<li>Residue free</li>
<li>Hospital grade disinfectant</li>
<li>No harsh chemicals</li>
</ul>',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => '',
),
array(
'key' => 'field_594947f37776c',
'label' => 'Homepage Link (optional)',
'name' => 'add_homepage_link',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => 'Add a link under the phone number to the homepage',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
array(
'key' => 'field_5949488cd278d',
'label' => 'Add Address (optional)',
'name' => 'add_address',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => 'Place your address in the footer',
'default_value' => 0,
'ui' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
),
),
'location' => array(
array(
array(
'param' => 'page_template',
'operator' => '==',
'value' => 'template-landing.php',
),
),
array(
array(
'param' => 'page_template',
'operator' => '==',
'value' => 'template-sandwich-landing.php',
),
),
),
'menu_order' => 0,
'position' => 'acf_after_title',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => array(
0 => 'the_content',
),
'active' => 1,
'description' => '',
));
acf_add_local_field_group(array(
'key' => 'group_5c05940af1162',
'title' => 'Sandwich Landing Page',
'fields' => array(
array(
'key' => 'field_5c0593dd63855',
'label' => 'iframe URL',
'name' => 'iframe_url',
'type' => 'url',
'instructions' => 'The middle part of the Sandwich Landing Page is an iframe from another source. Choose the middle part here.',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => 'https://hbcarpetcleaning.com/landing-page-piece',
'placeholder' => '',
),
),
'location' => array(
array(
array(
'param' => 'post_template',
'operator' => '==',
'value' => 'template-sandwich-landing.php',
),
),
),
'menu_order' => 0,
'position' => 'acf_after_title',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
endif;