| 1 |
<?php |
| 2 |
|
| 3 |
namespace LearnPress\Shortcodes; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class AbstractShortcode |
| 7 |
* |
| 8 |
* @package LearnPress\Shortcodes |
| 9 |
* @since 4.2.3 |
| 10 |
* @version 1.0.0 |
| 11 |
*/ |
| 12 |
abstract class AbstractShortcode { |
| 13 |
protected $prefix = 'learn_press_'; |
| 14 |
protected $shortcode_name; |
| 15 |
|
| 16 |
protected function init() { |
| 17 |
// Register shortcode. |
| 18 |
add_shortcode( $this->prefix . $this->shortcode_name, array( $this, 'render' ) ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Render template of shortcode. |
| 23 |
* If not set any attribute on short, $attrs is empty string. |
| 24 |
* |
| 25 |
* @param string|array $attrs |
| 26 |
* |
| 27 |
* @return string |
| 28 |
*/ |
| 29 |
abstract public function render( $attrs ): string; |
| 30 |
} |
| 31 |
|