block.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <?php
  2. /*
  3. * Name: Last posts
  4. * Section: content
  5. * Description: Last opsts list with different layouts
  6. */
  7. /* @var $options array */
  8. /* @var $wpdb wpdb */
  9. $defaults = array(
  10. 'button_url' => '',
  11. 'title' => 'An Awesome Title',
  12. 'text' => 'This is just a simple text you should change',
  13. 'font_family' => 'Helvetica, Arial, sans-serif',
  14. 'font_size' => '14',
  15. 'font_weight' => 'normal',
  16. 'font_color' => '#000000',
  17. 'title_font_family' => 'Helvetica, Arial, sans-serif',
  18. 'title_font_size' => '20',
  19. 'title_font_weight' => 'normal',
  20. 'title_font_color' => '#000000',
  21. 'block_background' => '#ffffff',
  22. 'layout' => 'full',
  23. 'button_label' => 'Click Here',
  24. 'button_color' => '#ffffff',
  25. 'button_background' => '#256F9C',
  26. 'layout' => 'full',
  27. 'block_padding_top'=>20,
  28. 'block_padding_bottom'=>20
  29. );
  30. $options = array_merge($defaults, $options);
  31. $layout = $options['layout'];
  32. if ($layout == 'full') {
  33. $options = array_merge(array('block_padding_left'=>0, 'block_padding_right'=>0), $options);
  34. } else {
  35. $options = array_merge(array('block_padding_left'=>15, 'block_padding_right'=>15), $options);
  36. }
  37. $url = $options['button_url'];
  38. $font_family = $options['font_family'];
  39. $font_size = $options['font_size'];
  40. $font_weight = $options['font_weight'];
  41. $font_color = $options['font_color'];
  42. $title_font_family = $options['title_font_family'];
  43. $title_font_size = $options['title_font_size'];
  44. $title_font_weight = $options['title_font_weight'];
  45. $title_font_color = $options['title_font_color'];
  46. $button_color = $options['button_color'];
  47. $button_background = $options['button_background'];
  48. $button_label = $options['button_label'];
  49. $layout = $options['layout'];
  50. if (!empty($options['image']['id'])) {
  51. if ($layout == 'full') {
  52. $image = tnp_media_resize($options['image']['id'], array(600, 0));
  53. } else {
  54. $image = tnp_media_resize($options['image']['id'], array(300, 200, true));
  55. }
  56. } else {
  57. $image = false;
  58. }
  59. ?>
  60. <?php if ($layout == 'full') { ?>
  61. <style>
  62. .hero-title {
  63. font-size: <?php echo $title_font_size ?>px;
  64. color: <?php echo $title_font_color ?>;
  65. padding-top: 30px;
  66. font-family: <?php echo $title_font_family ?>;
  67. font-weight: <?php echo $title_font_weight ?>;
  68. }
  69. .hero-text {
  70. padding: 20px 0 0 0;
  71. font-size: <?php echo $font_size ?>px;
  72. line-height: 150%;
  73. color: <?php echo $font_color ?>;
  74. font-family: <?php echo $font_family ?>;
  75. }
  76. .hero-button-table {
  77. background-color: <?php echo $button_background ?>;
  78. /*border:1px solid #353535;*/
  79. border-radius:5px;
  80. }
  81. .hero-button-td {
  82. color: <?php echo $button_color ?>;
  83. font-family:<?php echo $font_family ?>;
  84. font-size:16px;
  85. font-weight:normal;
  86. letter-spacing:-.5px;
  87. line-height:150%;
  88. padding-top:15px;
  89. padding-right:30px;
  90. padding-bottom:15px;
  91. padding-left:30px;
  92. }
  93. .hero-button-a {
  94. color:<?php echo $button_color ?>;
  95. text-decoration:none;
  96. }
  97. .hero-image {
  98. max-width: 100%!important;
  99. display: block;
  100. border: 0px;
  101. }
  102. </style>
  103. <!-- HERO IMAGE -->
  104. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  105. <tr>
  106. <td class="padding-copy tnpc-row-edit">
  107. <a href="<?php echo $url ?>" target="_blank" rel="noopener nofollow">
  108. <img src="<?php echo $image ?>" border="0" alt="Image" inline-class="hero-image">
  109. </a>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td>
  114. <!-- COPY -->
  115. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  116. <tr>
  117. <td align="center" inline-class="hero-title">
  118. <span><?php echo $options['title'] ?></span>
  119. </td>
  120. </tr>
  121. <tr>
  122. <td align="center" inline-class="hero-text">
  123. <span><?php echo $options['text'] ?></span>
  124. </td>
  125. </tr>
  126. <tr>
  127. <td align="center">
  128. <br>
  129. <table border="0" cellpadding="0" cellspacing="0" inline-class="hero-button-table" align="center">
  130. <tr>
  131. <td align="center" valign="middle" inline-class="hero-button-td">
  132. <a href="<?php echo esc_attr($url) ?>" target="_blank" inline-class="hero-button-a"><?php echo $button_label ?></a>
  133. </td>
  134. </tr>
  135. </table>
  136. </td>
  137. </tr>
  138. </table>
  139. </td>
  140. </tr>
  141. </table>
  142. <?php } ?>
  143. <?php if ($layout == 'left') { ?>
  144. <style>
  145. .hero-title {
  146. font-size: <?php echo $title_font_size ?>px;
  147. color: #333333;
  148. padding-top: 0;
  149. font-family: <?php echo $title_font_family ?>;
  150. font-weight: <?php echo $title_font_weight ?>;
  151. }
  152. .hero-text {
  153. padding: 20px 0 0 0;
  154. font-size: <?php echo $font_size ?>px;
  155. line-height: 150%;
  156. color: #666666;
  157. font-family: <?php echo $font_family ?>;
  158. font-weight: <?php echo $font_weight ?>;
  159. }
  160. .hero-button-table {
  161. background-color: <?php echo $button_background ?>;
  162. /*border:1px solid #353535;*/
  163. border-radius:5px;
  164. }
  165. .hero-button-td {
  166. color: <?php echo $button_color ?>;
  167. font-family:<?php echo $font_family ?>;
  168. font-size:<?php echo $font_size ?>px;
  169. font-weight:bold;
  170. letter-spacing:-.5px;
  171. line-height:150%;
  172. padding-top:10px;
  173. padding-right:30px;
  174. padding-bottom:10px;
  175. padding-left:30px;
  176. }
  177. .hero-button-a {
  178. color:<?php echo $button_color ?>;
  179. text-decoration:none;
  180. }
  181. </style>
  182. <table width="290" align="left" class="hero-table">
  183. <tr>
  184. <td align="center" valign="top">
  185. <img src="<?php echo $image ?>" border="0" alt="" style="max-width: 100%!important; height: auto!important; display: block;" class="img-max">
  186. </td>
  187. </tr>
  188. </table>
  189. <table width="290" align="right" class="hero-table hero-table-right">
  190. <tr>
  191. <td>
  192. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  193. <tr>
  194. <td align="center" inline-class="hero-title">
  195. <span><?php echo $options['title'] ?></span>
  196. </td>
  197. </tr>
  198. <tr>
  199. <td align="center" inline-class="hero-text">
  200. <span><?php echo $options['text'] ?></span>
  201. </td>
  202. </tr>
  203. </table>
  204. <br>
  205. <table border="0" cellpadding="0" cellspacing="0" align="center" inline-class="hero-button-table">
  206. <tr>
  207. <td align="center" valign="middle" inline-class="hero-button-td">
  208. <a href="<?php echo esc_attr($url) ?>" target="_blank" inline-class="hero-button-a"><?php echo $button_label ?></a>
  209. </td>
  210. </tr>
  211. </table>
  212. </td>
  213. </tr>
  214. </table>
  215. <?php } ?>