ec90ef80 by Jeff Balicki

clean up

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 475a0abc
...@@ -6,6 +6,7 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED); ...@@ -6,6 +6,7 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
6 require_once __DIR__ . '/vendor/autoload.php'; 6 require_once __DIR__ . '/vendor/autoload.php';
7 require_once 'inc/users.php'; 7 require_once 'inc/users.php';
8 require_once 'inc/learn.php'; 8 require_once 'inc/learn.php';
9 require_once 'inc/menus.php';
9 10
10 add_action('wp_enqueue_scripts', 'theme_broker_enqueue_scripts'); 11 add_action('wp_enqueue_scripts', 'theme_broker_enqueue_scripts');
11 function theme_broker_enqueue_scripts() 12 function theme_broker_enqueue_scripts()
...@@ -120,17 +121,14 @@ function theme_broker_enqueue_scripts() ...@@ -120,17 +121,14 @@ function theme_broker_enqueue_scripts()
120 } 121 }
121 122
122 123
123 124 if (is_page_template("badge-share.php"))
124
125 }
126
127
128 if (is_page_template("badge-share.php"))
129 { 125 {
130 wp_enqueue_script('sharerbox', get_bloginfo('template_url') . '/scripts/sharerbox.js', [], false, true); 126 wp_enqueue_script('sharerbox', get_bloginfo('template_url') . '/scripts/sharerbox.js', [], false, true);
127 }
128
131 } 129 }
132 130
133 add_action('admin_enqueue_scripts', 'enqueue_admin_store_locator_my_scripts'); 131
134 132
135 133
136 134
...@@ -196,42 +194,13 @@ function removeHeadLinks() ...@@ -196,42 +194,13 @@ function removeHeadLinks()
196 add_action('init', 'removeHeadLinks'); 194 add_action('init', 'removeHeadLinks');
197 remove_action('wp_head', 'wp_generator'); 195 remove_action('wp_head', 'wp_generator');
198 196
199 function register_menus() 197
200 {
201 register_nav_menus(
202 [
203
204 'broker-header' => 'Broker Header',
205 'broker-header-mobile' => 'Broker Header Mobile',
206 'broker-menu' => 'Broker Menu',
207 'broker-footer' => 'Broker Footer',
208
209 ]
210 );
211 }
212 add_theme_support( 'post-thumbnails' ); 198 add_theme_support( 'post-thumbnails' );
213 add_theme_support('custom-header'); 199 add_theme_support('custom-header');
214 add_action('init', 'register_menus');
215 200
216 201
217 202
218 function menu_has_children($sorted_menu_items, $args)
219 {
220 $last_top = 0;
221 foreach ($sorted_menu_items as $key => $obj) {
222 // it is a top lv item?
223 if (0 == $obj->menu_item_parent) {
224 // set the key of the parent
225 $last_top = $key;
226 } else {
227 $sorted_menu_items[$last_top]->classes['has-children'] = 'has-children';
228 }
229 }
230
231 return $sorted_menu_items;
232 }
233 203
234 add_filter('wp_nav_menu_objects', 'menu_has_children', 10, 2);
235 204
236 function register_widgets() 205 function register_widgets()
237 { 206 {
...@@ -562,144 +531,6 @@ function ja_theme_setup() ...@@ -562,144 +531,6 @@ function ja_theme_setup()
562 } 531 }
563 532
564 533
565 function clean_custom_menus()
566 {
567 $menu_name = 'broker-menu'; // specify custom menu slug
568 $menu_list = '';
569 if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
570 $menu = wp_get_nav_menu_object($locations[$menu_name]);
571 $menu_items = wp_get_nav_menu_items($menu->term_id);
572
573 $menu_list = '<nav class="col-sm-smallMenu">' . "\n";
574
575 $colCount = count($menu_items);
576 $colCount = 12 / $colCount;
577 if ($colCount == '2.4') {
578 $colCount = '5ths';
579 }
580
581 foreach ((array) $menu_items as $key => $menu_item) {
582 $title = $menu_item->title;
583 $url = $menu_item->url;
584 $classes = '';
585
586 // Getting the current post details
587 global $post;
588
589 // Checking if post ID exist...
590 if (isset($post->ID)) {
591 // Get the queried object and sanitize it
592 $current_page = sanitize_post($GLOBALS['wp_the_query']->get_queried_object());
593 // Get the page slug
594 $slug = $current_page->post_name;
595 // Getting the URL of the menu item
596 $menu_slug = strtolower(trim($url));
597
598 // If the menu item URL contains the current post types slug add the current-menu-item class
599 if (strpos($menu_slug, $slug) !== false) {
600 $classes .= 'current-menu-item';
601 }
602 }
603 foreach ($menu_item->classes as $class) {
604 $classes .= ' ' . $class;
605 }
606 //error_log(print_r( $menu_item,true));
607 $menu_list .= '<a href="' . $url . '" id="' . $post_title . '" class="col-xs-12 col-sm-' . $colCount . ' col-md-' . $colCount . ' tab_menu ' . $classes . ' ' . $menu_item->custom . '"><img src="' . $menu_item->custom_image . '"/><span class="tab_label">' . $title . '</span><span class="selected-arrow"></span></a>';
608 }
609
610 $menu_list .= "\t\t\t" . '</nav>' . "\n";
611 } else {
612 // $menu_list = '<!-- no list defined -->';
613 }
614 echo $menu_list;
615 }
616
617
618 function clean_custom_moblie_menus()
619 {
620 $current_user = wp_get_current_user();
621 $menu_name = 'broker-menu'; // specify custom menu slug
622 $menu_list = '';
623 if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
624 $menu = wp_get_nav_menu_object($locations[$menu_name]);
625 $menu_items = wp_get_nav_menu_items($menu->term_id);
626 $classes = '';
627 $menu_list = '<nav id="mainNav" class="navbar col-sm-mobile navbar-default navbar-fixed-top">
628 <div class="container">
629 <div class="mobile_collapse" id="mobile_collapse" >
630 <ul class="nav navbar-nav navbar-right">
631
632 ' . "\n";
633 foreach ((array) $menu_items as $key => $menu_item) {
634 $title = $menu_item->title;
635 $url = $menu_item->url;
636
637 foreach ($menu_item->classes as $classe) {
638 $classes .= ' ' . $classe;
639 }
640
641 $menu_list .= '<li><a href="' . $url . '" class="col-xs-12 col-sm-12 col-md-12 mobile_menu ' . $classes . ' ' . $menu_item->custom . '"><img src="' . $menu_item->custom_image . '"/><span class="tab_label">' . $title . '</span></a></li>';
642 }
643
644 $menu_list .= '</ul>';
645
646 $menu_name = 'broker-header-mobile';
647 $menu = wp_get_nav_menu_object($locations[$menu_name]);
648 $menu_items = wp_get_nav_menu_items($menu->term_id);
649
650 $menu_list .= '<ul class="header_background">';
651 foreach ((array) $menu_items as $key => $menu_item) {
652 $title = $menu_item->title;
653 $url = $menu_item->url;
654 $menu_list .= '<li><a href="' . $url . '">' . $title . '</a></li>';
655 }
656 $menu_list .= '</ul>';
657
658 $menu_list .= '<ul class="header_background2 grad_background"><li><h5>Account</h5></il><li>' . get_user_meta(
659 $current_user->ID,
660 'first_name',
661 true
662 ) . ' ' . get_user_meta(
663 $current_user->ID,
664 'last_name',
665 true
666 ) . '</li><li>' . $current_user->user_email . '</li></ul>';
667
668 $menu_list .= '<div class="arrow-up"></div>
669
670 </div>
671 <div id="seacrh_mobile">' . do_shortcode(
672 '[searchwp_search_form target="' . get_option('home') . '/search-results/" engine="default" var="searchvar" ]'
673 ) . '
674 <div class="arrow-up-right"></div>
675 </div>
676
677 <div class="navbar-header">
678 <button type="button" class="navbar-toggle collapsed" onClick="toggle_mobile_menu();" >
679 <span class="sr-only">Toggle navigation</span>
680 <span class="icon-bar"></span>
681 <span class="icon-bar"></span>
682 <span class="icon-bar"></span>
683 </button>
684 <a href="' . get_option('home') .'">
685 <img id="mobile-logo" src="' . get_bloginfo('template_url') . '/images/Commonwell-logo.svg" alt="Commonwell Mutual Insurance Group logo" />
686 </a>
687 <button onClick="showSearch();" type="button" class="search_icon_button" ><i class="search_icon material-icons">&#xE8B6;</i></button>
688 </div>
689 <div class="broker_mobile_hello">
690 <span class="username" style="text-transform:uppercase;">HI "' . esc_html($current_user->user_firstname) . '"</span><span class="greating"> - How can we help? <i id="tooltipmobile" class="material-icons" style="cursor: help;color:#229cde;top: 7px;position: relative; font-size: 20px;"></i></span>
691 </div>
692 <!-- Collect the nav links, forms, and other content for toggling -->
693 </div>
694 <!-- /.container-fluid -->
695 </nav>
696 ' . "\n";
697 } else {
698 // $menu_list = '<!-- no list defined -->';
699 }
700 echo $menu_list;
701 }
702
703 function enable_extended_upload($mime_types = array()) 534 function enable_extended_upload($mime_types = array())
704 { 535 {
705 536
...@@ -885,40 +716,6 @@ function custom_pagination($numpages = '', $pagerange = '', $paged = '') ...@@ -885,40 +716,6 @@ function custom_pagination($numpages = '', $pagerange = '', $paged = '')
885 } 716 }
886 } 717 }
887 718
888 add_shortcode("NewsText", "NewsText");
889 function NewsText()
890 {
891 $custom_args = array(
892 'post_type' => 'new_and_events',
893 'posts_per_page' => 10,
894 'paged' => 1,
895 'meta_query' => array(
896 'relation' => 'AND',
897 array(
898 'key' => 'type',
899 'value' => 'NewsText',
900 'compare' => '=',
901 ),
902 )
903 );
904
905 $custom_query = new WP_Query($custom_args);
906
907 if ($custom_query->have_posts()):
908 $news = '<h3>NEWS</h3>';
909 while ($custom_query->have_posts()): $custom_query->the_post();
910 $id = get_the_ID();
911 $post = get_post($id);
912 $news .= do_shortcode('[su_spoiler title="' . $post->post_title . '" icon="caret"]' . $post->post_content . '[/su_spoiler]');
913
914 endwhile;
915 $newspost = do_shortcode('[su_accordion]' . $news . '[/su_accordion]');
916 endif;
917
918 return $newspost;
919 }
920
921
922 719
923 add_shortcode("WaveButton", "WaveButton"); 720 add_shortcode("WaveButton", "WaveButton");
924 function WaveButton() 721 function WaveButton()
...@@ -1074,20 +871,13 @@ add_shortcode('add_hr', 'add_hr_shortcode'); ...@@ -1074,20 +871,13 @@ add_shortcode('add_hr', 'add_hr_shortcode');
1074 871
1075 function add_hr_shortcode() 872 function add_hr_shortcode()
1076 { 873 {
1077
1078 ob_start();?> 874 ob_start();?>
1079 875 <div class="hr"></div>
1080 <div class="hr"></div> 876 <?php return ob_get_clean();
1081
1082
1083 <?php
1084
1085 return ob_get_clean();
1086 } 877 }
1087 878
1088 879
1089 880
1090
1091 add_action('wp_logout', 'remove_custom_cookie_admin'); 881 add_action('wp_logout', 'remove_custom_cookie_admin');
1092 function remove_custom_cookie_admin() 882 function remove_custom_cookie_admin()
1093 { 883 {
...@@ -1143,30 +933,6 @@ function prefix_setup_schedule() { ...@@ -1143,30 +933,6 @@ function prefix_setup_schedule() {
1143 } 933 }
1144 934
1145 935
1146 add_action( 'prefix_daily_event', 'prefix_do_this_daily' );
1147 /**
1148 * On the scheduled action hook, run a function.
1149 */
1150 function prefix_do_this_daily() {
1151
1152 $broker = get_users( array( 'role__in' => array('subscriber' ) ) );
1153 // Array of WP_User objects.
1154 foreach ( $broker as $user ) {
1155 learndash_process_mark_complete($user->ID, 45654 );
1156
1157 }
1158
1159 }
1160
1161
1162 add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
1163 function wpb_new_gravatar ($avatar_defaults) {
1164 $myavatar = 'http://ccorp.test/wp-content/themes/commonwell-corp/images/CWL_Learning-Profile-Icon.gif';
1165 $avatar_defaults[$myavatar] = "Default Gravatar";
1166 return $avatar_defaults;
1167 }
1168
1169
1170 function get_excerpt($limit, $source = null){ 936 function get_excerpt($limit, $source = null){
1171 937
1172 $excerpt = $source == "content" ? get_the_content() : get_the_excerpt(); 938 $excerpt = $source == "content" ? get_the_content() : get_the_excerpt();
...@@ -1282,9 +1048,3 @@ add_filter( 'send_password_change_email', '__return_false' ); ...@@ -1282,9 +1048,3 @@ add_filter( 'send_password_change_email', '__return_false' );
1282 add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' ); 1048 add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' );
1283 // Disables the block editor from managing widgets. 1049 // Disables the block editor from managing widgets.
1284 add_filter( 'use_widgets_block_editor', '__return_false' ); 1050 add_filter( 'use_widgets_block_editor', '__return_false' );
1285
1286
1287
1288
1289
1290
......
...@@ -632,3 +632,26 @@ function the_bread() { ...@@ -632,3 +632,26 @@ function the_bread() {
632 }; 632 };
633 633
634 add_shortcode( 'breadcrumbs', 'the_bread' ); 634 add_shortcode( 'breadcrumbs', 'the_bread' );
635
636 add_action( 'prefix_daily_event', 'prefix_do_this_daily' );
637 /**
638 * On the scheduled action hook, run a function.
639 */
640 function prefix_do_this_daily() {
641
642 $broker = get_users( array( 'role__in' => array('subscriber' ) ) );
643 // Array of WP_User objects.
644 foreach ( $broker as $user ) {
645 learndash_process_mark_complete($user->ID, 45654 );
646
647 }
648
649 }
650
651 add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
652 function wpb_new_gravatar ($avatar_defaults) {
653 $myavatar = 'http://ccorp.test/wp-content/themes/commonwell-corp/images/CWL_Learning-Profile-Icon.gif';
654 $avatar_defaults[$myavatar] = "Default Gravatar";
655 return $avatar_defaults;
656 }
657
......
1 <?php
2
3
4 add_action('init', 'register_menus');
5
6
7 function register_menus()
8 {
9 register_nav_menus(
10 [
11
12 'broker-header' => 'Broker Header',
13 'broker-header-mobile' => 'Broker Header Mobile',
14 'broker-menu' => 'Broker Menu',
15 'broker-footer' => 'Broker Footer',
16
17 ]
18 );
19 }
20
21
22 function menu_has_children($sorted_menu_items, $args)
23 {
24 $last_top = 0;
25 foreach ($sorted_menu_items as $key => $obj) {
26 // it is a top lv item?
27 if (0 == $obj->menu_item_parent) {
28 // set the key of the parent
29 $last_top = $key;
30 } else {
31 $sorted_menu_items[$last_top]->classes['has-children'] = 'has-children';
32 }
33 }
34
35 return $sorted_menu_items;
36 }
37
38 add_filter('wp_nav_menu_objects', 'menu_has_children', 10, 2);
39
40 function clean_custom_menus()
41 {
42 $menu_name = 'broker-menu'; // specify custom menu slug
43 $menu_list = '';
44 if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
45 $menu = wp_get_nav_menu_object($locations[$menu_name]);
46 $menu_items = wp_get_nav_menu_items($menu->term_id);
47
48 $menu_list = '<nav class="col-sm-smallMenu">' . "\n";
49
50 $colCount = count($menu_items);
51 $colCount = 12 / $colCount;
52 if ($colCount == '2.4') {
53 $colCount = '5ths';
54 }
55
56 foreach ((array) $menu_items as $key => $menu_item) {
57 $title = $menu_item->title;
58 $url = $menu_item->url;
59 $classes = '';
60
61 // Getting the current post details
62 global $post;
63
64 // Checking if post ID exist...
65 if (isset($post->ID)) {
66 // Get the queried object and sanitize it
67 $current_page = sanitize_post($GLOBALS['wp_the_query']->get_queried_object());
68 // Get the page slug
69 $slug = $current_page->post_name;
70 // Getting the URL of the menu item
71 $menu_slug = strtolower(trim($url));
72
73 // If the menu item URL contains the current post types slug add the current-menu-item class
74 if (strpos($menu_slug, $slug) !== false) {
75 $classes .= 'current-menu-item';
76 }
77 }
78 foreach ($menu_item->classes as $class) {
79 $classes .= ' ' . $class;
80 }
81 //error_log(print_r( $menu_item,true));
82 $menu_list .= '<a href="' . $url . '" id="' . $post_title . '" class="col-xs-12 col-sm-' . $colCount . ' col-md-' . $colCount . ' tab_menu ' . $classes . ' ' . $menu_item->custom . '"><img src="' . $menu_item->custom_image . '"/><span class="tab_label">' . $title . '</span><span class="selected-arrow"></span></a>';
83 }
84
85 $menu_list .= "\t\t\t" . '</nav>' . "\n";
86 } else {
87 // $menu_list = '<!-- no list defined -->';
88 }
89 echo $menu_list;
90 }
91
92
93 function clean_custom_moblie_menus()
94 {
95 $current_user = wp_get_current_user();
96 $menu_name = 'broker-menu'; // specify custom menu slug
97 $menu_list = '';
98 if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
99 $menu = wp_get_nav_menu_object($locations[$menu_name]);
100 $menu_items = wp_get_nav_menu_items($menu->term_id);
101 $classes = '';
102 $menu_list = '<nav id="mainNav" class="navbar col-sm-mobile navbar-default navbar-fixed-top">
103 <div class="container">
104 <div class="mobile_collapse" id="mobile_collapse" >
105 <ul class="nav navbar-nav navbar-right">
106
107 ' . "\n";
108 foreach ((array) $menu_items as $key => $menu_item) {
109 $title = $menu_item->title;
110 $url = $menu_item->url;
111
112 foreach ($menu_item->classes as $classe) {
113 $classes .= ' ' . $classe;
114 }
115
116 $menu_list .= '<li><a href="' . $url . '" class="col-xs-12 col-sm-12 col-md-12 mobile_menu ' . $classes . ' ' . $menu_item->custom . '"><img src="' . $menu_item->custom_image . '"/><span class="tab_label">' . $title . '</span></a></li>';
117 }
118
119 $menu_list .= '</ul>';
120
121 $menu_name = 'broker-header-mobile';
122 $menu = wp_get_nav_menu_object($locations[$menu_name]);
123 $menu_items = wp_get_nav_menu_items($menu->term_id);
124
125 $menu_list .= '<ul class="header_background">';
126 foreach ((array) $menu_items as $key => $menu_item) {
127 $title = $menu_item->title;
128 $url = $menu_item->url;
129 $menu_list .= '<li><a href="' . $url . '">' . $title . '</a></li>';
130 }
131 $menu_list .= '</ul>';
132
133 $menu_list .= '<ul class="header_background2 grad_background"><li><h5>Account</h5></il><li>' . get_user_meta(
134 $current_user->ID,
135 'first_name',
136 true
137 ) . ' ' . get_user_meta(
138 $current_user->ID,
139 'last_name',
140 true
141 ) . '</li><li>' . $current_user->user_email . '</li></ul>';
142
143 $menu_list .= '<div class="arrow-up"></div>
144
145 </div>
146 <div id="seacrh_mobile">' . do_shortcode(
147 '[searchwp_search_form target="' . get_option('home') . '/search-results/" engine="default" var="searchvar" ]'
148 ) . '
149 <div class="arrow-up-right"></div>
150 </div>
151
152 <div class="navbar-header">
153 <button type="button" class="navbar-toggle collapsed" onClick="toggle_mobile_menu();" >
154 <span class="sr-only">Toggle navigation</span>
155 <span class="icon-bar"></span>
156 <span class="icon-bar"></span>
157 <span class="icon-bar"></span>
158 </button>
159 <a href="' . get_option('home') .'">
160 <img id="mobile-logo" src="' . get_bloginfo('template_url') . '/images/Commonwell-logo.svg" alt="Commonwell Mutual Insurance Group logo" />
161 </a>
162 <button onClick="showSearch();" type="button" class="search_icon_button" ><i class="search_icon material-icons">&#xE8B6;</i></button>
163 </div>
164 <div class="broker_mobile_hello">
165 <span class="username" style="text-transform:uppercase;">HI "' . esc_html($current_user->user_firstname) . '"</span><span class="greating"> - How can we help? <i id="tooltipmobile" class="material-icons" style="cursor: help;color:#229cde;top: 7px;position: relative; font-size: 20px;"></i></span>
166 </div>
167 <!-- Collect the nav links, forms, and other content for toggling -->
168 </div>
169 <!-- /.container-fluid -->
170 </nav>
171 ' . "\n";
172 } else {
173 // $menu_list = '<!-- no list defined -->';
174 }
175 echo $menu_list;
176 }