Exemple #1
0
 protected function get_button_html()
 {
     // add icon
     $icon = $this->atts['icon'];
     if ($icon) {
         if ('right' == $this->atts['icon_align']) {
             $this->content .= $icon;
         } else {
             $this->content = $icon . $this->content;
         }
     }
     return presscore_get_button_html(array('href' => $this->atts['link'], 'title' => $this->content, 'target' => $this->atts['target_blank'], 'class' => $this->get_button_class(), 'atts' => $this->get_button_style()));
 }
 protected function get_button_html()
 {
     // add icon
     $icon = $this->atts['icon'];
     if ($icon) {
         if ('right' == $this->atts['icon_align']) {
             $this->content .= $icon;
         } else {
             $this->content = $icon . $this->content;
         }
     }
     $button_html = presscore_get_button_html(array('href' => $this->atts['link'], 'title' => $this->content, 'target' => $this->atts['target_blank'], 'class' => $this->get_button_class(), 'atts' => $this->get_button_style()));
     if ('center' == $this->atts['button_alignment']) {
         $button_html = '<div class="text-centered">' . $button_html . '</div>';
     }
     return $button_html;
 }
 /**
  * Get project link.
  *
  * return string HTML.
  */
 function presscore_get_project_link($class = 'link dt-btn')
 {
     if (post_password_required() || !in_the_loop()) {
         return '';
     }
     $config = presscore_get_config();
     // project link html
     $project_link = '';
     if ($config->get('post.buttons.link.enabled')) {
         $title = $config->get('post.buttons.link.title');
         if (!$title) {
             $class .= ' no-text';
         }
         $project_link = presscore_get_button_html(array('title' => $title ? $title : __('Link', LANGUAGE_ZONE), 'href' => $config->get('post.buttons.link.url'), 'target' => $config->get('post.buttons.link.target_blank'), 'class' => $class));
     }
     return $project_link;
 }
 protected function get_html()
 {
     $before_title = $after_title = '';
     // add icon
     $icon = $this->atts['icon'];
     if ($icon) {
         if ('right' == $this->atts['icon_align']) {
             $after_title = $icon;
         } else {
             $before_title = $icon;
         }
     }
     // get button html
     $button_html = presscore_get_button_html(array('before_title' => $before_title, 'after_title' => $after_title, 'href' => $this->atts['link'], 'title' => $this->content, 'target' => $this->atts['target_blank'], 'class' => $this->get_html_class(), 'atts' => ' id="' . $this->get_button_id() . '"'));
     // alignment
     if ('center' == $this->atts['button_alignment']) {
         $button_html = '<div class="text-centered">' . $button_html . '</div>';
     }
     // get inline styleseet tag
     $output = $this->get_inline_style_tag();
     $output .= $button_html;
     return $output;
 }
