Skip to:
Content

bbPress.org

Changeset 1575


Ignore:
Timestamp:
07/02/2008 02:53:07 PM (13 years ago)
Author:
sambauers
Message:

bb_uri() and bb_get_uri() commit bomb.

BB_URI_CONTEXT_* definitions applied to all link creation functions and passed to their filters.

First stages of SSL support for user forms (login, registration, etc.) and admin area.

Links rewritten for SSL at this stage, but pages are not yet forced to SSL if loaded as non-secure.

bb_force_ssl_user_forms() and bb_force_ssl_admin() also included.

Introducing new config constants, BB_FORCE_SSL_USER_FORMS and BB_FORCE_SSL_ADMIN.

New config variable $bb->uri_ssl, a complete URI for the SSL links to go to. If not set it is based on replacing http with https in $bb->uri.

Location:
trunk
Files:
55 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/admin-functions.php

    r1546 r1575  
    168168    endif;
    169169    if ( $bb_current_submenu && !bb_current_user_can( $bb_current_submenu[1] ) || !bb_current_user_can( $bb_current_menu[1] ) ) {
    170         wp_redirect( bb_get_option( 'uri' ) );
     170        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    171171        exit();
    172172    }
     
    644644    $r .= "\t\t\t<div class='alignright'>\n";
    645645    if ( bb_current_user_can( 'manage_forums' ) )
    646         $r .= "\t\t\t\t<a class='edit' href='" . attribute_escape( bb_get_option('uri') . "bb-admin/content-forums.php?action=edit&id=$_forum->forum_id" ) . "'>" . __('Edit') . "</a>\n";
     646        $r .= "\t\t\t\t<a class='edit' href='" . attribute_escape( bb_get_uri('bb-admin/content-forums.php', array('action' => 'edit', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ) . "'>" . __('Edit') . "</a>\n";
    647647    if ( bb_current_user_can( 'delete_forum', $_forum->forum_id ) && 1 < $forums_count )
    648         $r .= "\t\t\t\t<a class='delete' href='" . attribute_escape( bb_get_option('uri') . "bb-admin/content-forums.php?action=delete&id=$_forum->forum_id" ) . "'>" . __('Delete') . "</a>\n";
     648        $r .= "\t\t\t\t<a class='delete' href='" . attribute_escape( bb_get_uri('bb-admin/content-forums.php', array('action' => 'delete', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ) . "'>" . __('Delete') . "</a>\n";
    649649    $r .= "\t\t\t</div>\n";
    650650    $r .= "\t\t\t" . get_forum_name( $_forum->forum_id ) . ' &#8212; ' . get_forum_description( $_forum->forum_id ) . "\n\t\t</div>\n";
     
    663663    $action = $forum_id ? 'update' : 'add';
    664664?>
    665 <form method="post" id="<?php echo $action; ?>-forum" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php">
     665<form method="post" id="<?php echo $action; ?>-forum" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    666666    <fieldset>
    667667    <table><col /><col style="width: 80%" />
  • trunk/bb-admin/admin-header.php

    r1367 r1575  
    44    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    55    <title><?php bb_admin_title() ?></title>
    6     <link rel="stylesheet" href="<?php bb_option('uri'); ?>bb-admin/style.css" type="text/css" />
     6    <link rel="stylesheet" href="<?php bb_uri('bb-admin/style.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_ADMIN); ?>" type="text/css" />
    77<?php if ( 'rtl' == bb_get_option( 'text_direction' ) ) : ?>
    8     <link rel="stylesheet" href="<?php bb_option('uri'); ?>bb-admin/style-rtl.css" type="text/css" />
     8    <link rel="stylesheet" href="<?php bb_uri('bb-admin/style-rtl.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_ADMIN); ?>" type="text/css" />
    99<?php endif; do_action('bb_admin_print_scripts'); do_action( 'bb_admin_head' ); ?>
    1010</head>
     
    1818                </h1>
    1919                <div id="bbVisitSite">
    20                     <a href="<?php bb_option('uri'); ?>"><span><?php _e('Visit Site'); ?></span></a>
     20                    <a href="<?php bb_uri(); ?>"><span><?php _e('Visit Site'); ?></span></a>
    2121                </div>
    2222            </div>
     
    2525                    <?php printf( __('Howdy, %1$s!'), bb_get_profile_link( array( 'text' => bb_get_current_user_info( 'name' ) ) ) );?>
    2626                    | <?php bb_logout_link(); ?>
    27                     | <a href="http://bbpress.org/forums/">Forums</a>
     27                    | <a href="http://bbpress.org/forums/">Support forums</a>
    2828                </p>
    2929            </div>
  • trunk/bb-admin/bb-forum.php

    r1285 r1575  
    66
    77if ( !isset($_POST['action']) )
    8     wp_redirect( bb_get_option( 'uri' ) . 'bb-admin/content-forums.php' );
     8    wp_redirect( bb_get_uri('bb-admin/content-forums.php', null, BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_ADMIN) );
    99
    1010$sent_from = wp_get_referer();
  • trunk/bb-admin/class-install.php

    r1574 r1575  
    503503                    // The database needs upgrading
    504504                    $this->strings[-1]['messages'][0][] = __('bbPress is already installed, but appears to require an upgrade.');
    505                     $this->strings[-1]['messages'][0][] = sprintf(__('Perhaps you meant to run the <a href="%s">upgrade script</a> instead?'), bb_get_option('uri') . 'bb-admin/upgrade.php');
     505                    $this->strings[-1]['messages'][0][] = sprintf(
     506                        __('Perhaps you meant to run the <a href="%s">upgrade script</a> instead?'),
     507                        bb_get_uri('bb-admin/upgrade.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN)
     508                    );
    506509                    $this->step = -1;
    507510                } else {
    508511                    // Redirect to the base url
    509                     bb_safe_redirect(bb_get_option('uri'));
     512                    bb_safe_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
    510513                    die();
    511514                }
     
    18811884            $keymaster_email_message = sprintf(
    18821885                __("Your new bbPress site has been successfully set up at:\n\n%1\$s\n\nYou can log in to the key master account with the following information:\n\nUsername: %2\$s\nPassword: %3\$s\n\nWe hope you enjoy your new forums. Thanks!\n\n--The bbPress Team\nhttp://bbpress.org/"),
    1883                 bb_get_option( 'uri' ),
     1886                bb_get_uri(null, null, BB_URI_CONTEXT_TEXT),
    18841887                $data3['keymaster_user_login']['value'],
    18851888                $data4['keymaster_user_password']['value']
  • trunk/bb-admin/content-forums.php

    r1385 r1575  
    1818        break;
    1919    case 'deleted' :
    20         bb_admin_notice( sprintf(__('Forum deleted.  You should have bbPress <a href="%s">recount your site information</a>.'), bb_get_option( 'uri' ) . 'bb-admin/site.php') );
     20        bb_admin_notice( sprintf(
     21            __('Forum deleted.  You should have bbPress <a href="%s">recount your site information</a>.'),
     22            bb_get_uri('bb-admin/site.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN)
     23        ) );
    2124        break;
    2225    endswitch;
     
    4548    </ul>
    4649
    47     <form method="post" id="delete-forums" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php">
     50    <form method="post" id="delete-forums" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    4851        <p>
    4952            <label for="move-topics-delete"><input type="radio" name="move_topics" id="move-topics-delete" value="delete" /> <?php _e('Delete all topics and posts in this forum. <em>This can never be undone.</em>'); ?></label><br />
     
    5861        <?php bb_nonce_field( 'delete-forums' ); ?>
    5962    </form>
    60     <form method="get" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php">
     63    <form method="get" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    6164        <p class="submit alignleft">
    6265            <input type="submit" value="<?php _e('&laquo; Go back'); ?>" tabindex="10" />
  • trunk/bb-admin/delete-post.php

    r1285 r1575  
    55
    66if ( !bb_current_user_can( 'delete_post', $post_id ) ) {
    7     wp_redirect( bb_get_option( 'uri' ) );
     7    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    88    exit();
    99}
  • trunk/bb-admin/delete-topic.php

    r728 r1575  
    55
    66if ( !bb_current_user_can( 'delete_topic', $topic_id ) ) {
    7     wp_redirect( bb_get_option( 'uri' ) );
     7    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    88    exit();
    99}
  • trunk/bb-admin/options-general.php

    r1504 r1575  
    4343<h2><?php _e('General Settings'); ?></h2>
    4444
    45 <form class="settings" method="post" action="<?php bb_option('uri'); ?>bb-admin/options-general.php">
     45<form class="settings" method="post" action="<?php bb_uri('bb-admin/options-general.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    4646    <fieldset>
    4747        <div>
  • trunk/bb-admin/options-wordpress.php

    r1507 r1575  
    6161</p>
    6262
    63 <form class="settings" method="post" action="<?php bb_option('uri'); ?>bb-admin/options-wordpress.php">
     63<form class="settings" method="post" action="<?php bb_uri('bb-admin/options-wordpress.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    6464    <fieldset>
    6565        <legend><?php _e('Cookies'); ?></legend>
     
    317317$wpRolesMap = bb_get_option('wp_roles_map');
    318318?>
    319 <form class="settings" method="post" action="<?php bb_option('uri'); ?>bb-admin/options-wordpress.php">
     319<form class="settings" method="post" action="<?php bb_uri('bb-admin/options-wordpress.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    320320    <fieldset>
    321321<?php
  • trunk/bb-admin/plugins.php

    r1299 r1575  
    143143        $href = attribute_escape(
    144144            bb_nonce_url(
    145                 add_query_arg(
     145                bb_get_uri(
     146                    'bb-admin/plugins.php',
    146147                    array(
    147148                        'action' => $action,
    148149                        'plugin' => urlencode($plugin)
    149150                    ),
    150                     bb_get_option( 'uri' ) . 'bb-admin/plugins.php'
     151                    BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN
    151152                ),
    152153                $action . '-plugin_' . $plugin
  • trunk/bb-admin/rewrite-rules.php

    r1045 r1575  
    55
    66if ( !bb_current_user_can('manage_options') ) {
    7     wp_redirect( bb_get_option( 'uri' ) );
     7    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    88    exit();
    99}
  • trunk/bb-admin/site.php

    r1325 r1575  
    1111pagination oddities.") ?></p>
    1212
    13 <form method="post" action="<?php bb_option('uri'); ?>bb-admin/bb-do-counts.php">
     13<form method="post" action="<?php bb_uri('bb-admin/bb-do-counts.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>">
    1414    <fieldset>
    1515        <legend><?php _e('Choose items to recalculate') ?></legend>
  • trunk/bb-admin/sticky.php

    r1287 r1575  
    1010
    1111if ( !bb_current_user_can( 'stick_topic', $topic_id ) ) {
    12     wp_redirect( bb_get_option( 'uri' ) );
     12    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    1313    exit();
    1414}
  • trunk/bb-admin/tag-destroy.php

    r1140 r1575  
    1616    printf(__("Rows deleted from tags table: %d <br />\n"), $destroyed['tags']);
    1717    printf(__("Rows deleted from tagged table: %d <br />\n"), $destroyed['tagged']);
    18     printf(__('<a href="%s">Home</a>'), bb_get_option( 'uri' ));
     18    printf(__('<a href="%s">Home</a>'), bb_get_uri());
    1919} else {
    2020   die(printf(__("Something odd happened when attempting to destroy that tag.<br />\n<a href=\"%s\">Try Again?</a>"), wp_get_referer()));
  • trunk/bb-admin/themes.php

    r1556 r1575  
    1111if ( isset($_GET['theme']) ) {
    1212    if ( !bb_current_user_can( 'manage_themes' ) ) {
    13         wp_redirect( bb_get_option( 'uri' ) );
     13        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    1414        exit;
    1515    }
     
    3131    }
    3232    do_action( 'bb_activate_theme_' . $theme );
    33     wp_redirect( bb_get_option( 'uri' ) . 'bb-admin/themes.php?activated&name=' . urlencode($name) );
     33    wp_redirect( bb_get_uri('bb-admin/themes.php', array('activated' => 1, 'name' => $name ), BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_ADMIN ) );
    3434    exit;
    3535}
     
    5353    $theme_data = file_exists( $theme_directory . 'style.css' ) ? bb_get_theme_data( $theme ) : false;
    5454    $screen_shot = file_exists( $theme_directory . 'screenshot.png' ) ? clean_url( bb_get_theme_uri( $theme ) . 'screenshot.png' ) : false;
    55     $activation_url = clean_url( bb_nonce_url( add_query_arg( 'theme', urlencode($theme), bb_get_option( 'uri' ) . 'bb-admin/themes.php' ), 'switch-theme' ) );
     55    $activation_url = bb_get_uri('bb-admin/themes.php', array('theme' => $theme), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     56    $activation_url = clean_url( bb_nonce_url( $activation_url, 'switch-theme' ) );
    5657?>
    5758    <li<?php alt_class( 'theme', $class ); ?>>
  • trunk/bb-admin/topic-move.php

    r1285 r1575  
    99
    1010if ( !bb_current_user_can( 'move_topic', $topic_id, $forum_id ) ) {
    11     wp_redirect( bb_get_option( 'uri' ) );
     11    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    1212    exit();
    1313}
  • trunk/bb-admin/topic-toggle.php

    r1285 r1575  
    99
    1010if ( !bb_current_user_can( 'close_topic', $topic_id ) ) {
    11     wp_redirect( bb_get_option( 'uri' ) );
     11    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    1212    exit();
    1313}
  • trunk/bb-admin/upgrade.php

    r1553 r1575  
    8080?>
    8181        <p class="last">
    82             <?php printf( __('Nothing to upgrade.  <a href="%s">Get back to work!</a>'), bb_get_option( 'uri' ) . 'bb-admin/' ); ?>
     82            <?php printf( __('Nothing to upgrade.  <a href="%s">Get back to work!</a>'), bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ); ?>
    8383        </p>
    8484<?php
     
    115115                    <span class="first">!</span> <?php _e('Your database has been successfully updated.<br />Enjoy!'); ?>
    116116                </p>
    117                 <form action="<?php bb_option('uri'); ?>bb-admin/" method="get">
     117                <form action="<?php bb_uri('bb-admin/', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" method="get">
    118118                    <label for="upgrade_log_container_toggle">
    119119                        <?php _e('Show upgrade log:'); ?>
  • trunk/bb-admin/view-ip.php

    r1299 r1575  
    33
    44if ( !bb_current_user_can('view_by_ip') ) {
    5     wp_redirect( bb_get_option( 'uri' ) );
     5    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    66    exit();
    77}
  • trunk/bb-edit.php

    r1339 r1575  
    99
    1010if ( !$bb_post ) {
    11     wp_redirect( bb_get_option( 'uri' ) );
     11    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    1212    die();
    1313}
     
    2929    wp_redirect( get_post_link( $post_id ) );
    3030else
    31     wp_redirect( bb_get_option( 'uri' ) );
     31    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    3232?>
  • trunk/bb-includes/default-filters.php

    r1535 r1575  
    7575    add_filter( 'bb_stylesheet_uri', 'attribute_escape', 1, 9999 );
    7676    add_filter( 'forum_link', 'attribute_escape', 1, 9999 );
    77     add_filter( 'forum_rss_link', 'attribute_escape', 1, 9999 );
     77    add_filter( 'bb_forum_posts_rss_link', 'attribute_escape', 1, 9999 );
     78    add_filter( 'bb_forum_topics_rss_link', 'attribute_escape', 1, 9999 );
    7879    add_filter( 'bb_tag_link', 'attribute_escape', 1, 9999 );
    7980    add_filter( 'tag_rss_link', 'attribute_escape', 1, 9999 );
  • trunk/bb-includes/deprecated.php

    r1553 r1575  
    535535function bb_path_to_url( $path ) {
    536536    bb_log_deprecated('function', __FUNCTION__, 'no alternative');
    537     return apply_filters( 'bb_path_to_url', bb_convert_path_base( $path, BB_PATH, bb_get_option( 'uri' ) ), $path );
     537    return apply_filters( 'bb_path_to_url', bb_convert_path_base( $path, BB_PATH, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT) ), $path );
    538538}
    539539
     
    541541function bb_url_to_path( $url ) {
    542542    bb_log_deprecated('function', __FUNCTION__, 'no alternative');
    543     return apply_filters( 'bb_url_to_path', bb_convert_path_base( $url, bb_get_option( 'uri' ), BB_PATH ), $url );
     543    return apply_filters( 'bb_url_to_path', bb_convert_path_base( $url, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), BB_PATH ), $url );
    544544}
    545545
     
    648648function forum_rss_link( $forum_id = 0 ) {
    649649    bb_log_deprecated('function', __FUNCTION__, 'bb_get_forum_posts_rss_link');
    650     echo bb_get_forum_posts_rss_link( $forum_id );
     650    bb_forum_posts_rss_link( $forum_id );
    651651}
    652652
  • trunk/bb-includes/functions.php

    r1572 r1575  
    17151715                    $r = 0;
    17161716                    break;
     1717                case 'uri_ssl':
     1718                    $r = preg_replace('|^http://|i', 'https://', bb_get_option('uri'));
    17171719            }
    17181720        }
     
    17631765        'description' => '',
    17641766        'uri' => '',
     1767        'uri_ssl' => '',
    17651768        'from_email' => '',
    17661769        'secret' => '',
     
    18081811function bb_delete_option( $option, $value = '' ) {
    18091812    return bb_delete_meta( 0, $option, $value, 'option', true );
     1813}
     1814
     1815/**
     1816 * BB_URI_CONTEXT_* - Bitwise definitions for bb_uri() and bb_get_uri() contexts
     1817 *
     1818 * @since 1.0-beta
     1819 **/
     1820define('BB_URI_CONTEXT_HEADER',               1);
     1821define('BB_URI_CONTEXT_TEXT',                 2);
     1822define('BB_URI_CONTEXT_A_HREF',               4);
     1823define('BB_URI_CONTEXT_FORM_ACTION',          8);
     1824define('BB_URI_CONTEXT_IMG_SRC',              16);
     1825define('BB_URI_CONTEXT_LINK_STYLESHEET_HREF', 32);
     1826define('BB_URI_CONTEXT_LINK_ALTERNATE_HREF',  64);
     1827define('BB_URI_CONTEXT_SCRIPT_SRC',           128);
     1828//define('BB_URI_CONTEXT_*',                    256);    // Reserved for future definitions
     1829//define('BB_URI_CONTEXT_*',                    512);    // Reserved for future definitions
     1830define('BB_URI_CONTEXT_BB_FEED',              1024);
     1831define('BB_URI_CONTEXT_BB_USER_FORMS',        2048);
     1832define('BB_URI_CONTEXT_BB_ADMIN',             4096);
     1833//define('BB_URI_CONTEXT_*',                    8192);   // Reserved for future definitions
     1834//define('BB_URI_CONTEXT_*',                    16384);  // Reserved for future definitions
     1835//define('BB_URI_CONTEXT_*',                    32768);  // Reserved for future definitions
     1836//define('BB_URI_CONTEXT_*',                    65536);  // Reserved for future definitions
     1837//define('BB_URI_CONTEXT_*',                    131072); // Reserved for future definitions
     1838//define('BB_URI_CONTEXT_*',                    262144); // Reserved for future definitions
     1839define('BB_URI_CONTEXT_AKISMET',              524288);
     1840
     1841/**
     1842 * bb_uri() - echo a URI based on the URI setting
     1843 *
     1844 * @since 1.0-beta
     1845 *
     1846 * @param $resource string The directory, may include a querystring
     1847 * @param $query mixed The query arguments as a querystring or an associative array
     1848 * @param $context integer The context of the URI, use BB_URI_CONTEXT_*
     1849 * @return void
     1850 **/
     1851function bb_uri($resource = null, $query = null, $context = BB_URI_CONTEXT_A_HREF) {
     1852    echo apply_filters('bb_uri', bb_get_uri($resource, $query, $context), $resource, $query, $context);
     1853}
     1854
     1855/**
     1856 * bb_get_uri() - return a URI based on the URI setting
     1857 *
     1858 * @since 1.0-beta
     1859 *
     1860 * @param $resource string The directory, may include a querystring
     1861 * @param $query mixed The query arguments as a querystring or an associative array
     1862 * @param $context integer The context of the URI, use BB_URI_CONTEXT_*
     1863 * @return string The complete URI
     1864 **/
     1865function bb_get_uri($resource = null, $query = null, $context = BB_URI_CONTEXT_A_HREF) {
     1866    // If there is a querystring in the resource then extract it
     1867    if ($resource && strpos($resource, '?') !== false) {
     1868        list($_resource, $_query) = explode('?', trim($resource));
     1869        $resource = $_resource;
     1870        $_query = wp_parse_args($_query);
     1871    }
     1872   
     1873    // Make sure $_query is an array for array_merge()
     1874    if (!$_query) {
     1875        $_query = array();
     1876    }
     1877   
     1878    // $query can be an array as well as a string
     1879    if ($query) {
     1880        if (is_string($query)) {
     1881            $query = ltrim(trim($query), '?');
     1882        }
     1883        $query = wp_parse_args($query);
     1884    }
     1885   
     1886    // Make sure $query is an array for array_merge()
     1887    if (!$query) {
     1888        $query = array();
     1889    }
     1890   
     1891    // Merge the queries into a single array
     1892    $query = array_merge($_query, $query);
     1893   
     1894    // Make sure context is an integer
     1895    if (!$context || !is_integer($context)) {
     1896        $context = BB_URI_CONTEXT_A_HREF;
     1897    }
     1898   
     1899    // Get the base URI
     1900    $uri = bb_get_option('uri');
     1901   
     1902    // Force https when required on user forms
     1903    if (($context & BB_URI_CONTEXT_BB_USER_FORMS) && bb_force_ssl_user_forms()) {
     1904        $uri = bb_get_option('uri_ssl');
     1905    }
     1906   
     1907    // Force https when required in admin
     1908    if (($context & BB_URI_CONTEXT_BB_ADMIN) && bb_force_ssl_admin()) {
     1909        $uri = bb_get_option('uri_ssl');
     1910    }
     1911   
     1912    // Add the directory
     1913    $uri .= ltrim($resource, '/');
     1914   
     1915    // Add the query string to the URI
     1916    $uri = add_query_arg($query, $uri);
     1917   
     1918    return apply_filters('bb_get_uri', $uri, $resource, $context);
     1919}
     1920
     1921/**
     1922 * bb_force_ssl_user_forms() - Whether SSL should be forced when sensitive user data is being submitted.
     1923 *
     1924 * @since 1.0-beta
     1925 *
     1926 * @param string|bool $force Optional.
     1927 * @return bool True if forced, false if not forced.
     1928 **/
     1929function bb_force_ssl_user_forms($force = '') {
     1930    static $forced;
     1931   
     1932    if ( '' != $force ) {
     1933        $old_forced = $forced;
     1934        $forced = $force;
     1935        return $old_forced;
     1936    }
     1937   
     1938    return $forced;
     1939}
     1940
     1941/**
     1942 * bb_force_ssl_admin() - Whether SSL should be forced when using the admin area.
     1943 *
     1944 * @since 1.0-beta
     1945 *
     1946 * @param string|bool $force Optional.
     1947 * @return bool True if forced, false if not forced.
     1948 **/
     1949function bb_force_ssl_admin($force = '') {
     1950    static $forced;
     1951   
     1952    if ( '' != $force ) {
     1953        $old_forced = $forced;
     1954        $forced = $force;
     1955        return $old_forced;
     1956    }
     1957   
     1958    return $forced;
    18101959}
    18111960
     
    25332682       
    25342683        $uri = false;
    2535         if ( function_exists('bb_get_option') && !BB_INSTALLING )
    2536             $uri = bb_get_option('uri');
     2684        if ( function_exists('bb_get_uri') && !BB_INSTALLING ) {
     2685            $uri = bb_get_uri();
     2686            $uri_stylesheet = bb_get_uri('bb-admin/install.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_INSTALLER);
     2687            $uri_stylesheet_rtl = bb_get_uri('bb-admin/install-rtl.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_INSTALLER);
     2688            $uri_logo = bb_get_uri('bb-admin/images/install-logo.gif', null, BB_URI_CONTEXT_IMG_SRC + BB_URI_CONTEXT_BB_INSTALLER);
     2689        }
    25372690       
    2538         if (!$uri)
     2691        if (!$uri) {
    25392692            $uri = preg_replace('|(/bb-admin)?/[^/]+?$|', '/', $_SERVER['PHP_SELF']);
     2693            $uri_stylesheet = $uri . 'bb-admin/install.css';
     2694            $uri_stylesheet_rtl = $uri . 'bb-admin/install-rtl.css';
     2695            $uri_logo = $uri . 'bb-admin/images/install-logo.gif';
     2696        }
    25402697   
    25412698    header('Content-Type: text/html; charset=utf-8');
     
    25472704    <title><?php echo $title; ?></title>
    25482705    <meta name="robots" content="noindex, nofollow" />
    2549     <link rel="stylesheet" href="<?php echo $uri; ?>bb-admin/install.css" type="text/css" />
     2706    <link rel="stylesheet" href="<?php echo $uri_stylesheet; ?>" type="text/css" />
    25502707<?php
    25512708    if ( function_exists( 'bb_get_option' ) && 'rtl' == bb_get_option( 'text_direction' ) ) {
    25522709?>
    2553     <link rel="stylesheet" href="<?php echo $uri; ?>bb-admin/install-rtl.css" type="text/css" />
     2710    <link rel="stylesheet" href="<?php echo $uri_stylesheet_rtl; ?>" type="text/css" />
    25542711<?php
    25552712    }
     
    25592716    <div id="container">
    25602717        <div class="logo">
    2561             <img src="<?php echo $uri; ?>bb-admin/images/install-logo.gif" alt="bbPress Installation" />
     2718            <img src="<?php echo $uri_logo; ?>" alt="bbPress Installation" />
    25622719        </div>
    25632720<?php
     
    25922749    <p><?php echo $message; ?></p>
    25932750<?php
    2594     if ($uri = bb_get_option('uri')) {
     2751    if ($uri = bb_get_uri()) {
    25952752?>
    25962753    <p class="last"><?php printf( __('Back to <a href="%s">%s</a>.'), $uri, bb_get_option( 'name' ) ); ?></p>
  • trunk/bb-includes/pluggable.php

    r1562 r1575  
    55    if ( !wp_validate_auth_cookie() ) {
    66        nocache_headers();
    7         header('Location: ' . bb_get_option('uri'));
     7        header('Location: ' . bb_get_uri(null, null, BB_URI_CONTEXT_HEADER));
    88        exit();
    99    }
     
    192192
    193193    $lp  = parse_url($location);
    194     $wpp = parse_url(bb_get_option('uri'));
     194    $wpp = parse_url(bb_get_uri());
    195195
    196196    $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
    197197
    198198    if ( isset($lp['host']) && !in_array($lp['host'], $allowed_hosts) )
    199         $location = bb_get_option('uri');
     199        $location = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
    200200
    201201    wp_redirect($location, $status);
     
    412412    if (!count(preg_grep('/^from:\s/im', $headers))) {
    413413        if (!$from = bb_get_option('from_email'))
    414             if ($uri_parsed = parse_url(bb_get_option('uri')))
     414            if ($uri_parsed = parse_url(bb_get_uri()))
    415415                if ($uri_parsed['host'])
    416416                    $from = 'bbpress@' . trim(preg_replace('/^www./i', '', $uri_parsed['host']));
  • trunk/bb-includes/registration-functions.php

    r1509 r1575  
    8383    bb_update_usermeta( $user->ID, 'newpwdkey', $resetkey );
    8484
    85     $message = sprintf( __("If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!"), bb_get_option('uri') . "bb-reset-password.php?key=$resetkey" );
     85    $message = sprintf(
     86        __("If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!"),
     87        bb_get_uri(
     88            'bb-reset-password.php',
     89            array('key' => $resetkey),
     90            BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_BB_USER_FORMS
     91        )
     92    );
    8693
    8794    return bb_mail( bb_get_user_email( $user->ID ), bb_get_option('name') . ': ' . __('Password Reset'), $message );
     
    165172        bb_get_user_email( $user->ID ),
    166173        bb_get_option('name') . ': ' . __('Password'),
    167         sprintf( $message, $user->user_login, $pass, bb_get_option('uri') )
     174        sprintf($message, $user->user_login, $pass, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT))
    168175    );
    169176}
  • trunk/bb-includes/script-loader.php

    r1544 r1575  
    22
    33function bb_default_scripts( &$scripts ) {
    4     $scripts->base_url = bb_get_option( 'uri' );
     4    $scripts->base_url = bb_get_uri(BB_INC, null, BB_URI_CONTEXT_SCRIPT_SRC);
     5    $scripts->base_url_admin = bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_SCRIPT_SRC + BB_URI_CONTEXT_BB_ADMIN);
    56    $scripts->default_version = bb_get_option( 'version' );
    67   
    7     $scripts->add( 'fat', $scripts->base_url . BB_INC . 'js/fat.js', array('add-load-event'), '1.0-RC1_3660' );
    8     $scripts->add( 'prototype', $scripts->base_url . BB_INC . 'js/prototype.js', false, '1.5.0' );
    9     $scripts->add( 'wp-ajax', $scripts->base_url . BB_INC . 'js/wp-ajax-js.php', array('prototype'), '2.1-beta2' );
    10     $scripts->add( 'listman', $scripts->base_url . BB_INC . 'js/list-manipulation-js.php', array('add-load-event', 'wp-ajax', 'fat'), '440' );
    11     $scripts->add( 'wp-ajax-response', $scripts->base_url . BB_INC . 'js/wp-ajax-response.js', array('jquery'), '20080316' );
     8    $scripts->add( 'fat',              $scripts->base_url . 'js/fat.js', array('add-load-event'), '1.0-RC1_3660' );
     9    $scripts->add( 'prototype',        $scripts->base_url . 'js/prototype.js', false, '1.5.0' );
     10    $scripts->add( 'wp-ajax',          $scripts->base_url . 'js/wp-ajax-js.php', array('prototype'), '2.1-beta2' );
     11    $scripts->add( 'listman',          $scripts->base_url . 'js/list-manipulation-js.php', array('add-load-event', 'wp-ajax', 'fat'), '440' );
     12    $scripts->add( 'wp-ajax-response', $scripts->base_url . 'js/wp-ajax-response.js', array('jquery'), '20080316' );
    1213    $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
    1314        'noPerm' => __('You do not have permission to do that.'),
    1415        'broken' => __('An unidentified error has occurred.')
    1516    ) );
    16     $scripts->add( 'wp-lists', $scripts->base_url . BB_INC . 'js/wp-lists.js', array('wp-ajax-response','jquery-color'), '20080411' );
     17    $scripts->add( 'wp-lists',         $scripts->base_url . 'js/wp-lists.js', array('wp-ajax-response','jquery-color'), '20080411' );
    1718    $scripts->localize( 'wp-lists', 'wpListL10n', array(
    18         'url' => "{$scripts->base_url}bb-admin/admin-ajax.php"
     19        'url' => $scripts->base_url_admin . 'admin-ajax.php'
    1920    ) );
    20     $scripts->add( 'topic', $scripts->base_url . BB_INC . 'js/topic.js', array('wp-lists'), '20080506' );
    21     $scripts->add( 'jquery', $scripts->base_url . BB_INC . 'js/jquery/jquery.js', false, '1.1.3.1');
    22     $scripts->add( 'interface', $scripts->base_url . BB_INC . 'js/jquery/interface.js', array('jquery'), '1.2.3');
    23     $scripts->add( 'jquery-color', $scripts->base_url . BB_INC . 'js/jquery/jquery.color.js', array('jquery'), '2.0-4561' );
    24     $scripts->add( 'add-load-event', $scripts->base_url . BB_INC . 'js/add-load-event.js' );
    25     $scripts->add( 'content-forums', $scripts->base_url . 'bb-admin/js/content-forums.js', array('listman', 'interface'), '20080309' );
     21    $scripts->add( 'topic',            $scripts->base_url . 'js/topic.js', array('wp-lists'), '20080506' );
     22    $scripts->add( 'jquery',           $scripts->base_url . 'js/jquery/jquery.js', false, '1.1.3.1');
     23    $scripts->add( 'interface',        $scripts->base_url . 'js/jquery/interface.js', array('jquery'), '1.2.3');
     24    $scripts->add( 'jquery-color',     $scripts->base_url . 'js/jquery/jquery.color.js', array('jquery'), '2.0-4561' );
     25    $scripts->add( 'add-load-event',   $scripts->base_url . 'js/add-load-event.js' );
     26    $scripts->add( 'content-forums',   $scripts->base_url_admin . 'js/content-forums.js', array('listman', 'interface'), '20080309' );
    2627    $scripts->localize( 'content-forums', 'bbSortForumsL10n', array(
    2728        'handleText' => __('drag'),
  • trunk/bb-includes/template-functions.php

    r1532 r1575  
    155155
    156156    if ( ( is_topic() && bb_current_user_can( 'write_post', $topic->topic_id ) && $page == $last_page ) || ( !is_topic() && bb_current_user_can( 'write_topic', $forum->forum_id ) ) ) {
    157         echo '<form class="postform post-form" id="postform" method="post" action="' . bb_get_option('uri') . 'bb-post.php">' . "\n";
    158         echo "<fieldset>\n";
     157        echo '<form class="postform post-form" id="postform" method="post" action="' . bb_get_uri('bb-post.php', null, BB_URI_CONTEXT_FORM_ACTION) . '">' . "\n";
     158        echo '<fieldset>' . "\n";
    159159        bb_load_template( 'post-form.php', array('h2' => $h2) );
    160160        bb_nonce_field( is_topic() ? 'create-post_' . $topic->topic_id : 'create-topic' );
     
    167167    } elseif ( !bb_is_user_logged_in() ) {
    168168        echo '<p>';
    169         printf(__('You must <a href="%s">log in</a> to post.'), attribute_escape( bb_get_option('uri') . 'bb-login.php' ));
     169        printf(
     170            __('You must <a href="%s">log in</a> to post.'),
     171            attribute_escape( bb_get_uri('bb-login.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS) )
     172        );
    170173        echo '</p>';
    171174    }
     
    176179    global $bb_post;
    177180    do_action('pre_edit_form');
    178     echo "<form class='postform edit-form' method='post' action='" . bb_get_option('uri')  . "bb-edit.php'>\n";
    179     echo "<fieldset>\n";
     181    echo '<form class="postform edit-form" method="post" action="' . bb_get_uri('bb-edit.php', null, BB_URI_CONTEXT_FORM_ACTION)  . '">' . "\n";
     182    echo '<fieldset>' . "\n";
    180183    bb_load_template( 'edit-form.php', array('topic_title') );
    181184    bb_nonce_field( 'edit-post_' . $bb_post->post_id );
    182185    do_action('edit_form');
    183     echo "\n</fieldset>\n</form>\n";
     186    echo "\n" . '</fieldset>' . "\n" . '</form>' . "\n";
    184187    do_action('post_edit_form');
    185188}
     
    380383            $feeds[] = array(
    381384                'title' => sprintf(__('User Favorites: %s'), get_user_name()),
    382                 'href'  => get_favorites_rss_link()
     385                'href'  => get_favorites_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    383386            );
    384387            break;
     
    387390            $feeds[] = array(
    388391                'title' => sprintf(__('Topic: %s'), get_topic_title()),
    389                 'href'  => get_topic_rss_link()
     392                'href'  => get_topic_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    390393            );
    391394            break;
     
    395398                $feeds[] = array(
    396399                    'title' => sprintf(__('Tag: %s'), bb_get_tag_name()),
    397                     'href'  => bb_get_tag_rss_link()
     400                    'href'  => bb_get_tag_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    398401                );
    399402            }
     
    403406            $feeds[] = array(
    404407                'title' => sprintf(__('Forum: %s - Recent Posts'), get_forum_name()),
    405                 'href'  => get_forum_rss_link()
     408                'href'  => bb_get_forum_posts_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    406409            );
    407410            $feeds[] = array(
    408411                'title' => sprintf(__('Forum: %s - Recent Topics'), get_forum_name()),
    409                 'href'  => bb_get_forum_topics_rss_link()
     412                'href'  => bb_get_forum_topics_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    410413            );
    411414            break;
     
    414417            $feeds[] = array(
    415418                'title' => __('Recent Posts'),
    416                 'href'  => bb_get_posts_rss_link()
     419                'href'  => bb_get_posts_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    417420            );
    418421            $feeds[] = array(
    419422                'title' => __('Recent Topics'),
    420                 'href'  => bb_get_topics_rss_link()
     423                'href'  => bb_get_topics_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    421424            );
    422425            break;
     
    427430                $feeds[] = array(
    428431                    'title' => get_view_name(),
    429                     'href'  => bb_get_view_rss_link()
     432                    'href'  => bb_get_view_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED)
    430433                );
    431434            }
     
    449452}
    450453
    451 function bb_get_posts_rss_link() {
     454function bb_get_posts_rss_link($context = 0) {
     455    if (!$context || !is_integer($context)) {
     456        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     457    }
    452458    if ( bb_get_option( 'mod_rewrite' ) )
    453         $link = bb_get_option( 'uri' ) . 'rss/';
     459        $link = bb_get_uri('rss/', null, $context);
    454460    else
    455         $link = bb_get_option( 'uri' ) . 'rss.php';
    456     return apply_filters( 'bb_get_posts_rss_link', $link );
    457 }
    458 
    459 function bb_get_topics_rss_link() {
     461        $link = bb_get_uri('rss.php', null, $context);
     462    return apply_filters( 'bb_get_posts_rss_link', $link, $context );
     463}
     464
     465function bb_get_topics_rss_link($context = 0) {
     466    if (!$context || !is_integer($context)) {
     467        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     468    }
    460469    if ( bb_get_option( 'mod_rewrite' ) )
    461         $link = bb_get_option( 'uri' ) . 'rss/topics';
     470        $link = bb_get_uri('rss/topics', null, $context);
    462471    else
    463         $link = bb_get_option( 'uri' ) . 'rss.php?topics=1';
    464     return apply_filters( 'bb_get_topics_rss_link', $link );
    465 }
    466 
    467 function bb_get_view_rss_link() {
     472        $link = bb_get_uri('rss.php', array('topics' => 1), $context);
     473    return apply_filters( 'bb_get_topics_rss_link', $link, $context );
     474}
     475
     476function bb_get_view_rss_link($context = 0) {
    468477    global $view;
     478    if (!$context || !is_integer($context)) {
     479        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     480    }
    469481    if ( bb_get_option( 'mod_rewrite' ) )
    470         $link = bb_get_option( 'uri' ) . 'rss/view/' . $view;
     482        $link = bb_get_uri('rss/view/' . $view, null, $context);
    471483    else
    472         $link = bb_get_option( 'uri' ) . 'rss.php?view=' . $view;
    473     return apply_filters( 'bb_get_view_rss_link', $link );
     484        $link = bb_get_uri('rss.php', array('view' => $view), $context);
     485    return apply_filters( 'bb_get_view_rss_link', $link, $context );
    474486}
    475487
     
    490502}
    491503
    492 function forum_link( $forum_id = 0, $page = 1 ) {
    493     echo apply_filters('forum_link', get_forum_link( $forum_id, $page ), $forum_id );
    494 }
    495 
    496 function get_forum_link( $forum_id = 0, $page = 1 ) {
     504function forum_link( $forum_id = 0, $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
     505    if (!$context || !is_integer($context)) {
     506        $context = BB_URI_CONTEXT_A_HREF;
     507    }
     508    echo apply_filters('forum_link', get_forum_link( $forum_id, $page, $context ), $forum_id, $context );
     509}
     510
     511function get_forum_link( $forum_id = 0, $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
    497512    $forum = get_forum( get_forum_id( $forum_id ) );
     513   
     514    if (!$context || !is_integer($context)) {
     515        $context = BB_URI_CONTEXT_A_HREF;
     516    }
     517   
    498518    $rewrite = bb_get_option( 'mod_rewrite' );
    499519    if ( $rewrite ) {
     
    503523            $column = 'forum_id';
    504524        }
    505         $link = bb_get_option( 'uri' ) . "forum/" . $forum->$column . ( 1 < $page ? "/page/$page" : '' );
     525        $page = $page > 1 ? $page : '';
     526        $link = bb_get_uri('forum/' . $forum->$column . $page, null, $context);
    506527    } else {
    507         $args = array();
    508         $link = bb_get_option( 'uri' ) . 'forum.php';
    509         $args['id'] = $forum->forum_id;
    510         $args['page'] = 1 < $page ? $page : false;
    511         $link = add_query_arg( $args, $link );
    512     }
    513 
    514     return apply_filters( 'get_forum_link', $link, $forum->forum_id );
     528        $query = array(
     529            'id' => $forum->forum_id,
     530            'page' => $page > 1 ? $page : false
     531        );
     532        $link = bb_get_uri('forum.php', $query, $context);
     533    }
     534
     535    return apply_filters( 'get_forum_link', $link, $forum->forum_id, $context );
    515536}
    516537
     
    580601}
    581602
    582 function bb_forum_posts_rss_link( $forum_id = 0 ) {
    583     echo apply_filters('bb_forum_posts_rss_link', bb_get_forum_posts_rss_link( $forum_id ) );
    584 }
    585 
    586 function bb_get_forum_posts_rss_link( $forum_id = 0 ) {
     603function bb_forum_posts_rss_link( $forum_id = 0, $context = 0 ) {
     604    if (!$context || !is_integer($context)) {
     605        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     606    }
     607    echo apply_filters('bb_forum_posts_rss_link', bb_get_forum_posts_rss_link( $forum_id, $context ), $context );
     608}
     609
     610function bb_get_forum_posts_rss_link( $forum_id = 0, $context = 0 ) {
    587611    $forum = get_forum( get_forum_id( $forum_id ) );
     612   
     613    if (!$context || !is_integer($context)) {
     614        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     615    }
     616   
    588617    $rewrite = bb_get_option( 'mod_rewrite' );
    589618    if ( $rewrite ) {
     
    593622            $column = 'forum_id';
    594623        }
    595         $link = bb_get_option('uri') . 'rss/forum/' . $forum->$column;
     624        $link = bb_get_uri('rss/forum/' . $forum->$column, null, $context);
    596625    } else {
    597         $link = bb_get_option('uri') . 'rss.php?forum=' . $forum->forum_id;
    598     }
    599     return apply_filters( 'bb_get_forum_posts_rss_link', $link, $forum->forum_id );
    600 }
    601 
    602 function bb_forum_topics_rss_link( $forum_id = 0 ) {
    603     echo apply_filters('bb_forum_topics_rss_link', bb_get_forum_topics_rss_link( $forum_id ) );
    604 }
    605 
    606 function bb_get_forum_topics_rss_link( $forum_id = 0 ) {
     626        $link = bb_get_uri('rss.php', array('forum' => $forum->forum_id), $context);
     627    }
     628    return apply_filters( 'bb_get_forum_posts_rss_link', $link, $forum->forum_id, $context );
     629}
     630
     631function bb_forum_topics_rss_link( $forum_id = 0, $context = 0 ) {
     632    if (!$context || !is_integer($context)) {
     633        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     634    }
     635    echo apply_filters('bb_forum_topics_rss_link', bb_get_forum_topics_rss_link( $forum_id, $context ), $context );
     636}
     637
     638function bb_get_forum_topics_rss_link( $forum_id = 0, $context = 0 ) {
    607639    $forum = get_forum( get_forum_id( $forum_id ) );
     640   
     641    if (!$context || !is_integer($context)) {
     642        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     643    }
     644   
    608645    $rewrite = bb_get_option( 'mod_rewrite' );
    609646    if ( $rewrite ) {
     
    613650            $column = 'forum_id';
    614651        }
    615         $link = bb_get_option('uri') . 'rss/forum/' . $forum->$column . '/topics';
     652        $link = bb_get_uri('rss/forum/' . $forum->$column . '/topics', null, $context);
    616653    } else {
    617         $link = bb_get_option('uri') . 'rss.php?forum=' . $forum->forum_id . '&amp;topics=1';
    618     }
    619     return apply_filters( 'bb_get_forum_topics_rss_link', $link, $forum->forum_id );
     654        $link = bb_get_uri('rss.php', array('forum' => $forum->forum_id, 'topics' => 1), $context);
     655    }
     656    return apply_filters( 'bb_get_forum_topics_rss_link', $link, $forum->forum_id, $context );
    620657}
    621658
     
    752789}
    753790
    754 function topic_link( $id = 0, $page = 1 ) {
    755     echo apply_filters( 'topic_link', get_topic_link( $id ), $id );
    756 }
    757 
    758 function get_topic_link( $id = 0, $page = 1 ) {
     791function topic_link( $id = 0, $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
     792    echo apply_filters( 'topic_link', get_topic_link( $id ), $id, $context );
     793}
     794
     795function get_topic_link( $id = 0, $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
    759796    $topic = get_topic( get_topic_id( $id ) );
     797
     798    if (!$context || !is_integer($context)) {
     799        $context = BB_URI_CONTEXT_A_HREF;
     800    }
    760801
    761802    $args = array();
     
    768809            $column = 'topic_id';
    769810        }
    770         $link = bb_get_option('uri') . "topic/" . $topic->$column . ( 1 < $page ? "/page/$page" : '' );
     811        $page = $page > 1 ? '/page/' . $page : '';
     812        $link = bb_get_uri('topic/' . $topic->$column . $page, null, $context);
    771813    } else {
    772         $link = bb_get_option('uri') . 'topic.php';
    773         $args['id'] = $topic->topic_id;
    774         $args['page'] = 1 < $page ? $page : false;
    775     }
    776 
    777     if ( $args )
    778         $link = add_query_arg( $args, $link );
    779 
    780     return apply_filters( 'get_topic_link', $link, $topic->topic_id );
    781 }
    782 
    783 function topic_rss_link( $id = 0 ) {
    784     echo apply_filters('topic_rss_link', get_topic_rss_link($id), $id );
    785 }
    786 
    787 function get_topic_rss_link( $id = 0 ) {
     814        $page = $page > 1 ? $page : false;
     815        $link = bb_get_uri('topic.php', array('id' => $topic->topic_id, 'page' => $page), $context);
     816    }
     817
     818    return apply_filters( 'get_topic_link', $link, $topic->topic_id, $context );
     819}
     820
     821function topic_rss_link( $id = 0, $context = 0 ) {
     822    if (!$context || !is_integer($context)) {
     823        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     824    }
     825    echo apply_filters('topic_rss_link', get_topic_rss_link($id, $context), $id, $context );
     826}
     827
     828function get_topic_rss_link( $id = 0, $context = 0 ) {
    788829    $topic = get_topic( get_topic_id( $id ) );
     830
     831    if (!$context || !is_integer($context)) {
     832        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     833    }
     834
    789835    $rewrite = bb_get_option( 'mod_rewrite' );
    790836    if ( $rewrite ) {
     
    794840            $column = 'topic_id';
    795841        }
    796         $link = bb_get_option('uri') . 'rss/topic/' . $topic->$column;
     842        $link = bb_get_uri('rss/topic/' . $topic->$column, null, $context);
    797843    } else {
    798         $link = bb_get_option('uri') . 'rss.php?topic=' . $topic->topic_id;
    799     }
    800     return apply_filters( 'get_topic_rss_link', $link, $topic->topic_id );
     844        $link = bb_get_uri('rss.php', array('topic' => $topic->topic_id), $context);
     845    }
     846    return apply_filters( 'get_topic_rss_link', $link, $topic->topic_id, $context );
    801847}
    802848
     
    9891035        return;
    9901036
    991     if ( 0 == $topic->topic_status )
    992         return "$before<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/delete-topic.php?id=' . $topic->topic_id , 'delete-topic_' . $topic->topic_id ) ) . "' onclick=\"return confirm('" . js_escape( __('Are you sure you wanna delete that?') ) . "')\">" . __('Delete entire topic') . "</a>$after";
    993     else
    994         return "$before<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/delete-topic.php?id=' . $topic->topic_id . '&view=all', 'delete-topic_' . $topic->topic_id ) ) . "' onclick=\"return confirm('" . js_escape( __('Are you sure you wanna undelete that?') ) . "')\">" . __('Undelete entire topic') . "</a>$after";
     1037    if ( 0 == $topic->topic_status ) {
     1038        $query   = array('id' => $topic->topic_id);
     1039        $confirm = __('Are you sure you wanna delete that?');
     1040        $display = __('Delete entire topic');
     1041    } else {
     1042        $query   = array('id' => $topic->topic_id, 'view' => 'all');
     1043        $confirm = __('Are you sure you wanna undelete that?');
     1044        $display = __('Undelete entire topic');
     1045    }
     1046    $uri = bb_get_uri('bb-admin/delete-topic.php', $query, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     1047    $uri = attribute_escape( bb_nonce_url( $uri, 'delete-topic_' . $topic->topic_id ) );
     1048   
     1049    return $before . '<a href="' . $uri . '" onclick="return confirm(\'' . js_escape( $confirm ) . '\');">' . $display . '</a>' . $after;
    9951050}
    9961051
     
    10091064        return;
    10101065
    1011     $text = topic_is_open( $topic->topic_id ) ? __('Close topic') : __('Open topic');
    1012     return "$before<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/topic-toggle.php?id=' . $topic->topic_id, 'close-topic_' . $topic->topic_id ) ) . "'>$text</a>$after";
     1066    $display = topic_is_open( $topic->topic_id ) ? __('Close topic') : __('Open topic');
     1067    $uri = bb_get_uri('bb-admin/topic-toggle.php', array('id' => $topic->topic_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     1068    $uri = attribute_escape( bb_nonce_url( $uri, 'close-topic_' . $topic->topic_id ) );
     1069   
     1070    return $before . '<a href="' . $uri . '" onclick="return confirm(\'' . js_escape( $confirm ) . '\');">' . $display . '</a>' . $after;
    10131071}
    10141072
     
    10271085        return;
    10281086
     1087    $uri_stick = bb_get_uri('bb-admin/sticky.php', array('id' => $topic->topic_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     1088    $uri_stick = attribute_escape( bb_nonce_url( $uri_stick, 'stick-topic_' . $topic->topic_id ) );
     1089
     1090    $uri_super = bb_get_uri('bb-admin/sticky.php', array('id' => $topic->topic_id, 'super' => 1), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     1091    $uri_stick = attribute_escape( bb_nonce_url( $uri_super, 'stick-topic_' . $topic->topic_id ) );
     1092
    10291093    if ( topic_is_sticky( $topic->topic_id ) )
    1030         return "$before<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/sticky.php?id=' . $topic->topic_id, 'stick-topic_' . $topic->topic_id ) ) . "'>". __('Unstick topic') ."</a>$after";
     1094        return "$before<a href='" . $uri_stick . "'>". __('Unstick topic') ."</a>$after";
    10311095    else
    1032         return "$before<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/sticky.php?id=' . $topic->topic_id, 'stick-topic_' . $topic->topic_id ) ) . "'>". __('Stick topic') . "</a> (<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/sticky.php?id=' . $topic->topic_id . '&super=1', 'stick-topic_' . $topic->topic_id ) ) . "'>" . __('to front') . "</a>)$after";
     1096        return "$before<a href='" . $uri_stick . "'>". __('Stick topic') . "</a> (<a href='" . $uri_super . "'>" . __('to front') . "</a>)$after";
    10331097}
    10341098
     
    10791143        return;
    10801144
    1081     echo '<form id="topic-move" method="post" action="' . bb_get_option('uri') . 'bb-admin/topic-move.php"><fieldset><div>' . "\n\t";
     1145    echo '<form id="topic-move" method="post" action="' . bb_get_uri('bb-admin/topic-move.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN) . '"><fieldset><div>' . "\n\t";
    10821146    echo "<input type='hidden' name='topic_id' value='$topic->topic_id' />\n\t";
    10831147    echo '<label for="forum-id">'. __('Move this topic to the selected forum:') . ' ';
     
    11231187        $url = get_forum_link() . '#postform';
    11241188    elseif ( is_front() )
    1125         $url = add_query_arg( 'new', '1', bb_get_option( 'uri' ) );
     1189        $url = bb_get_uri(null, array('new' => 1));
    11261190
    11271191    if ( !bb_is_user_logged_in() )
    1128         $url = add_query_arg( 're', urlencode($url), bb_get_option( 'uri' ) . 'bb-login.php' );
     1192        $url = bb_get_uri('bb-login.php', array('re' => $url), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS);
    11291193    elseif ( is_forum() || is_topic() ) {
    11301194        if ( !bb_current_user_can( 'write_topic', get_forum_id() ) )
     
    11361200
    11371201    if ( $url = attribute_escape( apply_filters( 'new_topic_url', $url ) ) )
    1138         echo "<a href='$url' class='new-topic'>$text</a>\n";
     1202        echo '<a href="' . $url . '" class="new-topic">' . $text . '</a>' . "\n";
    11391203}
    11401204
     
    13041368    if ( !bb_current_user_can( 'view_by_ip' ) )
    13051369        return;
    1306     $link = '<a href="' . attribute_escape( bb_get_option('uri') . 'bb-admin/view-ip.php?ip=' . get_post_ip( $post_id ) ) . '">' . get_post_ip( $post_id ) . '</a>';
     1370   
     1371    $uri = bb_get_uri('bb-admin/view-ip.php', array('ip' => get_post_ip($post_id)), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     1372    $link = '<a href="' . attribute_escape( $uri ) . '">' . get_post_ip( $post_id ) . '</a>';
    13071373    return apply_filters( 'post_ip_link', $link, get_post_id( $post_id ) );
    13081374}
     
    13141380function bb_get_post_edit_link( $post_id = 0 ) {
    13151381    $bb_post = bb_get_post( get_post_id( $post_id ) );
    1316     if ( bb_current_user_can( 'edit_post', $bb_post->post_id ) )
    1317         return "<a href='" . attribute_escape( apply_filters( 'post_edit_uri', bb_get_option('uri') . 'edit.php?id=' . $bb_post->post_id, $bb_post->post_id ) ) . "'>". __('Edit') ."</a>";
     1382    if ( bb_current_user_can( 'edit_post', $bb_post->post_id ) ) {
     1383        $uri = bb_get_uri('edit.php', array('id' => $bb_post->post_id));
     1384        return "<a href='" . attribute_escape( apply_filters( 'post_edit_uri', $uri, $bb_post->post_id ) ) . "'>". __('Edit') ."</a>";
     1385    }
    13181386}
    13191387
     
    13361404        return;
    13371405
    1338     if ( 1 == $bb_post->post_status )
    1339         $r = "<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/delete-post.php?id=' . $bb_post->post_id . '&status=0&view=all', 'delete-post_' . $bb_post->post_id ) ) . "' class='delete:thread:post-{$bb_post->post_id}'>". __('Undelete') ."</a>";
    1340     else
    1341         $r = "<a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/delete-post.php?id=' . $bb_post->post_id . '&status=1', 'delete-post_' . $bb_post->post_id ) ) . "' class='delete:thread:post-{$bb_post->post_id}'>". __('Delete') ."</a>";
     1406    if ( 1 == $bb_post->post_status ) {
     1407        $query = array('id' => $bb_post->post_id, 'status' => 0, 'view' => 'all');
     1408        $display = __('Undelete');
     1409    } else {
     1410        $query = array('id' => $bb_post->post_id, 'status' => 1);
     1411        $display = __('Delete');
     1412    }
     1413    $uri = bb_get_uri('bb-admin/delete-post.php', $query, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     1414    $uri = attribute_escape( bb_nonce_url( $uri, 'delete-post_' . $bb_post->post_id ) );
     1415    $r = '<a href="' . $uri . '" class="delete:thread:post-' . $bb_post->post_id . '">' . $display . '</a>';
    13421416    $r = apply_filters( 'post_delete_link', $r, $bb_post->post_status, $bb_post->post_id );
    13431417    return $r;
     
    14191493}
    14201494
    1421 function user_profile_link( $id = 0 , $page = 1 ) {
    1422     echo apply_filters( 'user_profile_link', get_user_profile_link( $id ), bb_get_user_id( $id ) );
    1423 }
    1424 
    1425 function get_user_profile_link( $id = 0, $page = 1 ) {
     1495function user_profile_link( $id = 0 , $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
     1496    if (!$context || !is_integer($context)) {
     1497        $context = BB_URI_CONTEXT_A_HREF;
     1498    }
     1499    echo apply_filters( 'user_profile_link', get_user_profile_link( $id ), bb_get_user_id( $id ), $context );
     1500}
     1501
     1502function get_user_profile_link( $id = 0, $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
    14261503    $user = bb_get_user( bb_get_user_id( $id ) );
     1504   
     1505    if (!$context || !is_integer($context)) {
     1506        $context = BB_URI_CONTEXT_A_HREF;
     1507    }
     1508   
    14271509    $rewrite = bb_get_option( 'mod_rewrite' );
    14281510    if ( $rewrite ) {
     
    14321514            $column = 'ID';
    14331515        }
    1434         $r = bb_get_option('uri') . "profile/" . $user->$column . ( 1 < $page ? "/page/$page" : '' );
     1516        $page = $page > 1 ? '/page/' . $page : '';
     1517        $r = bb_get_uri('profile/' . $user->$column . $page, null, $context);
    14351518    } else {
    1436         $r = bb_get_option('uri') . "profile.php?id=$user->ID" . ( 1 < $page ? "&page=$page" : '' );
    1437     }
    1438     return apply_filters( 'get_user_profile_link', $r, $user->ID );
     1519        $query = array(
     1520            'id' => $user->ID,
     1521            'page' => $page > 1 ? $page : false
     1522        );
     1523        $r = bb_get_uri('profile.php', $query, $context);
     1524    }
     1525    return apply_filters( 'get_user_profile_link', $r, $user->ID, $context );
    14391526}
    14401527
     
    18141901    extract($args, EXTR_SKIP);
    18151902
    1816     return apply_filters( 'bb_get_logout_link', "$before<a href='" . attribute_escape( bb_get_option( 'uri' ) . 'bb-login.php?logout' ) . "'>$text</a>$after", $args );
     1903    $uri = attribute_escape( bb_get_uri('bb-login.php', array('logout' => 1), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS) );
     1904
     1905    return apply_filters( 'bb_get_logout_link', $before . '<a href="' . $uri . '">' . $text . '</a>' . $after, $args );
    18171906}
    18181907
     
    18331922    extract($args, EXTR_SKIP);
    18341923
    1835     return apply_filters( 'bb_get_admin_link', "$before<a href='" . attribute_escape( bb_get_option( 'uri' ) . 'bb-admin/' ) . "'>$text</a>$after", $args );
     1924    $uri = attribute_escape( bb_get_uri('bb-login.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) );
     1925
     1926    return apply_filters( 'bb_get_admin_link', $before . '<a href="' . $uri . '">' . $text . '</a>' . $after, $args );
    18361927}
    18371928
     
    19572048}
    19582049
    1959 function bb_tag_rss_link( $id = 0 ) {
    1960     echo apply_filters( 'tag_rss_link', bb_get_tag_rss_link($id), $id );
    1961 }
    1962 
    1963 function bb_get_tag_rss_link( $tag_id = 0 ) {
     2050function bb_tag_rss_link( $id = 0, $context = 0 ) {
     2051    if (!$context || !is_integer($context)) {
     2052        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     2053    }
     2054    echo apply_filters( 'tag_rss_link', bb_get_tag_rss_link($id, $context), $id, $context );
     2055}
     2056
     2057function bb_get_tag_rss_link( $tag_id = 0, $context = 0 ) {
    19642058    global $tag;
    19652059    $tag_id = (int) $tag_id;
     
    19692063        $_tag =& $tag;
    19702064
     2065    if (!$context || !is_integer($context)) {
     2066        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     2067    }
     2068
    19712069    if ( bb_get_option('mod_rewrite') )
    1972         $link = bb_get_option('uri') . "rss/tags/$_tag->tag";
     2070        $link = bb_get_uri('rss/tags/' . $_tag->tag, null, $context);
    19732071    else
    1974         $link = bb_get_option('uri') . "rss.php?tag=$_tag->tag";
    1975 
    1976     return apply_filters( 'get_tag_rss_link', $link, $tag_id );
     2072        $link = bb_get_uri('rss.php', array('tag' => $_tag->tag), $context);
     2073
     2074    return apply_filters( 'get_tag_rss_link', $link, $tag_id, $context );
    19772075}
    19782076
     
    20332131?>
    20342132
    2035 <form id="tag-form" method="post" action="<?php bb_option('uri'); ?>tag-add.php" class="add:<?php echo attribute_escape( $list_id ); ?>:">
     2133<form id="tag-form" method="post" action="<?php bb_uri('tag-add.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" class="add:<?php echo attribute_escape( $list_id ); ?>:">
    20362134    <p>
    20372135        <input name="tag" type="text" id="tag" />
     
    20512149    $form  = "<ul id='manage-tags'>\n ";
    20522150    $form .= "<li id='tag-rename'>" . __('Rename tag:') . "\n\t";
    2053     $form .= "<form method='post' action='" . bb_get_option('uri') . "bb-admin/tag-rename.php'><div>\n\t";
     2151    $form .= "<form method='post' action='" . bb_get_uri('bb-admin/tag-rename.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN) . "'><div>\n\t";
    20542152    $form .= "<input type='text' name='tag' size='10' maxlength='30' />\n\t";
    20552153    $form .= "<input type='hidden' name='id' value='$tag->tag_id' />\n\t";
     
    20592157    echo "\n\t</div></form>\n  </li>\n ";
    20602158    $form  = "<li id='tag-merge'>" . __('Merge this tag into:') . "\n\t";
    2061     $form .= "<form method='post' action='" . bb_get_option('uri') . "bb-admin/tag-merge.php'><div>\n\t";
     2159    $form .= "<form method='post' action='" . bb_get_uri('bb-admin/tag-merge.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN) . "'><div>\n\t";
    20622160    $form .= "<input type='text' name='tag' size='10' maxlength='30' />\n\t";
    20632161    $form .= "<input type='hidden' name='id' value='$tag->tag_id' />\n\t";
     
    20682166    echo "\n\t</div></form>\n  </li>\n ";
    20692167    $form  = "<li id='tag-destroy'>" . __('Destroy tag:') . "\n\t";
    2070     $form .= "<form method='post' action='" . bb_get_option('uri') . "bb-admin/tag-destroy.php'><div>\n\t";
     2168    $form .= "<form method='post' action='" . bb_get_uri('bb-admin/tag-destroy.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN) . "'><div>\n\t";
    20712169    $form .= "<input type='hidden' name='id' value='$tag->tag_id' />\n\t";
    20722170    $form .= "<input type='submit' name='Submit' value='" . __('Destroy') . "' ";
     
    20942192    if ( !bb_current_user_can( 'edit_tag_by_on', $tag->user_id, $topic->topic_id ) )
    20952193        return false;
    2096     $url = add_query_arg( array('tag' => $tag->tag_id, 'user' => $tag->user_id, 'topic' => $tag->topic_id), bb_get_option('uri') . 'tag-remove.php' );
     2194    $url = bb_get_uri('tag-remove.php', array('tag' => $tag->tag_id, 'user' => $tag->user_id, 'topic' => $tag->topic_id) );
    20972195    $url = clean_url( bb_nonce_url( $url, 'remove-tag_' . $tag->tag_id . '|' . $tag->topic_id) );
    20982196    $title = attribute_escape( __('Remove this tag') );
     
    23352433}
    23362434
    2337 function favorites_rss_link( $id = 0 ) {
    2338     echo apply_filters('favorites_rss_link', get_favorites_rss_link( $id ));
    2339 }
    2340 
    2341 function get_favorites_rss_link( $id = 0 ) {
     2435function favorites_rss_link( $id = 0, $context = 0 ) {
     2436    if (!$context || !is_integer($context)) {
     2437        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     2438    }
     2439    echo apply_filters('favorites_rss_link', get_favorites_rss_link( $id, $context ), $context);
     2440}
     2441
     2442function get_favorites_rss_link( $id = 0, $context = 0 ) {
    23422443    $user = bb_get_user( bb_get_user_id( $id ) );
     2444   
     2445    if (!$context || !is_integer($context)) {
     2446        $context = BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_FEED;
     2447    }
     2448   
    23432449    $rewrite = bb_get_option( 'mod_rewrite' );
    23442450    if ( $rewrite ) {
     
    23482454            $column = 'ID';
    23492455        }
    2350         $link = bb_get_option('uri') . 'rss/profile/' . $user->$column;
     2456        $link = bb_get_uri('rss/profile/' . $user->$column, null, $context);
    23512457    } else {
    2352         $link = bb_get_option('uri') . 'rss.php?profile=' . $user->ID;
    2353     }
    2354     return apply_filters( 'get_favorites_rss_link', $link, $user->ID );
     2458        $link = bb_get_uri('rss.php', array('profile' => $user->ID), $context);
     2459    }
     2460    return apply_filters( 'get_favorites_rss_link', $link, $user->ID, $context );
    23552461}
    23562462
     
    23812487}
    23822488
    2383 function view_link( $_view = false, $page = 1 ) {
    2384     echo get_view_link( $_view, $page );
    2385 }
    2386 
    2387 function get_view_link( $_view = false, $page = 1 ) {
     2489function view_link( $_view = false, $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
     2490    echo get_view_link( $_view, $page, $context );
     2491}
     2492
     2493function get_view_link( $_view = false, $page = 1, $context = BB_URI_CONTEXT_A_HREF ) {
    23882494    global $view, $bb_views;
    23892495    if ( $_view )
     
    23912497    else
    23922498        $v =& $view;
    2393 
     2499   
     2500    if (!$context || !is_integer($context)) {
     2501        $context = BB_URI_CONTEXT_A_HREF;
     2502    }
     2503   
    23942504    if ( !array_key_exists($v, $bb_views) )
    2395         return bb_get_option('uri');
    2396     if ( bb_get_option('mod_rewrite') )
    2397         $link = bb_get_option('uri') . 'view/' . $v . ( 1 < $page ? "/page/$page" : '' );
    2398     else
    2399         $link = bb_get_option('uri') . "view.php?view=$v" . ( 1 < $page ? "&page=$page" : '');
    2400 
    2401     return apply_filters( 'get_view_link', $link, $v, $page );
     2505        return bb_get_uri(null, null, $context);
     2506    if ( bb_get_option('mod_rewrite') ) {
     2507        $page = $page > 1 ? '/page/' . $page : '';
     2508        $link = bb_get_uri('view/' . $v . $page, null, $context);
     2509    } else {
     2510        $query = array(
     2511            'page' => $page > 1 ? $page : false
     2512        );
     2513        $link = bb_get_uri('view.php', $query, $context);
     2514    }
     2515
     2516    return apply_filters( 'get_view_link', $link, $v, $page, $context );
    24022517}
    24032518
  • trunk/bb-login.php

    r1380 r1575  
    66    $re = $ref;
    77
    8 $home_url = parse_url( bb_get_option( 'uri' ) );
     8$home_url = parse_url( bb_get_uri(null, null, BB_URI_CONTEXT_TEXT) );
    99$home_path = $home_url['path'];
    1010
    1111if ( !$re || false !== strpos($re, $home_path . 'register.php') || false !== strpos($re, $home_path . 'bb-reset-password.php') )
    12     $re = bb_get_option( 'uri' );
     12    $re = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
    1313
    1414$re = clean_url( $re );
  • trunk/bb-plugins/akismet.php

    r1385 r1575  
    8181function bb_akismet_verify_key( $key ) {
    8282    global $bb_ksd_api_port;
    83     $blog = urlencode( bb_get_option('uri') );
     83    $blog = urlencode( bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET) );
    8484    $response = bb_ksd_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $bb_ksd_api_port);
    8585    if ( 'valid' == $response[1] )
     
    128128
    129129        $_submit = array(
    130             'blog' => bb_get_option('uri'),
     130            'blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET),
    131131            'user_ip' => $bb_post->poster_ip,
    132132            'permalink' => get_topic_link( $bb_post->topic_id ), // First page
     
    150150
    151151        $_submit = array(
    152             'blog' => bb_get_option('uri'),
     152            'blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET),
    153153            'permalink' => get_user_profile_link( $user->ID ),
    154154            'comment_type' => 'profile',
     
    167167
    168168        $_submit = array(
    169             'blog' => bb_get_option('uri'),
     169            'blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET),
    170170            'user_ip' => preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ),
    171171            'user_agent' => $_SERVER['HTTP_USER_AGENT'],
     
    292292    if ( !bb_current_user_can('moderate') )
    293293        return $link;
    294     if ( 2 == $post_status )
    295         $link .= " <a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/delete-post.php?id=' . get_post_id() . '&status=0&view=all', 'delete-post_' . get_post_id() ) ) . "' >" . __('Not Spam') ."</a>";
    296     else
    297         $link .= " <a href='" . attribute_escape( bb_nonce_url( bb_get_option('uri') . 'bb-admin/delete-post.php?id=' . get_post_id() . '&status=2', 'delete-post_' . get_post_id() ) ) . "' >" . __('Spam') ."</a>";
     294    if ( 2 == $post_status ) {
     295        $query = array(
     296            'id'     => get_post_id(),
     297            'status' => 0,
     298            'view'   => 'all'
     299        );
     300        $display = __('Not Spam');
     301    } else {
     302        $query = array(
     303            'id'     => get_post_id(),
     304            'status' => 2
     305        );
     306        $display = __('Spam');
     307    }
     308    $uri = bb_get_uri('bb-admin/delete-post.php', $query, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN);
     309    $uri = attribute_escape( bb_nonce_url( $uri, 'delete-post_' . get_post_id() ) );
     310    $link .= " <a href='" . $uri . "' >" . $display ."</a>";
    298311    return $link;
    299312}
  • trunk/bb-post.php

    r1435 r1575  
    5252    wp_redirect( $link );
    5353else
    54     wp_redirect( bb_get_option( 'uri' ) );
     54    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    5555exit;
    5656
  • trunk/bb-settings.php

    r1571 r1575  
    405405    $bb->uri = rtrim($bb->uri, '/') . '/';
    406406   
    407     // Not used in core anymore, only set here for plugin compatibility
    408407    if ( preg_match( '@^(https?://[^/]+)((?:/.*)*/{1,1})$@i', $bb->uri, $matches ) ) {
     408        // Not used in core anymore, only set here for plugin compatibility
    409409        $bb->domain = $matches[1];
     410        // Used when setting up cookie paths
    410411        $bb->path = $matches[2];
    411412    }
     
    432433    bb_die( __('Could not determine site URI') );
    433434}
     435
     436/**
     437 * BB_FORCE_SSL_USER_FORMS - Whether to force use of ssl on user forms like login, registration and profile editing
     438 **/
     439if ( !defined('BB_FORCE_SSL_USER_FORMS') ) {
     440    define('BB_FORCE_SSL_USER_FORMS', false);
     441}
     442bb_force_ssl_user_forms(BB_FORCE_SSL_USER_FORMS);
     443
     444/**
     445 * BB_FORCE_SSL_ADMIN - Whether to force use of ssl in the admin area
     446 **/
     447if ( !defined('BB_FORCE_SSL_ADMIN') ) {
     448    define('BB_FORCE_SSL_ADMIN', false);
     449}
     450bb_force_ssl_admin(BB_FORCE_SSL_ADMIN);
    434451
    435452
  • trunk/bb-templates/kakumei/edit-post.php

    r528 r1575  
    11<?php bb_get_header(); ?>
    2 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Edit Post'); ?></h3>
     2<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Edit Post'); ?></h3>
    33
    44<?php edit_form(); ?>
  • trunk/bb-templates/kakumei/favorites.php

    r1480 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Favorites'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Favorites'); ?></h3>
    44
    55<h2 id="currentfavorites"><?php _e('Current Favorites'); ?><?php if ( $topics ) echo ' (' . $favorites_total . ')'; ?></h2>
  • trunk/bb-templates/kakumei/forum.php

    r1531 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a><?php bb_forum_bread_crumb(); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a><?php bb_forum_bread_crumb(); ?></h3>
    44
    55<?php if ( $topics || $stickies ) : ?>
     
    3131<?php endforeach; endif; ?>
    3232</table>
    33 <p><a href="<?php forum_rss_link(); ?>" class="rss-link"><?php _e('RSS feed for this forum'); ?></a></p>
     33<p><a href="<?php bb_forum_posts_rss_link(); ?>" class="rss-link"><?php _e('RSS feed for this forum'); ?></a></p>
    3434<div class="nav">
    3535<?php forum_pages(); ?>
  • trunk/bb-templates/kakumei/front-page.php

    r1531 r1575  
    8080<?php else : // $forums ?>
    8181
    82 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a></h3>
     82<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a></h3>
    8383
    8484<?php post_form(); endif; // $forums ?>
  • trunk/bb-templates/kakumei/header.php

    r1487 r1575  
    1515
    1616<body id="<?php bb_location(); ?>">
    17    
    1817    <div id="wrapper">
    1918   
    2019        <div id="header">
    21             <h1><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a></h1>
     20            <h1><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a></h1>
    2221            <?php if ( bb_get_option('description') ) : ?><p class="description"><?php bb_option('description'); ?></p><?php endif; ?>
    2322
  • trunk/bb-templates/kakumei/login-form.php

    r1290 r1575  
    1 <form class="login" method="post" action="<?php bb_option('uri'); ?>bb-login.php">
    2     <p><?php printf(__('<a href="%1$s">Register</a> or log in'), bb_get_option('uri').'register.php') ?>:</p>
     1<form class="login" method="post" action="<?php bb_uri('bb-login.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_USER_FORMS); ?>">
     2    <p><?php printf(__('<a href="%1$s">Register</a> or log in'), bb_get_uri('register.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS)) ?>:</p>
    33    <div>
    44        <label><?php _e('Username:'); ?><br />
  • trunk/bb-templates/kakumei/login.php

    r1502 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Log in'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Log in'); ?></h3>
    44
    55<h2 id="userlogin"><?php isset($_POST['user_login']) ? _e('Log in Failed') : _e('Log in') ; ?></h2>
    66
    7 <form method="post" action="<?php bb_option('uri'); ?>bb-login.php">
     7<form method="post" action="<?php bb_uri('bb-login.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_USER_FORMS); ?>">
    88<fieldset>
    99<table>
     
    2222        <th scope="row"><label for="user_login"><?php _e('Username:'); ?></label></th>
    2323        <td><input name="user_login" id="user_login" type="text" value="<?php echo $user_login; ?>" /><br />
    24         <?php _e('This username does not exist.'); ?> <a href="<?php bb_option('uri'); ?>register.php?user=<?php echo $user_login; ?>"><?php _e('Register it?'); ?></a></td>
     24        <?php _e('This username does not exist.'); ?> <a href="<?php bb_uri('register.php', array('user' => $user_login), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS); ?>"><?php _e('Register it?'); ?></a></td>
    2525    </tr>
    2626    <tr valign="top">
     
    5555
    5656<?php if ( $user_exists ) : ?>
    57 <form method="post" action="<?php bb_option('uri'); ?>bb-reset-password.php">
     57<form method="post" action="<?php bb_uri('bb-reset-password.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_USER_FORMS); ?>">
    5858<fieldset>
    5959    <p><?php _e('If you would like to recover the password for this account, you may use the following button to start the recovery process:'); ?></p>
  • trunk/bb-templates/kakumei/password-reset.php

    r977 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Log in'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Log in'); ?></h3>
    44
    55<h2><?php _e('Password Reset'); ?></h2>
  • trunk/bb-templates/kakumei/profile-base.php

    r663 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php echo $profile_page_title; ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php echo $profile_page_title; ?></h3>
    44<h2><?php echo get_user_name( $user->ID ); ?></h2>
    55
  • trunk/bb-templates/kakumei/profile-edit.php

    r1433 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Edit Profile'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Edit Profile'); ?></h3>
    44<h2 id="userlogin"><?php echo get_user_name( $user->ID ); ?></h2>
    55<form method="post" action="<?php profile_tab_link($user->ID, 'edit');  ?>">
  • trunk/bb-templates/kakumei/profile.php

    r1328 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Profile') ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Profile') ?></h3>
    44<div id="useravatar"><?php echo bb_get_avatar( $user->ID ); ?></div>
    55<h2 id="userlogin"><?php echo get_user_name( $user->ID ); ?></h2>
  • trunk/bb-templates/kakumei/register-success.php

    r528 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Register'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Register'); ?></h3>
    44
    55<h2 id="register"><?php _e('Great!'); ?></h2>
  • trunk/bb-templates/kakumei/register.php

    r1502 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Register'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Register'); ?></h3>
    44
    55<h2 id="register"><?php _e('Registration'); ?></h2>
    66
    77<?php if ( !bb_is_user_logged_in() ) : ?>
    8 <form method="post" action="<?php bb_option('uri'); ?>register.php">
     8<form method="post" action="<?php bb_uri('register.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_USER_FORMS); ?>">
    99<fieldset>
    1010<legend><?php _e('Profile Information'); ?></legend>
  • trunk/bb-templates/kakumei/rss2.php

    r1489 r1575  
    1010<channel>
    1111<title><?php echo $title; ?></title>
    12 <link><?php bb_option('uri'); ?></link>
     12<link><?php bb_uri(); ?></link>
    1313<description><?php echo $description; ?></description>
    1414<language>en</language>
     
    2121<pubDate><?php bb_post_time('D, d M Y H:i:s +0000'); ?></pubDate>
    2222<dc:creator><?php post_author(); ?></dc:creator>
    23 <guid isPermaLink="false"><?php post_id(); ?>@<?php bb_option('uri'); ?></guid>
     23<guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid>
    2424<description><?php post_text(); ?></description>
    2525</item>
  • trunk/bb-templates/kakumei/search-form.php

    r1502 r1575  
    1 <form action="<?php bb_option('uri'); ?>search.php" method="get">
     1<form action="<?php bb_uri('search.php', null, BB_URI_CONTEXT_FORM_ACTION); ?>" method="get">
    22    <label class="hidden" for="q"><?php _e('Search:'); ?></label>
    33    <input class="text" type="text" size="14" maxlength="100" name="q" id="q" />
  • trunk/bb-templates/kakumei/search.php

    r1160 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Search')?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Search')?></h3>
    44<?php bb_topic_search_form(); ?>
    55
     
    3636<?php endif; ?>
    3737<br />
    38 <p><?php printf(__('You may also try your <a href="http://google.com/search?q=site:%1$s %2$s">search at Google</a>'), bb_get_option('uri'), urlencode($q)) ?></p>
     38<p><?php printf(__('You may also try your <a href="http://google.com/search?q=site:%1$s %2$s">search at Google</a>'), bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), urlencode($q)) ?></p>
    3939<?php bb_get_footer(); ?>
  • trunk/bb-templates/kakumei/stats.php

    r968 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Statistics'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Statistics'); ?></h3>
    44
    55<dl>
  • trunk/bb-templates/kakumei/tag-single.php

    r1337 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <a href="<?php bb_tag_page_link(); ?>"><?php _e('Tags'); ?></a> &raquo; <?php bb_tag_name(); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <a href="<?php bb_tag_page_link(); ?>"><?php _e('Tags'); ?></a> &raquo; <?php bb_tag_name(); ?></h3>
    44
    55<?php do_action('tag_above_table', ''); ?>
  • trunk/bb-templates/kakumei/tags.php

    r941 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Tags'); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Tags'); ?></h3>
    44
    55<p><?php _e('This is a collection of tags that are currently popular on the forums.'); ?></p>
  • trunk/bb-templates/kakumei/topic.php

    r1512 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a><?php bb_forum_bread_crumb(); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a><?php bb_forum_bread_crumb(); ?></h3>
    44<div class="infobox">
    55
  • trunk/bb-templates/kakumei/view.php

    r1337 r1575  
    11<?php bb_get_header(); ?>
    22
    3 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php view_name(); ?></h3>
     3<h3 class="bbcrumb"><a href="<?php bb_uri(); ?>"><?php bb_option('name'); ?></a> &raquo; <?php view_name(); ?></h3>
    44
    55<?php if ( $topics || $stickies ) : ?>
  • trunk/edit.php

    r728 r1575  
    99
    1010if ( !$bb_post || !bb_current_user_can( 'edit_post', $post_id ) ) {
    11     wp_redirect( bb_get_option( 'uri' ) );
     11    wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    1212    die();
    1313}
  • trunk/favorites.php

    r1285 r1575  
    2323
    2424    $ref = wp_get_referer();
    25     if ( false !== strpos( $ref, bb_get_option('uri') ) )
     25    if ( false !== strpos( $ref, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT) ) )
    2626        bb_safe_redirect( $ref );
    2727    else
  • trunk/profile-edit.php

    r1448 r1575  
    55
    66if ( !bb_current_user_can( 'edit_user', $user_id ) ) {
    7     $sendto = bb_get_option('uri');
     7    $sendto = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);
    88    wp_redirect( $sendto );
    99}
     
    5353        if ( isset($_POST['delete-user']) && $_POST['delete-user'] && $bb_current_id != $user->ID ) {
    5454            bb_delete_user( $user->ID );
    55             wp_redirect( bb_get_option( 'uri' ) );
     55            wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
    5656            exit;
    5757        }
Note: See TracChangeset for help on using the changeset viewer.