shortcode-vc-cta.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. /**
  6. * Call to action
  7. * @since 4.5
  8. */
  9. require_once vc_path_dir( 'CONFIG_DIR', 'content/vc-custom-heading-element.php' );
  10. $h2_custom_heading = vc_map_integrate_shortcode( vc_custom_heading_element_params(), 'h2_', esc_html__( 'Heading', 'js_composer' ), array(
  11. 'exclude' => array(
  12. 'source',
  13. 'text',
  14. 'css',
  15. ),
  16. ), array(
  17. 'element' => 'use_custom_fonts_h2',
  18. 'value' => 'true',
  19. ) );
  20. // This is needed to remove custom heading _tag and _align options.
  21. if ( is_array( $h2_custom_heading ) && ! empty( $h2_custom_heading ) ) {
  22. foreach ( $h2_custom_heading as $key => $param ) {
  23. if ( is_array( $param ) && isset( $param['type'] ) && 'font_container' === $param['type'] ) {
  24. $h2_custom_heading[ $key ]['value'] = '';
  25. if ( isset( $param['settings'] ) && is_array( $param['settings'] ) && isset( $param['settings']['fields'] ) ) {
  26. $sub_key = array_search( 'tag', $param['settings']['fields'], true );
  27. if ( false !== $sub_key ) {
  28. unset( $h2_custom_heading[ $key ]['settings']['fields'][ $sub_key ] );
  29. } elseif ( isset( $param['settings']['fields']['tag'] ) ) {
  30. unset( $h2_custom_heading[ $key ]['settings']['fields']['tag'] );
  31. }
  32. $sub_key = array_search( 'text_align', $param['settings']['fields'], true );
  33. if ( false !== $sub_key ) {
  34. unset( $h2_custom_heading[ $key ]['settings']['fields'][ $sub_key ] );
  35. } elseif ( isset( $param['settings']['fields']['text_align'] ) ) {
  36. unset( $h2_custom_heading[ $key ]['settings']['fields']['text_align'] );
  37. }
  38. }
  39. }
  40. }
  41. }
  42. $h4_custom_heading = vc_map_integrate_shortcode( vc_custom_heading_element_params(), 'h4_', esc_html__( 'Subheading', 'js_composer' ), array(
  43. 'exclude' => array(
  44. 'source',
  45. 'text',
  46. 'css',
  47. ),
  48. ), array(
  49. 'element' => 'use_custom_fonts_h4',
  50. 'value' => 'true',
  51. ) );
  52. // This is needed to remove custom heading _tag and _align options.
  53. if ( is_array( $h4_custom_heading ) && ! empty( $h4_custom_heading ) ) {
  54. foreach ( $h4_custom_heading as $key => $param ) {
  55. if ( is_array( $param ) && isset( $param['type'] ) && 'font_container' === $param['type'] ) {
  56. $h4_custom_heading[ $key ]['value'] = '';
  57. if ( isset( $param['settings'] ) && is_array( $param['settings'] ) && isset( $param['settings']['fields'] ) ) {
  58. $sub_key = array_search( 'tag', $param['settings']['fields'], true );
  59. if ( false !== $sub_key ) {
  60. unset( $h4_custom_heading[ $key ]['settings']['fields'][ $sub_key ] );
  61. } elseif ( isset( $param['settings']['fields']['tag'] ) ) {
  62. unset( $h4_custom_heading[ $key ]['settings']['fields']['tag'] );
  63. }
  64. $sub_key = array_search( 'text_align', $param['settings']['fields'], true );
  65. if ( false !== $sub_key ) {
  66. unset( $h4_custom_heading[ $key ]['settings']['fields'][ $sub_key ] );
  67. } elseif ( isset( $param['settings']['fields']['text_align'] ) ) {
  68. unset( $h4_custom_heading[ $key ]['settings']['fields']['text_align'] );
  69. }
  70. }
  71. }
  72. }
  73. }
  74. $params = array_merge( array(
  75. array(
  76. 'type' => 'textfield',
  77. 'heading' => esc_html__( 'Heading', 'js_composer' ),
  78. 'admin_label' => true,
  79. 'param_name' => 'h2',
  80. 'value' => esc_html__( 'Hey! I am first heading line feel free to change me', 'js_composer' ),
  81. 'description' => esc_html__( 'Enter text for heading line.', 'js_composer' ),
  82. 'edit_field_class' => 'vc_col-sm-9',
  83. ),
  84. array(
  85. 'type' => 'checkbox',
  86. 'heading' => esc_html__( 'Use custom font?', 'js_composer' ),
  87. 'param_name' => 'use_custom_fonts_h2',
  88. 'description' => esc_html__( 'Enable Google fonts.', 'js_composer' ),
  89. 'edit_field_class' => 'vc_col-sm-3',
  90. ),
  91. ), $h2_custom_heading, array(
  92. array(
  93. 'type' => 'textfield',
  94. 'heading' => esc_html__( 'Subheading', 'js_composer' ),
  95. 'param_name' => 'h4',
  96. 'value' => '',
  97. 'description' => esc_html__( 'Enter text for subheading line.', 'js_composer' ),
  98. 'edit_field_class' => 'vc_col-sm-9',
  99. ),
  100. array(
  101. 'type' => 'checkbox',
  102. 'heading' => esc_html__( 'Use custom font?', 'js_composer' ),
  103. 'param_name' => 'use_custom_fonts_h4',
  104. 'description' => esc_html__( 'Enable custom font option.', 'js_composer' ),
  105. 'edit_field_class' => 'vc_col-sm-3',
  106. ),
  107. ), $h4_custom_heading, array(
  108. array(
  109. 'type' => 'dropdown',
  110. 'heading' => esc_html__( 'Text alignment', 'js_composer' ),
  111. 'param_name' => 'txt_align',
  112. 'value' => vc_get_shared( 'text align' ),
  113. // default left
  114. 'description' => esc_html__( 'Select text alignment in "Call to Action" block.', 'js_composer' ),
  115. ),
  116. array(
  117. 'type' => 'dropdown',
  118. 'heading' => esc_html__( 'Shape', 'js_composer' ),
  119. 'param_name' => 'shape',
  120. 'std' => 'rounded',
  121. 'value' => array(
  122. esc_html__( 'Square', 'js_composer' ) => 'square',
  123. esc_html__( 'Rounded', 'js_composer' ) => 'rounded',
  124. esc_html__( 'Round', 'js_composer' ) => 'round',
  125. ),
  126. 'description' => esc_html__( 'Select call to action shape.', 'js_composer' ),
  127. ),
  128. array(
  129. 'type' => 'dropdown',
  130. 'heading' => esc_html__( 'Style', 'js_composer' ),
  131. 'param_name' => 'style',
  132. 'value' => array(
  133. esc_html__( 'Classic', 'js_composer' ) => 'classic',
  134. esc_html__( 'Flat', 'js_composer' ) => 'flat',
  135. esc_html__( 'Outline', 'js_composer' ) => 'outline',
  136. esc_html__( '3d', 'js_composer' ) => '3d',
  137. esc_html__( 'Custom', 'js_composer' ) => 'custom',
  138. ),
  139. 'std' => 'classic',
  140. 'description' => esc_html__( 'Select call to action display style.', 'js_composer' ),
  141. ),
  142. array(
  143. 'type' => 'colorpicker',
  144. 'heading' => esc_html__( 'Background color', 'js_composer' ),
  145. 'param_name' => 'custom_background',
  146. 'description' => esc_html__( 'Select custom background color.', 'js_composer' ),
  147. 'dependency' => array(
  148. 'element' => 'style',
  149. 'value' => array( 'custom' ),
  150. ),
  151. 'edit_field_class' => 'vc_col-sm-6',
  152. ),
  153. array(
  154. 'type' => 'colorpicker',
  155. 'heading' => esc_html__( 'Text color', 'js_composer' ),
  156. 'param_name' => 'custom_text',
  157. 'description' => esc_html__( 'Select custom text color.', 'js_composer' ),
  158. 'dependency' => array(
  159. 'element' => 'style',
  160. 'value' => array( 'custom' ),
  161. ),
  162. 'edit_field_class' => 'vc_col-sm-6',
  163. ),
  164. array(
  165. 'type' => 'dropdown',
  166. 'heading' => esc_html__( 'Color', 'js_composer' ),
  167. 'param_name' => 'color',
  168. 'value' => array( esc_html__( 'Classic', 'js_composer' ) => 'classic' ) + vc_get_shared( 'colors-dashed' ),
  169. 'std' => 'classic',
  170. 'description' => esc_html__( 'Select color schema.', 'js_composer' ),
  171. 'param_holder_class' => 'vc_colored-dropdown vc_cta3-colored-dropdown',
  172. 'dependency' => array(
  173. 'element' => 'style',
  174. 'value_not_equal_to' => array( 'custom' ),
  175. ),
  176. ),
  177. array(
  178. 'type' => 'textarea_html',
  179. 'heading' => esc_html__( 'Text', 'js_composer' ),
  180. 'param_name' => 'content',
  181. 'value' => esc_html__( 'I am promo text. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'js_composer' ),
  182. ),
  183. array(
  184. 'type' => 'dropdown',
  185. 'heading' => esc_html__( 'Width', 'js_composer' ),
  186. 'param_name' => 'el_width',
  187. 'value' => array(
  188. '100%' => '',
  189. '90%' => 'xl',
  190. '80%' => 'lg',
  191. '70%' => 'md',
  192. '60%' => 'sm',
  193. '50%' => 'xs',
  194. ),
  195. 'description' => esc_html__( 'Select call to action width (percentage).', 'js_composer' ),
  196. ),
  197. array(
  198. 'type' => 'dropdown',
  199. 'heading' => esc_html__( 'Add button', 'js_composer' ) . '?',
  200. 'description' => esc_html__( 'Add button for call to action.', 'js_composer' ),
  201. 'param_name' => 'add_button',
  202. 'value' => array(
  203. esc_html__( 'No', 'js_composer' ) => '',
  204. esc_html__( 'Top', 'js_composer' ) => 'top',
  205. esc_html__( 'Bottom', 'js_composer' ) => 'bottom',
  206. esc_html__( 'Left', 'js_composer' ) => 'left',
  207. esc_html__( 'Right', 'js_composer' ) => 'right',
  208. ),
  209. ),
  210. ), vc_map_integrate_shortcode( 'vc_btn', 'btn_', esc_html__( 'Button', 'js_composer' ), array(
  211. 'exclude' => array( 'css' ),
  212. ), array(
  213. 'element' => 'add_button',
  214. 'not_empty' => true,
  215. ) ), array(
  216. array(
  217. 'type' => 'dropdown',
  218. 'heading' => esc_html__( 'Add icon?', 'js_composer' ),
  219. 'description' => esc_html__( 'Add icon for call to action.', 'js_composer' ),
  220. 'param_name' => 'add_icon',
  221. 'value' => array(
  222. esc_html__( 'No', 'js_composer' ) => '',
  223. esc_html__( 'Top', 'js_composer' ) => 'top',
  224. esc_html__( 'Bottom', 'js_composer' ) => 'bottom',
  225. esc_html__( 'Left', 'js_composer' ) => 'left',
  226. esc_html__( 'Right', 'js_composer' ) => 'right',
  227. ),
  228. ),
  229. array(
  230. 'type' => 'checkbox',
  231. 'param_name' => 'i_on_border',
  232. 'heading' => esc_html__( 'Place icon on border?', 'js_composer' ),
  233. 'description' => esc_html__( 'Display icon on call to action element border.', 'js_composer' ),
  234. 'group' => esc_html__( 'Icon', 'js_composer' ),
  235. 'dependency' => array(
  236. 'element' => 'add_icon',
  237. 'not_empty' => true,
  238. ),
  239. ),
  240. ), vc_map_integrate_shortcode( 'vc_icon', 'i_', esc_html__( 'Icon', 'js_composer' ), array(
  241. 'exclude' => array(
  242. 'align',
  243. 'css',
  244. ),
  245. ), array(
  246. 'element' => 'add_icon',
  247. 'not_empty' => true,
  248. ) ), array(
  249. // cta3
  250. vc_map_add_css_animation(),
  251. array(
  252. 'type' => 'el_id',
  253. 'heading' => esc_html__( 'Element ID', 'js_composer' ),
  254. 'param_name' => 'el_id',
  255. 'description' => sprintf( esc_html__( 'Enter element ID (Note: make sure it is unique and valid according to %sw3c specification%s).', 'js_composer' ), '<a href="https://www.w3schools.com/tags/att_global_id.asp" target="_blank">', '</a>' ),
  256. ),
  257. array(
  258. 'type' => 'textfield',
  259. 'heading' => esc_html__( 'Extra class name', 'js_composer' ),
  260. 'param_name' => 'el_class',
  261. 'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
  262. ),
  263. array(
  264. 'type' => 'css_editor',
  265. 'heading' => esc_html__( 'CSS box', 'js_composer' ),
  266. 'param_name' => 'css',
  267. 'group' => esc_html__( 'Design Options', 'js_composer' ),
  268. ),
  269. ) );
  270. return array(
  271. 'name' => esc_html__( 'Call to Action', 'js_composer' ),
  272. 'base' => 'vc_cta',
  273. 'icon' => 'icon-wpb-call-to-action',
  274. 'category' => array( esc_html__( 'Content', 'js_composer' ) ),
  275. 'description' => esc_html__( 'Catch visitors attention with CTA block', 'js_composer' ),
  276. 'since' => '4.5',
  277. 'params' => $params,
  278. 'js_view' => 'VcCallToActionView3',
  279. );