function pagelines_import_export() { if (isset($_GET['download']) && $_GET['download'] == 'settings') { header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); header("Content-Type: text/plain"); header('Content-Disposition: attachment; filename="PageLines-' . THEMENAME . '-Settings-' . date("Ymd") . '.dat"'); $pagelines_settings = get_option(PAGELINES_SETTINGS); $pagelines_template = get_option('pagelines_template_map'); echo serialize(array('pagelines_settings' => $pagelines_settings, 'pagelines_template' => $pagelines_template)); exit; } if (isset($_POST['settings_upload']) && $_POST['settings_upload'] == 'settings') { if (strpos($_FILES['file']['name'], 'Settings') === false) { wp_redirect(admin_url('admin.php?page=pagelines&pageaction=import&error=wrongfile')); } elseif ($_FILES['file']['error'] > 0) { wp_redirect(admin_url('admin.php?page=pagelines&pageaction=import&error=file')); } else { $raw_options = file_get_contents($_FILES['file']['tmp_name']); $all_options = unserialize($raw_options); if (isset($all_options['pagelines_settings']) && isset($all_options['pagelines_template'])) { $pagelines_settings = $all_options['pagelines_settings']; $pagelines_template = $all_options['pagelines_template']; if (is_array($pagelines_settings)) { update_option(PAGELINES_SETTINGS, $pagelines_settings); } if (is_array($pagelines_template)) { update_option('pagelines_template_map', $pagelines_template); } } if (function_exists('wp_cache_clean_cache')) { global $file_prefix; wp_cache_clean_cache($file_prefix); } pagelines_build_dynamic_css(); wp_redirect(admin_url('admin.php?page=pagelines&pageaction=import&imported=true')); } } }
function pagelines_register_settings() { register_setting(PAGELINES_SETTINGS, PAGELINES_SETTINGS, 'pagelines_settings_callback'); /* Set default settings */ add_option(PAGELINES_SETTINGS, pagelines_settings_defaults()); // only fires first time pagelines_wp_option_defaults(); // Add stand alone wp options, only fires first time if (!isset($_REQUEST['page']) || $_REQUEST['page'] != 'pagelines') { return; } /* Typography Options */ $GLOBALS['pl_foundry'] = new PageLinesFoundry(); /* Import/Exporting */ pagelines_import_export(); pagelines_process_reset_options(); /* Regenerate Dynamic CSS ? */ $new_version_regen = !get_option("pl_dynamic_version") || get_option("pl_dynamic_version") != CORE_VERSION ? true : false; if (isset($_GET['activated']) || isset($_GET['updated']) || isset($_GET['reset']) || isset($_GET['settings-updated']) || $new_version_regen) { pagelines_build_dynamic_css('Page Load'); if (get_pagelines_option('lp_username') && get_pagelines_option('lp_password')) { if ($update = get_transient('pagelines-update-' . THEMENAME)) { $update = maybe_unserialize($update); if ($update['package'] == 'bad') { delete_transient('pagelines-update-' . THEMENAME); } delete_transient('pagelines-update-' . CHILDTHEMENAME); } } if ($new_version_regen) { update_option("pl_dynamic_version", CORE_VERSION); } } if (pagelines_option('reset')) { update_option(PAGELINES_SETTINGS, pagelines_settings_defaults()); pagelines_wp_option_defaults(true); pagelines_build_dynamic_css('Reset'); wp_redirect(admin_url('admin.php?page=pagelines&reset=true')); exit; } }
function pagelines_ajax_create_dynamic_css_callback() { global $wpdb; // this is how you get access to the database pagelines_build_dynamic_css( 'AJAX' ); die(); }
function pagelines_register_settings() { register_setting(PAGELINES_SETTINGS, PAGELINES_SETTINGS); /* Set default settings */ add_option(PAGELINES_SETTINGS, pagelines_settings_defaults()); // only fires first time pagelines_wp_option_defaults(); // Add stand alone wp options, only fires first time if (!isset($_REQUEST['page']) || $_REQUEST['page'] != 'pagelines') { return; } /* Import/Exporting */ pagelines_import_export(); pagelines_process_reset_options(); if (isset($_GET['activated']) || isset($_GET['updated']) || isset($_GET['reset'])) { pagelines_build_dynamic_css(); } if (pagelines_option('reset')) { update_option(PAGELINES_SETTINGS, pagelines_settings_defaults()); pagelines_wp_option_defaults(true); pagelines_build_dynamic_css(); wp_redirect(admin_url('admin.php?page=pagelines&reset=true')); exit; } }