function cap_add_admin() { global $themename, $req_cap_to_edit, $cap_menu_position, $cap_icon_url; if (!current_user_can($req_cap_to_edit)) { return; } if (isset($_GET['page']) && $_GET['page'] == basename(__FILE__)) { $options = cap_get_options(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $method = false; $done = false; $data = new ImportData(); switch ($action) { case 'save': $method = 'Update'; break; case 'Reset': $method = 'Reset'; break; } if ($method) { foreach ($options as $group) { foreach ($group->options as $option) { call_user_func(array($option, $method), $data); } } if ($done) { call_user_func($done, $data); } } } $pgName = "{$themename} Settings"; $hook = add_theme_page($pgName, $pgName, isset($req_cap_to_edit) ? $req_cap_to_edit : 'manage_options', basename(__FILE__), 'top_level_settings', isset($cap_icon_url) ? $cap_icon_url : $default, isset($cap_menu_position) ? $cap_menu_position : $default); add_action("admin_print_scripts-{$hook}", 'cap_admin_js_libs'); add_action("admin_footer-{$hook}", 'cap_admin_js_footer'); add_action("admin_print_styles-{$hook}", 'cap_admin_css'); }
function init() { if ($this->data) { return; } $this->data = array(); $options = cap_get_options(); foreach ($options as $group) { foreach ($group->options as $option) { $this->data[$option->_key] = $option; } } }
function show_page_for_user() { global $req_cap_to_edit; if (current_user_can('switch_themes')) { $req_cap_to_edit = 'switch_themes'; return TRUE; } $cap = new autoconfig(); $have_theme_settins_tab = FALSE; $groups = cap_get_options(); foreach ($groups as $group) { $role_section = substr($group->id, 4) . "_min_role"; if (current_user_can(strtolower($cap->{$role_section}))) { $have_theme_settins_tab = TRUE; } } if (!$have_theme_settins_tab) { $req_cap_to_edit = 'switch_themes'; } unset($cap); }