-
Notifications
You must be signed in to change notification settings - Fork 0
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
551 changed files
with
86,090 additions
and
5,089 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// General form mixins and styles. | ||
|
||
@mixin ame-visually-hide-input { | ||
//Hide an input like a radio or a checkbox but leave it interactive. | ||
position: absolute; | ||
left: -9999em; | ||
overflow: hidden; | ||
clip: rect(0, 0, 0, 0); | ||
margin: -1px; | ||
} | ||
|
||
$invalidColor: #d63638; //Matches the Theme Customizer. | ||
|
||
@mixin ame-invalid-input-styles { | ||
select, input { | ||
&:invalid, &.ame-has-validation-errors { | ||
border-color: $invalidColor; | ||
|
||
//Override the box shadow that WordPress adds on focus. | ||
&:focus { | ||
box-shadow: 0 0 0 1px $invalidColor; | ||
} | ||
} | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,133 @@ | ||
<?php | ||
|
||
namespace YahnisElsts\AdminMenuEditor\Customizable\Builders; | ||
|
||
use YahnisElsts\AdminMenuEditor\Customizable\Controls\UiElement; | ||
|
||
/** | ||
* @template ElementClass of UiElement | ||
*/ | ||
abstract class BaseElementBuilder implements ElementBuilder { | ||
/** | ||
* @var array | ||
*/ | ||
protected $params = array(); | ||
|
||
/** | ||
* @var class-string<ElementClass> | ||
*/ | ||
protected $elementClass; | ||
|
||
/** | ||
* @param class-string<\YahnisElsts\AdminMenuEditor\Customizable\Controls\UiElement> $elementClass | ||
* @param array $params | ||
*/ | ||
protected function __construct($elementClass, $params = array()) { | ||
$this->elementClass = $elementClass; | ||
$this->params = $params; | ||
} | ||
|
||
protected static function buildItems($items, $preserveKeys = false) { | ||
$results = array(); | ||
foreach ($items as $key => $item) { | ||
if ( is_array($item) ) { | ||
//Flatten nested arrays of buildable things. | ||
$results = array_merge($results, self::buildItems($item, $preserveKeys)); | ||
continue; | ||
} | ||
|
||
if ( $item instanceof ElementBuilder ) { | ||
$item = $item->build(); | ||
} elseif ( !($item instanceof UiElement) ) { | ||
$typeString = is_object($item) ? get_class($item) : gettype($item); | ||
throw new \InvalidArgumentException( | ||
'Invalid item type for an element builder: ' . $typeString | ||
); | ||
} | ||
|
||
if ( $preserveKeys ) { | ||
$results[$key] = $item; | ||
} else { | ||
$results[] = $item; | ||
} | ||
} | ||
return $results; | ||
} | ||
|
||
public function id($string) { | ||
$this->params['id'] = $string; | ||
return $this; | ||
} | ||
|
||
public function getCustomId() { | ||
return isset($this->params['id']) ? $this->params['id'] : null; | ||
} | ||
|
||
/** | ||
* @param string|callable $textOrCallback | ||
* @return $this | ||
*/ | ||
public function description($textOrCallback) { | ||
$this->params['description'] = $textOrCallback; | ||
return $this; | ||
} | ||
|
||
public function classes(...$cssClassNames) { | ||
return $this->addItemsToArrayParam('classes', $cssClassNames); | ||
} | ||
|
||
/** | ||
* Add CSS class names if their values are truthy. | ||
* | ||
* @param array<string,mixed> $classEnabled ['class-a' => true, 'class-b' => false, ...] | ||
* @return $this | ||
*/ | ||
public function conditionalClasses($classEnabled) { | ||
return $this->classes(...array_keys(array_filter($classEnabled))); | ||
} | ||
|
||
public function styles($propertyPairs) { | ||
return $this->addItemsToArrayParam('style', $propertyPairs); | ||
} | ||
|
||
/** | ||
* @param string $paramName | ||
* @param $items | ||
* @return $this | ||
*/ | ||
protected function addItemsToArrayParam($paramName, $items) { | ||
if ( !isset($this->params[$paramName]) ) { | ||
$this->params[$paramName] = array(); | ||
} | ||
$this->params[$paramName] = array_merge($this->params[$paramName], (array)$items); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Set one or more parameters for the element. | ||
* | ||
* Will overwrite any existing parameters with the same name. | ||
* | ||
* @param array<string,mixed> $additionalParams | ||
* @return $this | ||
*/ | ||
public function params($additionalParams) { | ||
$this->params = array_merge($this->params, $additionalParams); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Render the element only if the condition evaluates to true. | ||
* | ||
* @param bool|callable $condition | ||
*/ | ||
public function onlyIf($condition) { | ||
$this->params['renderCondition'] = $condition; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return ElementClass | ||
*/ | ||
abstract public function build(); | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace YahnisElsts\AdminMenuEditor\Customizable\Builders; | ||
|
||
use YahnisElsts\AdminMenuEditor\Customizable\Controls; | ||
|
||
class CodeEditorBuilder extends ControlBuilder { | ||
public function __construct($settings = array(), $params = array()) { | ||
parent::__construct(Controls\CodeEditor::class, $settings, $params); | ||
} | ||
|
||
public function cssMode() { | ||
$this->params['mimeType'] = 'text/css'; | ||
return $this; | ||
} | ||
|
||
public function jsMode() { | ||
$this->params['mimeType'] = 'application/javascript'; | ||
return $this; | ||
} | ||
|
||
public function htmlMode() { | ||
$this->params['mimeType'] = 'text/html'; | ||
return $this; | ||
} | ||
} |
Oops, something went wrong.