/wp-content/upgrade/live-composer-page-builder.1.0.8.4-H4uUxD/live-composer-page-builder/modules/tp-thumbnail/module.php

https://gitlab.com/mostafame/team_website · PHP · 384 lines · 343 code · 33 blank · 8 comment · 24 complexity · b507e76e8739cdecd8d88df7645d0493 MD5 · raw file

  1. <?php
  2. class DSLC_TP_Thumbnail extends DSLC_Module {
  3. var $module_id;
  4. var $module_title;
  5. var $module_icon;
  6. var $module_category;
  7. function __construct() {
  8. $this->module_id = 'DSLC_TP_Thumbnail';
  9. $this->module_title = __( 'Thumbnail', 'live-composer-page-builder' );
  10. $this->module_icon = 'picture';
  11. $this->module_category = 'single';
  12. }
  13. function options() {
  14. $dslc_options = array(
  15. array(
  16. 'label' => __( 'Show On', 'live-composer-page-builder' ),
  17. 'id' => 'css_show_on',
  18. 'std' => 'desktop tablet phone',
  19. 'type' => 'checkbox',
  20. 'choices' => array(
  21. array(
  22. 'label' => __( 'Desktop', 'live-composer-page-builder' ),
  23. 'value' => 'desktop'
  24. ),
  25. array(
  26. 'label' => __( 'Tablet', 'live-composer-page-builder' ),
  27. 'value' => 'tablet'
  28. ),
  29. array(
  30. 'label' => __( 'Phone', 'live-composer-page-builder' ),
  31. 'value' => 'phone'
  32. ),
  33. ),
  34. ),
  35. array(
  36. 'label' => __( 'Align', 'live-composer-page-builder' ),
  37. 'id' => 'css_align',
  38. 'std' => 'left',
  39. 'type' => 'text_align',
  40. 'refresh_on_change' => false,
  41. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  42. 'affect_on_change_rule' => 'text-align',
  43. 'section' => 'styling',
  44. ),
  45. array(
  46. 'label' => __( 'BG Color', 'live-composer-page-builder' ),
  47. 'id' => 'css_bg_color',
  48. 'std' => '',
  49. 'type' => 'color',
  50. 'refresh_on_change' => false,
  51. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  52. 'affect_on_change_rule' => 'background-color',
  53. 'section' => 'styling',
  54. ),
  55. array(
  56. 'label' => __( 'Border Color', 'live-composer-page-builder' ),
  57. 'id' => 'css_border_color',
  58. 'std' => '',
  59. 'type' => 'color',
  60. 'refresh_on_change' => false,
  61. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  62. 'affect_on_change_rule' => 'border-color',
  63. 'section' => 'styling',
  64. ),
  65. array(
  66. 'label' => __( 'Border Width', 'live-composer-page-builder' ),
  67. 'id' => 'css_border_width',
  68. 'std' => '0',
  69. 'type' => 'slider',
  70. 'refresh_on_change' => false,
  71. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  72. 'affect_on_change_rule' => 'border-width',
  73. 'section' => 'styling',
  74. 'ext' => 'px',
  75. ),
  76. array(
  77. 'label' => __( 'Borders', 'live-composer-page-builder' ),
  78. 'id' => 'css_border_trbl',
  79. 'std' => 'top right bottom left',
  80. 'type' => 'checkbox',
  81. 'choices' => array(
  82. array(
  83. 'label' => __( 'Top', 'live-composer-page-builder' ),
  84. 'value' => 'top'
  85. ),
  86. array(
  87. 'label' => __( 'Right', 'live-composer-page-builder' ),
  88. 'value' => 'right'
  89. ),
  90. array(
  91. 'label' => __( 'Bottom', 'live-composer-page-builder' ),
  92. 'value' => 'bottom'
  93. ),
  94. array(
  95. 'label' => __( 'Left', 'live-composer-page-builder' ),
  96. 'value' => 'left'
  97. ),
  98. ),
  99. 'refresh_on_change' => false,
  100. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  101. 'affect_on_change_rule' => 'border-style',
  102. 'section' => 'styling',
  103. ),
  104. array(
  105. 'label' => __( 'Border Radius - Top', 'live-composer-page-builder' ),
  106. 'id' => 'css_border_radius_top',
  107. 'std' => '0',
  108. 'type' => 'slider',
  109. 'refresh_on_change' => false,
  110. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  111. 'affect_on_change_rule' => 'border-top-left-radius,border-top-right-radius',
  112. 'section' => 'styling',
  113. 'ext' => 'px'
  114. ),
  115. array(
  116. 'label' => __( 'Border Radius - Bottom', 'live-composer-page-builder' ),
  117. 'id' => 'css_border_radius_bottom',
  118. 'std' => '0',
  119. 'type' => 'slider',
  120. 'refresh_on_change' => false,
  121. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  122. 'affect_on_change_rule' => 'border-bottom-left-radius,border-bottom-right-radius',
  123. 'section' => 'styling',
  124. 'ext' => 'px'
  125. ),
  126. array(
  127. 'label' => __( 'Lightbox', 'live-composer-page-builder' ),
  128. 'id' => 'lightbox_state',
  129. 'std' => 'disabled',
  130. 'type' => 'select',
  131. 'choices' => array(
  132. array(
  133. 'label' => __( 'Enabled', 'live-composer-page-builder' ),
  134. 'value' => 'enabled'
  135. ),
  136. array(
  137. 'label' => __( 'Disabled', 'live-composer-page-builder' ),
  138. 'value' => 'disabled'
  139. ),
  140. ),
  141. 'section' => 'styling',
  142. ),
  143. array(
  144. 'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
  145. 'id' => 'css_margin_bottom',
  146. 'std' => '0',
  147. 'type' => 'slider',
  148. 'refresh_on_change' => false,
  149. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  150. 'affect_on_change_rule' => 'margin-bottom',
  151. 'section' => 'styling',
  152. 'ext' => 'px',
  153. ),
  154. array(
  155. 'label' => __( 'Minimum Height', 'live-composer-page-builder' ),
  156. 'id' => 'css_min_height',
  157. 'std' => '0',
  158. 'type' => 'slider',
  159. 'refresh_on_change' => false,
  160. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  161. 'affect_on_change_rule' => 'min-height',
  162. 'section' => 'styling',
  163. 'ext' => 'px',
  164. 'min' => 0,
  165. 'max' => 1000,
  166. 'increment' => 5
  167. ),
  168. array(
  169. 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
  170. 'id' => 'css_padding_vertical',
  171. 'std' => '0',
  172. 'type' => 'slider',
  173. 'refresh_on_change' => false,
  174. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  175. 'affect_on_change_rule' => 'padding-top,padding-bottom',
  176. 'section' => 'styling',
  177. 'ext' => 'px',
  178. ),
  179. array(
  180. 'label' => __( 'Padding Horizontal', 'live-composer-page-builder' ),
  181. 'id' => 'css_padding_horizontal',
  182. 'std' => '0',
  183. 'type' => 'slider',
  184. 'refresh_on_change' => false,
  185. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  186. 'affect_on_change_rule' => 'padding-left,padding-right',
  187. 'section' => 'styling',
  188. 'ext' => 'px',
  189. ),
  190. array(
  191. 'label' => __( 'Resize - Width', 'live-composer-page-builder' ),
  192. 'id' => 'resize_width',
  193. 'std' => '',
  194. 'type' => 'text',
  195. 'section' => 'styling',
  196. ),
  197. array(
  198. 'label' => __( 'Resize - Height', 'live-composer-page-builder' ),
  199. 'id' => 'resize_height',
  200. 'std' => '',
  201. 'type' => 'text',
  202. 'section' => 'styling',
  203. ),
  204. /**
  205. * Responsive Tablet
  206. */
  207. array(
  208. 'label' => __( 'Responsive Styling', 'live-composer-page-builder' ),
  209. 'id' => 'css_res_t',
  210. 'std' => 'disabled',
  211. 'type' => 'select',
  212. 'choices' => array(
  213. array(
  214. 'label' => __( 'Disabled', 'live-composer-page-builder' ),
  215. 'value' => 'disabled'
  216. ),
  217. array(
  218. 'label' => __( 'Enabled', 'live-composer-page-builder' ),
  219. 'value' => 'enabled'
  220. ),
  221. ),
  222. 'section' => 'responsive',
  223. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  224. ),
  225. array(
  226. 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
  227. 'id' => 'css_res_t_padding_vertical',
  228. 'std' => '0',
  229. 'type' => 'slider',
  230. 'refresh_on_change' => false,
  231. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  232. 'affect_on_change_rule' => 'padding-top,padding-bottom',
  233. 'section' => 'responsive',
  234. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  235. 'ext' => 'px',
  236. ),
  237. array(
  238. 'label' => __( 'Padding Horizontal', 'live-composer-page-builder' ),
  239. 'id' => 'css_res_t_padding_horizontal',
  240. 'std' => '0',
  241. 'type' => 'slider',
  242. 'refresh_on_change' => false,
  243. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  244. 'affect_on_change_rule' => 'padding-left,padding-right',
  245. 'section' => 'responsive',
  246. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  247. 'ext' => 'px',
  248. ),
  249. /**
  250. * Responsive Phone
  251. */
  252. array(
  253. 'label' => __( 'Responsive Styling', 'live-composer-page-builder' ),
  254. 'id' => 'css_res_p',
  255. 'std' => 'disabled',
  256. 'type' => 'select',
  257. 'choices' => array(
  258. array(
  259. 'label' => __( 'Disabled', 'live-composer-page-builder' ),
  260. 'value' => 'disabled'
  261. ),
  262. array(
  263. 'label' => __( 'Enabled', 'live-composer-page-builder' ),
  264. 'value' => 'enabled'
  265. ),
  266. ),
  267. 'section' => 'responsive',
  268. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  269. ),
  270. array(
  271. 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
  272. 'id' => 'css_res_p_padding_vertical',
  273. 'std' => '0',
  274. 'type' => 'slider',
  275. 'refresh_on_change' => false,
  276. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  277. 'affect_on_change_rule' => 'padding-top,padding-bottom',
  278. 'section' => 'responsive',
  279. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  280. 'ext' => 'px',
  281. ),
  282. array(
  283. 'label' => __( 'Padding Horizontal', 'live-composer-page-builder' ),
  284. 'id' => 'css_res_p_padding_horizontal',
  285. 'std' => '0',
  286. 'type' => 'slider',
  287. 'refresh_on_change' => false,
  288. 'affect_on_change_el' => '.dslc-tp-thumbnail',
  289. 'affect_on_change_rule' => 'padding-left,padding-right',
  290. 'section' => 'responsive',
  291. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  292. 'ext' => 'px',
  293. ),
  294. );
  295. $dslc_options = array_merge( $dslc_options, $this->shared_options( 'animation_options', array('hover_opts' => false) ) );
  296. $dslc_options = array_merge( $dslc_options, $this->presets_options() );
  297. return apply_filters( 'dslc_module_options', $dslc_options, $this->module_id );
  298. }
  299. function output( $options ) {
  300. global $dslc_active;
  301. $post_id = $options['post_id'];
  302. $this->module_start( $options );
  303. if ( is_singular() ) {
  304. $post_id = get_the_ID();
  305. }
  306. /* Module output starts here */
  307. $manual_resize = false;
  308. if ( ! empty( $options['resize_width'] ) || ! empty( $options['resize_height'] ) ) {
  309. $manual_resize = true;
  310. $thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
  311. $thumb_url = $thumb_url[0];
  312. $resize_width = false;
  313. $resize_height = false;
  314. if ( isset( $options['resize_width'] ) && ! empty( $options['resize_width'] ) ) {
  315. $resize_width = $options['resize_width'];
  316. }
  317. if ( isset( $options['resize_height'] ) && ! empty( $options['resize_height'] ) ) {
  318. $resize_height = $options['resize_height'];
  319. }
  320. }
  321. if ( get_post_type( $post_id ) == 'dslc_templates' || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) :
  322. if ( has_post_thumbnail( $post_id ) ) :
  323. ?><div class="dslc-tp-thumbnail"><?php
  324. if ( $manual_resize ) : ?>
  325. <img src="<?php $res_img = dslc_aq_resize( $thumb_url, $resize_width, $resize_height, true ); echo $res_img; ?>" />
  326. <?php else : ?>
  327. <?php echo get_the_post_thumbnail( $post_id, 'full' ); ?>
  328. <?php endif;
  329. ?></div><?php
  330. else :
  331. ?><div class="dslc-tp-thumbnail dslc-tp-thumbnail-fake"><img src="<?php echo DS_LIVE_COMPOSER_URL; ?>/images/placeholders/tpl-thumb-placeholder.png" /></div><?php
  332. endif;
  333. else :
  334. ?><div class="dslc-tp-thumbnail">
  335. <?php if ( isset( $options['lightbox_state'] ) && $options['lightbox_state'] == 'enabled' ) : ?>
  336. <a href="<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); echo $thumb[0]; ?>" class="dslc-lightbox-image">
  337. <?php endif; ?>
  338. <?php if ( $manual_resize ) : ?>
  339. <img src="<?php $res_img = dslc_aq_resize( $thumb_url, $resize_width, $resize_height, true ); echo $res_img; ?>" alt="<?php echo dslc_get_attachment_alt( get_post_thumbnail_id() ); ?>" />
  340. <?php else : ?>
  341. <?php the_post_thumbnail( 'full' ); ?>
  342. <?php endif; ?>
  343. <?php if ( isset( $options['lightbox_state'] ) && $options['lightbox_state'] == 'enabled' ) : ?>
  344. </a>
  345. <?php endif; ?>
  346. </div><?php
  347. endif;
  348. /* Module output ends here */
  349. $this->module_end( $options );
  350. }
  351. }