-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
84 changed files
with
7,963 additions
and
3,015 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
engines: | ||
version: "2" | ||
plugins: | ||
phpcodesniffer: | ||
enabled: true | ||
config: | ||
file_extensions: "php" | ||
standard: "PSR1,PSR2" | ||
phpmd: | ||
enabled: true | ||
config: | ||
standard: "PSR1,PSR2" | ||
file_extensions: | ||
- php | ||
rulesets: "phpmd.xml" | ||
csslint: | ||
enabled: true | ||
eslint: | ||
enabled: true | ||
csslint: | ||
duplication: | ||
enabled: true | ||
fixme: | ||
enabled: true | ||
ratings: | ||
paths: | ||
- src/**/*.php | ||
- src/**/*.js | ||
- src/**/*.css | ||
- tests/**/*.php | ||
exclude_paths: | ||
- src/font-awesome/**/* | ||
exclude_patterns: | ||
- src/font-awesome/ | ||
- vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ build | |
setupLocalTest.sh | ||
vendor | ||
composer.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
namespace abrain\Einsatzverwaltung\CustomFields; | ||
|
||
/** | ||
* Represents an additional color picker of a taxonomy | ||
* @package abrain\Einsatzverwaltung\CustomFields | ||
*/ | ||
class ColorPicker extends CustomField | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function __construct($key, $label, $description, $defaultValue = '') | ||
{ | ||
parent::__construct($key, $label, $description, $defaultValue); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getAddTermInput() | ||
{ | ||
return sprintf( | ||
'<input id="tag-%1$s" type="text" value="" name="%1$s" class="einsatzverwaltung-color-picker" />', | ||
esc_attr($this->key) | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getEditTermInput($tag) | ||
{ | ||
return sprintf( | ||
'<input name="%1$s" id="%1$s" type="text" value="%2$s" class="einsatzverwaltung-color-picker" />', | ||
esc_attr($this->key), | ||
esc_attr($this->getValue($tag->term_id)) | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getColumnContent($termId) | ||
{ | ||
$value = $this->getValue($termId); | ||
if (empty($value)) { | ||
return ''; | ||
} | ||
|
||
return sprintf( | ||
'<div style="width: 20px; height: 20px; border: 1px solid black; background-color: %s"> </div>', | ||
esc_attr($value) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
namespace abrain\Einsatzverwaltung\CustomFields; | ||
|
||
/** | ||
* Base class for additional fields of taxonomies | ||
* @package abrain\Einsatzverwaltung\CustomFields | ||
*/ | ||
abstract class CustomField | ||
{ | ||
public $key; | ||
public $label; | ||
public $description; | ||
public $defaultValue; | ||
|
||
/** | ||
* CustomField constructor. | ||
* @param string $key | ||
* @param string $label | ||
* @param string $description | ||
* @param mixed $defaultValue | ||
*/ | ||
public function __construct($key, $label, $description, $defaultValue = false) | ||
{ | ||
$this->key = $key; | ||
$this->label = $label; | ||
$this->description = $description; | ||
$this->defaultValue = $defaultValue; | ||
} | ||
|
||
/** | ||
* @return string The markup for the form field shown when adding a new term. | ||
*/ | ||
public function getAddTermMarkup() | ||
{ | ||
return sprintf( | ||
'<div class="form-field"><label for="tag-%1$s">%2$s</label>%4$s<p>%3$s</p></div>', | ||
esc_attr($this->key), | ||
esc_html($this->label), | ||
esc_html($this->description), | ||
$this->getAddTermInput() | ||
); | ||
} | ||
|
||
/** | ||
* @param object $tag Current taxonomy term object. | ||
* @return string The markup for the form field shown when editing an existing term. | ||
*/ | ||
public function getEditTermMarkup($tag) | ||
{ | ||
return sprintf( | ||
'<tr class="form-field"><th scope="row"><label for="%1$s">%2$s</label></th><td>%4$s<p class="description">%3$s</p></td></tr>', | ||
esc_attr($this->key), | ||
esc_html($this->label), | ||
esc_html($this->description), | ||
$this->getEditTermInput($tag) | ||
); | ||
} | ||
|
||
/** | ||
* @param int $termId | ||
* @return mixed | ||
*/ | ||
public function getValue($termId) | ||
{ | ||
$termMeta = get_term_meta($termId, $this->key, true); | ||
return (false === $termMeta ? $this->defaultValue : $termMeta); | ||
} | ||
|
||
/** | ||
* @return string The markup for the input shown when adding a new term. | ||
*/ | ||
abstract public function getAddTermInput(); | ||
|
||
/** | ||
* @param int $termId | ||
* @return string | ||
*/ | ||
abstract public function getColumnContent($termId); | ||
|
||
/** | ||
* @param object $tag Current taxonomy term object. | ||
* @return string The markup for the input shown when editing an existing term. | ||
*/ | ||
abstract public function getEditTermInput($tag); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
namespace abrain\Einsatzverwaltung\CustomFields; | ||
|
||
/** | ||
* Represents an additional number input of a taxonomy | ||
* @package abrain\Einsatzverwaltung\CustomFields | ||
*/ | ||
class NumberInput extends CustomField | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function __construct($key, $label, $description, $defaultValue = 0) | ||
{ | ||
parent::__construct($key, $label, $description, $defaultValue); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getAddTermInput() | ||
{ | ||
return sprintf( | ||
'<input id="tag-%1$s" type="number" min="0" value="%2$d" name="%1$s">', | ||
esc_attr($this->key), | ||
esc_attr($this->defaultValue) | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getEditTermInput($tag) | ||
{ | ||
return sprintf( | ||
'<input id="tag-%1$s" type="number" min="0" value="%2$d" name="%1$s">', | ||
esc_attr($this->key), | ||
esc_attr($this->getValue($tag->term_id)) | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getColumnContent($termId) | ||
{ | ||
return esc_html($this->getValue($termId)); | ||
} | ||
} |
Oops, something went wrong.