widget_title = __( 'Content' , 'layerswp' ); $this->widget_id = 'column'; $this->post_type = ''; $this->taxonomy = ''; $this->checkboxes = array(); /* Widget settings. */ $widget_ops = array( 'classname' => 'obox-layers-' . $this->widget_id .'-widget', 'description' => __( 'This widget is used to display text and images in a flexible grid.', 'layerswp' ), 'customize_selective_refresh' => TRUE, ); /* Widget control settings. */ $control_ops = array( 'width' => LAYERS_WIDGET_WIDTH_LARGE, 'height' => NULL, 'id_base' => LAYERS_THEME_SLUG . '-widget-' . $this->widget_id, ); /* Create the widget. */ parent::__construct( LAYERS_THEME_SLUG . '-widget-' . $this->widget_id , $this->widget_title, $widget_ops, $control_ops ); /* Setup Widget Defaults */ $this->defaults = array ( 'title' => __( 'Our Services', 'layerswp' ), 'excerpt' => __( 'Our services run deep and are backed by over ten years of experience.', 'layerswp' ), 'design' => array( 'layout' => 'layout-boxed', 'liststyle' => 'list-grid', 'gutter' => 'on', 'background' => array( 'position' => 'center', 'repeat' => 'no-repeat' ), 'fonts' => array( 'align' => 'text-left', 'size' => 'medium', 'color' => NULL, 'shadow' => NULL, 'heading-type' => 'h3', ) ), ); /* Setup Widget Repeater Defaults */ $this->register_repeater_defaults( 'column', 3, array( 'title' => __( 'Your service title', 'layerswp' ), 'excerpt' => __( 'Give us a brief description of the service that you are promoting. Try keep it short so that it is easy for people to scan your page.', 'layerswp' ), 'width' => '4', 'design' => array( 'featuredimage-size' => '', 'imagealign' => 'image-top', 'background' => NULL, 'fonts' => array( 'align' => 'text-left', 'size' => 'medium', 'color' => NULL, 'shadow' => NULL, 'heading-type' => 'h5', ), ), ) ); } /** * Widget front end display */ function widget( $args, $instance ) { global $wp_customize; $this->backup_inline_css(); // Turn $args array into variables. extract( $args ); // Use defaults if $instance is empty. if( empty( $instance ) && ! empty( $this->defaults ) ) { $instance = wp_parse_args( $instance, $this->defaults ); } // Mix in new/unset defaults on every instance load (NEW) $instance = $this->apply_defaults( $instance ); // Enqueue Masonry if need be if( 'list-masonry' == $this->check_and_return( $instance , 'design', 'liststyle' ) ) { wp_enqueue_script( LAYERS_THEME_SLUG . '-layers-masonry-js' ); } // Set the background styling if( !empty( $instance['design'][ 'background' ] ) ) $this->inline_css .= layers_inline_styles( '#' . $widget_id, 'background', array( 'background' => $instance['design'][ 'background' ] ) ); if( !empty( $instance['design']['fonts'][ 'color' ] ) ) $this->inline_css .= layers_inline_styles( '#' . $widget_id, 'color', array( 'selectors' => array( '.section-title .heading' , '.section-title div.excerpt' ) , 'color' => $instance['design']['fonts'][ 'color' ] ) ); // Apply the advanced widget styling $this->apply_widget_advanced_styling( $widget_id, $instance ); /** * Generate the widget container class */ $widget_container_class = array(); $widget_container_class[] = 'widget'; $widget_container_class[] = 'layers-content-widget'; $widget_container_class[] = 'content-vertical-massive'; $widget_container_class[] = ( 'on' == $this->check_and_return( $instance , 'design', 'background', 'darken' ) ? 'darken' : '' ); $widget_container_class[] = $this->check_and_return( $instance , 'design', 'advanced', 'customclass' ); // Apply custom class from design-bar's advanced control. $widget_container_class[] = $this->get_widget_spacing_class( $instance ); $widget_container_class = apply_filters( 'layers_content_widget_container_class' , $widget_container_class, $this, $instance ); $widget_container_class = implode( ' ', $widget_container_class ); // Custom Anchor echo $this->custom_anchor( $instance ); ?>
selective_refresh_atts( $args ); ?>> check_and_return( $instance , 'title' ) || NULL !== $this->check_and_return( $instance , 'excerpt' ) ) { ?>
check_and_return( $instance , 'design', 'fonts', 'size' ); $section_title_class[] = $this->check_and_return( $instance , 'design', 'fonts', 'align' ); $section_title_class[] = ( $this->check_and_return( $instance, 'design', 'background' , 'color' ) && 'dark' == layers_is_light_or_dark( $this->check_and_return( $instance, 'design', 'background' , 'color' ) ) ? 'invert' : '' ); $section_title_class = implode( ' ', $section_title_class ); ?>
check_and_return( $instance, 'title' ) ) { ?> <check_and_return( $instance, 'design', 'fonts', 'heading-type' ); ?> class="heading"> check_and_return( $instance, 'design', 'fonts', 'heading-type' ); ?>> check_and_return( $instance, 'excerpt' ) ) { ?>
apply_defaults( $item_instance, 'column' ); // Get the Next Column for use later. if( isset( $column_ids[ ($col_no+1) ] ) && isset( $instance[ 'columns' ][ $column_ids[ ($col_no+1) ] ] ) ) { $next_item = $instance[ 'columns' ][ $column_ids[ ($col_no+1) ] ]; } // Set the background styling if( !empty( $item_instance['design'][ 'background' ] ) ) $this->inline_css .= layers_inline_styles( '#' . $widget_id . '-' . $column_key , 'background', array( 'background' => $item_instance['design'][ 'background' ] ) ); if( !empty( $item_instance['design']['fonts'][ 'color' ] ) ) $this->inline_css .= layers_inline_styles( '#' . $widget_id . '-' . $column_key , 'color', array( 'selectors' => array( '.heading a', '.heading' , 'div.excerpt' , 'div.excerpt p' ) , 'color' => $item_instance['design']['fonts'][ 'color' ] ) ); if( !empty( $item_instance['design']['fonts'][ 'shadow' ] ) ) $this->inline_css .= layers_inline_styles( '#' . $widget_id . '-' . $column_key , 'text-shadow', array( 'selectors' => array( '.heading a', '.heading' , 'div.excerpt' , 'div.excerpt p' ) , 'text-shadow' => $item_instance['design']['fonts'][ 'shadow' ] ) ); // Set column margin & padding if ( !empty( $item_instance['design']['advanced']['margin'] ) ) $this->inline_css .= layers_inline_styles( "#{$widget_id}-{$column_key}", 'margin', array( 'margin' => $item_instance['design']['advanced']['margin'] ) ); if ( !empty( $item_instance['design']['advanced']['padding'] ) ) $this->inline_css .= layers_inline_styles( "#{$widget_id}-{$column_key}", 'padding', array( 'padding' => $item_instance['design']['advanced']['padding'] ) ); if( !isset( $item_instance[ 'width' ] ) ) $item_instance[ 'width' ] = $this->column_defaults[ 'width' ]; // Set the button styling $button_size = ''; if ( function_exists( 'layers_pro_apply_widget_button_styling' ) ) { $this->inline_css .= layers_pro_apply_widget_button_styling( $this, $item_instance, array( "#{$widget_id}-{$column_key} .button" ) ); $button_size = $this->check_and_return( $item_instance , 'design' , 'buttons-size' ) ? 'btn-' . $this->check_and_return( $item_instance , 'design' , 'buttons-size' ) : '' ; } // Add the correct span class $span_class = 'span-' . $item_instance[ 'width' ]; $col_no++; $max = 12; $initial_width = $row_width; $item_width = $item_instance[ 'width' ]; $next_item_width = ( isset( $next_item[ 'width' ] ) ? $next_item[ 'width' ] : 0 ); $row_width += $item_width; if( $max == $row_width ){ $first_last_class = 'last'; $row_width = 0; } elseif( $max < $next_item_width + $row_width ){ $first_last_class = 'last'; $row_width = 0; } elseif( 0 == $initial_width ){ $first_last_class = 'first'; } else { $first_last_class = ''; } // Set Featured Media $featureimage = $this->check_and_return( $item_instance , 'design' , 'featuredimage' ); $featurevideo = $this->check_and_return( $item_instance , 'design' , 'featuredvideo' ); // Calculate which cut based on ratio. if( isset( $item_instance['design'][ 'imageratios' ] ) ){ // Translate Image Ratio into something usable $image_ratio = layers_translate_image_ratios( $item_instance['design'][ 'imageratios' ] ); if( !isset( $item_instance[ 'width' ] ) ) $item_instance[ 'width' ] = 6; if( 4 >= $item_instance['width'] && 'layout-fullwidth' != $this->check_and_return( $instance, 'design', 'layout' ) ) $use_image_ratio = $image_ratio . '-medium'; else $use_image_ratio = $image_ratio . '-large'; } else { if( 4 > $item_instance['width'] ) $use_image_ratio = 'medium'; else $use_image_ratio = 'full'; } $media = layers_get_feature_media( $featureimage , $use_image_ratio , $featurevideo ); // Set Image Size if( isset( $item_instance['design']['featuredimage-size'] ) && 0 != $item_instance['design']['featuredimage-size'] && '' != $item_instance['design']['featuredimage-size'] ) { $image_width = $item_instance['design'][ 'featuredimage-size' ].'px'; $this->inline_css .= layers_inline_styles( "#{$widget_id}-{$column_key} .media-image img { max-width : {$image_width}; }"); } // Get the link array. $link_array = $this->check_and_return_link( $item_instance, 'button' ); $link_href_attr = ( $link_array['link'] ) ? 'href="' . esc_url( $link_array['link'] ) . '"' : ''; $link_target_attr = ( '_blank' == $link_array['target'] ) ? 'target="_blank"' : ''; /** * Set Individual Column CSS */ $classes = array(); $classes[] = 'layers-masonry-column'; $classes[] = $this->id_base . '-' . $column_key; $classes[] = $span_class; $classes[] = ( 'on' == $this->check_and_return( $item_instance , 'design', 'background', 'darken' ) ? 'darken' : '' ); $classes[] = ( '' != $first_last_class ? $first_last_class : '' ); $classes[] = ( 'list-masonry' == $this->check_and_return( $instance, 'design', 'liststyle' ) ? '' : '' ); $classes[] = 'column' . ( 'on' != $this->check_and_return( $instance, 'design', 'gutter' ) ? '-flush' : '' ); $classes[] = $this->check_and_return( $item_instance, 'design', 'advanced', 'customclass' ); // Apply custom class from design-bar's advanced control. if( $this->check_and_return( $item_instance, 'design' , 'background', 'image' ) || '' != $this->check_and_return( $item_instance, 'design' , 'background', 'color' ) ) $classes[] = 'content'; if( false != $media ) $classes[] = 'has-image'; $classes = apply_filters( 'layers_content_widget_item_class', $classes, $this, $item_instance ); $classes = implode( ' ', $classes ); ?>
check_and_return( $instance, 'design', 'gutter' ) ) { $column_inner_classes[] = 'no-push-bottom'; } if( $this->check_and_return( $item_instance, 'design', 'background' , 'color' ) ) { if( 'dark' == layers_is_light_or_dark( $this->check_and_return( $item_instance, 'design', 'background' , 'color' ) ) ) { $column_inner_classes[] = 'invert'; } } else { if( $this->check_and_return( $instance, 'design', 'background' , 'color' ) && 'dark' == layers_is_light_or_dark( $this->check_and_return( $instance, 'design', 'background' , 'color' ) ) ) { $column_inner_classes[] = 'invert'; } } $column_inner_classes[] = $this->check_and_return( $item_instance, 'design', 'imagealign' ); $column_inner_classes[] = $this->check_and_return( $item_instance, 'design', 'fonts' , 'size' ); $column_inner_classes = implode( ' ', $column_inner_classes ); ?>
check_and_return( $item_instance, 'title') ) { ?> <check_and_return( $item_instance, 'design', 'fonts', 'heading-type' ) ?> class="heading"> > check_and_return( $item_instance, 'design', 'fonts', 'heading-type' ) ?>> check_and_return( $item_instance, 'title' ) || $this->check_and_return( $item_instance, 'excerpt' ) || ( $link_array['link'] && $link_array['text'] ) ) { ?>
check_and_return( $item_instance, 'excerpt' ) ) { ?>
class="button " >
print_inline_css(); if( 'list-masonry' == $this->check_and_return( $instance , 'design', 'liststyle' ) ) { ?>
checkboxes ) ) { foreach( $this->checkboxes as $cb ) { if( isset( $old_instance[ $cb ] ) ) { $old_instance[ $cb ] = strip_tags( $new_instance[ $cb ] ); } } // foreach checkboxes } // if checkboxes return $new_instance; } /** * Widget form * * We use regular HTML here, it makes reading the widget much easier than if we used just php to echo all the HTML out. * */ function form( $instance ){ // Use defaults if $instance is empty. if( empty( $instance ) && ! empty( $this->defaults ) ) { $instance = wp_parse_args( $instance, $this->defaults ); } // Mix in new/unset defaults on every instance load (NEW) $instance = $this->apply_defaults( $instance ); $this->design_bar( 'side', // CSS Class Name array( // Widget Object 'name' => $this->get_layers_field_name( 'design' ), 'id' => $this->get_layers_field_id( 'design' ), 'widget_id' => $this->widget_id, ), $instance, // Widget Values apply_filters( 'layers_column_widget_design_bar_components', array( // Components 'layout', 'liststyle' => array( 'icon-css' => 'icon-list-masonry', 'label' => __( 'List Style', 'layerswp' ), 'wrapper-class' => 'layers-small to layers-pop-menu-wrapper layers-animate', 'elements' => array( 'liststyle' => array( 'type' => 'select-icons', 'name' => $this->get_layers_field_name( 'design', 'liststyle' ) , 'id' => $this->get_layers_field_id( 'design', 'liststyle' ) , 'value' => ( isset( $instance['design'][ 'liststyle' ] ) ) ? $instance['design'][ 'liststyle' ] : NULL, 'options' => array( 'list-grid' => __( 'Grid' , 'layerswp' ), 'list-masonry' => __( 'Masonry' , 'layerswp' ) ) ), 'gutter' => array( 'type' => 'checkbox', 'label' => __( 'Gutter' , 'layerswp' ), 'name' => $this->get_layers_field_name( 'design', 'gutter' ) , 'id' => $this->get_layers_field_id( 'design', 'gutter' ) , 'value' => ( isset( $instance['design']['gutter'] ) ) ? $instance['design']['gutter'] : NULL ) ) ), 'background', 'advanced', ), $this, $instance ) ); ?>
form_elements()->header( array( 'title' =>'Content', 'icon_class' =>'text' ) ); ?>
form_elements()->input( array( 'type' => 'text', 'name' => $this->get_layers_field_name( 'title' ) , 'id' => $this->get_layers_field_id( 'title' ) , 'placeholder' => __( 'Enter title here' , 'layerswp' ), 'value' => ( isset( $instance['title'] ) ) ? $instance['title'] : NULL , 'class' => 'layers-text layers-large layers-input-has-controls', ) ); ?> design_bar( 'top', // CSS Class Name array( // Widget Object 'name' => $this->get_layers_field_name( 'design' ), 'id' => $this->get_layers_field_id( 'design' ), 'widget_id' => $this->widget_id, 'show_trash' => FALSE, 'inline' => TRUE, 'align' => 'right', ), $instance, // Widget Values apply_filters( 'layers_column_widget_inline_design_bar_components', array( // Components 'fonts', ), $this, $instance ) ); ?>
form_elements()->input( array( 'type' => 'rte', 'name' => $this->get_layers_field_name( 'excerpt' ) , 'id' => $this->get_layers_field_id( 'excerpt' ) , 'placeholder' => __( 'Short Excerpt' , 'layerswp' ), 'value' => ( isset( $instance['excerpt'] ) ) ? $instance['excerpt'] : NULL , 'class' => 'layers-textarea layers-large' ) ); ?>
repeater( 'column', $instance ); ?>
apply_defaults( $item_instance, 'column' ); ?>
  • format_repeater_title( $item_instance['title'] ); ?>
    design_bar( 'top', // CSS Class Name array( // Widget Object 'name' => $this->get_layers_field_name( 'design' ), 'id' => $this->get_layers_field_id( 'design' ), 'widget_id' => $this->widget_id . '_item', 'number' => $this->number, 'show_trash' => TRUE, ), $item_instance, // Widget Values apply_filters( 'layers_column_widget_column_design_bar_components', array( // Components 'background', 'featuredimage', 'imagealign', 'fonts', 'buttons' => array( 'icon-css' => 'icon-call-to-action', 'label' => __( 'Buttons', 'layerswp' ), 'elements' => array( 'layers-pro-upsell' =>array( 'type' => 'html', 'html' => '
    Upgrade to Layers Pro
    Want more control over your button styling and sizes? Purchase Layers Pro and gain more control over your button styling!
    ' ) ), 'elements_combine' => 'replace', ), 'width' => array( 'icon-css' => 'icon-columns', 'label' => 'Column Width', 'elements' => array( 'layout' => array( 'type' => 'select', 'label' => __( '' , 'layerswp' ), 'name' => $this->get_layers_field_name( 'width' ), 'id' => $this->get_layers_field_id( 'width' ), 'value' => ( isset( $item_instance['width'] ) ) ? $item_instance['width'] : NULL, 'options' => array( '1' => __( '1 of 12 columns' , 'layerswp' ), '2' => __( '2 of 12 columns' , 'layerswp' ), '3' => __( '3 of 12 columns' , 'layerswp' ), '4' => __( '4 of 12 columns' , 'layerswp' ), '5' => __( '5 of 12 columns' , 'layerswp' ), '6' => __( '6 of 12 columns' , 'layerswp' ), '7' => __( '7 of 12 columns' , 'layerswp' ), '8' => __( '8 of 12 columns' , 'layerswp' ), '9' => __( '9 of 12 columns' , 'layerswp' ), '10' => __( '10 of 12 columns' , 'layerswp' ), '11' => __( '11 of 12 columns' , 'layerswp' ), '12' => __( '12 of 12 columns' , 'layerswp' ) ) ) ) ), 'advanced' => array( 'elements' => array( 'padding' => array( 'type' => 'trbl-fields', 'label' => __( 'Padding (px)', 'layerswp' ), 'name' => $this->get_layers_field_name( 'design', 'advanced', 'padding' ), 'id' => $this->get_layers_field_id( 'design', 'advanced', 'padding' ), 'value' => ( isset( $item_instance['design']['advanced']['padding'] ) ) ? $item_instance['design']['advanced']['padding'] : NULL, 'fields' => array( 'top', 'right', 'bottom', 'left', ), ), 'margin' => array( 'type' => 'trbl-fields', 'label' => __( 'Margin (px)', 'layerswp' ), 'name' => $this->get_layers_field_name( 'design', 'advanced', 'margin' ), 'id' => $this->get_layers_field_id( 'design', 'advanced', 'margin' ), 'value' => ( isset( $item_instance['design']['advanced']['margin'] ) ) ? $item_instance['design']['advanced']['margin'] : NULL, 'fields' => array( 'top', 'bottom', ), ), 'customclass', ), 'elements_combine' => 'replace', ), ), $this, $item_instance ) ); ?>

    form_elements()->input( array( 'type' => 'text', 'name' => $this->get_layers_field_name( 'title' ), 'id' => $this->get_layers_field_id( 'title' ), 'placeholder' => __( 'Enter title here' , 'layerswp' ), 'value' => ( isset( $item_instance['title'] ) ) ? $item_instance['title'] : NULL , 'class' => 'layers-text' ) ); ?>

    form_elements()->input( array( 'type' => 'rte', 'name' => $this->get_layers_field_name( 'excerpt' ), 'id' => $this->get_layers_field_id( 'excerpt' ), 'placeholder' => __( 'Short Excerpt' , 'layerswp' ), 'value' => ( isset( $item_instance['excerpt'] ) ) ? $item_instance['excerpt'] : NULL , 'class' => 'layers-form-item layers-textarea', 'rows' => 6 ) ); ?>

    convert_legacy_widget_links( $item_instance, 'button' ); ?>
    form_elements()->input( array( 'type' => 'link-group', 'name' => $this->get_layers_field_name( 'button' ), 'id' => $this->get_layers_field_id( 'button' ), 'value' => ( isset( $item_instance['button'] ) ) ? $item_instance['button'] : NULL, ) ); ?>