From 702f443c33c71361cc9138bb14ffcd90bad6e054 Mon Sep 17 00:00:00 2001 From: jjgrainger Date: Mon, 13 Jun 2022 21:50:40 +0100 Subject: [PATCH] clean up comments --- src/Columns.php | 74 ++++++++++++++++++---------- src/Contracts/Taxonomy.php | 2 +- src/PostType.php | 18 ++++--- src/Registrars/PostTypeRegistrar.php | 1 - src/Registrars/TaxonomyRegistrar.php | 5 +- src/Taxonomy.php | 8 +-- 6 files changed, 68 insertions(+), 40 deletions(-) diff --git a/src/Columns.php b/src/Columns.php index 3040add..638bf29 100644 --- a/src/Columns.php +++ b/src/Columns.php @@ -58,8 +58,9 @@ class Columns public $sortable = []; /** - * Set the all columns - * @param array $columns an array of all the columns to replace + * Set the all columns. + * + * @param array $columns an array of all the columns to replace. */ public function set($columns) { @@ -67,9 +68,12 @@ public function set($columns) } /** - * Add a new column - * @param string $column the slug of the column - * @param string $label the label for the column + * Add a new column. + * + * @param string $column the slug of the column. + * @param string $label the label for the column. + * + * @return PostType\Columns */ public function add($columns, $label = null) { @@ -90,8 +94,11 @@ public function add($columns, $label = null) } /** - * Add a column to hide - * @param string $column the slug of the column to hdie + * Add a column to hide. + * + * @param string $column the slug of the column to hide. + * + * @return PostType\Columns */ public function hide($columns) { @@ -107,9 +114,12 @@ public function hide($columns) } /** - * Set a custom callback to populate a column - * @param string $column the column slug - * @param mixed $callback callback function + * Set a custom callback to populate a column. + * + * @param string $column the column slug. + * @param mixed $callback callback function. + * + * @return PostType\Columns */ public function populate($column, $callback) { @@ -119,8 +129,11 @@ public function populate($column, $callback) } /** - * Define the postion for a columns + * Define the postion for a columns. + * * @param string $columns an array of columns + * + * @return PostType\Columns */ public function order($columns) { @@ -132,10 +145,13 @@ public function order($columns) } /** - * Set columns that are sortable + * Set columns that are sortable. + * * @param string $column the slug of the column * @param string $meta_value the meta_value to orderby * @param boolean $is_num whether to order by string/number + * + * @return PostType\Columns */ public function sortable($sortable) { @@ -148,7 +164,10 @@ public function sortable($sortable) /** * Check if an orderby field is a custom sort option. - * @param string $orderby the orderby value from query params + * + * @param string $orderby the orderby value from query params. + * + * @return boolean */ public function isSortable($orderby) { @@ -170,7 +189,10 @@ public function isSortable($orderby) /** * Get meta key for an orderby. - * @param string $orderby the orderby value from query params + * + * @param string $orderby the orderby value from query params + * + * @return mixed */ public function sortableMeta($orderby) { @@ -191,46 +213,48 @@ public function sortableMeta($orderby) } /** - * Modify the columns for the object + * Modify the columns for the object. + * * @param array $columns WordPress default columns - * @return array The modified columns + * + * @return array */ public function modifyColumns($columns) { - // if user defined set columns, return those + // If user defined set columns, return those. if (!empty($this->items)) { return $this->items; } - // add additional columns + // Add additional columns. if (!empty($this->add)) { foreach ($this->add as $key => $label) { $columns[$key] = $label; } } - // unset hidden columns + // Unset hidden columns. if (!empty($this->hide)) { foreach ($this->hide as $key) { unset($columns[$key]); } } - // if user has made added custom columns + // If user has made added custom columns. if (!empty($this->positions)) { foreach ($this->positions as $key => $position) { - // find index of the element in the array + // Find index of the element in the array. $index = array_search($key, array_keys($columns)); - // retrieve the element in the array of columns + // Retrieve the element in the array of columns. $item = array_slice($columns, $index, 1); - // remove item from the array + // Remove item from the array. unset($columns[$key]); - // split columns array into two at the desired position + // Split columns array into two at the desired position. $start = array_slice($columns, 0, $position, true); $end = array_slice($columns, $position, count($columns) - 1, true); - // insert column into position + // Insert column into position. $columns = $start + $item + $end; } } diff --git a/src/Contracts/Taxonomy.php b/src/Contracts/Taxonomy.php index ed1bc6f..21710a8 100644 --- a/src/Contracts/Taxonomy.php +++ b/src/Contracts/Taxonomy.php @@ -36,7 +36,7 @@ public function labels(array $labels); * * @param array $posttypes An array of post types to register to the taxonomy. * - * @return PostType\Taxonomy + * @return PostTypes\Taxonomy */ public function posttype(array $posttypes); diff --git a/src/PostType.php b/src/PostType.php index cabfa91..3294721 100644 --- a/src/PostType.php +++ b/src/PostType.php @@ -110,7 +110,7 @@ public function __construct($names, $options = [], $labels = []) * * @param mixed $names A string for the name, or an array of names. * - * @return $this + * @return PostTypes\PostType */ public function names($names) { @@ -125,7 +125,7 @@ public function names($names) * * @param array $options An array of options for the PostType. * - * @return $this + * @return PostTypes\PostType */ public function options(array $options) { @@ -139,7 +139,7 @@ public function options(array $options) * * @param array $labels An array of labels for the PostType. * - * @return $this + * @return PostTypes\PostType */ public function labels(array $labels) { @@ -153,7 +153,7 @@ public function labels(array $labels) * * @param mixed $taxonomies The Taxonomy name(s) to add. * - * @return $this + * @return PostTypes\PostType */ public function taxonomy($taxonomies) { @@ -167,7 +167,7 @@ public function taxonomy($taxonomies) * * @param array $filters An array of Taxonomy filters. * - * @return $this + * @return PostTypes\PostType */ public function filters(array $filters) { @@ -177,9 +177,11 @@ public function filters(array $filters) } /** - * Set the menu icon for the PostType - * @param string $icon A dashicon class for the menu icon - * @return $this + * Set the menu icon for the PostType. + * + * @param string $icon A dashicon class for the menu icon. + * + * @return PostTypes\PostType */ public function icon($icon) { diff --git a/src/Registrars/PostTypeRegistrar.php b/src/Registrars/PostTypeRegistrar.php index 07af77d..b33e75f 100644 --- a/src/Registrars/PostTypeRegistrar.php +++ b/src/Registrars/PostTypeRegistrar.php @@ -371,5 +371,4 @@ public function sortSortableColumns($query) $query->set('orderby', $meta_value); } } - } diff --git a/src/Registrars/TaxonomyRegistrar.php b/src/Registrars/TaxonomyRegistrar.php index 0ce734c..f99a090 100644 --- a/src/Registrars/TaxonomyRegistrar.php +++ b/src/Registrars/TaxonomyRegistrar.php @@ -207,7 +207,10 @@ public function modifyColumns($columns) public function populateColumns($content, $column, $term_id) { if (isset($this->taxonomy->columns->populate[$column])) { - $content = call_user_func_array($this->taxonomy->columns()->populate[$column], [$content, $column, $term_id]); + $content = call_user_func_array( + $this->taxonomy->columns()->populate[$column], + [$content, $column, $term_id] + ); } return $content; diff --git a/src/Taxonomy.php b/src/Taxonomy.php index 38175c9..7918ff5 100644 --- a/src/Taxonomy.php +++ b/src/Taxonomy.php @@ -94,7 +94,7 @@ public function __construct($names, $options = [], $labels = []) * * @param mixed $names The name(s) for the Taxonomy. * - * @return $this + * @return PostType\Taxonomy */ public function names($names) { @@ -108,7 +108,7 @@ public function names($names) * * @param array $options An array of Taxonomy options. * - * @return $this + * @return PostType\Taxonomy */ public function options(array $options = []) { @@ -122,7 +122,7 @@ public function options(array $options = []) * * @param array $labels The Taxonomy labels. * - * @return $this + * @return PostType\Taxonomy */ public function labels(array $labels = []) { @@ -136,7 +136,7 @@ public function labels(array $labels = []) * * @param mixed $posttypes An array of post types names. * - * @return $this + * @return PostType\Taxonomy */ public function posttype($posttypes) {