\DewdropPaths

This utility makes it easier to navigate the WP environment by supplying quick access to common Dewdrop paths. Being out in the middle of the plugins folder can make it hard to find your way around, so rather than manually traversing back up the filesystem with a bunch of "__DIR__ . '/.

./../../../../'" messiness, just use the methods in this class to find your way around.

Summary

Methods
Properties
Constants
__construct()
getRoot()
isWp()
getWpRoot()
getDewdropLib()
getPluginRoot()
getAppRoot()
getWww()
getActivityLog()
getAdmin()
getCommands()
getData()
getDb()
getLib()
getVendor()
getModels()
getShortCodes()
getTests()
No public properties found
No constants found
detectRoot()
detectPluginRoot()
$root
$dewdropLib
$pluginRoot
N/A
No private methods found
No private properties found
N/A

Properties

$root

$root : string

The root of the WordPress installation (i.e. the folder containing wp-config.php).

Type

string

$dewdropLib

$dewdropLib : string

The location of the Dewdrop libraries.

Type

string

$pluginRoot

$pluginRoot : string

The root folder of your plugin.

Type

string

Methods

__construct()

__construct() 

Find the 3 core paths:

  • The WP root
  • The lib folder
  • The plugin root

getRoot()

getRoot() : string

The root of the WP install (i.e. where wp-config.php lives)

Throws

\Dewdrop\Exception

Returns

string

isWp()

isWp() : boolean

Check to see if we're running in WP. We currently just look for the WPINC constant, but there might be better ways of detecting this.

Returns

boolean

getWpRoot()

getWpRoot() : string

This is just an alias to getRoot(). Used by some older Dewdrop code.

Returns

string

getDewdropLib()

getDewdropLib() : string

The Dewdrop folder inside "vendor"

Returns

string

getPluginRoot()

getPluginRoot() : string

The root of your Dewdrop-based plugin

Returns

string

getAppRoot()

getAppRoot() : string

Just an alias for getPluginRoot() that can be called when not using Dewdrop in the context of a WordPress plugin.

Returns

string

getWww()

getWww() : string

We expect a "www" folder inside the plugin/app root where client-side assets can be included.

Returns

string

getActivityLog()

getActivityLog() : string

Get the folder where we can find custom activity log handlers.

Returns

string

getAdmin()

getAdmin() : string

The folder housing your admin components

Returns

string

getCommands()

getCommands() : string

The folder where custom CLI commands are located.

Returns

string

getData()

getData() : string

Get the data folder where Dewdrop can write data on the server.

Returns

string

getDb()

getDb() : string

The folder housing your dbdeploy deltas

Returns

string

getLib()

getLib() : string

The "lib" folder inside your plugin

Returns

string

getVendor()

getVendor() : string

The "vendor" folder inside your plugin.

Returns

string

getModels()

getModels() : string

The folder housing your models

Returns

string

getShortCodes()

getShortCodes() : string

The folder housing your shortcodes

Returns

string

getTests()

getTests() : string

The folder housing your plugin's tests

Returns

string

detectRoot()

detectRoot() : string

Detect the root path for this application. This is either the main working directory for a standalone application, or the WordPress root folder in WP plugin -- the folder containing wp-config.php.

Returns

string

detectPluginRoot()

detectPluginRoot() : string

Detect the plugin or app root folder. In a standalone app, we traverse up the filesystem until we exit the Composer-created vendor folder. Using this approach, rather than just grabbing the current working directory, allows Dewdrop to work consistently regardless of whether the application is all running inside the document root or with only a front controller in the document root and the remainder of the code stored elsewhere. In a WordPress app, it is the folder housing the plugin based on Dewdrop.

Returns

string