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);
require_once __DIR__ . '/vendor/autoload.php';
require_once 'inc/users.php';
require_once 'inc/learn.php';
require_once 'inc/menus.php';
add_action('wp_enqueue_scripts', 'theme_broker_enqueue_scripts');
function theme_broker_enqueue_scripts()
......@@ -120,17 +121,14 @@ function theme_broker_enqueue_scripts()
}
}
if (is_page_template("badge-share.php"))
if (is_page_template("badge-share.php"))
{
wp_enqueue_script('sharerbox', get_bloginfo('template_url') . '/scripts/sharerbox.js', [], false, true);
}
}
add_action('admin_enqueue_scripts', 'enqueue_admin_store_locator_my_scripts');
......@@ -196,42 +194,13 @@ function removeHeadLinks()
add_action('init', 'removeHeadLinks');
remove_action('wp_head', 'wp_generator');
function register_menus()
{
register_nav_menus(
[
'broker-header' => 'Broker Header',
'broker-header-mobile' => 'Broker Header Mobile',
'broker-menu' => 'Broker Menu',
'broker-footer' => 'Broker Footer',
]
);
}
add_theme_support( 'post-thumbnails' );
add_theme_support('custom-header');
add_action('init', 'register_menus');
function menu_has_children($sorted_menu_items, $args)
{
$last_top = 0;
foreach ($sorted_menu_items as $key => $obj) {
// it is a top lv item?
if (0 == $obj->menu_item_parent) {
// set the key of the parent
$last_top = $key;
} else {
$sorted_menu_items[$last_top]->classes['has-children'] = 'has-children';
}
}
return $sorted_menu_items;
}
add_filter('wp_nav_menu_objects', 'menu_has_children', 10, 2);
function register_widgets()
{
......@@ -562,144 +531,6 @@ function ja_theme_setup()
}
function clean_custom_menus()
{
$menu_name = 'broker-menu'; // specify custom menu slug
$menu_list = '';
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list = '<nav class="col-sm-smallMenu">' . "\n";
$colCount = count($menu_items);
$colCount = 12 / $colCount;
if ($colCount == '2.4') {
$colCount = '5ths';
}
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
$classes = '';
// Getting the current post details
global $post;
// Checking if post ID exist...
if (isset($post->ID)) {
// Get the queried object and sanitize it
$current_page = sanitize_post($GLOBALS['wp_the_query']->get_queried_object());
// Get the page slug
$slug = $current_page->post_name;
// Getting the URL of the menu item
$menu_slug = strtolower(trim($url));
// If the menu item URL contains the current post types slug add the current-menu-item class
if (strpos($menu_slug, $slug) !== false) {
$classes .= 'current-menu-item';
}
}
foreach ($menu_item->classes as $class) {
$classes .= ' ' . $class;
}
//error_log(print_r( $menu_item,true));
$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>';
}
$menu_list .= "\t\t\t" . '</nav>' . "\n";
} else {
// $menu_list = '<!-- no list defined -->';
}
echo $menu_list;
}
function clean_custom_moblie_menus()
{
$current_user = wp_get_current_user();
$menu_name = 'broker-menu'; // specify custom menu slug
$menu_list = '';
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$classes = '';
$menu_list = '<nav id="mainNav" class="navbar col-sm-mobile navbar-default navbar-fixed-top">
<div class="container">
<div class="mobile_collapse" id="mobile_collapse" >
<ul class="nav navbar-nav navbar-right">
' . "\n";
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
foreach ($menu_item->classes as $classe) {
$classes .= ' ' . $classe;
}
$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>';
}
$menu_list .= '</ul>';
$menu_name = 'broker-header-mobile';
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list .= '<ul class="header_background">';
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
$menu_list .= '<li><a href="' . $url . '">' . $title . '</a></li>';
}
$menu_list .= '</ul>';
$menu_list .= '<ul class="header_background2 grad_background"><li><h5>Account</h5></il><li>' . get_user_meta(
$current_user->ID,
'first_name',
true
) . ' ' . get_user_meta(
$current_user->ID,
'last_name',
true
) . '</li><li>' . $current_user->user_email . '</li></ul>';
$menu_list .= '<div class="arrow-up"></div>
</div>
<div id="seacrh_mobile">' . do_shortcode(
'[searchwp_search_form target="' . get_option('home') . '/search-results/" engine="default" var="searchvar" ]'
) . '
<div class="arrow-up-right"></div>
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" onClick="toggle_mobile_menu();" >
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="' . get_option('home') .'">
<img id="mobile-logo" src="' . get_bloginfo('template_url') . '/images/Commonwell-logo.svg" alt="Commonwell Mutual Insurance Group logo" />
</a>
<button onClick="showSearch();" type="button" class="search_icon_button" ><i class="search_icon material-icons">&#xE8B6;</i></button>
</div>
<div class="broker_mobile_hello">
<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>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
</div>
<!-- /.container-fluid -->
</nav>
' . "\n";
} else {
// $menu_list = '<!-- no list defined -->';
}
echo $menu_list;
}
function enable_extended_upload($mime_types = array())
{
......@@ -885,40 +716,6 @@ function custom_pagination($numpages = '', $pagerange = '', $paged = '')
}
}
add_shortcode("NewsText", "NewsText");
function NewsText()
{
$custom_args = array(
'post_type' => 'new_and_events',
'posts_per_page' => 10,
'paged' => 1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'type',
'value' => 'NewsText',
'compare' => '=',
),
)
);
$custom_query = new WP_Query($custom_args);
if ($custom_query->have_posts()):
$news = '<h3>NEWS</h3>';
while ($custom_query->have_posts()): $custom_query->the_post();
$id = get_the_ID();
$post = get_post($id);
$news .= do_shortcode('[su_spoiler title="' . $post->post_title . '" icon="caret"]' . $post->post_content . '[/su_spoiler]');
endwhile;
$newspost = do_shortcode('[su_accordion]' . $news . '[/su_accordion]');
endif;
return $newspost;
}
add_shortcode("WaveButton", "WaveButton");
function WaveButton()
......@@ -1074,20 +871,13 @@ add_shortcode('add_hr', 'add_hr_shortcode');
function add_hr_shortcode()
{
ob_start();?>
<div class="hr"></div>
<?php
return ob_get_clean();
<div class="hr"></div>
<?php return ob_get_clean();
}
add_action('wp_logout', 'remove_custom_cookie_admin');
function remove_custom_cookie_admin()
{
......@@ -1143,30 +933,6 @@ function prefix_setup_schedule() {
}
add_action( 'prefix_daily_event', 'prefix_do_this_daily' );
/**
* On the scheduled action hook, run a function.
*/
function prefix_do_this_daily() {
$broker = get_users( array( 'role__in' => array('subscriber' ) ) );
// Array of WP_User objects.
foreach ( $broker as $user ) {
learndash_process_mark_complete($user->ID, 45654 );
}
}
add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'http://ccorp.test/wp-content/themes/commonwell-corp/images/CWL_Learning-Profile-Icon.gif';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}
function get_excerpt($limit, $source = null){
$excerpt = $source == "content" ? get_the_content() : get_the_excerpt();
......@@ -1282,9 +1048,3 @@ add_filter( 'send_password_change_email', '__return_false' );
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' );
// Disables the block editor from managing widgets.
add_filter( 'use_widgets_block_editor', '__return_false' );
......
......@@ -632,3 +632,26 @@ function the_bread() {
};
add_shortcode( 'breadcrumbs', 'the_bread' );
add_action( 'prefix_daily_event', 'prefix_do_this_daily' );
/**
* On the scheduled action hook, run a function.
*/
function prefix_do_this_daily() {
$broker = get_users( array( 'role__in' => array('subscriber' ) ) );
// Array of WP_User objects.
foreach ( $broker as $user ) {
learndash_process_mark_complete($user->ID, 45654 );
}
}
add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'http://ccorp.test/wp-content/themes/commonwell-corp/images/CWL_Learning-Profile-Icon.gif';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}
......
<?php
add_action('init', 'register_menus');
function register_menus()
{
register_nav_menus(
[
'broker-header' => 'Broker Header',
'broker-header-mobile' => 'Broker Header Mobile',
'broker-menu' => 'Broker Menu',
'broker-footer' => 'Broker Footer',
]
);
}
function menu_has_children($sorted_menu_items, $args)
{
$last_top = 0;
foreach ($sorted_menu_items as $key => $obj) {
// it is a top lv item?
if (0 == $obj->menu_item_parent) {
// set the key of the parent
$last_top = $key;
} else {
$sorted_menu_items[$last_top]->classes['has-children'] = 'has-children';
}
}
return $sorted_menu_items;
}
add_filter('wp_nav_menu_objects', 'menu_has_children', 10, 2);
function clean_custom_menus()
{
$menu_name = 'broker-menu'; // specify custom menu slug
$menu_list = '';
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list = '<nav class="col-sm-smallMenu">' . "\n";
$colCount = count($menu_items);
$colCount = 12 / $colCount;
if ($colCount == '2.4') {
$colCount = '5ths';
}
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
$classes = '';
// Getting the current post details
global $post;
// Checking if post ID exist...
if (isset($post->ID)) {
// Get the queried object and sanitize it
$current_page = sanitize_post($GLOBALS['wp_the_query']->get_queried_object());
// Get the page slug
$slug = $current_page->post_name;
// Getting the URL of the menu item
$menu_slug = strtolower(trim($url));
// If the menu item URL contains the current post types slug add the current-menu-item class
if (strpos($menu_slug, $slug) !== false) {
$classes .= 'current-menu-item';
}
}
foreach ($menu_item->classes as $class) {
$classes .= ' ' . $class;
}
//error_log(print_r( $menu_item,true));
$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>';
}
$menu_list .= "\t\t\t" . '</nav>' . "\n";
} else {
// $menu_list = '<!-- no list defined -->';
}
echo $menu_list;
}
function clean_custom_moblie_menus()
{
$current_user = wp_get_current_user();
$menu_name = 'broker-menu'; // specify custom menu slug
$menu_list = '';
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$classes = '';
$menu_list = '<nav id="mainNav" class="navbar col-sm-mobile navbar-default navbar-fixed-top">
<div class="container">
<div class="mobile_collapse" id="mobile_collapse" >
<ul class="nav navbar-nav navbar-right">
' . "\n";
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
foreach ($menu_item->classes as $classe) {
$classes .= ' ' . $classe;
}
$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>';
}
$menu_list .= '</ul>';
$menu_name = 'broker-header-mobile';
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list .= '<ul class="header_background">';
foreach ((array) $menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
$menu_list .= '<li><a href="' . $url . '">' . $title . '</a></li>';
}
$menu_list .= '</ul>';
$menu_list .= '<ul class="header_background2 grad_background"><li><h5>Account</h5></il><li>' . get_user_meta(
$current_user->ID,
'first_name',
true
) . ' ' . get_user_meta(
$current_user->ID,
'last_name',
true
) . '</li><li>' . $current_user->user_email . '</li></ul>';
$menu_list .= '<div class="arrow-up"></div>
</div>
<div id="seacrh_mobile">' . do_shortcode(
'[searchwp_search_form target="' . get_option('home') . '/search-results/" engine="default" var="searchvar" ]'
) . '
<div class="arrow-up-right"></div>
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" onClick="toggle_mobile_menu();" >
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="' . get_option('home') .'">
<img id="mobile-logo" src="' . get_bloginfo('template_url') . '/images/Commonwell-logo.svg" alt="Commonwell Mutual Insurance Group logo" />
</a>
<button onClick="showSearch();" type="button" class="search_icon_button" ><i class="search_icon material-icons">&#xE8B6;</i></button>
</div>
<div class="broker_mobile_hello">
<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>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
</div>
<!-- /.container-fluid -->
</nav>
' . "\n";
} else {
// $menu_list = '<!-- no list defined -->';
}
echo $menu_list;
}