Created
March 19, 2012 16:24
-
-
Save sloped/2117989 to your computer and use it in GitHub Desktop.
Edit Wordpress Dashboard and Admin Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function admin_bar_edit() { | |
global $wp_admin_bar; | |
$wp_admin_bar->remove_menu('comments'); | |
$wp_admin_bar->remove_menu('wp-logo'); | |
$wp_admin_bar->remove_menu('new-content'); | |
global $current_user; | |
get_currentuserinfo(); | |
$args = array( 'author' => $current_user->ID, 'post_type' => 'food_trucks', 'posts_per_page' => -1); | |
query_posts( $args ); | |
global $wp_query; | |
//print_r($wp_query->posts) | |
if(count($wp_query->posts) > 3) { | |
$wp_admin_bar->add_menu( array( | |
'parent' => false, // use 'false' for a root menu, or pass the ID of the parent menu | |
'id' => 'food_trucks', // link ID, defaults to a sanitized title value | |
'title' => __('Edit Food Truck(s)'), // link title | |
'href' => admin_url( 'edit.php?post_type=food_trucks'), // name of file | |
'meta' => false | |
)); | |
while ( have_posts() ) : the_post(); | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'food_trucks', // use 'false' for a root menu, or pass the ID of the parent menu | |
'id' => 'food_truck_' . get_the_id(), // link ID, defaults to a sanitized title value | |
'title' => __(get_the_title()), // link title | |
'href' => get_edit_post_link(), // name of file | |
'meta' => false | |
)); | |
endwhile; | |
} | |
else { | |
while ( have_posts() ) : the_post(); | |
$wp_admin_bar->add_menu( array( | |
'parent' => false, // use 'false' for a root menu, or pass the ID of the parent menu | |
'id' => 'food_truck_' . get_the_id(), // link ID, defaults to a sanitized title value | |
'title' => __('Edit ' . get_the_title()), // link title | |
'href' => get_edit_post_link(), // name of file | |
'meta' => false | |
)); | |
endwhile; | |
} | |
} | |
function dashboard_footer_version() { | |
echo '<p class="alignright">© MSP Street Food</p>'; | |
} | |
function dashboard_footer() { | |
echo '<span>For questions, contact Conner McCall. | email: <a href="mailto:[email protected]">[email protected]</a> | phone: 612-326-4230</span>'; | |
} | |
function admin_favicon() { | |
echo '<link rel="icon" href="' . get_bloginfo('template_url') . '/images/admin-favicon.png" type="image/png" />'; | |
} | |
function add_featured_image_instruction( $content ) { | |
return $content .= '<p>The featured image will be included on your truck\'s page. Please click the above link, upload your image, and then click, "Use As Featured Image" in the window that appears. The button titled "Insert Into Post" will not work. </p>'; | |
} | |
function add_dashboard_widgets() { | |
global $dashboard_truck; | |
// wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback ); | |
wp_enqueue_script('dashboard_js'); | |
wp_add_dashboard_widget('quick_view', 'Quick View', 'db_quick_view'); | |
wp_add_dashboard_widget('truck_news', 'News', 'db_truck_news'); | |
wp_add_dashboard_widget('truck_locations', 'Locations', 'db_truck_locations'); | |
wp_add_dashboard_widget('mobile_info', 'Mobile Access', 'db_mobile_info'); | |
global $wp_meta_boxes; | |
$my_widget = $wp_meta_boxes['dashboard']['normal']['core']['truck_locations']; | |
unset($wp_meta_boxes['dashboard']['normal']['core']['truck_locations']); | |
$wp_meta_boxes['dashboard']['side']['core']['truck_locations'] = $my_widget; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment