/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
- <?php
- class DSLC_TP_Downloads_Button extends DSLC_Module {
- var $module_id;
- var $module_title;
- var $module_icon;
- var $module_category;
- function __construct() {
- $this->module_id = 'DSLC_TP_Downloads_Button';
- $this->module_title = __( 'Download Button', 'live-composer-page-builder' );
- $this->module_icon = 'download-alt';
- $this->module_category = 'single';
- }
-
- function options() {
- $dslc_options = array(
-
- array(
- 'label' => __( 'Show On', 'live-composer-page-builder' ),
- 'id' => 'css_show_on',
- 'std' => 'desktop tablet phone',
- 'type' => 'checkbox',
- 'choices' => array(
- array(
- 'label' => __( 'Desktop', 'live-composer-page-builder' ),
- 'value' => 'desktop'
- ),
- array(
- 'label' => __( 'Tablet', 'live-composer-page-builder' ),
- 'value' => 'tablet'
- ),
- array(
- 'label' => __( 'Phone', 'live-composer-page-builder' ),
- 'value' => 'phone'
- ),
- ),
- ),
- array(
- 'label' => __( 'Text', 'live-composer-page-builder' ),
- 'id' => 'button_text',
- 'std' => __( 'DOWNLOAD', 'live-composer-page-builder' ),
- 'type' => 'text',
- 'section' => 'styling',
- 'tab' => __( 'Button', 'live-composer-page-builder' ),
- ),
- array(
- 'label' => __( 'BG Color', 'live-composer-page-builder' ),
- 'id' => 'css_button_bg_color',
- 'std' => '#5890e5',
- 'type' => 'color',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'background-color',
- 'section' => 'styling',
- ),
- array(
- 'label' => __( 'BG Color - Hover', 'live-composer-page-builder' ),
- 'id' => 'css_button_bg_color_hover',
- 'std' => '#4678c2',
- 'type' => 'color',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a:hover',
- 'affect_on_change_rule' => 'background-color',
- 'section' => 'styling',
- ),
- array(
- 'label' => __( 'Border Color', 'live-composer-page-builder' ),
- 'id' => 'css_button_border_color',
- 'std' => '',
- 'type' => 'color',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'border-color',
- 'section' => 'styling',
- ),
- array(
- 'label' => __( 'Border Color - Hover', 'live-composer-page-builder' ),
- 'id' => 'css_button_border_color_hover',
- 'std' => '',
- 'type' => 'color',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a:hover',
- 'affect_on_change_rule' => 'border-color',
- 'section' => 'styling',
- ),
- array(
- 'label' => __( 'Border Width', 'live-composer-page-builder' ),
- 'id' => 'css_button_border_width',
- 'std' => '0',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'border-width',
- 'section' => 'styling',
- 'ext' => 'px',
- ),
- array(
- 'label' => __( 'Borders', 'live-composer-page-builder' ),
- 'id' => 'css_button_border_trbl',
- 'std' => 'top right bottom left',
- 'type' => 'checkbox',
- 'choices' => array(
- array(
- 'label' => __( 'Top', 'live-composer-page-builder' ),
- 'value' => 'top'
- ),
- array(
- 'label' => __( 'Right', 'live-composer-page-builder' ),
- 'value' => 'right'
- ),
- array(
- 'label' => __( 'Bottom', 'live-composer-page-builder' ),
- 'value' => 'bottom'
- ),
- array(
- 'label' => __( 'Left', 'live-composer-page-builder' ),
- 'value' => 'left'
- ),
- ),
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'border-style',
- 'section' => 'styling',
- ),
- array(
- 'label' => __( 'Border Radius', 'live-composer-page-builder' ),
- 'id' => 'css_button_border_radius',
- 'std' => '3',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'border-radius',
- 'section' => 'styling',
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
- 'id' => 'css_button_margin_bottom',
- 'std' => '10',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button',
- 'affect_on_change_rule' => 'margin-bottom',
- 'section' => 'styling',
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Minimum Height', 'live-composer-page-builder' ),
- 'id' => 'css_min_height',
- 'std' => '0',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button',
- 'affect_on_change_rule' => 'min-height',
- 'section' => 'styling',
- 'ext' => 'px',
- 'min' => 0,
- 'max' => 1000,
- 'increment' => 5
- ),
- array(
- 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
- 'id' => 'css_button_padding_vertical',
- 'std' => '15',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'padding-top,padding-bottom',
- 'section' => 'styling',
- 'ext' => 'px'
- ),
- /**
- * Typography
- */
- array(
- 'label' => __( 'Color', 'live-composer-page-builder' ),
- 'id' => 'css_button_color',
- 'std' => '#ffffff',
- 'type' => 'color',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'color',
- 'section' => 'styling',
- 'tab' => __( 'typography', 'live-composer-page-builder' ),
- ),
- array(
- 'label' => __( 'Color - Hover', 'live-composer-page-builder' ),
- 'id' => 'css_button_color_hover',
- 'std' => '',
- 'type' => 'color',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a:hover',
- 'affect_on_change_rule' => 'color',
- 'section' => 'styling',
- 'tab' => __( 'typography', 'live-composer-page-builder' ),
- ),
- array(
- 'label' => __( 'Font Size', 'live-composer-page-builder' ),
- 'id' => 'css_button_font_size',
- 'std' => '13',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'font-size',
- 'section' => 'styling',
- 'tab' => __( 'typography', 'live-composer-page-builder' ),
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Font Weight', 'live-composer-page-builder' ),
- 'id' => 'css_button_font_weight',
- 'std' => '700',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'font-weight',
- 'section' => 'styling',
- 'tab' => __( 'typography', 'live-composer-page-builder' ),
- 'ext' => '',
- 'min' => 100,
- 'max' => 900,
- 'increment' => 100
- ),
- array(
- 'label' => __( 'Font Family', 'live-composer-page-builder' ),
- 'id' => 'css_button_font_family',
- 'std' => 'Open Sans',
- 'type' => 'font',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'font-family',
- 'section' => 'styling',
- 'tab' => __( 'typography', 'live-composer-page-builder' ),
- ),
-
- /**
- * Icon
- */
- array(
- 'label' => __( 'Icon', 'live-composer-page-builder' ),
- 'id' => 'button_icon_id',
- 'std' => 'download-alt',
- 'type' => 'icon',
- 'section' => 'styling',
- 'tab' => __( 'icon', 'live-composer-page-builder' ),
- ),
- array(
- 'label' => __( 'Color', 'live-composer-page-builder' ),
- 'id' => 'css_button_icon_color',
- 'std' => '#9fbeeb',
- 'type' => 'color',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
- 'affect_on_change_rule' => 'color',
- 'section' => 'styling',
- 'tab' => __( 'icon', 'live-composer-page-builder' ),
- ),
- array(
- 'label' => __( 'Margin Right', 'live-composer-page-builder' ),
- 'id' => 'css_button_icon_margin',
- 'std' => '10',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
- 'affect_on_change_rule' => 'margin-right',
- 'section' => 'styling',
- 'ext' => 'px',
- 'tab' => __( 'icon', 'live-composer-page-builder' ),
- ),
- /**
- * Responsive Tablet
- */
- array(
- 'label' => __( 'Responsive Styling', 'live-composer-page-builder' ),
- 'id' => 'css_res_t',
- 'std' => 'disabled',
- 'type' => 'select',
- 'choices' => array(
- array(
- 'label' => __( 'Disabled', 'live-composer-page-builder' ),
- 'value' => 'disabled'
- ),
- array(
- 'label' => __( 'Enabled', 'live-composer-page-builder' ),
- 'value' => 'enabled'
- ),
- ),
- 'section' => 'responsive',
- 'tab' => __( 'tablet', 'live-composer-page-builder' ),
- ),
- array(
- 'label' => __( 'Font Size', 'live-composer-page-builder' ),
- 'id' => 'css_res_t_button_font_size',
- 'std' => '13',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'font-size',
- 'section' => 'responsive',
- 'tab' => __( 'tablet', 'live-composer-page-builder' ),
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
- 'id' => 'css_res_t_button_margin_bottom',
- 'std' => '10',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button',
- 'affect_on_change_rule' => 'margin-bottom',
- 'section' => 'responsive',
- 'tab' => __( 'tablet', 'live-composer-page-builder' ),
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
- 'id' => 'css_res_t_button_padding_vertical',
- 'std' => '15',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'padding-top,padding-bottom',
- 'section' => 'responsive',
- 'tab' => __( 'tablet', 'live-composer-page-builder' ),
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Icon - Margin Right', 'live-composer-page-builder' ),
- 'id' => 'css_res_t_button_icon_margin',
- 'std' => '10',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
- 'affect_on_change_rule' => 'margin-right',
- 'section' => 'responsive',
- 'tab' => __( 'tablet', 'live-composer-page-builder' ),
- 'ext' => 'px',
- ),
- /**
- * Responsive Phone
- */
- array(
- 'label' => __( 'Responsive Styling', 'live-composer-page-builder' ),
- 'id' => 'css_res_p',
- 'std' => 'disabled',
- 'type' => 'select',
- 'choices' => array(
- array(
- 'label' => __( 'Disabled', 'live-composer-page-builder' ),
- 'value' => 'disabled'
- ),
- array(
- 'label' => __( 'Enabled', 'live-composer-page-builder' ),
- 'value' => 'enabled'
- ),
- ),
- 'section' => 'responsive',
- 'tab' => __( 'phone', 'live-composer-page-builder' ),
- ),
- array(
- 'label' => __( 'Font Size', 'live-composer-page-builder' ),
- 'id' => 'css_res_p_button_font_size',
- 'std' => '13',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'font-size',
- 'section' => 'responsive',
- 'tab' => __( 'phone', 'live-composer-page-builder' ),
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
- 'id' => 'css_res_p_button_margin_bottom',
- 'std' => '10',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button',
- 'affect_on_change_rule' => 'margin-bottom',
- 'section' => 'responsive',
- 'tab' => __( 'phone', 'live-composer-page-builder' ),
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
- 'id' => 'css_res_p_button_padding_vertical',
- 'std' => '15',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a',
- 'affect_on_change_rule' => 'padding-top,padding-bottom',
- 'section' => 'responsive',
- 'tab' => __( 'phone', 'live-composer-page-builder' ),
- 'ext' => 'px'
- ),
- array(
- 'label' => __( 'Icon - Margin Right', 'live-composer-page-builder' ),
- 'id' => 'css_res_p_button_icon_margin',
- 'std' => '10',
- 'type' => 'slider',
- 'refresh_on_change' => false,
- 'affect_on_change_el' => '.dslc-tp-download-button a .dslc-icon',
- 'affect_on_change_rule' => 'margin-right',
- 'section' => 'responsive',
- 'tab' => __( 'phone', 'live-composer-page-builder' ),
- 'ext' => 'px',
- ),
- );
- $dslc_options = array_merge( $dslc_options, $this->shared_options( 'animation_options', array('hover_opts' => false) ) );
- $dslc_options = array_merge( $dslc_options, $this->presets_options() );
- return apply_filters( 'dslc_module_options', $dslc_options, $this->module_id );
- }
- function output( $options ) {
- global $dslc_active;
- if ( $dslc_active && is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) )
- $dslc_is_admin = true;
- else
- $dslc_is_admin = false;
- $this->module_start( $options );
- $show_fake = true;
- if ( is_singular() ) {
- $post_id = get_the_ID();
- $show_fake = false;
- if ( get_post_type( $post_id ) == 'dslc_templates' ) {
- $show_fake = true;
- } else {
- if ( get_post_meta( $post_id, 'dslc_download_file', true ) )
- $download_link = wp_get_attachment_url( get_post_meta( $post_id, 'dslc_download_file', true ) );
- elseif ( get_post_meta( $post_id, 'dslc_download_url', true ) )
- $download_link = get_post_meta( $post_id, 'dslc_download_url', true );
- else
- $download_link = false;
- }
- }
- /* Module output starts here */
-
- ?>
- <div class="dslc-tp-download-button">
- <?php if ( $show_fake ) : ?>
- <a href="#">
- <?php else : ?>
- <a target="_blank" class="dslc-download-count-hook" data-post-id="<?php echo $post_id; ?>" href="<?php echo $download_link; ?>">
- <?php endif; ?>
- <?php if ( isset( $options['button_icon_id'] ) && $options['button_icon_id'] != '' ) : ?>
- <span class="dslc-icon dslc-icon-<?php echo $options['button_icon_id']; ?>"></span>
- <?php endif; ?>
- <?php if ( $dslc_is_admin ) : ?>
- <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>
- <?php else : ?>
- <span><?php echo $options['button_text']; ?></span>
- <?php endif; ?>
- </a>
- </div><!-- .dslc-download-button -->
- <?php
- /* Module output ends here */
- $this->module_end( $options );
- }
- }