class CRM_Utils_System_WordPress extends CRM_Utils_System_Base

WordPress specific stuff goes here

Properties

bool $is_drupal Deprecated property to check if this is a drupal install. from CRM_Utils_System_Base
bool $is_joomla Deprecated property to check if this is a joomla install. The correct method is to have functions on the UF classes for all UF specific functions and leave the codebase oblivious to the type of CMS from CRM_Utils_System_Base
bool $is_wordpress deprecated property to check if this is a wordpress install. The correct method is to have functions on the UF classes for all UF specific functions and leave the codebase oblivious to the type of CMS from CRM_Utils_System_Base
bool $supports_UF_Logging Does this CMS / UF support a CMS specific logging mechanism? from CRM_Utils_System_Base
bool $supports_form_extensions from CRM_Utils_System_Base

Methods

initialize()

No description

loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL)

Load wordpress bootstrap.

appendBreadCrumb(array $breadCrumbs)

No description

resetBreadCrumb()

No description

addHTMLHead(string $head)

No description

mapConfigToSSL()

No description

string
postURL(string $action)

Figure out the post url for QuickForm.

string
url(string $path = NULL, string $query = NULL, bool $absolute = FALSE, string $fragment = NULL, bool $frontend = FALSE, bool $forceBackend = FALSE)

No description

array|bool
authenticate(string $name, string $password, bool $loadCMSBootstrap = FALSE, string $realPath = NULL)

No description

setMessage(string $message)

FIXME: Do something

bool
loadUser(obj $user)

No description

permissionDenied()

FIXME: Use CMS-native approach

logout()

No description

updateCategories()

Clear CMS caches related to the user registration/profile forms.

string|null
getUFLocale()

No description

string|null
theme(string $content, bool $print = FALSE, bool $maintenance = FALSE)

If we are using a theming system, invoke theme, else just print the content.

string
getDefaultBlockLocation()

No description

bool|mixed|string
getAbsoluteBaseURL()

Get the absolute path to the site's base url.

bool
getRelativeBaseURL()

Get the relative path to the sites base url.

string
getVersion()

No description

string
languageNegotiationURL(string $url, bool $addLanguagePart = TRUE, bool $removeLanguagePart = FALSE)

Format the url as per language Negotiation.

string|null
cmsRootPath()

Determine the location of the CMS root.

int|bool
createUser(array $params, string $mail)

No description

updateCMSName(int $ufID, $ufName)

No description

bool
isUserLoggedIn()

No description

bool
isUserRegistrationPermitted()

No description

bool
isPasswordUserGenerated()

No description

bool
isFrontEndPage()

Is a front end page being accessed.

string
getLoginURL(string $destination = '')

No description

string|NULL
getLoginDestination(CRM_Core_Form $form)

FIXME: Do something.

getUfId(string $username)

Determine the native ID of the CMS user.

bool
setUFLocale(string $civicrm_language)

No description

setUserSession(array $data)

Set a init session with user object.

flush()

Reset any system caches that may be required for proper CiviCRM integration.

clearResourceCache()

Flush css/js caches.

bool
addScriptUrl(string $url, string $region)

Add a script file.

bool
addScript(string $code, string $region)

Add an inline script.

bool
addStyleUrl(string $url, string $region)

Add a css file.

bool
addStyle(string $code, string $region)

Add an inline style.

setTitle(string $title, string|null $pageTitle = NULL)

No description

array
getDefaultSiteSettings(string $dir)

Return default Site Settings.

array
getDefaultFileStorage()

Moved from CRM_Utils_System_Base

array
getCiviSourceStorage()

Determine the location of the CiviCRM source tree.

userLoginFinalize(array $params = [])

Perform any post login activities required by the CMS.

setMySQLTimeZone()

Set timezone in mysql so that timestamp fields show the correct time.

string|false|null
getTimeZoneOffset()

Get timezone from CMS.

string
getTimeZoneString()

No description

mixed
getUniqueIdentifierFromUserObject(object $user)

No description

null|int
getUserIDFromUserObject(object $user)

Get User ID from UserFramework system (Joomla)

array
getUser(int $contactID)

Get an array of user details for a contact, containing at minimum the user ID & name.

int|null
getLoggedInUfID()

