$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_get_export() {
$advtag_tags = get_option(advtag_tags);
$output = '';
switch($_POST['export_type']) {
case 'csv':
foreach ($advtag_tags as $tagset) {
$output .= '"'.stripslashes($tagset[0]).'","'.stripslashes($tagset[1]).'","'.stripslashes($tagset[2]).'"'."\n";
}
break;
}
return $output;
}
*/
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; }
if (count($data) == 1) {
$results[] = array($data[0], '', '');
}
else if (count($data) == 2) {
$results[] = array($data[0], $data[1], '');
}
else if (count($data) == 3) {
$results[] = $data;
} else {
//error: invalid format
return "Invalid format (1-3 columns expected, found ".count($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($echo = TRUE) {
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);
}
if (empty($idx)) { $idx = 0; }
$text = stripslashes($advtag_tags[$idx][0]);
$link = stripslashes($advtag_tags[$idx][1]);
$target = stripslashes($advtag_tags[$idx][2]);
if (!empty($link)) {
$t = '';
if (!empty($target)) { $t = ' target="'.$target.'"'; }
$output = ''.$text.'';
} else {
$output = $text;
}
if ($echo) {
echo $output;
} else {
return $output;
}
}
function advtag_script() {
$path = get_option('siteurl')."/wp-content/plugins/advanced-tagline/";
$html.= "\n";
$html.= "\n";
$html.= "\n";
$html.= "\n";
$html.="
";
print($html);
}
function advtag_replace_tagline($info, $show) {
if ($show == 'description') {
$info = advtag_get_tagline(false);
}
return $info;
}
add_action('admin_menu', 'advtag_admin_menu');
add_action('admin_head', 'advtag_script');
add_action('get_header', 'advtag_next_tagline');
add_filter('bloginfo','advtag_replace_tagline',10,2);
?>