function install()
{
require_once dirname(__FILE__) . '/../magic-fields/RCCWP_CustomWritePanel.php';
// Create default write pages
$existing_write_panels = array();
foreach (RCCWP_CustomWritePanel::GetCustomWritePanels() as $panel) {
array_push($existing_write_panels, $panel->name);
}
$panels_dir_name = dirname(__FILE__) . '/panels/';
$panels_dir = opendir($panels_dir_name);
$panels = array();
while (false !== ($panel_file = readdir($panels_dir))) {
$panel_name = basename($panel_file, ".pnl");
if (!is_dir($panel_file) && $panel_name && $panel_name != $panel_file && !in_array($panel_name, $existing_write_panels)) {
// If this file isn't a directory, ends with .pnl, and isn't already an existing panel, create and store it for import.
// $panel_id = RCCWP_CustomWritePanel::Create($panel_name, '', array(), array(), 1, "post", false);
RCCWP_CustomWritePanel::Import($panels_dir_name . $panel_file);
$panels[$panel_name] = $panel_file;
}
}
foreach ($panels as $panel_name => $panel_file) {
RCCWP_CustomWritePanel::Import($panels_dir_name . $panel_file, $panel_name, true);
}
}