Guest User

Untitled

a guest
Nov 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. function calendar_menu()
  2. {
  3. global $wpdb;
  4.  
  5. // Set admin as the only one who can use Calendar for security
  6. $allowed_group = 'manage_options';
  7.  
  8. // Use the database to *potentially* override the above if allowed
  9. $configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='can_manage_events'");
  10. if (!empty($configs))
  11. {
  12. foreach ($configs as $config)
  13. {
  14. $allowed_group = $config->config_value;
  15. }
  16. }
  17.  
  18. // Add the admin panel pages for Calendar. Use permissions pulled from above
  19. if (function_exists('add_menu_page') && !current_user_can('manage_options'))
  20. {
  21. add_menu_page(__('Calendar','calendar'), __('Calendar','calendar'), $allowed_group, 'calendar', 'edit_calendar');
  22. }
  23. if (function_exists('add_submenu_page') && !current_user_can('manage_options'))
  24. {
  25. add_submenu_page('calendar', __('Manage Calendar','calendar'), __('Manage Calendar','calendar'), $allowed_group, 'calendar', 'edit_calendar');
  26. add_action( "admin_head", 'calendar_add_javascript' );
  27. // Note only admin can change calendar options
  28. add_submenu_page('calendar', __('Manage Categories','calendar'), __('Manage Categories','calendar'), 'manage_options', 'calendar-categories', 'manage_categories');
  29. add_submenu_page('calendar', __('Calendar Config','calendar'), __('Calendar Options','calendar'), 'manage_options', 'calendar-config', 'edit_calendar_config');
  30. }
  31. }
Add Comment
Please, Sign In to add comment