| @@ -1,5 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * TermObjectController.php | |
| 4 | + * | |
| 5 | + * The TermObjectController class file. | |
| 6 | + * | |
| 7 | + * PHP versions 5 | |
| 8 | + * | |
| 9 | + * @author Alexander Schneider <alexanderschneider85@gmail.com> | |
| 10 | + * @copyright 2008-2017 Alexander Schneider | |
| 11 | + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 | |
| 12 | + * @version SVN: $id$ | |
| 13 | + * @link http://wordpress.org/extend/plugins/user-access-manager/ | |
| 14 | + */ | |
| 2 | 15 | |
| 3 | 16 | declare(strict_types=1); |
| 4 | 17 | |
| 5 | 18 | namespace UserAccessManager\Controller\Backend; |
| @@ -7,10 +20,20 @@ | ||
| 7 | 20 | use UserAccessManager\Object\ObjectHandler; |
| 8 | 21 | use UserAccessManager\UserGroup\UserGroupTypeException; |
| 9 | 22 | use WP_Term; |
| 10 | 23 | |
| 24 | +/** | |
| 25 | + * Class TermObjectController | |
| 26 | + * | |
| 27 | + * @package UserAccessManager\Controller\Backend | |
| 28 | + */ | |
| 11 | 29 | class TermObjectController extends ObjectController |
| 12 | 30 | { |
| 31 | + /** | |
| 32 | + * The function for the manage_categories_columns filter. | |
| 33 | + * @param array $defaults The table headers. | |
| 34 | + * @return array | |
| 35 | + */ | |
| 13 | 36 | public function addTermColumnsHeader(array $defaults): array |
| 14 | 37 | { |
| 15 | 38 | $defaults[self::COLUMN_NAME] = TXT_UAM_COLUMN_ACCESS; |
| 16 | 39 | return $defaults; |
| @@ -16,11 +39,16 @@ | ||
| 16 | 39 | return $defaults; |
| 17 | 40 | } |
| 18 | 41 | |
| 19 | 42 | /** |
| 43 | + * The function for the manage_categories_custom_column action. | |
| 44 | + * @param string $content Content for the column. Multiple filter calls are possible, so we need to append. | |
| 45 | + * @param string $columnName The column name. | |
| 46 | + * @param integer $id The id. | |
| 47 | + * @return string $content with content appended for self::COLUMN_NAME column | |
| 20 | 48 | * @throws UserGroupTypeException |
| 21 | 49 | */ |
| 22 | - public function addTermColumn(?string $content, string $columnName, int|string|null $id): ?string | |
| 50 | + public function addTermColumn(string $content, string $columnName, int $id): string | |
| 23 | 51 | { |
| 24 | 52 | if ($columnName === self::COLUMN_NAME) { |
| 25 | 53 | $term = $this->objectHandler->getTerm($id); |
| 26 | 54 | $objectType = ($term !== false) ? $term->taxonomy : ObjectHandler::GENERAL_TERM_OBJECT_TYPE; |
| @@ -30,11 +58,13 @@ | ||
| 30 | 58 | return $content; |
| 31 | 59 | } |
| 32 | 60 | |
| 33 | 61 | /** |
| 62 | + * The function for the edit_{term}_form action. | |
| 63 | + * @param string|WP_Term $term The term. | |
| 34 | 64 | * @throws UserGroupTypeException |
| 35 | 65 | */ |
| 36 | - public function showTermEditForm($term): void | |
| 66 | + public function showTermEditForm($term) | |
| 37 | 67 | { |
| 38 | 68 | if ($term instanceof WP_Term) { |
| 39 | 69 | $this->setObjectInformation($term->taxonomy, $term->term_id); |
| 40 | 70 | } else { |
| @@ -44,11 +74,13 @@ | ||
| 44 | 74 | echo $this->getIncludeContents('TermEditForm.php'); |
| 45 | 75 | } |
| 46 | 76 | |
| 47 | 77 | /** |
| 78 | + * The function for the edit_term action. | |
| 79 | + * @param int|string $termId The term id. | |
| 48 | 80 | * @throws UserGroupTypeException |
| 49 | 81 | */ |
| 50 | - public function saveTermData($termId): void | |
| 82 | + public function saveTermData($termId) | |
| 51 | 83 | { |
| 52 | 84 | $term = $this->objectHandler->getTerm($termId); |
| 53 | 85 | $objectType = ($term !== false) ? $term->taxonomy : ObjectHandler::GENERAL_TERM_OBJECT_TYPE; |
| 54 | 86 | $this->saveObjectData($objectType, $termId); |
| @@ -53,9 +85,13 @@ | ||
| 53 | 85 | $objectType = ($term !== false) ? $term->taxonomy : ObjectHandler::GENERAL_TERM_OBJECT_TYPE; |
| 54 | 86 | $this->saveObjectData($objectType, $termId); |
| 55 | 87 | } |
| 56 | 88 | |
| 57 | - public function removeTermData(int|string|null $termId): void | |
| 89 | + /** | |
| 90 | + * The function for the delete_{term} action. | |
| 91 | + * @param int|string $termId The id of the term. | |
| 92 | + */ | |
| 93 | + public function removeTermData($termId) | |
| 58 | 94 | { |
| 59 | 95 | $this->removeObjectData(ObjectHandler::GENERAL_TERM_OBJECT_TYPE, $termId); |
| 60 | 96 | } |
| 61 | 97 | } |