chavewain
12/16/2016 - 2:43 PM

wordpress Routes - access to a method through url

wordpress Routes - access to a method through url

function create_routes( $router ) {
    $router->add_route('facebook-login', array(
        'path' => 'login',
        'access_callback' => true,
        'page_callback' => 'facebook_login'
    ));
    $router->add_route('facebook-logout', array(
        'path' => 'logout',
        'access_callback' => true,
        'page_callback' => 'facebook_logout'
    ));
    $router->add_route('error', array(
        'path' => 'error',
        'access_callback' => true,
        'page_callback' => 'error'
    ));
}
add_action( 'wp_router_generate_routes', 'create_routes' );

function facebook_login() {
    if ($facebook_user) {
        load_template(get_template_directory() . '/template-checkout.php', false );
    } else {
        load_template(get_template_directory() . '/template-checkout.php', false );
    }
    exit();
}

function facebook_logout() {
    exit();
}

function error() {
    exit();
}