shortcode-vc-hoverbox.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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(), 'primary_title_', esc_html__( 'Primary Title', 'js_composer' ), array(
  11. 'exclude' => array(
  12. 'source',
  13. 'text',
  14. 'css',
  15. ),
  16. ), array(
  17. 'element' => 'use_custom_fonts_primary_title',
  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(), 'hover_title_', esc_html__( 'Hover Title', 'js_composer' ), array(
  43. 'exclude' => array(
  44. 'source',
  45. 'text',
  46. 'css',
  47. ),
  48. ), array(
  49. 'element' => 'use_custom_fonts_hover_title',
  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' => 'attach_image',
  77. 'heading' => esc_html__( 'Image', 'js_composer' ),
  78. 'param_name' => 'image',
  79. 'value' => '',
  80. 'description' => esc_html__( 'Select image from media library.', 'js_composer' ),
  81. 'admin_label' => true,
  82. ),
  83. array(
  84. 'type' => 'textfield',
  85. 'heading' => esc_html__( 'Primary title', 'js_composer' ),
  86. 'admin_label' => true,
  87. 'param_name' => 'primary_title',
  88. 'value' => esc_html__( 'Hover Box Element', 'js_composer' ),
  89. 'description' => esc_html__( 'Enter text for heading line.', 'js_composer' ),
  90. 'edit_field_class' => 'vc_col-sm-9',
  91. ),
  92. array(
  93. 'type' => 'checkbox',
  94. 'heading' => esc_html__( 'Use custom font?', 'js_composer' ),
  95. 'param_name' => 'use_custom_fonts_primary_title',
  96. 'description' => esc_html__( 'Enable Google fonts.', 'js_composer' ),
  97. 'edit_field_class' => 'vc_col-sm-3',
  98. ),
  99. array(
  100. 'type' => 'dropdown',
  101. 'heading' => esc_html__( 'Primary title alignment', 'js_composer' ),
  102. 'param_name' => 'primary_align',
  103. 'value' => vc_get_shared( 'text align' ),
  104. 'std' => 'center',
  105. 'description' => esc_html__( 'Select text alignment for primary title.', 'js_composer' ),
  106. ),
  107. ), $h2_custom_heading, array(
  108. array(
  109. 'type' => 'textfield',
  110. 'heading' => esc_html__( 'Hover title', 'js_composer' ),
  111. 'param_name' => 'hover_title',
  112. 'value' => 'Hover Box Element',
  113. 'description' => esc_html__( 'Hover Box Element', 'js_composer' ),
  114. 'group' => esc_html__( 'Hover Block', 'js_composer' ),
  115. 'edit_field_class' => 'vc_col-sm-9',
  116. ),
  117. array(
  118. 'type' => 'checkbox',
  119. 'heading' => esc_html__( 'Use custom font?', 'js_composer' ),
  120. 'param_name' => 'use_custom_fonts_hover_title',
  121. 'description' => esc_html__( 'Enable custom font option.', 'js_composer' ),
  122. 'group' => esc_html__( 'Hover Block', 'js_composer' ),
  123. 'edit_field_class' => 'vc_col-sm-3',
  124. ),
  125. array(
  126. 'type' => 'dropdown',
  127. 'heading' => esc_html__( 'Hover title alignment', 'js_composer' ),
  128. 'param_name' => 'hover_align',
  129. 'value' => vc_get_shared( 'text align' ),
  130. 'std' => 'center',
  131. 'group' => esc_html__( 'Hover Block', 'js_composer' ),
  132. 'description' => esc_html__( 'Select text alignment for hovered title.', 'js_composer' ),
  133. ),
  134. array(
  135. 'type' => 'textarea_html',
  136. 'heading' => esc_html__( 'Hover text', 'js_composer' ),
  137. 'param_name' => 'content',
  138. 'value' => esc_html__( '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' ),
  139. 'group' => esc_html__( 'Hover Block', 'js_composer' ),
  140. 'description' => esc_html__( 'Hover part text.', 'js_composer' ),
  141. ),
  142. ), $h4_custom_heading, array(
  143. array(
  144. 'type' => 'dropdown',
  145. 'heading' => esc_html__( 'Shape', 'js_composer' ),
  146. 'param_name' => 'shape',
  147. 'std' => 'rounded',
  148. 'value' => array(
  149. esc_html__( 'Square', 'js_composer' ) => 'square',
  150. esc_html__( 'Rounded', 'js_composer' ) => 'rounded',
  151. esc_html__( 'Round', 'js_composer' ) => 'round',
  152. ),
  153. 'description' => esc_html__( 'Select block shape.', 'js_composer' ),
  154. ),
  155. array(
  156. 'type' => 'dropdown',
  157. 'heading' => esc_html__( 'Background Color', 'js_composer' ),
  158. 'param_name' => 'hover_background_color',
  159. 'value' => vc_get_shared( 'colors-dashed' ) + array( esc_html__( 'Custom', 'js_composer' ) => 'custom' ),
  160. 'description' => esc_html__( 'Select color schema.', 'js_composer' ),
  161. 'std' => 'grey',
  162. 'group' => esc_html__( 'Hover Block', 'js_composer' ),
  163. 'param_holder_class' => 'vc_colored-dropdown vc_cta3-colored-dropdown',
  164. ),
  165. array(
  166. 'type' => 'colorpicker',
  167. 'heading' => esc_html__( 'Background color', 'js_composer' ),
  168. 'param_name' => 'hover_custom_background',
  169. 'description' => esc_html__( 'Select custom background color.', 'js_composer' ),
  170. 'group' => esc_html__( 'Hover Block', 'js_composer' ),
  171. 'dependency' => array(
  172. 'element' => 'hover_background_color',
  173. 'value' => array( 'custom' ),
  174. ),
  175. 'edit_field_class' => 'vc_col-sm-6',
  176. ),
  177. array(
  178. 'type' => 'dropdown',
  179. 'heading' => esc_html__( 'Width', 'js_composer' ),
  180. 'param_name' => 'el_width',
  181. 'value' => array(
  182. '100%' => '100',
  183. '90%' => '90',
  184. '80%' => '80',
  185. '70%' => '70',
  186. '60%' => '60',
  187. '50%' => '50',
  188. '40%' => '40',
  189. '30%' => '30',
  190. '20%' => '20',
  191. '10%' => '10',
  192. ),
  193. 'description' => esc_html__( 'Select block width (percentage).', 'js_composer' ),
  194. ),
  195. array(
  196. 'type' => 'dropdown',
  197. 'heading' => esc_html__( 'Alignment', 'js_composer' ),
  198. 'param_name' => 'align',
  199. 'description' => esc_html__( 'Select block alignment.', 'js_composer' ),
  200. 'value' => array(
  201. esc_html__( 'Left', 'js_composer' ) => 'left',
  202. esc_html__( 'Right', 'js_composer' ) => 'right',
  203. esc_html__( 'Center', 'js_composer' ) => 'center',
  204. ),
  205. 'std' => 'center',
  206. ),
  207. array(
  208. 'type' => 'checkbox',
  209. 'heading' => esc_html__( 'Add button', 'js_composer' ) . '?',
  210. 'description' => esc_html__( 'Add button for call to action.', 'js_composer' ),
  211. 'group' => esc_html__( 'Hover Block', 'js_composer' ),
  212. 'param_name' => 'hover_add_button',
  213. ),
  214. array(
  215. 'type' => 'checkbox',
  216. 'heading' => esc_html__( 'Reverse blocks', 'js_composer' ),
  217. 'param_name' => 'reverse',
  218. 'description' => esc_html__( 'Reverse hover and primary block.', 'js_composer' ),
  219. ),
  220. ), vc_map_integrate_shortcode( 'vc_btn', 'hover_btn_', esc_html__( 'Hover Button', 'js_composer' ), array(
  221. 'exclude' => array( 'css' ),
  222. ), array(
  223. 'element' => 'hover_add_button',
  224. 'not_empty' => true,
  225. ) ), array(
  226. vc_map_add_css_animation(),
  227. array(
  228. 'type' => 'el_id',
  229. 'heading' => esc_html__( 'Element ID', 'js_composer' ),
  230. 'param_name' => 'el_id',
  231. '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>' ),
  232. ),
  233. array(
  234. 'type' => 'textfield',
  235. 'heading' => esc_html__( 'Extra class name', 'js_composer' ),
  236. 'param_name' => 'el_class',
  237. 'description' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
  238. ),
  239. array(
  240. 'type' => 'css_editor',
  241. 'heading' => esc_html__( 'CSS box', 'js_composer' ),
  242. 'param_name' => 'css',
  243. 'group' => esc_html__( 'Design Options', 'js_composer' ),
  244. ),
  245. ) );
  246. return array(
  247. 'name' => esc_html__( 'Hover Box', 'js_composer' ),
  248. 'base' => 'vc_cta',
  249. 'icon' => 'vc_icon-vc-hoverbox',
  250. 'category' => array( esc_html__( 'Content', 'js_composer' ) ),
  251. 'description' => esc_html__( 'Animated flip box with image and text', 'js_composer' ),
  252. 'params' => $params,
  253. );