<?php
/**
 * Child theme functions
 *
 * When using a child theme (see http://codex.wordpress.org/Theme_Development
 * and http://codex.wordpress.org/Child_Themes), you can override certain
 * functions (those wrapped in a function_exists() call) by defining them first
 * in your child theme's functions.php file. The child theme's functions.php
 * file is included before the parent theme's file, so the child theme
 * functions would be used.
 *
 * Text Domain: wpex
 * @link http://codex.wordpress.org/Plugin_API
 *
 */

/**
 * Load the parent style.css file
 *
 * @link http://codex.wordpress.org/Child_Themes
 */

add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {

global $user_ID;

if ( current_user_can( 'hartling group staff' ) ) {
remove_menu_page('edit.php'); // Posts
remove_menu_page('link-manager.php'); // Links
remove_menu_page('edit-comments.php'); // Comments
remove_menu_page('edit.php?post_type=page'); // Pages
remove_menu_page('plugins.php'); // Plugins
remove_menu_page('themes.php'); // Appearance
remove_menu_page('users.php'); // Users
remove_menu_page('tools.php'); // Tools
remove_menu_page('options-general.php'); // Settings
remove_menu_page('wpcf-cpt');
remove_menu_page('vc-welcome');	
remove_menu_page('wpcf7');	
remove_menu_page('edit.php?post_type=special');	
remove_menu_page('edit.php?post_type=award');	
remove_menu_page('edit.php?post_type=testimonial');
remove_menu_page('edit.php?post_type=slideshow');	
remove_menu_page('edit.php?post_type=gallery');	
remove_menu_page('edit.php?post_type=company-announcement');
remove_menu_page('edit.php?post_type=media-clip');
remove_menu_page('edit.php?post_type=newsletter');
remove_menu_page('edit.php?post_type=real-estate');
remove_menu_page('edit.php?post_type=dir-announcement');
remove_menu_page('edit.php?post_type=dir-activity');
remove_menu_page('edit.php?post_type=dir-dining');
remove_menu_page('edit.php?post_type=dir-activity');
remove_menu_page('edit.php?post_type=media-clips');
remove_menu_page('edit.php?post_type=testimonials');
remove_menu_page('edit.php?post_type=staff');
remove_menu_page('edit.php?post_type=portfolio');
remove_menu_page('admin.php?page=ai1wm_import');
remove_menu_page('index.php');
}
}

function total_child_enqueue_parent_theme_style() {

	// Dynamically get version number of the parent stylesheet (lets browsers re-cache your stylesheet when you update your theme)
	$theme   = wp_get_theme( 'Total' );
	$version = $theme->get( 'Version' );

	// Load the stylesheet
	wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css', array(), $version );
	
}
add_action( 'wp_enqueue_scripts', 'total_child_enqueue_parent_theme_style' );

function thumbnail_in_content($atts) {
    global $post;
    return get_the_post_thumbnail($post->ID);
}
add_shortcode('thumbnail', 'thumbnail_in_content');

add_action('after_setup_theme', 'remove_admin_bar');
 
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
  show_admin_bar(false);
}
}

/**
 * Helper for removing the Revslider Metabox from being on every CPT edit screen
 *
 * @param $post_type
 */
function remove_revslider_metabox($post_type)
{
    add_action('do_meta_boxes', function () use ($post_type) {
        remove_meta_box('mymetabox_revslider_0', $post_type, 'normal');
    });
}
add_action('registered_post_type', 'remove_revslider_metabox');

