| @@ -1,6 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | + exit; | |
| 5 | +} | |
| 6 | + | |
| 2 | 7 | use ABlocks\Controls\Link; |
| 8 | +use ABlocks\Controls\Icon; | |
| 9 | +use ABlocks\Controls\Range; | |
| 3 | 10 | $attributes = [ |
| 4 | 11 | 'block_id' => [ |
| 5 | 12 | 'type' => 'string', |
| 6 | 13 | 'default' => '', |
| @@ -24,8 +31,16 @@ | ||
| 24 | 31 | 'link' => [ |
| 25 | 32 | 'type' => 'string', |
| 26 | 33 | 'default' => '#', |
| 27 | 34 | ], |
| 35 | + 'showIcon' => [ | |
| 36 | + 'type' => 'boolean', | |
| 37 | + 'default' => false, | |
| 38 | + ], | |
| 39 | + 'iconPosition' => [ | |
| 40 | + 'type' => 'string', | |
| 41 | + 'default' => 'left', | |
| 42 | + ], | |
| 28 | 43 | ]; |
| 29 | 44 | |
| 30 | 45 | $attributes = array_merge( |
| 31 | 46 | $attributes, |
| @@ -30,7 +45,22 @@ | ||
| 30 | 45 | $attributes = array_merge( |
| 31 | 46 | $attributes, |
| 32 | 47 | // Adding attributes from various controls |
| 33 | 48 | Link::get_attribute( 'link' ), |
| 49 | + // The icon is stored in the block comment: the item's dropdown arrow also | |
| 50 | + // uses `svg.ablocks-svg-icon`, so an HTML-sourced icon would read it back. | |
| 51 | + Icon::get_attribute( 'icon', [ | |
| 52 | + 'size' => 16, | |
| 53 | + 'color' => '', | |
| 54 | + 'hasNoSelectorOrSource' => true, | |
| 55 | + ] ), | |
| 56 | + Range::get_attribute([ | |
| 57 | + 'attributeName' => 'iconSpace', | |
| 58 | + 'attributeObjectKey' => 'value', | |
| 59 | + 'isResponsive' => true, | |
| 60 | + 'defaultValue' => 8, | |
| 61 | + 'hasUnit' => true, | |
| 62 | + 'unitDefaultValue' => 'px', | |
| 63 | + ]), | |
| 34 | 64 | ); |
| 35 | 65 | |
| 36 | 66 | return $attributes; |