🏡 index : ~doyle/koselig.git

author Jordan Doyle <jordan@doyle.wf> 2016-10-07 11:58:01.0 +00:00:00
committer Jordan Doyle <jordan@doyle.wf> 2016-10-07 11:58:01.0 +00:00:00
commit
deb2e457c49ec7e31ba1545936d90397e43ff937 [patch]
tree
985f455bcb728651eee9c7bd86cbddcc1d1a59a3
parent
749811172b4e0feef46d63b7b98b0798b51ae607
download
deb2e457c49ec7e31ba1545936d90397e43ff937.tar.gz

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(-)

diff --git a/src/Providers/WordpressServiceProvider.php b/src/Providers/WordpressServiceProvider.php
index 88e91ee..8b80600 100644
--- a/src/Providers/WordpressServiceProvider.php
+++ b/src/Providers/WordpressServiceProvider.php
@@ -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;
diff --git a/src/Support/Wordpress.php b/src/Support/Wordpress.php
index 8b18435..dec572a 100644
--- a/src/Support/Wordpress.php
+++ b/src/Support/Wordpress.php
@@ -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()