Esempio n. 1
0
/**
 * We use the blogfilter function to define all the page urls
 *
 * @params the name of the page
 * @params 'display'
 * @return string url
 *
 */
function hma_blogfilter($arg, $arg2)
{
    switch ($arg2) {
        case 'login_url':
            return apply_filters('hma_login_url', home_url(trailingslashit(hma_get_login_rewrite_slug())));
            break;
        case 'login_inline_url':
            return apply_filters('hma_login_inline_url', home_url(trailingslashit(hma_get_login_inline_rewrite_slug())));
            break;
        case 'register_url':
            return apply_filters('hma_register_url', home_url(trailingslashit(hma_get_register_rewrite_slug())));
            break;
        case 'register_inline_url':
            return apply_filters('hma_register_inline_url', home_url(trailingslashit(hma_get_lost_password_inline_rewrite_slug())));
            break;
        case 'lost_password_url':
            return apply_filters('hma_lost_password_url', home_url(trailingslashit(hma_get_lost_password_rewrite_slug())));
            break;
        case 'lost_password_inline_url':
            return apply_filters('hma_lot_password_inline_url', home_url(trailingslashit(hma_get_lost_password_inline_rewrite_slug())));
            break;
        case 'my_profile_url':
            _deprecated_argument(__FUNCTION__, '2.0', 'Use edit_profile_url instead of my_profile_url');
            return apply_filters('hma_my_profile_url', home_url(trailingslashit(hma_get_edit_profile_rewrite_slug())));
            break;
        case 'edit_profile_url':
            return apply_filters('hma_edit_profile_url', home_url(trailingslashit(hma_get_edit_profile_rewrite_slug())));
            break;
        case 'logout_url':
            // TODO couldn't this just add action = logout to the current url?
            return add_query_arg('action', 'logout', hma_get_login_url());
            break;
    }
    return $arg;
}
Esempio n. 2
0
/**
 * Create the rewrite rules for the user accounts section
 *
 * Will only create rules for the template files that exist
 *
 * @return null
 */
function hma_rewrite_rules()
{
    if (file_exists($login = hma_get_login_template())) {
        hm_add_rewrite_rule('^' . hma_get_login_rewrite_slug() . '/?$', 'is_login=1', $login, array('post_query_properties' => array('is_home' => false, 'is_404' => false, 'is_login' => true), 'permission' => 'logged_out_only'));
    }
    if (file_exists($login_inline = hma_get_login_inline_template())) {
        hm_add_rewrite_rule('^' . hma_get_login_inline_rewrite_slug() . '/?$', 'is_login=1', $login_inline, array('post_query_properties' => array('is_home' => false, 'is_404' => false, 'is_login' => true), 'permission' => 'logged_out_only'));
    }
    if (file_exists($lost_pass = hma_get_lost_password_template())) {
        hm_add_rewrite_rule('^' . hma_get_lost_password_rewrite_slug() . '/?$', 'is_lost_password=1', $lost_pass, array('post_query_properties' => array('is_home' => false, 'is_404' => false, 'is_lost_password' => true), 'permission' => 'logged_out_only'));
    }
    if (file_exists($lost_pass_inline = hma_get_lost_password_inline_template())) {
        hm_add_rewrite_rule('^' . hma_get_lost_password_inline_rewrite_slug() . '/?$', 'is_lost_password=1', $lost_pass_inline, array('post_query_properties' => array('is_home' => false, 'is_404' => false, 'is_lost_password' => true), 'permission' => 'logged_out_only'));
    }
    if (file_exists($register = hma_get_register_template())) {
        hm_add_rewrite_rule('^' . hma_get_register_rewrite_slug() . '/?$', 'is_register=1', $register, array('post_query_properties' => array('is_home' => false, 'is_404' => false, 'is_register' => true), 'permission' => 'logged_out_only'));
    }
    if (file_exists($register_inline = hma_get_register_inline_template())) {
        hm_add_rewrite_rule('^' . hma_get_register_inline_rewrite_slug() . '/?$', 'is_register=1', $register_inline, array('post_query_properties' => array('is_home' => false, 'is_404' => false, 'is_register' => true), 'permission' => 'logged_out_only'));
    }
    if (file_exists($edit_profile = hma_get_edit_profile_template())) {
        hm_add_rewrite_rule('^' . hma_get_edit_profile_rewrite_slug() . '/?$', 'author_name=$matches[1]&is_profile=1', $edit_profile, array('post_query_properties' => array('is_home' => false, 'is_edit_profile' => true), 'permission' => 'displayed_user_only', 'request_callback' => function ($request) {
            if (is_user_logged_in()) {
                $request->query_vars['author'] = get_current_user_id();
            }
        }));
    }
    if (file_exists($profile = hma_get_user_profile_template())) {
        hm_add_rewrite_rule('^' . hma_get_user_profile_rewrite_slug() . '/([^\\/]*)(/page/([\\d]*))?/?$', 'author_name=$matches[1]&paged=$matches[3]', $profile, array('post_query_properties' => array('is_home' => false, 'is_user_profile' => true)));
    }
    // Single Sign On
    hm_add_rewrite_rule('^login/sso/twitter/authenticate/?$', 'is_login=1&is_twitter_popup=1', null, array('post_query_properties' => array('is_login' => true)));
    hm_add_rewrite_rule('^login/sso/twitter/authenticate/callback/?$', 'is_login=1&is_twitter_popup=1', null, array('post_query_properties' => array('is_login' => true)));
    hm_add_rewrite_rule('^login/sso/authenticated/?$', 'is_login=1', null, array('post_query_properties' => array('is_login' => true)));
    hm_add_rewrite_rule('^register/sso/authenticated/?$', 'is_register=1', null, array('post_query_properties' => array('is_register' => true)));
    hm_add_rewrite_rule('^profile/sso/authenticated/?$', 'is_login=1');
    hm_add_rewrite_rule('^profile/sso/deauthenticate/?$', 'is_login=1');
    do_action('hma_added_rewrite_rules');
}