Skip to content

Commit

Permalink
Merge pull request #1137 from versionpress/1136-autocomplete-capital-p
Browse files Browse the repository at this point in the history
Autocomplete: Capital P, dangit!
  • Loading branch information
JanVoracek committed Oct 10, 2016
2 parents 81239e5 + 26d96b2 commit 2032574
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions plugins/versionpress/src/Utils/AutocompleteUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static function getActionsConfig($actionsInfoProvider)
foreach ($actionsInfoProvider->getAllActionsInfo() as $scope => $actionsInfo) {
foreach ($actionsInfo->getActions() as $action => $actionInfo) {
$actions[] = [
'label' => Strings::capitalize($action) . ' ' . $scope,
'label' => self::capitalize($action . ' ' . $scope),
'value' => $scope . '/' . $action,
];
}
Expand All @@ -61,7 +61,7 @@ private static function getScopesConfig($actionsInfoProvider)
$scopes = [];
foreach ($actionsInfoProvider->getAllActionsInfo() as $scope => $actionsInfo) {
$scopes[] = [
'label' => Strings::capitalize($scope),
'label' => self::capitalize($scope),
'value' => $scope,
];
}
Expand Down Expand Up @@ -102,4 +102,21 @@ private static function getDateConfig()
'type' => 'date'
];
}

/**
* Capitalize the first word of a string.
* Also fix the capitalization of WordPress and VersionPress.
*
* @param $string
* @return string
*/
private function capitalize($string)
{
$capitalizedString = Strings::firstUpper($string);
return str_ireplace(
['wordpress', 'versionpress'],
['WordPress', 'VersionPress'],
$capitalizedString
);
}
}

0 comments on commit 2032574

Please sign in to comment.