Beispiel #1
0
    function vcex_newsletter_form_shortcode($atts)
    {
        extract(shortcode_atts(array('provider' => 'mailchimp', 'mailchimp_form_action' => '', 'input_width' => '100%', 'input_height' => '50px', 'input_border' => '', 'input_border_radius' => '', 'input_bg' => '', 'input_color' => '', 'input_padding' => '', 'input_font_size' => '', 'input_letter_spacing' => '', 'input_weight' => '', 'input_transform' => '', 'placeholder_text' => __('Enter your email address', 'wpex'), 'submit_text' => __('Go', 'wpex'), 'submit_border' => '', 'submit_border_radius' => '', 'submit_bg' => '', 'submit_hover_bg' => '', 'submit_color' => '', 'submit_hover_color' => '', 'submit_padding' => '', 'submit_font_size' => '', 'submit_height' => '', 'submit_position_right' => '', 'submit_letter_spacing' => '', 'submit_weight' => '', 'submit_transform' => ''), $atts));
        // Turn output buffer on
        ob_start();
        // Vars
        $output = $input_style = $submit_style = $input_classes = $submit_data = '';
        // Input Style
        if ($input_border) {
            $input_style .= 'border:' . $input_border . ';';
        }
        if ($input_border_radius) {
            $input_style .= 'border-radius:' . $input_border_radius . ';';
        }
        if ($input_padding) {
            $input_style .= 'padding:' . $input_padding . ';';
        }
        if ($input_letter_spacing) {
            $input_style .= 'letter-spacing:' . $input_letter_spacing . ';';
        }
        if ($input_height) {
            $input_height = intval($input_height);
            $input_style .= 'height:' . $input_height . 'px;';
        }
        if ($input_bg) {
            $input_style .= 'background:' . $input_bg . ';';
        }
        if ($input_color) {
            $input_style .= 'color:' . $input_color . ';';
        }
        if ($input_font_size) {
            $input_style .= 'font-size:' . $input_font_size . ';';
        }
        if ($input_style) {
            $input_style = ' style="' . esc_attr($input_style) . '"';
        }
        // Input classes
        if ($input_weight) {
            $input_classes .= ' font-weight-' . $input_weight;
        }
        if ($input_transform) {
            $input_classes .= ' text-transform-' . $input_transform;
        }
        // Submit Style
        if ($submit_height) {
            $submit_height = intval($submit_height);
            $submit_style .= 'height:' . $submit_height . 'px;line-height: ' . $submit_height . 'px;margin-top:-' . $submit_height / 2 . 'px;';
        }
        if ($submit_position_right) {
            $submit_position_right = intval($submit_position_right);
            $submit_style .= 'right:' . $submit_position_right . 'px;';
        }
        if ($submit_border) {
            $submit_style .= 'border:' . $submit_border . ';';
        }
        if ($submit_letter_spacing) {
            $submit_style .= 'letter-spacing:' . $submit_letter_spacing . ';';
        }
        if ($submit_border_radius) {
            $submit_style .= 'border-radius:' . $submit_border_radius . ';';
        }
        if ($submit_padding) {
            $submit_style .= 'padding:' . $submit_padding . ';';
        }
        if ($submit_bg) {
            $submit_style .= 'background:' . $submit_bg . ';';
        }
        if ($submit_color) {
            $submit_style .= 'color:' . $submit_color . ';';
        }
        if ($submit_font_size) {
            $submit_style .= 'font-size:' . $submit_font_size . ';';
        }
        if ($submit_style) {
            $submit_style = ' style="' . esc_attr($submit_style) . '"';
        }
        // Submit classes
        $submit_classes = 'vcex-newsletter-form-button';
        if ($submit_weight) {
            ' font-weight-' . $submit_weight;
        }
        if ($submit_transform) {
            $submit_classes .= ' text-transform-' . $submit_transform;
        }
        // Submit Data
        if ($submit_hover_bg) {
            $submit_data .= ' data-hover-background="' . $submit_hover_bg . '"';
            $submit_classes .= ' wpex-data-hover';
        }
        if ($submit_hover_color) {
            $submit_data .= ' data-hover-color="' . $submit_hover_color . '"';
        }
        // Load inline js for data hover
        if ($submit_hover_bg || $submit_hover_color) {
            vcex_data_hover_js();
        }
        // Mailchimp
        if ($provider == 'mailchimp') {
            ?>
			<div class="vcex-newsletter-form clr">
				<!-- Begin MailChimp Signup Form -->
				<div id="mc_embed_signup" class="vcex-newsletter-form-wrap" style="width: <?php 
            echo $input_width;
            ?>
;">
					<form action="<?php 
            echo $mailchimp_form_action;
            ?>
" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
						<input type="email" value="<?php 
            echo $placeholder_text;
            ?>
" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" name="EMAIL" class="required email<?php 
            echo $input_classes;
            ?>
" id="mce-EMAIL"<?php 
            echo $input_style;
            ?>
>
						<button type="submit" value="" name="subscribe" id="mc-embedded-subscribe" class="<?php 
            echo $submit_classes;
            ?>
"<?php 
            echo $submit_style;
            echo $submit_data;
            ?>
>
							<?php 
            echo $submit_text;
            ?>
						</button>
					</form>
				</div><!--End mc_embed_signup-->
			</div><!-- .vcex-newsletter-form -->
		<?php 
        }
        // Return outbut buffer
        return ob_get_clean();
    }