Exemple #5
0
 function widget($args, $instance)
 {
     // enqueue script in footer
     $this->presscore_enqueue_scripts();
     static $number = 0;
     $number++;
     extract($args);
     $instance = wp_parse_args((array) $instance, self::$widget_defaults);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $text = $instance['text'];
     $send_to = $instance['send_to'];
     $fields = $instance['fields'];
     $fields_not_empty = in_array(true, wp_list_pluck($fields, 'on'));
     $msg_height = $instance['msg_height'];
     $class_adapter = array('email' => 'mail');
     echo $before_widget;
     // title
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     // content
     if ($text) {
         echo '<div class="widget-info">' . apply_filters('get_the_excerpt', $text) . '</div>';
     }
     // fields
     if ($fields_not_empty) {
         // form begin
         echo '<form class="contact-form dt-form" action="/" method="post">' . "\n";
         echo '<input type="hidden" name="widget_id" value="' . $this->id . '" />';
         // some sort of bot check
         echo '<input type="hidden" name="send_message" value="" />';
         $fields_str = '';
         $message = '';
         // fields loop
         foreach ($fields as $index => $field) {
             $tmp_field = '';
             // if field disabled - continue
             if (empty($field['on'])) {
                 continue;
             }
             // if field not in reference array - continue
             // this check may be replased with array_intersect_key before loop
             if (!isset(self::$fields_list[$index])) {
                 continue;
             }
             // get field data from reference array ( title and default values )
             $field_data = self::$fields_list[$index];
             // init some handy variables
             $valid_class = '';
             $title = $field_data['title'];
             $name = $index;
             $required_str = 'false';
             $field_class = $index;
             // class adapter for some of fields
             if (isset($class_adapter[$index])) {
                 $field_class = $class_adapter[$index];
             }
             // do some stuff for required fields
             if ($field['required']) {
                 // add * to title )
                 $title .= ' *';
                 // some strange flag
                 $required_str = 'true';
                 // construct validation class for validationEngine
                 $valid_params = array('required');
                 switch ($index) {
                     case 'email':
                         $valid_params[] = 'custom[email]';
                         break;
                     case 'telephone':
                         $valid_params[] = 'custom[phone]';
                         break;
                     case 'website':
                         $valid_params[] = 'custom[url]';
                         break;
                 }
                 $valid_class = ' class="' . esc_attr(sprintf('validate[%s]', implode(',', $valid_params))) . '"';
             }
             // escape some variables for output
             $title = esc_attr($title);
             $name = esc_attr($name);
             $required_str = esc_attr($required_str);
             // textarea or input ?
             if ('message' != $index) {
                 $tmp_field = '<input type="text"' . $valid_class . ' placeholder="' . $title . '" name="' . $name . '" value="" aria-required="' . $required_str . '">' . "\n";
             } else {
                 $tmp_field = '<textarea' . $valid_class . ' placeholder="' . $title . '" name="' . $name . '" rows="' . esc_attr($msg_height) . '" aria-required="' . $required_str . '"></textarea>' . "\n";
             }
             // end field output
             $tmp_field = sprintf('<span class="form-%s"><label class="assistive-text">%s</label>%s</span>', esc_attr($field_class), $title, $tmp_field);
             if ('message' != $index) {
                 $fields_str .= $tmp_field;
             } else {
                 $message = $tmp_field;
             }
         }
         if ($fields_str) {
             $fields_str = '<div class="form-fields">' . $fields_str . '</div>';
         }
         echo $fields_str . $message;
         $button_title = !empty($instance['button_title']) ? $instance['button_title'] : _x('Submit', 'widget', LANGUAGE_ZONE);
         // buttons
         echo '<p>';
         echo presscore_get_button_html(array('href' => '#', 'title' => esc_html($button_title), 'class' => 'dt-btn dt-btn-' . esc_attr($instance['button_size']) . ' dt-btn-submit'));
         echo presscore_get_button_html(array('href' => '#', 'title' => _x('clear', 'widget', LANGUAGE_ZONE), 'class' => 'clear-form'));
         echo '<input class="assistive-text" type="submit" value="' . esc_attr(_x('submit', 'widget', LANGUAGE_ZONE)) . '">';
         echo '</p>';
         // form end
         echo '</form>' . "\n";
     }
     echo $after_widget;
 }
 /**
  * PressCore comments fields filter. Add Post Comment and clear links before hudden fields.
  *
  * @since presscore 0.1
  */
 function presscore_comment_id_fields_filter($result)
 {
     $comment_buttons = presscore_get_button_html(array('href' => 'javascript: void(0);', 'title' => __('clear form', 'the7mk2'), 'class' => 'clear-form'));
     $comment_buttons .= presscore_get_button_html(array('href' => 'javascript: void(0);', 'title' => __('Submit', 'the7mk2'), 'class' => 'dt-btn dt-btn-m'));
     return $comment_buttons . $result;
 }
Exemple #7
0
 /**
  * Get project link.
  *
  * return string HTML.
  */
 function presscore_get_project_link($class = 'link dt-btn')
 {
     if (post_password_required() || !in_the_loop()) {
         return '';
     }
     global $post;
     // project link
     $project_link = '';
     if (get_post_meta($post->ID, '_dt_project_options_show_link', true)) {
         $title = get_post_meta($post->ID, '_dt_project_options_link_name', true);
         $project_link = presscore_get_button_html(array('title' => $title ? $title : __('Link', LANGUAGE_ZONE), 'href' => get_post_meta($post->ID, '_dt_project_options_link', true), 'target' => get_post_meta($post->ID, '_dt_project_options_link_target', true), 'class' => $class));
     }
     return $project_link;
 }
 /**
  * Display share buttons.
  */
 function presscore_display_share_buttons($place = '', $options = array())
 {
     $default_options = array('echo' => true, 'class' => array('project-share-overlay'), 'id' => null, 'title' => of_get_option("social_buttons-{$place}-button_title", ''));
     $options = wp_parse_args($options, $default_options);
     $share_buttons = presscore_get_share_buttons_list($place, $options['id']);
     if (apply_filters('presscore_hide_share_buttons', empty($share_buttons))) {
         return '';
     }
     $class = $options['class'];
     if (!is_array($class)) {
         $class = explode(' ', $class);
     }
     $title = esc_html($options['title']);
     $html = '<div class="' . esc_attr(implode(' ', $class)) . '">' . presscore_get_button_html(array('title' => $title ? $title : __('Share this', 'the7mk2'), 'href' => '#', 'class' => 'share-button entry-share h5-size' . ($title ? '' : ' no-text'))) . '<div class="soc-ico">' . implode('', $share_buttons) . '</div>' . '</div>';
     $html = apply_filters('presscore_display_share_buttons', $html);
     if ($options['echo']) {
         echo $html;
     }
     return $html;
 }
