File: /home/workshopbrain/www/mis/wp-content/themes/MDISTOUR/functions.php
<?php
//Replace howdy within the admin panel
function replace_howdy( $wp_admin_bar ) {
$my_account=$wp_admin_bar->get_node('my-account');
$newtitle = str_replace( 'Howdy,', 'Hello, welcome back! - ', $my_account->title );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $newtitle,
) );
}
add_filter( 'admin_bar_menu', 'replace_howdy',25 );
//Replace howdy within the admin panel end
//hide help menu and screen options menu
function hide_help() {
echo '<style type="text/css">
#contextual-help-link-wrap { display: none !important; }
</style>';
}
add_action('admin_head', 'hide_help');
//hide help menu end
//available leasing space custom post type
add_action('init', 'available_space_register_post_type');
function available_space_register_post_type() {
register_post_type('leasing-space', array(
'labels' => array(
'name' => 'Available Space',
'singular_name' => 'Available Space',
'add_new' => 'Add new space',
'edit_item' => 'Edit space',
'new_item' => 'New space',
'view_item' => 'View space',
'search_items' => 'Search space',
'not_found' => 'No space found',
'not_found_in_trash' => 'No space found in Trash'
),
'show_ui' => true,
'public' => true,
'menu_position' => 5,
'taxonomies' => array('category', 'post_tag'), // this is IMPORTANT
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'post-formats'
)
));
}
//available leasing space custom post type end
//add custom post types to the category queries
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = get_post_types();
$query->set( 'post_type', $post_types );
return $query;
}
}
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' );
//add custom post types to the category queries end
//remove wordpress stuff from admin menu
function annointed_admin_bar_remove() {
global $wp_admin_bar;
/* Remove their stuff */
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('new-content');
}
add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
//remove wordpress stuff from admin menu end
// hide administration page header logo and blavatar
function remove_admin_logo() {
echo '<style>#wp-admin-bar-wp-logo{ display: none; }
img.blavatar { display: none;}
#wpadminbar .quicklinks li div.blavatar {display:none;}
#wpadminbar .quicklinks li .blavatar {display:none;}
#wpadminbar #wp-admin-bar-new-content .ab-icon:before {display:none;}
#wpadminbar .quicklinks li .blavatar:before {display:none;}
</style>';
}
add_action('admin_head', 'remove_admin_logo');
// hide administration page header logo and blavatar end
//removing that stuff from the dashboard
function remove_dashboard_meta() {
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
}
add_action( 'admin_init', 'remove_dashboard_meta' );
//removing that stuff from the dashboard end
//more hides of the wordpress stuff
function b3m_login_logo_url_title() {
return 'MDIS Development by work.shop';
}
add_filter( 'login_headertitle', 'b3m_login_logo_url_title' );
function b3m_modify_footer_admin () {
echo '<span id="footer-thankyou">MDIS Development by <a href="http://www.workshop-mg.com" target="_blank">work.shop</a></span>';
}
add_filter('admin_footer_text', 'b3m_modify_footer_admin');
//more hides of the wordpress stuff end
//dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff -
//add custom widget within admin dashboard
// Function used in the action hook
function b3m_add_dashboard_widgets() {
wp_add_dashboard_widget('wp_dashboard_widget', 'Your Company MIS Details', 'b3m_theme_info');
}
// Function that outputs the contents of the dashboard widget
function b3m_theme_info() {
echo "
<ul>
<li><b>Logging In:</b></li>
<li>If you are a <b><i>Leasing Representative</i></b> or a <b><i>Corporate Admin</i></b> you will land here within the <b><i>Dashboard</i></b> at login.
This is to show you that in the left hand navigation is the linking to allow you to make changes
to the Available Leasing spaces and/or the content. If you are done within the backend you more than likely
want to go here next: <a href='../information-center/'>Information Center</a>.
</li>
</ul>
<hr>
<ul>
<li>GK Development Links:</li>
<li><a href='../information-center/'>Retail Client Homepage</a> <i>*Main Home for Retail Merchants</i></li>
<li><a href='../information-center/'>Leasing Rep Homepage</a> <i>*Main Home for Leasing Reps</i></li>
<li><a href='../information-center/'>Corporate Manager Homepage</a> <i>*Main Home for Corporate Manager</i></li>
</ul>
<hr>
";
}
// Register the new dashboard widget with the 'wp_dashboard_setup' action
add_action('wp_dashboard_setup', 'b3m_add_dashboard_widgets' );
//add custom widget within admin dashboard end
//end end //end end //end end //end end //end end //end end //end end
//Here is another example of a dashboard widget
// Function that outputs the contents of the dashboard widget
function dashboard_widget_function( $post, $callback_args ) {
echo "
<ul>
<li><strong>Your Corporate Site:</strong> <a href='http://workshop-mg.com' target='_blank'>www.workshop-mg.com</a></li>
<li><strong>Corporate Manager:</strong> <a href='mailto:michael@workshop-mg.com'>michael@workshop-mg.com</a></li>
<li><strong>Leasing Rep:</strong> <a href='mailto:support@workshop-mg.com'>support@workshop-mg.com</a></li>
</ul>
";
}
// Function used in the action hook
function add_dashboard_widgets() {
wp_add_dashboard_widget('dashboard_widget', 'Your Custom Contact Information', 'dashboard_widget_function');
}
// Register the new dashboard widget with the 'wp_dashboard_setup' action
add_action('wp_dashboard_setup', 'add_dashboard_widgets' );
//Here is another example of a dashboard widget - end
//end end //end end //end end //end end //end end //end end //end end
//Here is another example of a dashboard widget - This one goes to the top right
// Function that outputs the contents of the dashboard widget
function dashboard_widget_function_topright( $post, $callback_args ) {
echo "
<ul>
<li><strong>Website:</strong> <a href='http://workshop-mg.com' target='_blank'>www.workshop-mg.com</a></li>
<li><strong>Contact:</strong> <a href='mailto:michael@workshop-mg.com'>michael@workshop-mg.com</a></li>
<li><strong>Support:</strong> <a href='mailto:support@workshop-mg.com'>support@workshop-mg.com</a></li>
</ul>
";
}
// Function used in the action hook
function add_dashboard_widget_topright() {
//wp_add_dashboard_widget('dashboard_widget', 'Contact work.shop', 'dashboard_widget_function');
add_meta_box('1', 'Contact work.shop', 'dashboard_widget_function_topright', 'dashboard', 'side', 'high');
}
// Register the new dashboard widget with the 'wp_dashboard_setup' action
add_action('wp_dashboard_setup', 'add_dashboard_widget_topright' );
//Here is another example of a dashboard widget - top right end
//end end //end end //end end //end end //end end //end end
//Here is another example of a dashboard widget - This one goes to the top right
// Function that outputs the contents of the dashboard widget
function dashboard_widget_function_botright( $post, $callback_args ) {
echo "
<img src='http://mis.workshop-mg.com/mdis-tour/wp-content/uploads/sites/5/2014/09/work.shop_.logo_.png' style='width:100%;' />
";
}
// Function used in the action hook
function add_dashboard_widget_botright() {
//wp_add_dashboard_widget('dashboard_widget', 'Contact work.shop', 'dashboard_widget_function');
add_meta_box('2', 'work.shop MIS v2.0.1', 'dashboard_widget_function_botright', 'dashboard', 'side', 'low');
}
// Register the new dashboard widget with the 'wp_dashboard_setup' action
add_action('wp_dashboard_setup', 'add_dashboard_widget_botright' );
//Here is another example of a dashboard widget - top right end
//end end //end end //end end //end end //end end //end end
//dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff - dashboard stuff -
//this if for level 4 only
if (current_user_is("s2member_level4")){
//remove menu items
function remove_menus(){
//remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
//remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
//remove_menu_page( 'themes.php' ); //Appearance
//remove_menu_page( 'plugins.php' ); //Plugins
//remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'edit.php?post_type=project' ); //Projects
//remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'remove_menus' );
// remove menu items end
} //level 4 only end
//this if for level 5 only
if (current_user_is("s2member_level5")){
//remove menu items
function remove_menus(){
//remove_menu_page( 'index.php' ); //Dashboard
//remove_menu_page( 'edit.php' ); //Posts
//remove_menu_page( 'upload.php' ); //Media
//remove_menu_page( 'edit.php?post_type=page' ); //Pages
//remove_menu_page( 'edit-comments.php' ); //Comments
//remove_menu_page( 'themes.php' ); //Appearance
//remove_menu_page( 'plugins.php' ); //Plugins
//remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'edit.php?post_type=project' ); //Projects
//remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'remove_menus' );
// remove menu items end
} //level 5 only end
//this if for level 6 only
if (current_user_is("s2member_level6")){
//remove menu items
function remove_menus(){
//remove_menu_page( 'index.php' ); //Dashboard
//remove_menu_page( 'edit.php' ); //Posts
//remove_menu_page( 'upload.php' ); //Media
//remove_menu_page( 'edit.php?post_type=page' ); //Pages
//remove_menu_page( 'edit-comments.php' ); //Comments
//remove_menu_page( 'themes.php' ); //Appearance
//remove_menu_page( 'plugins.php' ); //Plugins
//remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'edit.php?post_type=project' ); //Projects
//remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'remove_menus' );
// remove menu items end
} //level 6 only end
//This is for the user screens
//This is for the user screens
//this if for level 4 only
if (current_user_is("s2member_level4")){
class JPB_User_Caps {
// Add our filters
function JPB_User_Caps(){
add_filter( 'editable_roles', array(&$this, 'editable_roles'));
add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4);
}
// Remove 'editor' from the list of roles if the current user is not an admin
function editable_roles( $roles ){
if( isset( $roles['editor'] ) && !current_user_can('editor') ){
unset( $roles['editor']);
}
if( isset( $roles['author'] ) && !current_user_can('author') ){
unset( $roles['author']);
}
if( isset( $roles['contributor'] ) && !current_user_can('contributor') ){
unset( $roles['contributor']);
}
if( isset( $roles['s2member_level5'] ) && !current_user_can('s2member_level5') ){
unset( $roles['s2member_level5']);
}
if( isset( $roles['s2member_level6'] ) && !current_user_can('s2member_level6') ){
unset( $roles['s2member_level6']);
}
if( isset( $roles['s2member_level0'] ) && !current_user_can('s2member_level0') ){
unset( $roles['s2member_level0']);
}
return $roles;
}
// If someone is trying to edit or delete and admin and that user isn't an admin, don't allow it
function map_meta_cap( $caps, $cap, $user_id, $args ){
switch( $cap ){
case 'edit_user':
case 'remove_user':
case 'promote_user':
if( isset($args[0]) && $args[0] == $user_id )
break;
elseif( !isset($args[0]) )
$caps[] = 'do_not_allow';
$other = new WP_User( absint($args[0]) );
if( $other->has_cap( 'editor' ) ){
if(!current_user_can('editor')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level4' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level5' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level6' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
break;
case 'delete_user':
case 'delete_users':
if( !isset($args[0]) )
break;
$other = new WP_User( absint($args[0]) );
if( $other->has_cap( 'editor' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level4' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level5' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level6' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
break;
default:
break;
}
return $caps;
}
}
$jpb_user_caps = new JPB_User_Caps();
//the end of doing it for the editor
} //level 4 only end
//This is for the user screens
//This is for the user screens
//This is for the user screens
//This is for the user screens
//this if for level 4 only
if (current_user_is("s2member_level5")){
class JPB_User_Caps {
// Add our filters
function JPB_User_Caps(){
add_filter( 'editable_roles', array(&$this, 'editable_roles'));
add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4);
}
// Remove 'editor' from the list of roles if the current user is not an admin
function editable_roles( $roles ){
if( isset( $roles['editor'] ) && !current_user_can('editor') ){
unset( $roles['editor']);
}
return $roles;
}
// If someone is trying to edit or delete and admin and that user isn't an admin, don't allow it
function map_meta_cap( $caps, $cap, $user_id, $args ){
switch( $cap ){
case 'edit_user':
case 'remove_user':
case 'promote_user':
if( isset($args[0]) && $args[0] == $user_id )
break;
elseif( !isset($args[0]) )
$caps[] = 'do_not_allow';
$other = new WP_User( absint($args[0]) );
if( $other->has_cap( 'editor' ) ){
if(!current_user_can('editor')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level5' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level6' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
break;
case 'delete_user':
case 'delete_users':
if( !isset($args[0]) )
break;
$other = new WP_User( absint($args[0]) );
if( $other->has_cap( 'editor' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level5' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level6' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
break;
default:
break;
}
return $caps;
}
}
$jpb_user_caps = new JPB_User_Caps();
//the end of doing it for the editor
} //level 4 only end
//This is for the user screens
//This is for the user screens
//This is for the user screens
//This is for the user screens
//this if for level 4 only
if (current_user_is("s2member_level6")){
class JPB_User_Caps {
// Add our filters
function JPB_User_Caps(){
add_filter( 'editable_roles', array(&$this, 'editable_roles'));
add_filter( 'map_meta_cap', array(&$this, 'map_meta_cap'),10,4);
}
// Remove 'editor' from the list of roles if the current user is not an admin
function editable_roles( $roles ){
if( isset( $roles['editor'] ) && !current_user_can('editor') ){
unset( $roles['editor']);
}
return $roles;
}
// If someone is trying to edit or delete and admin and that user isn't an admin, don't allow it
function map_meta_cap( $caps, $cap, $user_id, $args ){
switch( $cap ){
case 'edit_user':
case 'remove_user':
case 'promote_user':
if( isset($args[0]) && $args[0] == $user_id )
break;
elseif( !isset($args[0]) )
$caps[] = 'do_not_allow';
$other = new WP_User( absint($args[0]) );
if( $other->has_cap( 'editor' ) ){
if(!current_user_can('editor')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level6' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
break;
case 'delete_user':
case 'delete_users':
if( !isset($args[0]) )
break;
$other = new WP_User( absint($args[0]) );
if( $other->has_cap( 'editor' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
if( $other->has_cap( 's2member_level6' ) ){
if(!current_user_can('administrator')){
$caps[] = 'do_not_allow';
}
}
break;
default:
break;
}
return $caps;
}
}
$jpb_user_caps = new JPB_User_Caps();
//the end of doing it for the editor
} //level 4 only end
//This is for the user screens
//This is for the user screens
//This sets the admin dashboard color set - (For New Users)
function set_default_admin_color($user_id) {
$args = array(
'ID' => $user_id,
'admin_color' => 'light');
wp_update_user( $args );
}
add_action('user_register', 'set_default_admin_color');
//This sets the admin dashboard color set
?>