/** * Custom Image Output for Simple Image & Content template. */ function mm_posts_output_custom_post_image_simple_image_content($post, $context, $args) { $custom_output = apply_filters('mm_posts_post_image', '', $post, $context, $args); if ('' !== $custom_output) { echo $custom_output; return; } // Default to using the 'post-thumbnail' size. if ('' !== $args['featured_image_size']) { $image_size = esc_attr($args['featured_image_size']); } else { $image_size = 'post-thumbnail'; } // Check for existing featured image if (has_post_thumbnail($post->ID)) { $image_tag = get_the_post_thumbnail($post->ID, $image_size); } else { $fallback_image = $args['fallback_image']; // Support the fallback image if (is_numeric($fallback_image)) { $image_tag = wp_get_attachment_image($fallback_image, $image_size); } } // Output image with/without link if (mm_true_or_false($args['link_title'])) { printf('<div class="entry-image"><a href="%s">%s</a></div>', get_permalink($post->ID), $image_tag); } else { printf('<div class="entry-image">%s</div>', $image_tag); } }
/** * Default post title output. * * @since 1.0.0 * * @param object $post The current post object. * @param object $context The global post object. * @param array $args The instance args. */ function mm_posts_output_post_title($post, $context, $args) { $custom_output = apply_filters('mm_posts_post_title', '', $post, $context, $args); if ('' !== $custom_output) { echo $custom_output; return; } $heading_level = $args['heading_level']; $link_title = mm_true_or_false($args['link_title']); if ($link_title) { printf('<%s class="entry-title" itemprop="headline"><a href="%s" title="%s" rel="bookmark">%s</a></%s>', esc_attr($heading_level), get_permalink($post->ID), get_the_title($post->ID), get_the_title($post->ID), esc_attr($heading_level)); } else { printf('<%s class="entry-title" itemprop="headline">%s</%s>', esc_attr($heading_level), get_the_title($post->ID), esc_attr($heading_level)); } }
/** * Build and return the Social Icons component. * * @since 1.0.0 * * @param array $args The args. * * @return string The HTML. */ function mm_social_icons($args) { $component = 'mm-social-icons'; // Set our defaults and use them as needed. $defaults = array('icon_type' => 'fontawesome', 'image_size' => 'thumbnail', 'alignment' => 'left', 'style' => 'icon-only', 'ghost' => '', 'color' => '', 'size' => 'normal-size'); $args = wp_parse_args((array) $args, $defaults); // Allow custom output to be used. $custom_output = apply_filters('mm_social_icons_custom_output', '', $args); if ('' !== $custom_output) { return $custom_output; } // Get clean param values. $icon_type = $args['icon_type']; $image_size = $args['image_size']; $alignment = $args['alignment']; $style = $args['style']; $ghost = $args['ghost']; $color = $args['color']; $size = $args['size']; $social_networks = mm_get_social_networks('mm-social-icons'); // Set up the icon classes. $classes = array(); if ('images' == $icon_type) { $classes[] = 'images'; $alignment = 'mm-image-align-' . $args['alignment']; } else { $classes[] = 'icons'; $alignment = 'mm-text-align-' . $args['alignment']; } if (!empty($style)) { $classes[] = $style; } if (mm_true_or_false($ghost)) { $classes[] = 'ghost'; } if (!empty($color)) { $classes[] = $color; } if (!empty($size)) { $classes[] = $size; } $classes = implode(' ', $classes); // Get Mm classes. $mm_classes = apply_filters('mm_components_custom_classes', '', $component, $args); // Combine Mm classes with icon classes. $mm_classes = $mm_classes . ' ' . $classes . ' ' . $alignment; ob_start(); ?> <div class="<?php echo esc_attr($mm_classes); ?> "> <?php foreach ($social_networks as $social_network => $social_network_name) { $link = isset($args[$social_network . '_link']) ? $args[$social_network . '_link'] : ''; $image = isset($args[$social_network . '_image']) ? $args[$social_network . '_image'] : ''; if ($link) { if ('images' == $icon_type && (int) $image) { $icon = wp_get_attachment_image((int) $image, $image_size); } else { $icon_class = 'fa fa-' . $social_network; $icon_class = apply_filters('mm_social_icons_icon_class', $icon_class, $social_network, $args); $icon = sprintf('<i class="icon %s"></i>', esc_attr($icon_class)); } printf('<a href="%s" class="%s">%s</a>', esc_url($link), esc_attr($social_network . '-link'), $icon); } } ?> </div> <?php return ob_get_clean(); }
/** * Output the Widgets settings form. * * @since 1.0.0 * * @param array $instance The options for the widget instance. */ public function form($instance) { $defaults = array('title' => '', 'link' => '', 'button_text' => '', 'style' => '', 'corner_style' => '', 'border_weight' => '', 'color' => '', 'size' => '', 'full_width' => '', 'alignment' => ''); // Use our instance args if they are there, otherwise use the defaults. $instance = wp_parse_args($instance, $defaults); $title = $instance['title']; $link = $instance['link']; $button_text = $instance['button_text']; $style = $instance['style']; $corner_style = $instance['corner_style']; $border_weight = $instance['border_weight']; $color = $instance['color']; $size = $instance['size']; $full_width = mm_true_or_false($instance['full_width']); $alignment = $instance['alignment']; $classname = $this->options['classname']; $colors = mm_get_colors('mm-button'); $text_alignment = mm_get_text_alignment('mm-button'); // Handle the case of a newly added widget that doesn't yet have button text set. $preview_instance = $instance; if ('' == $preview_instance['button_text']) { $preview_instance['button_text'] = __('Button Text', 'mm-components'); } // Title. $this->field_text(__('Title', 'mm-components'), '', $classname . '-title widefat', 'title', $title); // Preview. $this->field_custom(__('Button Preview', 'mm-components'), '', '<div class="mm-button-preview-wrap">' . mm_button($preview_instance) . '</div>'); // Button text. $this->field_text(__('Button Text', 'mm-components'), '', $classname . '-button-text widefat', 'button_text', $button_text); // Link. $this->field_text(__('Button Link', 'mm-components'), '', $classname . '-link widefat', 'link', $link); // Button style. $this->field_select(__('Button Style', 'mm-components'), '', $classname . '-style widefat', 'style', $style, array('default' => __('Default', 'mm-components'), 'ghost' => __('Ghost', 'mm-components'), 'solid-to-ghost' => __('Solid to Ghost', 'mm-components'), 'three-d' => __('3D', 'mm-components'), 'gradient' => __('Gradient', 'mm-components'))); // Corner style. $this->field_select(__('Corner Style', 'mm-components'), '', $classname . '-corner-style widefat', 'corner_style', $corner_style, array('pointed' => __('Pointed', 'mm-components'), 'rounded' => __('Rounded', 'mm-components'), 'pill' => __('Pill', 'mm-components'))); // Border weight. $this->field_select(__('Border Weight', 'mm-components'), '', $classname . 'border-weight widefat', 'border_weight', $border_weight, array('thin' => __('Thin', 'mm-components'), 'thick' => __('Thick', 'mm-components'))); // Color. $this->field_select(__('Color', 'mm-components'), '', $classname . '-color widefat', 'color', $color, $colors); // Size. $this->field_select(__('Size', 'mm-components'), '', $classname . '-size widefat', 'size', $size, array('normal' => __('Normal', 'mm-components'), 'small' => __('Small', 'mm-components'), 'large' => __('Large', 'mm-components'))); // Full width. $this->field_checkbox(__('Full Width', 'mm-components'), __('Choosing full-width will make the button take up the width of its container.', 'mm-components'), $classname . '-full-width widefat', 'full_width', $full_width); // Alignment. $this->field_select(__('Button Alignment', 'mm-components'), '', $classname . '-alignment widefat', 'alignment', $alignment, $text_alignment); }
/** * Output an alpha color picker. * * @since 1.0.0 */ public function field_alpha_color_picker($label = '', $description = '', $classes = '', $key = '', $value = '', $options = array()) { // Set our defaults for additional args. $palette = isset($options['palette']) ? $options['palette'] : 'true'; $default = isset($options['default']) ? $options['default'] : '#222'; $show_opacity = isset($options['show-opacity']) ? $options['show_opacity'] : 'true'; // Process the palette. if (is_array($palette)) { $palette = implode('|', $palette); } else { $palette = mm_true_or_false($palette) ? 'true' : 'false'; } $show_opacity = mm_true_or_false($show_opacity) ? 'true' : 'false'; echo '<p class="mm-alpha-color-picker-field-wrap">'; echo '<label>' . esc_html($label) . '</label><br />'; printf('<input class="%s" type="text" name="%s" value="%s" data-palette="%s" data-show-opacity="%s" data-default-color="%s" />', esc_attr($classes) . ' alpha-color-picker', $this->get_field_name($key), esc_attr($value), esc_attr($palette), esc_attr($show_opacity), esc_attr($default)); if ('' !== $description) { printf('<small class="mm-description-text">%s</small>', esc_html($description)); } echo '</p>'; }
/** * Default post content output. * * @since 1.0.0 * * @param object $post The current post object. * @param object $context The global post object. * @param array $args The instance args. */ function mm_posts_output_post_content($post, $context, $args) { $custom_output = apply_filters('mm_posts_post_content', '', $post, $context, $args); if ('' !== $custom_output) { echo $custom_output; return; } echo '<div class="entry-content" itemprop="text">'; if (mm_true_or_false($args['use_post_content'])) { the_content(); } else { the_excerpt(); } echo '</div>'; }
/** * MIGHTYminnow Components * * Component: Hero Banner * * @package mm-components * @since 1.0.0 */ function mm_hero_banner($args) { $component = 'mm-hero-banner'; // Set our defaults and use them as needed. $defaults = array('background_image' => '', 'background_position' => 'center center', 'full_height' => 0, 'min_height' => 360, 'overlay_color' => '', 'overlay_opacity' => '0.1', 'text_color' => 'default', 'heading_level' => 'h2', 'heading_text' => '', 'content' => '', 'secondary_content' => '', 'content_align' => 'left', 'button_link' => '', 'button_link_target' => '_self', 'button_text' => '', 'button_style' => '', 'button_border_weight' => 'default', 'button_corner_style' => '', 'button_color' => ''); $args = wp_parse_args((array) $args, $defaults); // Get clean param values. $background_image = $args['background_image']; $background_position = $args['background_position']; $full_height = $args['full_height']; $min_height = $args['min_height']; $overlay_color = $args['overlay_color']; $overlay_opacity = $args['overlay_opacity']; $text_color = $args['text_color']; $heading_level = $args['heading_level']; $heading_text = $args['heading_text']; $content = $args['content']; $secondary_content = $args['secondary_content']; $content_align = $args['content_align']; $button_link = $args['button_link']; $button_link_target = $args['button_link_target']; $button_text = $args['button_text']; $button_style = $args['button_style']; $button_border_weight = $args['button_border_weight']; $button_corner_style = $args['button_corner_style']; $button_color = $args['button_color']; $heading_output = ''; $content_output = ''; $overlay_output = ''; $button_output = ''; $secondary_content_output = ''; // Get Mm classes. $mm_classes = apply_filters('mm_components_custom_classes', '', $component, $args); $mm_classes .= ' mm-text-align-' . $content_align; if (mm_true_or_false($full_height)) { $mm_classes .= ' mm-full-window-height'; } // Support the background image being an ID or a URL. if (is_numeric($background_image)) { $image_size = apply_filters('mm_hero_banner_image_size', 'full'); $image_array = wp_get_attachment_image_src($background_image, $image_size); $image_url = $image_array[0]; } else { $image_url = esc_url($background_image); } // Build wrapper styles. $wrap_styles = array(); if ($image_url) { $wrap_styles[] = "background-image: url({$image_url});"; } if ($background_position) { $wrap_styles[] = "background-position: {$background_position};"; } if (1 < (int) $min_height) { $wrap_styles[] = 'min-height: ' . (int) $min_height . 'px;'; } $wrap_styles = implode(' ', $wrap_styles); // Build background overlay. if ($overlay_color) { $overlay_styles = array(); $overlay_styles[] = 'background-color: ' . $overlay_color . ';'; $overlay_styles[] = 'opacity: ' . (double) $overlay_opacity . ';'; $overlay_styles[] = 'filter: alpha(opacity=' . (double) $overlay_opacity * 100 . ');'; $overlay_styles = implode(' ', $overlay_styles); $overlay_output = '<div class="hero-overlay" style="' . esc_attr($overlay_styles) . '"></div>'; } // Build the heading. if ($heading_text) { $heading_output = sprintf('<%s class="hero-heading %s">%s</%s>', esc_html($heading_level), esc_attr('mm-text-color-' . $text_color), esc_html($heading_text), esc_html($heading_level)); } // Build the content. if (strpos($content, '<')) { /* We have HTML */ $content_output = function_exists('wpb_js_remove_wpautop') ? wpb_js_remove_wpautop($content, true) : $content; } elseif (mm_is_base64($content)) { /* We have a base64 encoded string */ $content_output = rawurldecode(base64_decode($content)); } else { /* We have a non-HTML string */ $content_output = $content; } if ($content) { $content_output = sprintf('<div class="hero-content %s">%s</div>', esc_attr('mm-text-color-' . $text_color), do_shortcode($content_output)); } // Build the button output. if ($button_text) { $button_args = array('link' => $button_link, 'link_title' => $button_text, 'link_target' => $button_link_target, 'button_text' => $button_text, 'style' => $button_style, 'corner_style' => $button_corner_style, 'border_weight' => $button_border_weight, 'color' => $button_color, 'alignment' => $content_align); $button_output = mm_button($button_args); } // Handle $secondary_content being HTML, plain text, or a base64 encoded string. if (strpos($secondary_content, '<')) { /* We have HTML */ $secondary_content_output = function_exists('wpb_js_remove_wpautop') ? wpb_js_remove_wpautop($secondary_content, true) : $secondary_content; } elseif (mm_is_base64($secondary_content)) { /* We have a base64 encoded string */ $secondary_content_output = rawurldecode(base64_decode($secondary_content)); } else { /* We have a non-HTML string */ $secondary_content_output = $secondary_content; } if ($secondary_content) { $secondary_content_output = sprintf('<div class="hero-secondary-content %s">%s</div>', esc_attr('mm-text-color-' . $text_color), do_shortcode($secondary_content_output)); } ob_start(); ?> <div class="<?php echo esc_attr($mm_classes); ?> " style="<?php echo esc_attr($wrap_styles); ?> "> <?php echo $overlay_output; ?> <div class="hero-content-wrap"> <?php echo wp_kses_post($heading_output); ?> <?php echo wp_kses_post($content_output); ?> <?php echo wp_kses_post($button_output); ?> <?php echo wp_kses_post($secondary_content_output); ?> </div> </div> <?php return ob_get_clean(); }