Use this functions code to add Jobs list (w/ count) link to top Admin bar!
-
I got tired of going to the dashboard to get to the Pending Jobs in admin so I made this to add it to the top Admin bar. I wanted to share, you’ll find it a time saver! Let me know if I did anything wrong, I followed the best practices I believe.
Paste this in your themes child functions.php file:
add_action( 'admin_bar_menu', 'admin_bar_item', 500 ); function admin_bar_item ( WP_Admin_Bar $admin_bar ) { if ( ! current_user_can( 'manage_options' ) ) { return; } $pending_jobs_count = WP_Job_Manager_Cache_Helper::get_listings_count(); $admin_bar->add_menu( array( 'id' => 'menu-id', 'parent' => null, 'group' => null, 'title' => '✓ Jobs <span style="display: inline; padding: 1px 7px 1px 6px!important; border-radius: 50%; color: #fff; background-color: #d54e21;">'.esc_attr( $pending_jobs_count ).'</span>', 'href' => admin_url('edit.php?post_type=job_listing'), 'meta' => [ 'title' => __( 'View Jobs as Admin', 'textdomain' ), //This title will show on hover ] ) ); }
enjoy
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Use this functions code to add Jobs list (w/ count) link to top Admin bar!’ is closed to new replies.