| 1 |
<?php |
| 2 |
/** |
| 3 |
* ConvertKit Block Formatter class. |
| 4 |
* |
| 5 |
* @package ConvertKit |
| 6 |
* @author ConvertKit |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Base class for registering a formatter in Gutenberg |
| 11 |
* using the Formatting Toolbar API. |
| 12 |
* |
| 13 |
* @package ConvertKit |
| 14 |
* @author ConvertKit |
| 15 |
*/ |
| 16 |
class ConvertKit_Block_Formatter { |
| 17 |
|
| 18 |
/** |
| 19 |
* Registers this formatter with the ConvertKit Plugin. |
| 20 |
* |
| 21 |
* @since 2.2.0 |
| 22 |
* |
| 23 |
* @param array $formatters Formatters to register. |
| 24 |
* @return array Formatters to register. |
| 25 |
*/ |
| 26 |
public function register( $formatters ) { |
| 27 |
|
| 28 |
$formatters[ $this->get_name() ] = array_merge( |
| 29 |
$this->get_overview(), |
| 30 |
array( |
| 31 |
'name' => $this->get_name(), |
| 32 |
'tag' => $this->get_tag(), |
| 33 |
'attributes' => $this->get_attributes(), |
| 34 |
'fields' => $this->get_fields(), |
| 35 |
) |
| 36 |
); |
| 37 |
|
| 38 |
return $formatters; |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Returns this formatters's programmatic name, excluding the convertkit- prefix. |
| 44 |
* |
| 45 |
* @since 2.2.0 |
| 46 |
*/ |
| 47 |
public function get_name() { |
| 48 |
|
| 49 |
/** |
| 50 |
* This will register as: |
| 51 |
* - a Gutenberg formatters toolbar button, with the name convertkit/{name}. |
| 52 |
*/ |
| 53 |
return ''; |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Returns the tag that this formatter applies when used. |
| 59 |
* |
| 60 |
* @since 2.2.0 |
| 61 |
*/ |
| 62 |
public function get_tag() { |
| 63 |
|
| 64 |
return 'a'; |
| 65 |
|
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Returns this formatters's Title, Description and Icon |
| 70 |
* |
| 71 |
* @since 2.2.0 |
| 72 |
* |
| 73 |
* @return array |
| 74 |
*/ |
| 75 |
public function get_overview() { |
| 76 |
|
| 77 |
return array(); |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Returns this formatter's attributes, which are applied |
| 83 |
* to the tag. |
| 84 |
* |
| 85 |
* @since 2.2.0 |
| 86 |
* |
| 87 |
* @return array |
| 88 |
*/ |
| 89 |
public function get_attributes() { |
| 90 |
|
| 91 |
return array(); |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* Returns this formatter's fields to display when the formatter |
| 97 |
* button is clicked in the toolbar. |
| 98 |
* |
| 99 |
* @since 2.2.0 |
| 100 |
* |
| 101 |
* @return array |
| 102 |
*/ |
| 103 |
public function get_fields() { |
| 104 |
|
| 105 |
return array(); |
| 106 |
|
| 107 |
} |
| 108 |
|
| 109 |
} |
| 110 |
|