function direct_bootstrap() { global $k2sbm_registered_modules, $k2sbm_registered_sidebars, $k2sbm_active_modules, $k2sbm_disabled_modules, $k2sbm_error_text; // You MUST be an admin to access this stuff auth_redirect(); K2SBM::pre_bootstrap(); // Check for specific actions that return a HTML response if ($_POST['action'] == 'control-show') { if (isset($_POST['module_id'])) { $all_modules = K2SBM::get_all_modules(); $all_modules[$_POST['module_id']]->displayControl(); } else { echo false; } } elseif ($_POST['action'] == 'control-post-list-show') { if (isset($_POST['module_id'])) { $all_modules = K2SBM::get_all_modules(); $all_modules[$_POST['module_id']]->displayPostList(); } else { echo false; } } elseif ($_POST['action'] == 'control-page-list-show') { if (isset($_POST['module_id'])) { $all_modules = K2SBM::get_all_modules(); $all_modules[$_POST['module_id']]->displayPageList(); } else { echo false; } } elseif ($_POST['action'] == 'backup') { header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=sbm-' . date('Y-m-d') . '.dat'); header('Content-Type: text/plain; charset=' . get_option('blog_charset'), true); echo serialize(array('sbm_version' => SBM_VERSION, 'active_modules' => $k2sbm_active_modules, 'disabled_modules' => $k2sbm_disabled_modules, 'id' => get_option('k2sbm_modules_next_id'))); } else { // Set the output type header('Content-type: text/plain; charset: UTF-8'); // Check what the action is switch ($_POST['action']) { // Add a module to the sidebar case 'add': // Check the title was correct if (isset($_POST['add_name']) and trim((string) $_POST['add_name']) != '') { K2SBM::add_module(stripslashes($_POST['add_name']), $_POST['add_type'], $_POST['add_sidebar']); } else { K2SBM::set_error_text(__('You must specify a valid module name', 'k2_domain')); } break; // Update a module // Update a module case 'update': if (isset($_POST['sidebar_id']) and isset($_POST['module_id'])) { K2SBM::update_module($_POST['sidebar_id'], $_POST['module_id']); } else { K2SBM::set_error_text(__('Missing sidebar and module ids', 'k2_domain')); } break; // Remove a module from the sidebar // Remove a module from the sidebar case 'remove': if (isset($_POST['sidebar_id']) and isset($_POST['module_id'])) { K2SBM::remove_module($_POST['sidebar_id'], $_POST['module_id']); } else { K2SBM::set_error_text(__('Missing sidebar and module ids', 'k2_domain')); } break; // Re-order the modules in the sidebar // Re-order the modules in the sidebar case 'reorder': if (isset($_POST['sidebar_ordering'])) { K2SBM::reorder_sidebar($_POST['sidebar_ordering']); } else { K2SBM::set_error_text(__('Missing ordering data', 'k2_domain')); } break; // Error // Error default: K2SBM::set_error_text(__('Invalid call', 'k2_domain')); break; } // Begin the JSON response echo '{result: '; if ($k2sbm_error_text != null) { echo 'false, error: "' . $k2sbm_error_text . '"'; } else { echo 'true'; } // End the response echo '}'; // Safeguard wp_cache_flush(); } }