Example #1
0
function wlcmsImport()
{
    if ($_FILES['wlcms_import']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['wlcms_import']['tmp_name'])) {
        $import = file_get_contents($_FILES['wlcms_import']['tmp_name']);
        // Clean up the serialise data first
        $import = str_replace("\r\n", "\n", $import);
        $import = str_replace("\r", "\n", $import);
        $import = unserialize($import);
        if (!is_array($import)) {
            // Not an array some how? Rather than pressing on, just return.
            header("Location: admin.php?page=wlcms-plugin.php&import=false&error=noArray");
        }
        // Reset all WLCMS settings;
        wlcmsReset(true);
        $site_url = get_bloginfo('url');
        foreach ($import as $name => $value) {
            // If the value includes this shortcode, replace it.
            $val = str_replace('{SITEURL}', $site_url, $value);
            // Check that our option key starts with WLCMS
            if (strpos($name, 'wlcms_o') === 0) {
                add_option($name, $val);
            } else {
                wp_die(__('<strong>Error!</strong> During the import process we almost imported a non White Label CMS setting - please ensure you uploaded the correct file and try again.'));
            }
        }
        header("Location: admin.php?page=wlcms-plugin.php&import=true");
        exit;
    }
    header("Location: admin.php?page=wlcms-plugin.php&import=false");
    die;
}
function wlcmsImport()
{
    if ($_FILES['wlcms_import']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['wlcms_import']['tmp_name'])) {
        $import = file_get_contents($_FILES['wlcms_import']['tmp_name']);
        $import = unserialize($import);
        if (!is_array($import)) {
            // Not an array some how? Rather than pressing on, just return.
            header("Location: admin.php?page=wlcms-plugin.php&import=false&error=noArray");
        }
        // Reset all WLCMS settings;
        wlcmsReset(true);
        $site_url = get_bloginfo('url');
        foreach ($import as $name => $value) {
            $val = str_replace('{SITEURL}', $site_url, $value);
            add_option($name, $val);
            // Add in new option
        }
        header("Location: admin.php?page=wlcms-plugin.php&import=true");
        exit;
    }
    header("Location: admin.php?page=wlcms-plugin.php&import=false");
    die;
}