No description

string|null
getLoggedInUniqueIdentifier()

No description

int
getBestUFID(object $user = NULL)

Return a UFID (user account ID from the UserFramework / CMS system.

string
getBestUFUniqueIdentifier(object $user = NULL)

Return a unique identifier (usually an email address or username) from the UserFramework / CMS system.

array
getModules()

List modules installed in the CMS, including enabled and disabled ones.

string|null
getUserRecordUrl(int $contactID)

No description

bool
checkPermissionAddUser()

Is the current user permitted to add a user.

outputError(string $content)

Output code from error function.

logger(string $message)

Log error to CMS.

appendCoreResources(GenericHookEvent $e)

Append WP js to coreResourcesList.

alterAssetUrl(GenericHookEvent $e)

No description

setHttpHeader(string $name, string $value)

No description

array
synchronizeUsers()

No description

sendResponse(ResponseInterface $response)

Send an HTTP Response base on PSR HTTP RespnseInterface response.

__construct()

No description

static 
_showHTMLHead()

WP action callback.

bool
validInstallDir($dir)

No description

checkUserNameEmailExists(array $params, $errors, string $emailName = 'email')

No description

mixed
getLoggedInUserObject()

No description

Details

in CRM_Utils_System_Base at line 53
initialize()

at line 467
loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL)

Load wordpress bootstrap.

Parameters

$params
$loadUser
$throwError
$realPath

at line 127
appendBreadCrumb(array $breadCrumbs)

Parameters

array $breadCrumbs

at line 155
resetBreadCrumb()

at line 163
addHTMLHead(string $head)

Parameters

string $head The new string to be appended.

at line 189
mapConfigToSSL()

in CRM_Utils_System_Base at line 100
string postURL(string $action)

Figure out the post url for QuickForm.

Parameters

string $action The default url if one is pre-specified.

Return Value

string The url to post the form.

at line 197
string url(string $path = NULL, string $query = NULL, bool $absolute = FALSE, string $fragment = NULL, bool $frontend = FALSE, bool $forceBackend = FALSE)

Parameters

string $path The path being linked to, such as "civicrm/add".
string $query A query string to append to the link.
bool $absolute Whether to force the output to be an absolute link (beginning with http). Useful for links that will be displayed outside the site, such as in an RSS feed.
string $fragment A fragment identifier (named anchor) to append to the link.
bool $frontend This link should be to the CMS front end (applies to WP & Joomla).
bool $forceBackend This link should be to the CMS back end (applies to WP & Joomla).

Return Value

string

at line 334
array|bool authenticate(string $name, string $password, bool $loadCMSBootstrap = FALSE, string $realPath = NULL)

Parameters

string $name The user name.
string $password The password for the above user.
bool $loadCMSBootstrap Load cms bootstrap?.
string $realPath Filename of script

Return Value

array|bool [contactID, ufID, unique string] else false if no auth

at line 364
setMessage(string $message)

FIXME: Do something

Parameters

string $message The message to set.

at line 372
bool loadUser(obj $user)

Parameters

obj $user

Return Value

bool

at line 392
permissionDenied()

FIXME: Use CMS-native approach

at line 414
logout()

in CRM_Utils_System_Base at line 201
updateCategories()

Clear CMS caches related to the user registration/profile forms.

Used when updating/embedding profiles on CMS user forms.

See also

CRM-3600

at line 426
string|null getUFLocale()

Return Value

string|null Locale or null for none

in CRM_Utils_System_Base at line 232
string|null theme(string $content, bool $print = FALSE, bool $maintenance = FALSE)

If we are using a theming system, invoke theme, else just print the content.

Parameters

string $content The content that will be themed.
bool $print Are we displaying to the screen or bypassing theming?.
bool $maintenance For maintenance mode.

Return Value

string|null NULL, If $print is FALSE, and some other criteria match up. The themed string, otherwise.

Exceptions

Exception

in CRM_Utils_System_Base at line 287
string getDefaultBlockLocation()

Return Value

string

in CRM_Utils_System_Base at line 296
bool|mixed|string getAbsoluteBaseURL()

Get the absolute path to the site's base url.

Return Value

bool|mixed|string

