X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem%2FWordPress.php;h=84cba04f8847189ca92858346c53ea17eed006dc;hb=79dd7fe9704b3ddf0ef674567e60aa45c0b35476;hp=5449099855055d0e71f48e34b3775f596b52dc8d;hpb=be2fb01f90f5f299dd07402a41fed7c7c7567f00;p=civicrm-core.git diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 5449099855..84cba04f88 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -37,6 +37,7 @@ * WordPress specific stuff goes here */ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { + /** */ public function __construct() { @@ -400,7 +401,8 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { * 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); @@ -460,6 +462,9 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { * Optional credentials * - name: string, cms username * - pass: string, cms password + * @param bool $loadUser + * @param bool $throwError + * @param mixed $realPath * * @return bool */ @@ -468,9 +473,6 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { $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); @@ -496,7 +498,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { 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)); @@ -788,7 +790,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { 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; } @@ -797,10 +799,20 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { /** * 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; + } } /** @@ -851,4 +863,19 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { ]; } + /** + * 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); + } + } + }