vamtam-cta.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <?php
  2. /**
  3. * @class VamtamCtaModule
  4. */
  5. class VamtamCtaModule extends FLBuilderModule {
  6. /**
  7. * @method __construct
  8. */
  9. public function __construct() {
  10. $path = trailingslashit( 'modules/' . basename( dirname( __FILE__ ) ) );
  11. parent::__construct(array(
  12. 'name' => __( 'Call to Action', 'vamtam-elements-b' ),
  13. 'description' => __( 'Display a heading, subheading and a button.', 'vamtam-elements-b' ),
  14. 'category' => __( 'VamTam Modules', 'vamtam-elements-b' ),
  15. 'partial_refresh' => true,
  16. 'dir' => VAMTAMEL_B_DIR . $path,
  17. 'url' => VAMTAMEL_B_URL . $path,
  18. ));
  19. }
  20. /**
  21. * @method get_classname
  22. */
  23. public function get_classname() {
  24. $classname = 'fl-cta-wrap fl-cta-' . $this->settings->layout;
  25. if ( $this->settings->layout == 'stacked' ) {
  26. $classname .= ' fl-cta-' . $this->settings->alignment;
  27. }
  28. return $classname;
  29. }
  30. public static function get_button_settings( $settings ) {
  31. return array(
  32. 'align' => '',
  33. 'color' => $settings->btn_color,
  34. 'hover_color' => $settings->btn_hover_color,
  35. 'font_size' => $settings->btn_font_size,
  36. 'icon' => $settings->btn_icon,
  37. 'icon_position' => $settings->btn_icon_position,
  38. 'link' => $settings->btn_link,
  39. 'link_target' => $settings->btn_link_target,
  40. 'padding' => $settings->btn_padding,
  41. 'layout_type' => $settings->btn_layout_type,
  42. 'text' => $settings->btn_text,
  43. 'width' => $settings->layout == 'stacked' ? 'auto' : 'full',
  44. );
  45. }
  46. /**
  47. * @method render_button
  48. */
  49. public function render_button() {
  50. FLBuilder::render_module_html( 'vamtam-button', self::get_button_settings( $this->settings ) );
  51. }
  52. }
  53. /**
  54. * Register the module and its form settings.
  55. */
  56. FLBuilder::register_module('VamtamCtaModule', array(
  57. 'general' => array(
  58. 'title' => __( 'General', 'vamtam-elements-b' ),
  59. 'sections' => array(
  60. 'content' => array(
  61. 'title' => '',
  62. 'fields' => array(
  63. 'title' => array(
  64. 'type' => 'text',
  65. 'label' => __( 'Heading', 'vamtam-elements-b' ),
  66. 'default' => __( 'Ready to find out more?', 'vamtam-elements-b' ),
  67. 'preview' => array(
  68. 'type' => 'text',
  69. 'selector' => '.fl-cta-title',
  70. ),
  71. ),
  72. 'text' => array(
  73. 'type' => 'editor',
  74. 'label' => __( 'Text', 'vamtam-elements-b' ),
  75. 'media_buttons' => false,
  76. 'default' => __( 'Drop us a line today for a free quote!', 'vamtam-elements-b' ),
  77. 'preview' => array(
  78. 'type' => 'text',
  79. 'selector' => '.fl-cta-text-content',
  80. ),
  81. ),
  82. 'image' => array(
  83. 'type' => 'photo',
  84. 'label' => __( 'Image', 'fl-builder' ),
  85. ),
  86. ),
  87. ),
  88. ),
  89. ),
  90. 'style' => array(
  91. 'title' => __( 'Style', 'vamtam-elements-b' ),
  92. 'sections' => array(
  93. 'structure' => array(
  94. 'title' => __( 'Structure', 'vamtam-elements-b' ),
  95. 'fields' => array(
  96. 'layout' => array(
  97. 'type' => 'select',
  98. 'label' => __( 'Layout', 'vamtam-elements-b' ),
  99. 'default' => 'inline',
  100. 'options' => array(
  101. 'inline' => __( 'Inline', 'vamtam-elements-b' ),
  102. 'stacked' => __( 'Stacked', 'vamtam-elements-b' ),
  103. ),
  104. 'toggle' => array(
  105. 'stacked' => array(
  106. 'fields' => array( 'alignment' ),
  107. ),
  108. ),
  109. ),
  110. 'alignment' => array(
  111. 'type' => 'select',
  112. 'label' => __( 'Alignment', 'vamtam-elements-b' ),
  113. 'default' => 'center',
  114. 'options' => array(
  115. 'left' => __( 'Left', 'vamtam-elements-b' ),
  116. 'center' => __( 'Center', 'vamtam-elements-b' ),
  117. 'right' => __( 'Right', 'vamtam-elements-b' ),
  118. ),
  119. ),
  120. 'spacing' => array(
  121. 'type' => 'text',
  122. 'label' => __( 'Spacing', 'vamtam-elements-b' ),
  123. 'default' => '0',
  124. 'maxlength' => '3',
  125. 'size' => '4',
  126. 'description' => 'px',
  127. 'preview' => array(
  128. 'type' => 'css',
  129. 'selector' => '.fl-module-content',
  130. 'property' => 'padding',
  131. 'unit' => 'px',
  132. ),
  133. ),
  134. ),
  135. ),
  136. 'title_structure' => array(
  137. 'title' => __( 'Heading Structure', 'vamtam-elements-b' ),
  138. 'fields' => array(
  139. 'title_tag' => array(
  140. 'type' => 'select',
  141. 'label' => __( 'Heading Tag', 'vamtam-elements-b' ),
  142. 'default' => 'h3',
  143. 'options' => array(
  144. 'h1' => 'h1',
  145. 'h2' => 'h2',
  146. 'h3' => 'h3',
  147. 'h4' => 'h4',
  148. 'h5' => 'h5',
  149. 'h6' => 'h6',
  150. ),
  151. ),
  152. 'title_size' => array(
  153. 'type' => 'select',
  154. 'label' => __( 'Heading Size', 'vamtam-elements-b' ),
  155. 'default' => 'default',
  156. 'options' => array(
  157. 'default' => __( 'Default', 'vamtam-elements-b' ),
  158. 'custom' => __( 'Custom', 'vamtam-elements-b' ),
  159. ),
  160. 'toggle' => array(
  161. 'custom' => array(
  162. 'fields' => array( 'title_custom_size' ),
  163. ),
  164. ),
  165. ),
  166. 'title_custom_size' => array(
  167. 'type' => 'text',
  168. 'label' => __( 'Heading Custom Size', 'vamtam-elements-b' ),
  169. 'default' => '24',
  170. 'maxlength' => '3',
  171. 'size' => '4',
  172. 'description' => 'px',
  173. ),
  174. ),
  175. ),
  176. 'colors' => array(
  177. 'title' => __( 'Colors', 'vamtam-elements-b' ),
  178. 'fields' => array(
  179. 'text_color' => array(
  180. 'type' => 'vamtam-color',
  181. 'label' => __( 'Text Color', 'vamtam-elements-b' ),
  182. 'default' => '',
  183. ),
  184. 'bg_color' => array(
  185. 'type' => 'vamtam-color',
  186. 'label' => __( 'Background Color', 'vamtam-elements-b' ),
  187. 'default' => '',
  188. ),
  189. ),
  190. ),
  191. ),
  192. ),
  193. 'button' => array(
  194. 'title' => __( 'Button', 'vamtam-elements-b' ),
  195. 'sections' => array(
  196. 'btn_text' => array(
  197. 'title' => '',
  198. 'fields' => array(
  199. 'btn_text' => array(
  200. 'type' => 'text',
  201. 'label' => __( 'Text', 'vamtam-elements-b' ),
  202. 'default' => __( 'Click Here', 'vamtam-elements-b' ),
  203. 'preview' => array(
  204. 'type' => 'text',
  205. 'selector' => '.vamtam-button-text',
  206. ),
  207. ),
  208. 'btn_icon' => array(
  209. 'type' => 'icon',
  210. 'label' => __( 'Icon', 'vamtam-elements-b' ),
  211. 'show_remove' => true,
  212. ),
  213. 'btn_icon_position' => array(
  214. 'type' => 'select',
  215. 'label' => __( 'Icon Position', 'vamtam-elements-b' ),
  216. 'default' => 'before',
  217. 'options' => array(
  218. 'before' => __( 'Before Text', 'vamtam-elements-b' ),
  219. 'after' => __( 'After Text', 'vamtam-elements-b' ),
  220. ),
  221. ),
  222. ),
  223. ),
  224. 'btn_link' => array(
  225. 'title' => __( 'Button Link', 'vamtam-elements-b' ),
  226. 'fields' => array(
  227. 'btn_link' => array(
  228. 'type' => 'link',
  229. 'label' => __( 'Link', 'vamtam-elements-b' ),
  230. 'preview' => array(
  231. 'type' => 'none',
  232. ),
  233. ),
  234. 'btn_link_target' => array(
  235. 'type' => 'select',
  236. 'label' => __( 'Link Target', 'vamtam-elements-b' ),
  237. 'default' => '_self',
  238. 'options' => array(
  239. '_self' => __( 'Same Window', 'vamtam-elements-b' ),
  240. '_blank' => __( 'New Window', 'vamtam-elements-b' ),
  241. ),
  242. 'preview' => array(
  243. 'type' => 'none',
  244. ),
  245. ),
  246. ),
  247. ),
  248. 'btn_colors' => array(
  249. 'title' => __( 'Button Colors', 'vamtam-elements-b' ),
  250. 'fields' => array(
  251. 'btn_color' => array(
  252. 'type' => 'select',
  253. 'label' => __( 'Normal Color', 'vamtam-elements-b' ),
  254. 'default' => 'accent1',
  255. 'options' => array(
  256. 'accent1' => esc_html__( 'Accent 1', 'vamtam-elements-b' ),
  257. 'accent2' => esc_html__( 'Accent 2', 'vamtam-elements-b' ),
  258. 'accent3' => esc_html__( 'Accent 3', 'vamtam-elements-b' ),
  259. 'accent4' => esc_html__( 'Accent 4', 'vamtam-elements-b' ),
  260. 'accent5' => esc_html__( 'Accent 5', 'vamtam-elements-b' ),
  261. 'accent6' => esc_html__( 'Accent 6', 'vamtam-elements-b' ),
  262. 'accent7' => esc_html__( 'Accent 7', 'vamtam-elements-b' ),
  263. 'accent8' => esc_html__( 'Accent 8', 'vamtam-elements-b' ),
  264. ),
  265. ),
  266. 'btn_hover_color' => array(
  267. 'type' => 'select',
  268. 'label' => __( 'Hover Color', 'vamtam-elements-b' ),
  269. 'default' => 'accent2',
  270. 'options' => array(
  271. 'accent1' => esc_html__( 'Accent 1', 'vamtam-elements-b' ),
  272. 'accent2' => esc_html__( 'Accent 2', 'vamtam-elements-b' ),
  273. 'accent3' => esc_html__( 'Accent 3', 'vamtam-elements-b' ),
  274. 'accent4' => esc_html__( 'Accent 4', 'vamtam-elements-b' ),
  275. 'accent5' => esc_html__( 'Accent 5', 'vamtam-elements-b' ),
  276. 'accent6' => esc_html__( 'Accent 6', 'vamtam-elements-b' ),
  277. 'accent7' => esc_html__( 'Accent 7', 'vamtam-elements-b' ),
  278. 'accent8' => esc_html__( 'Accent 8', 'vamtam-elements-b' ),
  279. ),
  280. ),
  281. ),
  282. ),
  283. 'btn_style' => array(
  284. 'title' => __( 'Button Style', 'vamtam-elements-b' ),
  285. 'fields' => array(
  286. 'btn_layout_type' => array(
  287. 'type' => 'select',
  288. 'label' => __( 'Button Type', 'vamtam-elements-b' ),
  289. 'default' => 'solid',
  290. 'options' => array(
  291. 'solid' => esc_html__( 'Solid', 'vamtam-elements-b' ),
  292. 'border' => esc_html__( 'Border', 'vamtam-elements-b' ),
  293. 'underline' => esc_html__( 'Underline', 'vamtam-elements-b' ),
  294. ),
  295. ),
  296. ),
  297. ),
  298. 'btn_structure' => array(
  299. 'title' => __( 'Button Structure', 'vamtam-elements-b' ),
  300. 'fields' => array(
  301. 'btn_width' => array(
  302. 'type' => 'select',
  303. 'label' => __( 'Button Width', 'vamtam-elements-b' ),
  304. 'default' => 'auto',
  305. 'options' => array(
  306. 'auto' => _x( 'Auto', 'Width.', 'vamtam-elements-b' ),
  307. 'full' => __( 'Full Width', 'vamtam-elements-b' ),
  308. ),
  309. ),
  310. 'btn_font_size' => array(
  311. 'type' => 'text',
  312. 'label' => __( 'Font Size', 'vamtam-elements-b' ),
  313. 'default' => '14',
  314. 'maxlength' => '3',
  315. 'size' => '4',
  316. 'description' => 'px',
  317. ),
  318. 'btn_padding' => array(
  319. 'type' => 'text',
  320. 'label' => __( 'Padding', 'vamtam-elements-b' ),
  321. 'default' => '10',
  322. 'maxlength' => '3',
  323. 'size' => '4',
  324. 'description' => 'px',
  325. ),
  326. ),
  327. ),
  328. ),
  329. ),
  330. ));