PluginProbe
Themify Builder / 7.7.4
Themify Builder v7.7.4
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / modules / module-optin.php

module-optin.php in Themify Builder 7.7.4, at modules/module-optin.php

105 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') || exit;
3
4 /**
5 * Module Name: Optin Forms
6 * Description: Displays Optin form
7 */
8 class TB_Optin_Module extends Themify_Builder_Component_Module {
9
10 public static function init():void {
11 include_once( THEMIFY_BUILDER_INCLUDES_DIR . '/optin-services/base.php' );
12 add_action('wp_ajax_tb_optin_get_settings', array(__CLASS__, 'ajax_tb_optin_get_settings'));
13 }
14
15 public static function get_module_name():string {
16 return __('Optin Form', 'themify');
17 }
18
19 public static function get_module_icon():string {
20 return 'email';
21 }
22
23 public static function get_js_css():array {
24 $_arr = array(
25 'css' => 1
26 );
27 if (!Themify_Builder_Model::is_front_builder_activate()) {
28 $_arr['js'] = 1;
29 }
30 return $_arr;
31 }
32
33
34 /**
35 * Handles Ajax request to get the options for providers
36 *
37 * @since 4.2.3
38 */
39 public static function ajax_tb_optin_get_settings() {
40 check_ajax_referer('tf_nonce', 'nonce');
41 $providers = Builder_Optin_Service::get_providers('all',true);
42 $providers_settings = $providers_list = $providers_binding = array();
43 foreach ($providers as $id => $instance) {
44 $providers_list[$id] = $instance::get_label();
45
46 $providers_settings[] = array(
47 'type' => 'group',
48 'options' => $instance::get_settings(),
49 'wrap_class' => $id
50 );
51
52 $providers_binding[$id] = array(
53 'hide' => array_values(array_diff(array_keys($providers), array($id))),
54 'show' => $id,
55 );
56 }
57
58 $options = array(
59 array(
60 'id' => 'provider',
61 'type' => 'select',
62 'options' => $providers_list,
63 'binding' => $providers_binding
64 ),
65 array(
66 'type' => 'group',
67 'id' => 'provider_settings',
68 'options' => $providers_settings
69 )
70 );
71 die(json_encode($options));
72 }
73
74
75 /**
76 * Render plain content for static content.
77 *
78 * @param array $module
79 * @return string
80 */
81 public static function get_static_content(array $module):string {
82 return '';
83 }
84
85 public static function get_styling_image_fields() : array {
86 return [
87 'b_i' => ''
88 ];
89 }
90
91 public static function get_translatable_text_fields( $module ) : array {
92 return [ 'mod_title', 'label_firstname', 'fn_placeholder', 'label_lastname', 'ln_placeholder', 'label_email', 'email_placeholder', 'label_submit' ];
93 }
94
95 public static function get_translatable_textarea_fields( $module ) : array {
96 return [ 'gdpr_label', 'errmsg', 'message' ];
97 }
98
99 public static function get_translatable_link_fields( $module ) : array {
100 return [ 'redirect_to' ];
101 }
102 }
103
104 TB_Optin_Module::init();
105