'; $sup_close = ''; }else{ $sup_open = ''; $sup_close = ''; } // Check for starting number $start_number = 0; if($sn_open = strpos($data, "'); $sn_length = $sn_close - $sn_open - 13; $start_number = (int) substr($data, $sn_open + 13, $sn_length); $start_number--; } // Create the footnotes $counter = $start_number; while($footnote_start = strpos($data, $footnote_open)) { $counter++; $footnote_end = strpos($data, $footnote_close); $footnote_true_end = $footnote_end + $footnote_close_len; $before = substr($data, 0, $footnote_start); $after = substr($data, $footnote_true_end); $footnote_length = $footnote_end - ($footnote_start + $footnote_open_len); $footnote_text = substr($data, $footnote_start + $footnote_open_len, $footnote_length); if (substr($footnote_text,0,4) == 'ref:'){ $ref = substr($footnote_text,4); $data = $before.$sup_open.$current_settings['pre_link'].''.swas_counter_symbol($ref).''.$current_settings['post_link'].$sup_close.$after; $counter--; }else { $footnotes[] = $footnote_text; $data = $before.$sup_open.$current_settings['pre_link'].''.swas_counter_symbol($counter).''.$current_settings['post_link'].$sup_close.$after; } } // A little bit of legacy support if ($current_settings['legacy']){ $tag = "footnote"; $taglength = strlen($tag); while($footnote_start = strpos($data, "<".$tag.">")) { $counter++; $footnote_end = strpos($data, ""); $footnote_true_end = $footnote_end + $taglenth + 3 + $taglength; $before = substr($data, 0, $footnote_start); $after = substr($data, $footnote_true_end); $footnote_length = $footnote_end - ($footnote_start+2+$taglength); $footnote_text = substr($data, $footnote_start+2+$taglength, $footnote_length); if (substr($footnote_text,0,4) == 'ref:'){ $ref = substr($footnote_text,4); $data = $before.$sup_open.$current_settings['pre_link'].''.swas_counter_symbol($ref).''.$current_settings['post_link'].$sup_close.$after; $counter--; }else { $footnotes[] = $footnote_text; $data = $before.$sup_open.$current_settings['pre_link'].''.swas_counter_symbol($counter).''.$current_settings['post_link'].$sup_close.$after; } } } if ($footnotes){ $counter = $start_number; if ($current_settings['use_symbols']) $ol_style = ' style="list-style-type: none; padding-left: 0;"'; else $ol_style = ''; if ($start_number != 0) $data = $data.'
'; else $data = $data.'
'; foreach($footnotes as $footnote){ $counter++; if ($current_settings['use_symbols']) $marker = swas_counter_symbol($counter) . ' '; else $marker = ''; $data = $data.'
  • '.$marker.$footnote.' '.$current_settings['pre_backlink'].''.$current_settings['backlink'].''.$current_settings['post_backlink'].'
  • '; } $data = $data.''; } return $data; } // Create the options page function swas_footnotes_options_page() { $current_settings = get_option('swas_footnote_options'); if ($_POST['action']){?>

    Options saved.

    Footnotes Options

    There are a few options you can set for displaying your footnotes using this Footnotes plugin.

    You can use any HTML entity for the back link. One that is quite popular is &#8617; (↩). But more importantly this feature allows the footnotes to be addapted for other languages.

    ">
    Options:
    />
    />
    />

    Upgrade

    ',$footnote_open,$data); $data = str_replace('',$footnote_close,$data); return $data; } $current_settings = get_option('swas_footnote_options'); add_filter('the_content', 'swas_footnote'); add_action('admin_menu', 'swas_add_options'); // Insert the Admin panel. if ($current_settings['legacy']) add_filter('content_edit_pre','swas_upgrade_post'); if (!get_option('swas_footnote_options')){ // create default options $footnotes_options['superscript'] = true; $footnotes_options['legacy'] = true; $footnotes_options['pre_backlink'] = '['; $footnotes_options['backlink'] = 'back'; $footnotes_options['post_backlink'] = ']'; $footnotes_options['pre_link'] = ''; $footnotes_options['post_link'] = ''; $footnotes_options['use_symbols'] = false; $footnotes_options['symbols'] = '*†‡§¶#'; update_option('swas_footnote_options', $footnotes_options); } if ($_POST['action'] == 'save_options'){ swas_save_options(); } ?>