Exemple #9
0
 public function shortcode($atts, $content = null)
 {
     $default_atts = array('size' => 'link', 'color' => '', 'link' => '', 'target_blank' => '1', 'animation' => 'none', 'icon' => '', 'icon_align' => 'left', 'el_class' => '');
     extract(shortcode_atts($default_atts, $atts));
     $button_colors = array('white', 'red', 'berry', 'orange', 'yellow', 'pink', 'green', 'dark_green', 'blue', 'dark_blue', 'violet', 'black', 'gray', 'grey');
     $link = $link ? esc_url($link) : '#';
     $size = in_array($size, array('link', 'small', 'medium', 'big')) ? $size : $default_atts['size'];
     $color = in_array($color, $button_colors) ? $color : $default_atts['color'];
     $target_blank = apply_filters('dt_sanitize_flag', $target_blank);
     $animation = in_array($animation, array('none', 'scale', 'fade', 'left', 'right', 'bottom', 'top')) ? $animation : $default_atts['animation'];
     $icon_align = in_array($icon_align, array('left', 'right')) ? $icon_align : $default_atts['icon_align'];
     $el_class = sanitize_html_class($el_class);
     // if we have base64 code
     if (preg_match('/^fa\\sfa-(\\w)/', $icon)) {
         $icon = '<i class="' . esc_attr($icon) . '"></i>';
     } else {
         $icon = wp_kses(rawurldecode(base64_decode($icon)), array('i' => array('class' => array())));
     }
     $classes = array();
     switch ($size) {
         case 'small':
             $classes[] = 'dt-btn';
             $classes[] = 'dt-btn-s';
             break;
         case 'medium':
             $classes[] = 'dt-btn';
             $classes[] = 'dt-btn-m';
             break;
         case 'big':
             $classes[] = 'dt-btn';
             $classes[] = 'dt-btn-l';
             break;
         default:
             $classes[] = 'more-link';
             $classes[] = 'details';
     }
     if ($color) {
         $color = 'grey' == $color ? 'gray' : $color;
         $classes[] = 'btn-' . str_replace('_', '-', $color);
     }
     if ('none' != $animation) {
         switch ($animation) {
             case 'scale':
                 $classes[] = 'scale-up';
                 break;
             case 'fade':
                 $classes[] = 'fade-in';
                 break;
             case 'left':
                 $classes[] = 'right-to-left';
                 break;
             case 'right':
                 $classes[] = 'left-to-right';
                 break;
             case 'bottom':
                 $classes[] = 'top-to-bottom';
                 break;
             case 'top':
                 $classes[] = 'bottom-to-top';
                 break;
         }
         $classes[] = 'animate-element';
         $classes[] = 'animation-builder';
     }
     // add icon
     if ($icon && 'right' == $icon_align) {
         $content .= $icon;
         $classes[] = 'ico-right-side';
     } else {
         if ($icon) {
             $content = $icon . $content;
         }
     }
     if ($el_class) {
         $classes[] = $el_class;
     }
     // ninjaaaa!
     $classes = implode(' ', $classes);
     // $output = '<a class="' . esc_attr( $classes ) . '" href="' . $link . '"' . ($target_blank ? ' target="_blank"' : '') . '>' . $content . '</a>';
     $output = presscore_get_button_html(array('href' => $link, 'title' => $content, 'class' => $classes, 'target' => $target_blank));
     return $output;
 }