pluralize() 공개 정적인 메소드

Note: It's very, very simplified! From: https://gist.github.com/tbrianjones/ba0460cc1d55f357e00b
public static pluralize ( string $string ) : string
$string string
리턴 string
예제 #1
0
 public function getChangeDescription()
 {
     if ($this->count === 1) {
         return $this->changeInfos[0]->getChangeDescription();
     }
     return sprintf("%s %d %s", Strings::capitalize(StringUtils::verbToPastTense($this->getAction())), $this->count, StringUtils::pluralize($this->getEntityName()));
 }
예제 #2
0
 public function getChangeDescription()
 {
     if ($this->count === 1) {
         return $this->changeInfos[0]->getChangeDescription();
     }
     $taxonomies = StringUtils::pluralize($this->getTaxonomyName());
     if ($this->getAction() === "delete") {
         return "Deleted {$this->count} {$taxonomies}";
     }
     return parent::getChangeDescription();
 }
예제 #3
0
 public function getChangeDescription()
 {
     $entityName = $this->getScope();
     $action = $this->getAction();
     if ($this->count === 1) {
         $defaultDescription = $this->changeInfos[0]->getChangeDescription();
     } else {
         $defaultDescription = sprintf("%s %d %s", Strings::capitalize(StringUtils::verbToPastTense($action)), $this->count, StringUtils::pluralize($entityName));
     }
     $tags = array_map(function (TrackedChangeInfo $changeInfo) {
         return $changeInfo->getCustomTags();
     }, $this->changeInfos);
     return apply_filters("vp_bulk_change_description_{$entityName}", $defaultDescription, $action, $this->count, $tags);
 }
예제 #4
0
 public function getChangeDescription()
 {
     /** @var PostChangeInfo $postChangeInfo */
     $postChangeInfo = $this->changeInfos[0];
     $postTypePlural = StringUtils::pluralize($postChangeInfo->getPostType());
     if ($postTypePlural === "nav_menu_item") {
         return "Updated menu items";
     }
     if ($this->count === 1) {
         return $this->changeInfos[0]->getChangeDescription();
     }
     switch ($this->getAction()) {
         case "trash":
             return "Moved {$this->count} {$postTypePlural} to trash";
         case "untrash":
             return "Moved {$this->count} {$postTypePlural} from trash";
         case "edit":
             return "Updated {$this->count} {$postTypePlural}";
     }
     return parent::getChangeDescription();
 }
예제 #5
0
add_filter('vp_entity_action_term', function ($action, $oldEntity, $newEntity) {
    if ($action === 'edit' && $oldEntity['name'] !== $newEntity['name']) {
        return 'rename';
    }
    return $action;
}, 10, 3);
add_filter('vp_entity_tags_term', function ($tags, $oldEntity, $newEntity, $action) {
    if ($action === 'rename') {
        $tags['VP-Term-OldName'] = $oldEntity['name'];
    }
    return $tags;
}, 10, 4);
add_filter('vp_bulk_change_description_term', function ($description, $action, $count, $tags) {
    if ($action === "delete") {
        $taxonomy = str_replace("_", " ", $tags[0]['VP-Term-Taxonomy']);
        $taxonomies = StringUtils::pluralize($taxonomy);
        return "Deleted {$count} {$taxonomies}";
    }
    return $description;
}, 10, 4);
add_filter('vp_entity_tags_term_taxonomy', function ($tags, $oldEntity, $newEntity, $action) {
    global $versionPressContainer;
    /** @var \VersionPress\Storages\StorageFactory $storageFactory */
    $storageFactory = $versionPressContainer->resolve(VersionPressServices::STORAGE_FACTORY);
    /** @var \VersionPress\Storages\DirectoryStorage $termStorage */
    $termStorage = $storageFactory->getStorage('term');
    $termId = isset($newEntity['vp_term_id']) ? $newEntity['vp_term_id'] : $oldEntity['vp_term_id'];
    $term = $termStorage->loadEntity($termId);
    $tags['VP-Term-Name'] = $term['name'];
    return $tags;
}, 10, 4);