Nicer WP interfacing & allow CMS to be outside /cms
Diff
src/Providers/WordpressServiceProvider.php | 7 ++++---
src/Support/Wordpress.php | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 5 deletions(-)
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Koselig\Guards\WordpressGuard;
use Koselig\Support\Action;
use Koselig\Support\Wordpress;
/**
* Service provider for everything Wordpress, configures
@@ -174,13 +175,13 @@ class WordpressServiceProvider extends ServiceProvider
// separate directories.
Action::hook('network_site_url', function ($url, $path, $scheme) {
if ($scheme == 'relative') {
$url = get_current_site()->path;
$url = Wordpress::site()->path;
} else {
$url = set_url_scheme('http://' . get_current_site()->domain . get_current_site()->path, $scheme);
$url = set_url_scheme('http://' . Wordpress::site()->domain . Wordpress::site()->path, $scheme);
}
if ($path && is_string($path)) {
$url .= 'cms/' . ltrim($path, '/');
$url .= str_replace('public/', '', WP_PATH) . ltrim($path, '/');
}
return $url;
@@ -80,7 +80,7 @@ class Wordpress
}
}
return $id === null ? is_multisite() : ($id === static::getMultisite());
return $id === null ? is_multisite() : ($id === static::getSiteId());
}
/**
@@ -88,16 +88,28 @@ class Wordpress
*
* @return int
*/
public static function getMultisite()
public static function getSiteId()
{
return get_current_blog_id();
}
/**
* Get the current site that the user is currently browsing.
*
* @return \WP_Network
*/
public static function site()
{
return get_current_site();
}
/**
* Get the current logged in user. Generally, you shouldn't be using this
* function and should instead be using Auth::user() from Laravel to get
* the current logged in Wordpress user.
*
* Use of WP_User is deprecated, however this method will not be removed.
*
* @return \WP_User
*/
public static function currentUser()