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 ); ?>
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()->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' ); ?>