Skip to content

Commit

Permalink
Add backend shortcut routing on env('WP_BACNENDURL') != env('WP_SITEU…
Browse files Browse the repository at this point in the history
…RL').
  • Loading branch information
jumilla committed Jul 14, 2015
1 parent 7511092 commit db2e6dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions app/Http/wp-routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,21 @@ function add_site_file_download_routes($app)
// Login Gate
$app->group(['prefix' => $wp_backend_prefix, 'namespace' => $wp_namespace], function ($app) {
// ?action = ['postpass', 'logout', logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register']
$app->get('login', 'GateController@login');
$app->get('wp-login.php', 'GateController@login');
$app->post('wp-login.php', 'GateController@login');
});

// Shortcuts
$app->group(['prefix' => $wp_backend_prefix, 'namespace' => $wp_namespace], function ($app) {
$admin_url = config('wordpress.url.backend').'/wp-admin/';

$admin_url = rtrim(config('wordpress.url.backend'), '/').'/wp-admin/';
// WordPress+ original routing
if (config('wordpress.url.backend') != config('wordpress.url.site')) {
$app->get('', function () use ($admin_url) { return redirect()->to($admin_url); });
}

// MEMO from wp_redirect_admin_locations() on 'wp-includes/canonical.php'
$app->get('login', 'GateController@login');
$app->get('admin', function () use ($admin_url) { return redirect()->to($admin_url); });
$app->get('dashboard', function () use ($admin_url) { return redirect()->to($admin_url); });
});
Expand Down
4 changes: 2 additions & 2 deletions config/wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

return [
'url' => [
'backend' => env('WP_BACKENDURL'),
'site' => env('WP_SITEURL'),
'backend' => rtrim(env('WP_BACKENDURL'), '/'),
'site' => rtrim(env('WP_SITEURL'), '/'),
'backend_prefix' => trim(parse_url(env('WP_BACKENDURL'), PHP_URL_PATH), '/').'/',
'site_prefix' => trim(parse_url(env('WP_SITEURL'), PHP_URL_PATH), '/').'/',
],
Expand Down

0 comments on commit db2e6dc

Please sign in to comment.