* 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);
$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));
/**
* Append WP js to coreResourcesList.
*
- * @param array $list
+ * @param \Civi\Core\Event\GenericHookEvent $e
+ */
+ public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
+ $e->list[] = 'js/crm.wordpress.js';
+ }
+
+ /**
+ * @inheritDoc
*/
- public function appendCoreResources(&$list) {
- $list[] = 'js/crm.wordpress.js';
+ 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);
+ }
+ }
+
}