insightdes

splitImageTextDouble.old.php

Aug 8th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.50 KB | None | 0 0
  1. <?php
  2.  
  3. class splitImageTextDouble extends ET_Builder_Module {
  4. function init() {
  5. $this->name = esc_html__( 'Split Image Text Double', 'et_builder' );
  6. $this->slug = 'insightdesign_split_image_text_double';
  7. $this->vb_support = 'on';
  8.  
  9. $this->main_css_element = '%%order_class%%.insightdesign_split_image_text_double';
  10.  
  11. $this->settings_modal_toggles = array(
  12. 'general' => array(
  13. 'toggles' => array(
  14. 'main_content' => esc_html__( 'Text', 'et_builder' ),
  15. 'image' => esc_html__( 'Image', 'et_builder' ),
  16. ),
  17. ),
  18. 'advanced' => array(
  19. 'toggles' => array(
  20. 'image' => esc_html__( 'Image', 'et_builder' ),
  21. 'text' => array(
  22. 'title' => esc_html__( 'Text', 'et_builder' ),
  23. 'priority' => 49,
  24. ),
  25. 'color' => esc_html__( 'Color', 'et_builder' ),
  26. ),
  27. ),
  28. 'custom_css' => array(
  29. 'toggles' => array(
  30. 'animation' => array(
  31. 'title' => esc_html__( 'Animation', 'et_builder' ),
  32. 'priority' => 90,
  33. ),
  34. ),
  35. ),
  36. );
  37.  
  38. $this->advanced_fields = array(
  39. 'background' => array(
  40. 'settings' => array(
  41. 'color' => 'alpha',
  42. ),
  43. ),
  44. 'image' => array(
  45. 'css' => array(
  46. 'main' => '%%order_class%% .et_insightdesign_split_image',
  47. ),
  48. ),
  49. 'button' => false,
  50. );
  51. }
  52.  
  53. function get_fields() {
  54. $fields = array(
  55. 'sit_title_1' => array(
  56. 'label' => esc_html__( 'Title 1', 'et_builder' ),
  57. 'type' => 'text',
  58. 'option_category' => 'basic_option',
  59. 'description' => esc_html__( 'Input the title of the section', 'et_builder' ),
  60. 'toggle_slug' => 'main_content',
  61. ),
  62. 'sit_title_2' => array(
  63. 'label' => esc_html__( 'Title 2', 'et_builder' ),
  64. 'type' => 'text',
  65. 'option_category' => 'basic_option',
  66. 'description' => esc_html__( 'Input the title of the section', 'et_builder' ),
  67. 'toggle_slug' => 'main_content',
  68. ),
  69. 'sit_date_1' => array(
  70. 'label' => esc_html__( 'Date to display 1', 'et_builder' ),
  71. 'type' => 'text',
  72. 'option_category' => 'basic_option',
  73. 'description' => esc_html__( 'Input the date for your module here.', 'et_builder' ),
  74. 'toggle_slug' => 'main_content',
  75. ),
  76. 'sit_date_2' => array(
  77. 'label' => esc_html__( 'Date to display 2', 'et_builder' ),
  78. 'type' => 'text',
  79. 'option_category' => 'basic_option',
  80. 'description' => esc_html__( 'Input the date for your module here.', 'et_builder' ),
  81. 'toggle_slug' => 'main_content',
  82. ),
  83. 'sit_link_1' => array(
  84. 'label' => esc_html__( 'Link 1', 'et_builder' ),
  85. 'type' => 'text',
  86. 'option_category' => 'basic_option',
  87. 'description' => esc_html__( "What URL does this module link to?", 'et_builder' ),
  88. 'toggle_slug' => 'main_content',
  89. ),
  90. 'sit_link_2' => array(
  91. 'label' => esc_html__( 'Link 2', 'et_builder' ),
  92. 'type' => 'text',
  93. 'option_category' => 'basic_option',
  94. 'description' => esc_html__( "What URL does this module link to?", 'et_builder' ),
  95. 'toggle_slug' => 'main_content',
  96. ),
  97. 'sit_image_1' => array(
  98. 'label' => esc_html__( 'Image URL 1', 'et_builder' ),
  99. 'type' => 'upload',
  100. 'option_category' => 'basic_option',
  101. 'upload_button_text' => esc_attr__( 'Upload an image', 'et_builder' ),
  102. 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ),
  103. 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ),
  104. 'description' => esc_html__( 'Upload your desired image, or type in the URL to the image you would like to display.', 'et_builder' ),
  105. 'toggle_slug' => 'image',
  106. 'affects' => array('sit_color_1',),
  107. ),
  108. 'sit_image_2' => array(
  109. 'label' => esc_html__( 'Image URL 2', 'et_builder' ),
  110. 'type' => 'upload',
  111. 'option_category' => 'basic_option',
  112. 'upload_button_text' => esc_attr__( 'Upload an image', 'et_builder' ),
  113. 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ),
  114. 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ),
  115. 'description' => esc_html__( 'Upload your desired image, or type in the URL to the image you would like to display.', 'et_builder' ),
  116. 'toggle_slug' => 'image',
  117. 'affects' => array('sit_color_2',),
  118. ),
  119. 'sit_color_1' => array(
  120. 'default' => et_builder_accent_color(),
  121. 'label' => esc_html__( 'Text Background Color 1', 'et_builder' ),
  122. 'type' => 'color-alpha',
  123. 'description' => esc_html__( 'This will adjust the background color to the text.', 'et_builder' ),
  124. 'depends_show_if' => 'on',
  125. 'toggle_slug' => 'main_content',
  126. ),
  127. 'sit_color_2' => array(
  128. 'default' => et_builder_accent_color(),
  129. 'label' => esc_html__( 'Text Background Color 2', 'et_builder' ),
  130. 'type' => 'color-alpha',
  131. 'description' => esc_html__( 'This will adjust the background color to the text.', 'et_builder' ),
  132. 'depends_show_if' => 'on',
  133. 'toggle_slug' => 'main_content',
  134. ),
  135. );
  136.  
  137. return $fields;
  138. }
  139.  
  140. function render( $attrs, $content = null, $render_slug ) {
  141. $link_1 = $this->props['sit_link_1'];
  142. $link_2 = $this->props['sit_link_2'];
  143. $title_1 = $this->props['sit_title_1'];
  144. $title_2 = $this->props['sit_title_2'];
  145. $date_1 = $this->props['sit_date_1'];
  146. $date_2 = $this->props['sit_date_2'];
  147. $image_1 = $this->props['sit_image_1'];
  148. $image_2 = $this->props['sit_image_2'];
  149. $color_1 = $this->props['sit_color_1'];
  150. $color_2 = $this->props['sit_color_2'];
  151.  
  152. // Added for backward compatibility
  153. if ( empty( $animation ) ) {
  154. $animation = 'top';
  155. }
  156.  
  157. $output = sprintf(
  158. '<style>
  159. .split-double {width: 50%%; float: left; position: relative;}
  160. @media (max-width: 600px) {
  161. .split-double {width: 100%%; float: none;}
  162. }
  163. </style>
  164. <div class="split-double" style="background: url(%4$s) center center no-repeat; background-size:cover; height: 340px;">
  165. <div class="splitIT-text" style="position: absolute; bottom: 0; background-color: %5$s; width: 100%%; padding: 1em 4em; height: 100px;">
  166. <h3 style="font-size: 14px; padding-bottom: 5px; text-align: center;"><a href="%1$s" style="color: white;">%2$s</a></h3>
  167. <p style="font-size: 12px; text-align: center;"><a href="%1$s" style="color: white;">%3$s</a></p>
  168. </div>
  169. </div>
  170. <div class="split-double" style="background: url(%9$s) center center no-repeat; background-size:cover; height: 340px;">
  171. <div class="splitIT-text" style="position: absolute; bottom: 0; background-color: %10$s; width: 100%%; padding: 1em 4em; height: 100px;">
  172. <h3 style="font-size: 14px; padding-bottom: 5px; text-align: center;"><a href="%6$s" style="color: white;">%7$s</a></h3>
  173. <p style="font-size: 12px; text-align: center;"><a href="%6$s" style="color: white;">%8$s</a></p>
  174. </div>
  175. </div>',
  176. $link_1,
  177. $title_1,
  178. $date_1,
  179. $image_1,
  180. $color_1,
  181. $link_2,
  182. $title_2,
  183. $date_2,
  184. $image_2,
  185. $color_2
  186. );
  187.  
  188. return $output;
  189. }
  190. }
  191.  
  192. new splitImageTextDouble;
Advertisement
Add Comment
Please, Sign In to add comment