Skip to content

Function

Parse the request.

tml_parse_request( $wp )

Parameters

$wp
WP The WordPress object.

Source

function tml_parse_request( $wp ) {

    if ( ! isset( $wp->query_vars['action'] ) ) {
        return;
    }

    $action = $wp->query_vars['action'];

    // Fix some alias actions
    if ( 'retrievepassword' === $action ) {
        $action = 'lostpassword';
    } elseif ( 'rp' === $action ) {
        $action = 'resetpass';
    }

    // Ensure that the permalink action is passed
    if ( ! empty( $wp->did_permalink ) && false === strpos( $wp->matched_query, "action=$action" ) ) {

        // Get the action from the matched query
        preg_match( '/action=([^&]+)/', $wp->matched_query, $matches );
        if ( ! empty( $matches ) ) {
            $action = $matches[1];
        }
    }

    // Bail if not a TML action
    if ( ! tml_action_exists( $action ) ) {
        return;
    }

    // Set the proper action
    if ( $action !== $wp->query_vars['action'] ) {
        $wp->set_query_var( 'action', $action );
    }
}

Uses

Changelog

VersionDescription
7.0.10 Introduced.