PluginProbe
User Access Manager / 2.2.24
User Access Manager v2.2.24
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / Controller / Backend / TermObjectController.php

TermObjectController.php in User Access Manager 2.2.24, at src/Controller/Backend/TermObjectController.php

98 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 */
15
16 declare(strict_types=1);
17
18 namespace UserAccessManager\Controller\Backend;
19
20 use UserAccessManager\Object\ObjectHandler;
21 use UserAccessManager\UserGroup\UserGroupTypeException;
22 use WP_Term;
23
24 /**
25 * Class TermObjectController
26 *
27 * @package UserAccessManager\Controller\Backend
28 */
29 class TermObjectController extends ObjectController
30 {
31 /**
32 * The function for the manage_categories_columns filter.
33 * @param array $defaults The table headers.
34 * @return array
35 */
36 public function addTermColumnsHeader(array $defaults): array
37 {
38 $defaults[self::COLUMN_NAME] = TXT_UAM_COLUMN_ACCESS;
39 return $defaults;
40 }
41
42 /**
43 * The function for the manage_categories_custom_column action.
44 * @param string|null $content Content for the column. Multiple filter calls are possible, so we need to append.
45 * @param string $columnName The column name.
46 * @param int|string $id The id.
47 * @return string|null $content with content appended for self::COLUMN_NAME column
48 * @throws UserGroupTypeException
49 */
50 public function addTermColumn(?string $content, string $columnName, $id): ?string
51 {
52 if ($columnName === self::COLUMN_NAME) {
53 $term = $this->objectHandler->getTerm($id);
54 $objectType = ($term !== false) ? $term->taxonomy : ObjectHandler::GENERAL_TERM_OBJECT_TYPE;
55 $content .= $this->getGroupColumn($objectType, $id);
56 }
57
58 return $content;
59 }
60
61 /**
62 * The function for the edit_{term}_form action.
63 * @param string|WP_Term $term The term.
64 * @throws UserGroupTypeException
65 */
66 public function showTermEditForm($term)
67 {
68 if ($term instanceof WP_Term) {
69 $this->setObjectInformation($term->taxonomy, $term->term_id);
70 } else {
71 $this->setObjectInformation($term, null);
72 }
73
74 echo $this->getIncludeContents('TermEditForm.php');
75 }
76
77 /**
78 * The function for the edit_term action.
79 * @param int|string $termId The term id.
80 * @throws UserGroupTypeException
81 */
82 public function saveTermData($termId)
83 {
84 $term = $this->objectHandler->getTerm($termId);
85 $objectType = ($term !== false) ? $term->taxonomy : ObjectHandler::GENERAL_TERM_OBJECT_TYPE;
86 $this->saveObjectData($objectType, $termId);
87 }
88
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)
94 {
95 $this->removeObjectData(ObjectHandler::GENERAL_TERM_OBJECT_TYPE, $termId);
96 }
97 }
98