Beispiel #2
0
    function vcex_button_shortcode($atts, $content = null)
    {
        extract(shortcode_atts(array('unique_id' => '', 'layout' => '', 'style' => 'flat', 'color' => 'blue', 'custom_color' => '', 'custom_background' => '', 'custom_hover_background' => '', 'custom_hover_color' => '', 'url' => '', 'title' => __('Visit Site', 'wpex'), 'target' => '', 'size' => 'normal', 'font_weight' => '', 'text_transform' => '', 'font_size' => '', 'letter_spacing' => '', 'font_padding' => '', 'align' => 'alignleft', 'rel' => '', 'border_radius' => '', 'class' => '', 'icon_left' => '', 'icon_right' => '', 'css_animation' => '', 'icon_left_padding' => '', 'icon_right_padding' => '', 'lightbox' => '', 'lightbox_type' => '', 'data_attributes' => '', 'classes' => ''), $atts));
        ob_start();
        // Unique ID
        if ($unique_id) {
            $unique_id = 'id="' . $unique_id . '"';
        }
        // Rel
        $rel = 'none' != $rel ? 'rel="' . $rel . '"' : NULL;
        // Button Classes
        if ($classes) {
            $classes .= ' ';
        }
        $classes .= 'vcex-button';
        if ($layout) {
            $classes .= ' ' . $layout;
        }
        $classes .= ' ' . $style;
        $classes .= ' align-' . $align;
        if ($size) {
            $classes .= ' ' . $size;
        }
        if ($text_transform) {
            $classes .= ' text-transform-' . $text_transform;
        }
        if ($color) {
            $classes .= ' ' . $color;
        }
        if ($class) {
            $classes .= ' ' . $class;
        }
        if ($css_animation) {
            $classes .= ' wpb_animate_when_almost_visible wpb_' . $css_animation . '';
        }
        if ('local' == $target) {
            $classes .= ' local-scroll-link';
        }
        // Lightbox classes and data attributes
        if ('' != $lightbox) {
            if ('image' == $lightbox_type) {
                $classes .= ' wpex-lightbox';
                $data_attributes .= 'data-type="image"';
            } elseif ('video_embed' == $lightbox_type) {
                $classes .= ' wpex-lightbox';
                $data_attributes .= 'data-type="iframe"';
                $data_attributes .= 'data-options="width:1920,height:1080"';
            } elseif ('html5' == $lightbox_type) {
                $poster = wp_get_attachment_image_src($img_id, 'large');
                $poster = $poster[0];
                $classes .= ' wpex-lightbox';
                $data_attributes .= 'data-type="video"';
                $data_attributes .= 'data-options="width:848, height:480, html5video: { webm: \'' . $lightbox_video_html5_webm . '\', poster: \'' . $poster . '\' }"';
            } elseif ('quicktime' == $lightbox_type) {
                $classes .= ' wpex-lightbox';
                $data_attributes .= 'data-type="video"';
                $data_attributes .= 'data-options="width:1920,height:1080"';
            } else {
                $classes .= ' wpex-lightbox-autodetect';
            }
        }
        // Wrap classes
        $wrap_classes = '';
        if ('center' == $align) {
            $wrap_classes = 'textcenter ';
        }
        if ('block' == $layout) {
            $wrap_classes .= 'vcex-button-block-wrap';
        }
        if ('expanded' == $layout) {
            $wrap_classes .= 'vcex-button-expanded-wrap';
            $classes .= ' expanded';
        }
        // Original styles
        $original_color = '#fff';
        // Custom Style
        $inline_style = '';
        if ($custom_background && in_array($style, array('flat', 'graphical', 'three-d'))) {
            $inline_style .= 'background:' . $custom_background . ';';
        }
        if ($custom_color) {
            $inline_style .= 'color:' . $custom_color . ';';
            $original_color = $custom_color;
            if ('outline' == $style) {
                $inline_style .= 'border-color:' . $custom_color . ';';
            }
        }
        if ($letter_spacing) {
            $inline_style .= 'letter-spacing:' . $letter_spacing . ';';
        }
        if ($font_size) {
            $inline_style .= 'font-size:' . $font_size . ';';
        }
        if ($font_weight) {
            $inline_style .= 'font-weight:' . $font_weight . ';';
        }
        if ($border_radius) {
            $inline_style .= 'border-radius:' . $border_radius . ';';
        }
        if ($font_padding) {
            $inline_style .= 'padding:' . $font_padding . ';';
        }
        if ($inline_style) {
            $inline_style = 'style="' . $inline_style . '"';
        }
        // Data attributes
        if ($custom_hover_background && in_array($style, array('flat', 'graphical', 'three-d'))) {
            $data_attributes .= 'data-hover-background="' . $custom_hover_background . '"';
        }
        if ($custom_hover_color && in_array($style, array('flat', 'graphical', 'three-d'))) {
            $data_attributes .= 'data-hover-color="' . $custom_hover_color . '"';
        }
        if ($data_attributes) {
            $classes .= ' wpex-data-hover';
        }
        // Link Target
        if ('blank' == $target) {
            $target = 'target="_' . $target . '"';
        } else {
            $target = '';
        }
        // Load inline js for data hover
        if ($custom_hover_background || $custom_hover_color) {
            vcex_data_hover_js();
        }
        // Display Button
        if ($wrap_classes) {
            ?>
			<div class="<?php 
            echo $wrap_classes;
            ?>
 clr">
		<?php 
        }
        ?>
		<a href="<?php 
        echo esc_url($url);
        ?>
" class="<?php 
        echo $classes;
        ?>
" title="<?php 
        echo $title;
        ?>
" <?php 
        echo $inline_style;
        ?>
 <?php 
        echo $rel;
        ?>
 <?php 
        echo $data_attributes;
        ?>
 <?php 
        echo $unique_id;
        ?>
 <?php 
        echo $target;
        ?>
>
			<span class="vcex-button-inner">
				<?php 
        // Left Icon
        if ($icon_left && 'none' !== $icon_left) {
            if ($icon_left_padding) {
                $icon_left_padding = 'style="padding-right: ' . $icon_left_padding . ';"';
            }
            ?>
					<span class="vcex-button-icon-left fa fa-<?php 
            echo $icon_left;
            ?>
" <?php 
            echo $icon_left_padding;
            ?>
></span>
				<?php 
        }
        // The button text
        echo $content;
        ?>
				<?php 
        // Right Icon
        if ($icon_right && 'none' != $icon_right) {
            if ($icon_right_padding) {
                $icon_right_padding = 'style="padding-left: ' . $icon_right_padding . ';"';
            }
            ?>
					<span class="vcex-button-icon-right fa fa-<?php 
            echo $icon_right;
            ?>
" <?php 
            echo $icon_right_padding;
            ?>
></span>
				<?php 
        }
        ?>
			</span>
		</a>
		<?php 
        if ($wrap_classes) {
            ?>
			</div>
		<?php 
        }
        return ob_get_clean();
    }