* WordPress specific stuff goes here
*/
class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
+
/**
*/
public function __construct() {
* Determine the native ID of the CMS user.
*
* @param string $username
- * @return int|NULL
+ *
+ * @return int|null
*/
public function getUfId($username) {
$userdata = get_user_by('login', $username);
* Optional credentials
* - name: string, cms username
* - pass: string, cms password
+ * @param bool $loadUser
+ * @param bool $throwError
+ * @param mixed $realPath
*
* @return bool
*/
$name = CRM_Utils_Array::value('name', $params);
$pass = CRM_Utils_Array::value('pass', $params);
- if (isset($params['uid'])) {
- throw new \RuntimeException("Not implemented WordPress::loadBootStrap([uid=>\$num]))");
- }
if (!defined('WP_USE_THEMES')) {
define('WP_USE_THEMES', FALSE);
CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone();
}
require_once $cmsRootPath . DIRECTORY_SEPARATOR . 'wp-includes/pluggable.php';
- $uid = CRM_Utils_Array::value('uid', $name);
+ $uid = CRM_Utils_Array::value('uid', $params);
if (!$uid) {
$name = $name ? $name : trim(CRM_Utils_Array::value('name', $_REQUEST));
$pass = $pass ? $pass : trim(CRM_Utils_Array::value('pass', $_REQUEST));
public function getUserRecordUrl($contactID) {
$uid = CRM_Core_BAO_UFMatch::getUFId($contactID);
if (CRM_Core_Session::singleton()
- ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users'])
+ ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users'])
) {
return CRM_Core_Config::singleton()->userFrameworkBaseURL . "wp-admin/user-edit.php?user_id=" . $uid;
}
/**
* Append WP js to coreResourcesList.
*
- * @param array $list
+ * @param \Civi\Core\Event\GenericHookEvent $e
*/
- public function appendCoreResources(&$list) {
- $list[] = 'js/crm.wordpress.js';
+ public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
+ $e->list[] = 'js/crm.wordpress.js';
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) {
+ // Set menubar breakpoint to match WP admin theme
+ if ($e->asset == 'crm-menubar.css') {
+ $e->params['breakpoint'] = 783;
+ }
}
/**
];
}
+ /**
+ * Set the HTTP Status Code for a request
+ * @param string $statusCode
+ */
+ public function setStatusCode($statusCode) {
+ status_header($statusCode);
+ if (function_exists('http_response_code')) {
+ // PHP 5.4+
+ http_response_code($statusCode);
+ }
+ else {
+ header('X-PHP-Response-Code: ' . $statusCode, TRUE, $statusCode);
+ }
+ }
+
}