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())); }
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(); }
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); }
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(); }
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);