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

https://gitlab.com/mostafame/team_website · PHP · 487 lines · 439 code · 34 blank · 14 comment · 16 complexity · 1724b2a212cc3b1f5efaaed4013ec8f5 MD5 · raw file

  1. <?php
  2. class DSLC_TP_Downloads_Button 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_Downloads_Button';
  9. $this->module_title = __( 'Download Button', 'live-composer-page-builder' );
  10. $this->module_icon = 'download-alt';
  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' => __( 'Text', 'live-composer-page-builder' ),
  37. 'id' => 'button_text',
  38. 'std' => __( 'DOWNLOAD', 'live-composer-page-builder' ),
  39. 'type' => 'text',
  40. 'section' => 'styling',
  41. 'tab' => __( 'Button', 'live-composer-page-builder' ),
  42. ),
  43. array(
  44. 'label' => __( 'BG Color', 'live-composer-page-builder' ),
  45. 'id' => 'css_button_bg_color',
  46. 'std' => '#5890e5',
  47. 'type' => 'color',
  48. 'refresh_on_change' => false,
  49. 'affect_on_change_el' => '.dslc-tp-download-button a',
  50. 'affect_on_change_rule' => 'background-color',
  51. 'section' => 'styling',
  52. ),
  53. array(
  54. 'label' => __( 'BG Color - Hover', 'live-composer-page-builder' ),
  55. 'id' => 'css_button_bg_color_hover',
  56. 'std' => '#4678c2',
  57. 'type' => 'color',
  58. 'refresh_on_change' => false,
  59. 'affect_on_change_el' => '.dslc-tp-download-button a:hover',
  60. 'affect_on_change_rule' => 'background-color',
  61. 'section' => 'styling',
  62. ),
  63. array(
  64. 'label' => __( 'Border Color', 'live-composer-page-builder' ),
  65. 'id' => 'css_button_border_color',
  66. 'std' => '',
  67. 'type' => 'color',
  68. 'refresh_on_change' => false,
  69. 'affect_on_change_el' => '.dslc-tp-download-button a',
  70. 'affect_on_change_rule' => 'border-color',
  71. 'section' => 'styling',
  72. ),
  73. array(
  74. 'label' => __( 'Border Color - Hover', 'live-composer-page-builder' ),
  75. 'id' => 'css_button_border_color_hover',
  76. 'std' => '',
  77. 'type' => 'color',
  78. 'refresh_on_change' => false,
  79. 'affect_on_change_el' => '.dslc-tp-download-button a:hover',
  80. 'affect_on_change_rule' => 'border-color',
  81. 'section' => 'styling',
  82. ),
  83. array(
  84. 'label' => __( 'Border Width', 'live-composer-page-builder' ),
  85. 'id' => 'css_button_border_width',
  86. 'std' => '0',
  87. 'type' => 'slider',
  88. 'refresh_on_change' => false,
  89. 'affect_on_change_el' => '.dslc-tp-download-button a',
  90. 'affect_on_change_rule' => 'border-width',
  91. 'section' => 'styling',
  92. 'ext' => 'px',
  93. ),
  94. array(
  95. 'label' => __( 'Borders', 'live-composer-page-builder' ),
  96. 'id' => 'css_button_border_trbl',
  97. 'std' => 'top right bottom left',
  98. 'type' => 'checkbox',
  99. 'choices' => array(
  100. array(
  101. 'label' => __( 'Top', 'live-composer-page-builder' ),
  102. 'value' => 'top'
  103. ),
  104. array(
  105. 'label' => __( 'Right', 'live-composer-page-builder' ),
  106. 'value' => 'right'
  107. ),
  108. array(
  109. 'label' => __( 'Bottom', 'live-composer-page-builder' ),
  110. 'value' => 'bottom'
  111. ),
  112. array(
  113. 'label' => __( 'Left', 'live-composer-page-builder' ),
  114. 'value' => 'left'
  115. ),
  116. ),
  117. 'refresh_on_change' => false,
  118. 'affect_on_change_el' => '.dslc-tp-download-button a',
  119. 'affect_on_change_rule' => 'border-style',
  120. 'section' => 'styling',
  121. ),
  122. array(
  123. 'label' => __( 'Border Radius', 'live-composer-page-builder' ),
  124. 'id' => 'css_button_border_radius',
  125. 'std' => '3',
  126. 'type' => 'slider',
  127. 'refresh_on_change' => false,
  128. 'affect_on_change_el' => '.dslc-tp-download-button a',
  129. 'affect_on_change_rule' => 'border-radius',
  130. 'section' => 'styling',
  131. 'ext' => 'px'
  132. ),
  133. array(
  134. 'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
  135. 'id' => 'css_button_margin_bottom',
  136. 'std' => '10',
  137. 'type' => 'slider',
  138. 'refresh_on_change' => false,
  139. 'affect_on_change_el' => '.dslc-tp-download-button',
  140. 'affect_on_change_rule' => 'margin-bottom',
  141. 'section' => 'styling',
  142. 'ext' => 'px'
  143. ),
  144. array(
  145. 'label' => __( 'Minimum Height', 'live-composer-page-builder' ),
  146. 'id' => 'css_min_height',
  147. 'std' => '0',
  148. 'type' => 'slider',
  149. 'refresh_on_change' => false,
  150. 'affect_on_change_el' => '.dslc-tp-download-button',
  151. 'affect_on_change_rule' => 'min-height',
  152. 'section' => 'styling',
  153. 'ext' => 'px',
  154. 'min' => 0,
  155. 'max' => 1000,
  156. 'increment' => 5
  157. ),
  158. array(
  159. 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
  160. 'id' => 'css_button_padding_vertical',
  161. 'std' => '15',
  162. 'type' => 'slider',
  163. 'refresh_on_change' => false,
  164. 'affect_on_change_el' => '.dslc-tp-download-button a',
  165. 'affect_on_change_rule' => 'padding-top,padding-bottom',
  166. 'section' => 'styling',
  167. 'ext' => 'px'
  168. ),
  169. /**
  170. * Typography
  171. */
  172. array(
  173. 'label' => __( 'Color', 'live-composer-page-builder' ),
  174. 'id' => 'css_button_color',
  175. 'std' => '#ffffff',
  176. 'type' => 'color',
  177. 'refresh_on_change' => false,
  178. 'affect_on_change_el' => '.dslc-tp-download-button a',
  179. 'affect_on_change_rule' => 'color',
  180. 'section' => 'styling',
  181. 'tab' => __( 'typography', 'live-composer-page-builder' ),
  182. ),
  183. array(
  184. 'label' => __( 'Color - Hover', 'live-composer-page-builder' ),
  185. 'id' => 'css_button_color_hover',
  186. 'std' => '',
  187. 'type' => 'color',
  188. 'refresh_on_change' => false,
  189. 'affect_on_change_el' => '.dslc-tp-download-button a:hover',
  190. 'affect_on_change_rule' => 'color',
  191. 'section' => 'styling',
  192. 'tab' => __( 'typography', 'live-composer-page-builder' ),
  193. ),
  194. array(
  195. 'label' => __( 'Font Size', 'live-composer-page-builder' ),
  196. 'id' => 'css_button_font_size',
  197. 'std' => '13',
  198. 'type' => 'slider',
  199. 'refresh_on_change' => false,
  200. 'affect_on_change_el' => '.dslc-tp-download-button a',
  201. 'affect_on_change_rule' => 'font-size',
  202. 'section' => 'styling',
  203. 'tab' => __( 'typography', 'live-composer-page-builder' ),
  204. 'ext' => 'px'
  205. ),
  206. array(
  207. 'label' => __( 'Font Weight', 'live-composer-page-builder' ),
  208. 'id' => 'css_button_font_weight',
  209. 'std' => '700',
  210. 'type' => 'slider',
  211. 'refresh_on_change' => false,
  212. 'affect_on_change_el' => '.dslc-tp-download-button a',
  213. 'affect_on_change_rule' => 'font-weight',
  214. 'section' => 'styling',
  215. 'tab' => __( 'typography', 'live-composer-page-builder' ),
  216. 'ext' => '',
  217. 'min' => 100,
  218. 'max' => 900,
  219. 'increment' => 100
  220. ),
  221. array(
  222. 'label' => __( 'Font Family', 'live-composer-page-builder' ),
  223. 'id' => 'css_button_font_family',
  224. 'std' => 'Open Sans',
  225. 'type' => 'font',
  226. 'refresh_on_change' => false,
  227. 'affect_on_change_el' => '.dslc-tp-download-button a',
  228. 'affect_on_change_rule' => 'font-family',
  229. 'section' => 'styling',
  230. 'tab' => __( 'typography', 'live-composer-page-builder' ),
  231. ),
  232. /**
  233. * Icon
  234. */
  235. array(
  236. 'label' => __( 'Icon', 'live-composer-page-builder' ),
  237. 'id' => 'button_icon_id',
  238. 'std' => 'download-alt',
  239. 'type' => 'icon',
  240. 'section' => 'styling',
  241. 'tab' => __( 'icon', 'live-composer-page-builder' ),
  242. ),
  243. array(
  244. 'label' => __( 'Color', 'live-composer-page-builder' ),
  245. 'id' => 'css_button_icon_color',
  246. 'std' => '#9fbeeb',
  247. 'type' => 'color',
  248. 'refresh_on_change' => false,
  249. 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
  250. 'affect_on_change_rule' => 'color',
  251. 'section' => 'styling',
  252. 'tab' => __( 'icon', 'live-composer-page-builder' ),
  253. ),
  254. array(
  255. 'label' => __( 'Margin Right', 'live-composer-page-builder' ),
  256. 'id' => 'css_button_icon_margin',
  257. 'std' => '10',
  258. 'type' => 'slider',
  259. 'refresh_on_change' => false,
  260. 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
  261. 'affect_on_change_rule' => 'margin-right',
  262. 'section' => 'styling',
  263. 'ext' => 'px',
  264. 'tab' => __( 'icon', 'live-composer-page-builder' ),
  265. ),
  266. /**
  267. * Responsive Tablet
  268. */
  269. array(
  270. 'label' => __( 'Responsive Styling', 'live-composer-page-builder' ),
  271. 'id' => 'css_res_t',
  272. 'std' => 'disabled',
  273. 'type' => 'select',
  274. 'choices' => array(
  275. array(
  276. 'label' => __( 'Disabled', 'live-composer-page-builder' ),
  277. 'value' => 'disabled'
  278. ),
  279. array(
  280. 'label' => __( 'Enabled', 'live-composer-page-builder' ),
  281. 'value' => 'enabled'
  282. ),
  283. ),
  284. 'section' => 'responsive',
  285. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  286. ),
  287. array(
  288. 'label' => __( 'Font Size', 'live-composer-page-builder' ),
  289. 'id' => 'css_res_t_button_font_size',
  290. 'std' => '13',
  291. 'type' => 'slider',
  292. 'refresh_on_change' => false,
  293. 'affect_on_change_el' => '.dslc-tp-download-button a',
  294. 'affect_on_change_rule' => 'font-size',
  295. 'section' => 'responsive',
  296. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  297. 'ext' => 'px'
  298. ),
  299. array(
  300. 'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
  301. 'id' => 'css_res_t_button_margin_bottom',
  302. 'std' => '10',
  303. 'type' => 'slider',
  304. 'refresh_on_change' => false,
  305. 'affect_on_change_el' => '.dslc-tp-download-button',
  306. 'affect_on_change_rule' => 'margin-bottom',
  307. 'section' => 'responsive',
  308. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  309. 'ext' => 'px'
  310. ),
  311. array(
  312. 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
  313. 'id' => 'css_res_t_button_padding_vertical',
  314. 'std' => '15',
  315. 'type' => 'slider',
  316. 'refresh_on_change' => false,
  317. 'affect_on_change_el' => '.dslc-tp-download-button a',
  318. 'affect_on_change_rule' => 'padding-top,padding-bottom',
  319. 'section' => 'responsive',
  320. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  321. 'ext' => 'px'
  322. ),
  323. array(
  324. 'label' => __( 'Icon - Margin Right', 'live-composer-page-builder' ),
  325. 'id' => 'css_res_t_button_icon_margin',
  326. 'std' => '10',
  327. 'type' => 'slider',
  328. 'refresh_on_change' => false,
  329. 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
  330. 'affect_on_change_rule' => 'margin-right',
  331. 'section' => 'responsive',
  332. 'tab' => __( 'tablet', 'live-composer-page-builder' ),
  333. 'ext' => 'px',
  334. ),
  335. /**
  336. * Responsive Phone
  337. */
  338. array(
  339. 'label' => __( 'Responsive Styling', 'live-composer-page-builder' ),
  340. 'id' => 'css_res_p',
  341. 'std' => 'disabled',
  342. 'type' => 'select',
  343. 'choices' => array(
  344. array(
  345. 'label' => __( 'Disabled', 'live-composer-page-builder' ),
  346. 'value' => 'disabled'
  347. ),
  348. array(
  349. 'label' => __( 'Enabled', 'live-composer-page-builder' ),
  350. 'value' => 'enabled'
  351. ),
  352. ),
  353. 'section' => 'responsive',
  354. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  355. ),
  356. array(
  357. 'label' => __( 'Font Size', 'live-composer-page-builder' ),
  358. 'id' => 'css_res_p_button_font_size',
  359. 'std' => '13',
  360. 'type' => 'slider',
  361. 'refresh_on_change' => false,
  362. 'affect_on_change_el' => '.dslc-tp-download-button a',
  363. 'affect_on_change_rule' => 'font-size',
  364. 'section' => 'responsive',
  365. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  366. 'ext' => 'px'
  367. ),
  368. array(
  369. 'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
  370. 'id' => 'css_res_p_button_margin_bottom',
  371. 'std' => '10',
  372. 'type' => 'slider',
  373. 'refresh_on_change' => false,
  374. 'affect_on_change_el' => '.dslc-tp-download-button',
  375. 'affect_on_change_rule' => 'margin-bottom',
  376. 'section' => 'responsive',
  377. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  378. 'ext' => 'px'
  379. ),
  380. array(
  381. 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
  382. 'id' => 'css_res_p_button_padding_vertical',
  383. 'std' => '15',
  384. 'type' => 'slider',
  385. 'refresh_on_change' => false,
  386. 'affect_on_change_el' => '.dslc-tp-download-button a',
  387. 'affect_on_change_rule' => 'padding-top,padding-bottom',
  388. 'section' => 'responsive',
  389. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  390. 'ext' => 'px'
  391. ),
  392. array(
  393. 'label' => __( 'Icon - Margin Right', 'live-composer-page-builder' ),
  394. 'id' => 'css_res_p_button_icon_margin',
  395. 'std' => '10',
  396. 'type' => 'slider',
  397. 'refresh_on_change' => false,
  398. 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
  399. 'affect_on_change_rule' => 'margin-right',
  400. 'section' => 'responsive',
  401. 'tab' => __( 'phone', 'live-composer-page-builder' ),
  402. 'ext' => 'px',
  403. ),
  404. );
  405. $dslc_options = array_merge( $dslc_options, $this->shared_options( 'animation_options', array('hover_opts' => false) ) );
  406. $dslc_options = array_merge( $dslc_options, $this->presets_options() );
  407. return apply_filters( 'dslc_module_options', $dslc_options, $this->module_id );
  408. }
  409. function output( $options ) {
  410. global $dslc_active;
  411. if ( $dslc_active && is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) )
  412. $dslc_is_admin = true;
  413. else
  414. $dslc_is_admin = false;
  415. $this->module_start( $options );
  416. $show_fake = true;
  417. if ( is_singular() ) {
  418. $post_id = get_the_ID();
  419. $show_fake = false;
  420. if ( get_post_type( $post_id ) == 'dslc_templates' ) {
  421. $show_fake = true;
  422. } else {
  423. if ( get_post_meta( $post_id, 'dslc_download_file', true ) )
  424. $download_link = wp_get_attachment_url( get_post_meta( $post_id, 'dslc_download_file', true ) );
  425. elseif ( get_post_meta( $post_id, 'dslc_download_url', true ) )
  426. $download_link = get_post_meta( $post_id, 'dslc_download_url', true );
  427. else
  428. $download_link = false;
  429. }
  430. }
  431. /* Module output starts here */
  432. ?>
  433. <div class="dslc-tp-download-button">
  434. <?php if ( $show_fake ) : ?>
  435. <a href="#">
  436. <?php else : ?>
  437. <a target="_blank" class="dslc-download-count-hook" data-post-id="<?php echo $post_id; ?>" href="<?php echo $download_link; ?>">
  438. <?php endif; ?>
  439. <?php if ( isset( $options['button_icon_id'] ) && $options['button_icon_id'] != '' ) : ?>
  440. <span class="dslc-icon dslc-icon-<?php echo $options['button_icon_id']; ?>"></span>
  441. <?php endif; ?>
  442. <?php if ( $dslc_is_admin ) : ?>
  443. <span class="dslca-editable-content" data-id="button_text" data-type="simple" <?php if ( $dslc_is_admin ) echo 'contenteditable'; ?>><?php echo $options['button_text']; ?></span>
  444. <?php else : ?>
  445. <span><?php echo $options['button_text']; ?></span>
  446. <?php endif; ?>
  447. </a>
  448. </div><!-- .dslc-download-button -->
  449. <?php
  450. /* Module output ends here */
  451. $this->module_end( $options );
  452. }
  453. }