in CRM_Utils_System_Base at line 318
bool getRelativeBaseURL()

Get the relative path to the sites base url.

Return Value

bool

at line 789
string getVersion()

Return Value

string

in CRM_Utils_System_Base at line 347
string languageNegotiationURL(string $url, bool $addLanguagePart = TRUE, bool $removeLanguagePart = FALSE)

Format the url as per language Negotiation.

Parameters

string $url
bool $addLanguagePart
bool $removeLanguagePart

Return Value

string Formatted url.

at line 547
string|null cmsRootPath()

Determine the location of the CMS root.

Return Value

string|null Local file system path to CMS root, or NULL if it cannot be determined

at line 608
int|bool createUser(array $params, string $mail)

Parameters

array $params
string $mail Email id for cms user.

Return Value

int|bool uid if user exists, false otherwise

at line 644
updateCMSName(int $ufID, $ufName)

Parameters

int $ufID User ID in CMS.
$ufName

at line 693
bool isUserLoggedIn()

Return Value

bool

at line 705
bool isUserRegistrationPermitted()

Return Value

bool

at line 715
bool isPasswordUserGenerated()

Return Value

bool

in CRM_Utils_System_Base at line 426
bool isFrontEndPage()

Is a front end page being accessed.

Generally this would be a contribution form or other public page as opposed to a backoffice page (like contact edit).

Return Value

bool

at line 769
string getLoginURL(string $destination = '')

Parameters

string $destination If present, add destination to querystring (works for Drupal only).

Return Value

string loginURL for the current CMS

at line 782
string|NULL getLoginDestination(CRM_Core_Form $form)

FIXME: Do something.

Parameters

CRM_Core_Form $form Form object representing the 'current' form - to which the user will be returned.

Return Value

string|NULL destination value for URL

at line 403
getUfId(string $username)

Determine the native ID of the CMS user.

Parameters

string $username

at line 449
bool setUFLocale(string $civicrm_language)

Parameters

string $civicrm_language

Return Value

bool

in CRM_Utils_System_Base at line 485
setUserSession(array $data)

Set a init session with user object.

Parameters

array $data Array with user specific data

in CRM_Utils_System_Base at line 495
flush()

Reset any system caches that may be required for proper CiviCRM integration.

in CRM_Utils_System_Base at line 502
clearResourceCache()

Flush css/js caches.

in CRM_Utils_System_Base at line 519
bool addScriptUrl(string $url, string $region)

Add a script file.

Note: This function is not to be called directly

Parameters

string $url absolute path to file
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

See also

CRM_Core_Region::render

in CRM_Utils_System_Base at line 536
bool addScript(string $code, string $region)

Add an inline script.

Note: This function is not to be called directly

Parameters

string $code javascript code
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

See also

CRM_Core_Region::render

in CRM_Utils_System_Base at line 553
bool addStyleUrl(string $url, string $region)

Add a css file.

Note: This function is not to be called directly

Parameters

string $url absolute path to file
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

See also

CRM_Core_Region::render

in CRM_Utils_System_Base at line 570
bool addStyle(string $code, string $region)

Add an inline style.

Note: This function is not to be called directly

Parameters

string $code css code
string $region location within the document: 'html-header', 'page-header', 'page-footer'.

Return Value

bool TRUE if we support this operation in this CMS, FALSE otherwise

See also

CRM_Core_Region::render

at line 57
setTitle(string $title, string|null $pageTitle = NULL)

Parameters

string $title Title to set in html header
string|null $pageTitle Title to set in html body (if different)

in CRM_Utils_System_Base at line 595
array getDefaultSiteSettings(string $dir)

Return default Site Settings.

Parameters

string $dir

Return Value

array
  • $url, (Joomla - non admin url)
    • $siteName,
    • $siteRoot

at line 79
array getDefaultFileStorage()

Moved from CRM_Utils_System_Base

Return Value

array
  • url: string. ex: "http://example.com/sites/foo.com/files/civicrm"
    • path: string. ex: "/var/www/sites/foo.com/files/civicrm"

at line 99
array getCiviSourceStorage()

Determine the location of the CiviCRM source tree.

Return Value

array
  • url: string. ex: "http://example.com/sites/all/modules/civicrm"
    • path: string. ex: "/var/www/sites/all/modules/civicrm"

