shortcode.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Shortcodes; |
| 5 | |
| 6 | use Jet_Form_Builder\Classes\Arguments\Form_Arguments; |
| 7 | use JFB_Components\Repository\Repository_Item_Instance_Trait; |
| 8 | |
| 9 | // If this file is called directly, abort. |
| 10 | if ( ! defined( 'WPINC' ) ) { |
| 11 | die; |
| 12 | } |
| 13 | |
| 14 | abstract class Shortcode implements Repository_Item_Instance_Trait { |
| 15 | |
| 16 | public function __construct() { |
| 17 | add_shortcode( $this->get_name(), array( $this, 'add_shortcode_callback' ) ); |
| 18 | } |
| 19 | |
| 20 | abstract public function get_name(); |
| 21 | |
| 22 | abstract public function generate( $settings ); |
| 23 | |
| 24 | public function rep_item_id() { |
| 25 | return $this->get_name(); |
| 26 | } |
| 27 | |
| 28 | protected function default_args() { |
| 29 | return array(); |
| 30 | } |
| 31 | |
| 32 | public function add_shortcode_callback( $atts ) { |
| 33 | $settings = shortcode_atts( $this->default_args(), $atts, $this->get_name() ); |
| 34 | |
| 35 | return $this->generate( $settings ); |
| 36 | } |
| 37 | |
| 38 | } |
| 39 |