| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) |
| 4 |
exit; // Exit if accessed directly |
| 5 |
/** |
| 6 |
* Module Name: Event Posts |
| 7 |
* Description: Display Event Posts |
| 8 |
*/ |
| 9 |
|
| 10 |
class TB_Event_Posts_Module extends Themify_Builder_Component_Module { |
| 11 |
|
| 12 |
public static function get_json_file():array{ |
| 13 |
$instance = Themify_Event_Post::get_instance(); |
| 14 |
return [ 'f' => $instance->url . 'json/style.json', 'v' => $instance->version ]; |
| 15 |
} |
| 16 |
|
| 17 |
public static function get_module_name() : string { |
| 18 |
add_filter( 'themify_builder_active_vars', [ __CLASS__, 'builder_active_enqueue' ] ); |
| 19 |
return __('Event Posts', 'themify-event-post'); |
| 20 |
} |
| 21 |
|
| 22 |
public static function get_module_icon() : string { |
| 23 |
return 'calendar'; |
| 24 |
} |
| 25 |
|
| 26 |
public static function builder_active_enqueue(array $vars ):array { |
| 27 |
$instance = Themify_Event_Post::get_instance(); |
| 28 |
themify_enque_script( 'tb_builder_event_post', $instance->url . 'assets/active.js', $instance->version, [ 'themify-builder-app-js' ] ); |
| 29 |
|
| 30 |
$i18n = include( trailingslashit( dirname( __DIR__ ) ) . 'includes/i18n.php' ); |
| 31 |
$vars['i18n']['label'] = array_merge( $i18n, $vars['i18n']['label'] ); |
| 32 |
|
| 33 |
return $vars; |
| 34 |
} |
| 35 |
|
| 36 |
public function __construct() { |
| 37 |
if(method_exists('Themify_Builder_Model', 'add_module')){ |
| 38 |
parent::__construct('event-posts'); |
| 39 |
} |
| 40 |
else{//backward |
| 41 |
parent::__construct(array( |
| 42 |
'name' => $this->get_name(), |
| 43 |
'slug' => 'event-posts' |
| 44 |
)); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
public function get_name(){//backward |
| 49 |
return self::get_module_name(); |
| 50 |
} |
| 51 |
|
| 52 |
public function get_icon(){//backward |
| 53 |
return self::get_module_icon(); |
| 54 |
} |
| 55 |
|
| 56 |
public function get_visual_type() { |
| 57 |
return 'ajax'; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Render plain content for static content. |
| 62 |
* |
| 63 |
* @param array $module |
| 64 |
* @return string |
| 65 |
*/ |
| 66 |
public function get_plain_content($module) { |
| 67 |
return ''; // no static content for dynamic content |
| 68 |
} |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
if ( ! method_exists( 'Themify_Builder_Component_Module', 'get_module_class' ) ) { |
| 73 |
if ( method_exists( 'Themify_Builder_Model', 'add_module' ) ) { |
| 74 |
new TB_Event_Posts_Module(); |
| 75 |
} else { |
| 76 |
Themify_Builder_Model::register_module('TB_Event_Posts_Module'); |
| 77 |
} |
| 78 |
} |