in CRM_Utils_System_Base at line 711
userLoginFinalize(array $params = [])

Perform any post login activities required by the CMS.

e.g. for drupal: records a watchdog message about the new session, saves the login timestamp, calls hook_user op 'login' and generates a new session.

Parameters

array $params FIXME: Document values accepted/required by $params

in CRM_Utils_System_Base at line 717
setMySQLTimeZone()

Set timezone in mysql so that timestamp fields show the correct time.

in CRM_Utils_System_Base at line 730
string|false|null getTimeZoneOffset()

Get timezone from CMS.

Return Value

string|false|null

at line 801
string getTimeZoneString()

Return Value

string Timezone string e.g. 'America/Los_Angeles'

at line 762
mixed getUniqueIdentifierFromUserObject(object $user)

Parameters

object $user Object as described by the User Framework.

Return Value

mixed Unique identifier from the user Framework system

at line 755
null|int getUserIDFromUserObject(object $user)

Get User ID from UserFramework system (Joomla)

Parameters

object $user Object as described by the User Framework.

Return Value

null|int

in CRM_Utils_System_Base at line 804
array getUser(int $contactID)

Get an array of user details for a contact, containing at minimum the user ID & name.

Parameters

int $contactID

Return Value

array CMS user details including - id - name (ie the system user name.

at line 734
int|null getLoggedInUfID()

Return Value

int|null logged in user uf id.

at line 743
string|null getLoggedInUniqueIdentifier()

Return Value

string|null logged in user unique identifier

in CRM_Utils_System_Base at line 851
int getBestUFID(object $user = NULL)

Return a UFID (user account ID from the UserFramework / CMS system.

ID is based on the user object passed, defaulting to the logged in user if not passed.

Note that ambiguous situation occurs in CRM_Core_BAO_UFMatch::synchronize - a cleaner approach would seem to be resolving the user id before calling the function.

Note there is already a function getUFId which takes $username as a param - we could add $user as a second param to it but it seems messy - just overloading it because the name is taken.

Parameters

object $user

Return Value

int User ID of UF System

in CRM_Utils_System_Base at line 871
string getBestUFUniqueIdentifier(object $user = NULL)

Return a unique identifier (usually an email address or username) from the UserFramework / CMS system.

This is based on the user object passed, defaulting to the logged in user if not passed.

Note that ambiguous situation occurs in CRM_Core_BAO_UFMatch::synchronize - a cleaner approach would seem to be resolving the unique identifier before calling the function.

Parameters

object $user

Return Value

string unique identifier from the UF System

in CRM_Utils_System_Base at line 884
array getModules()

List modules installed in the CMS, including enabled and disabled ones.

Return Value

array [CRM_Core_Module]

at line 808
string|null getUserRecordUrl(int $contactID)

Parameters

int $contactID Contact ID.

Return Value

string|null

in CRM_Utils_System_Base at line 905
bool checkPermissionAddUser()

Is the current user permitted to add a user.

Return Value

bool

in CRM_Utils_System_Base at line 914
outputError(string $content)

Output code from error function.

Parameters

string $content

in CRM_Utils_System_Base at line 923
logger(string $message)

Log error to CMS.

Parameters

string $message

at line 822
appendCoreResources(GenericHookEvent $e)

Append WP js to coreResourcesList.

Parameters

GenericHookEvent $e

at line 829
alterAssetUrl(GenericHookEvent $e)

Parameters

GenericHookEvent $e

in CRM_Utils_System_Base at line 946
setHttpHeader(string $name, string $value)

Parameters

string $name
string $value

at line 839
array synchronizeUsers()

Return Value

array

at line 886
sendResponse(ResponseInterface $response)

Send an HTTP Response base on PSR HTTP RespnseInterface response.

Parameters

ResponseInterface $response

at line 43
__construct()

at line 179
static _showHTMLHead()

WP action callback.

at line 533
bool validInstallDir($dir)

Parameters

$dir

Return Value

bool

at line 662
checkUserNameEmailExists(array $params, $errors, string $emailName = 'email')

Parameters

array $params
$errors
string $emailName

at line 722
mixed getLoggedInUserObject()

Return Value

mixed