$tagLines"; $error = TRUE; } else { if ($_POST['import_type'] == 'replace') { $advtag_tags = array(); } foreach ($tagLines as $tagLine) { $advtag_tags[] = $tagLine; } update_option(ADVTAG_TAGPAIRS, $advtag_tags); $message.=__('Import successful.', 'advtag'); } } } include("Settings.php"); $script = "\n"; print($script); } function advtag_parse_csv($fileName) { $results = array(); $handle = fopen($fileName, "r"); while (($data = fgetcsv($handle, 4096)) !== FALSE) { //skip blank lines, which return an array comprising a single null field if (count($data) > 0 && $data[0] == null) { continue; } //error: invalid format (two cols per row only) if (count($data) != 2) { return "Invalid format (2 columns expected, found ".count($data).")."; } $results[] = $data; } fclose($handle); return $results; } function prepare_for_input($value) { return str_replace('"', '"', $value); } function advtag_update_option($key, $value) { if( get_magic_quotes_gpc() ) { $value = stripslashes($value); } update_option($key, $value); } function advtag_admin_menu() { if (function_exists('add_options_page')) { add_options_page('Advanced Tagline', 'Advanced Tagline', 8, basename(__FILE__), 'advtag_options_page'); } } function advtag_next_tagline() { global $advtag_type; global $advtag_tags; //i haven't figured out why yet (not much looking) but the header file is parsed when the //.css is imported so skip that if ($advtag_type == "sequential" && !preg_match("/\.css$/", $_SERVER['HTTP_REFERER'])) { $idx = $_COOKIE["advtag_idx"] + 1; if ($idx >= count($advtag_tags)) { $idx = 0; } setcookie("advtag_idx", $idx, 0, "/"); } } function advtag_get_tagline() { global $advtag_tags; global $advtag_type; $idx = 0; if ($advtag_type == "sequential") { $idx = $_COOKIE["advtag_idx"]; } else { $idx = mt_rand(0, count($advtag_tags) - 1); } echo ''.stripslashes($advtag_tags[$idx][0]).''; } function advtag_script() { $path = get_option('siteurl')."/wp-content/plugins/advanced-tagline/"; $html.= "\n"; $html.= "\n"; $html.= "\n"; $html.= "\n"; $html.=" "; print($html); } add_action('admin_menu', 'advtag_admin_menu'); add_action('admin_head', 'advtag_script'); ?>