Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * wollaston Coustom Widgts Section Two
- *
- * @package wtc
- * @since 1.0
- * @license GPL 2.0
- */
- /*--------------------------------------------------------------
- >>> TABLE OF CONTENTS: CUSTOM wollaston WIDGETS
- ----------------------------------------------------------------
- 1.0 - wollaston S2: Contruct
- 1.1 - wollaston S2: Widget Decloration
- 1.2 - wollaston S2: Widget Form
- 1.2.1 - Custom Background Image uploader
- 1.2.2 - Custom Menu Selction
- 1.2.3 - Introductory Text Area
- 2.0 Typography
- 3.0 Elements
- 4.0 Forms
- 5.0 Navigation
- 5.1 Links
- 5.2 Menus
- 6.0 Accessibility
- 7.0 Alignments
- 8.0 Clearings
- 9.0 Widgets
- 10.0 Content
- 10.1 Posts and pages
- 10.2 Asides
- 10.3 Comments
- 11.0 Infinite scroll
- 12.0 Media
- 12.1 Captions
- 12.2 Galleries
- --------------------------------------------------------------*/
- /*--------------------------------------------------------------
- >>> 1.0 - wollaston S2: Contruct
- --------------------------------------------------------------*/
- class wollaston_split_six_Widget extends WP_Widget {
- public function __construct() {
- // widget actual processes
- parent::__construct(
- 'sec-two-widget', // Base ID
- __('Home: Split Six', 'wtc'), // Name
- array(
- 'description' => __( 'Click here to edit section two template', 'wtc' ),
- 'panels_groups' => array('home')
- ) // Args
- );
- add_action( 'sidebar_admin_setup', array( $this, 'admin_setup' ) );
- }
- /// Declare Widget Form Styles and Functions
- function admin_setup(){
- wp_enqueue_media();
- wp_register_script('wtc-admin-js', get_template_directory_uri() . '/widgets/src/wtc_uploader.js', array( 'jquery', 'media-upload', 'media-views' ) );
- wp_enqueue_script('wtc-admin-js');
- wp_enqueue_style('wtc-admin', get_template_directory_uri() . '/widgets/src/wtc_styles.css' );
- }
- // >>> 1.2 - wollaston S2: widget Form
- //-------------------------------------------------------------*/
- /**
- * @param array $instance
- * @return string|void
- */
- public function form( $instance ) {
- $title = esc_attr($instance['title']);
- $link_1 = esc_attr($instance['link_1']);
- $link_2 = esc_attr($instance['link_2']);
- $subtitle = esc_attr($instance['subtitle']);
- $sec_colour = esc_attr($instance['sec_colour']);
- $read_more = esc_attr($instance['read_more']);
- $nav_menu1 = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
- $textarea = esc_textarea($instance['textarea']);
- $bg_image_1 = ( isset( $instance['background_image_1'] ) ) ? $instance['background_image_1'] : '';
- $bg_image_2 = ( isset( $instance['background_image_2'] ) ) ? $instance['background_image_2'] : '';
- $menu_title = isset( $instance['menu_title'] ) ? $instance['menu_title'] : '';
- $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
- //Video Control
- $video_phdr = ( isset( $instance['video_phdr'] ) ) ? $instance['video_phdr'] : '';
- $video_link = esc_attr($instance['video_link']);
- // Get menus
- $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
- $menu_opt = isset( $instance['menu_opt'] ) ? $instance['menu_opt'] : '';
- ?>
- <!-- Load icon set -->
- <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
- <script>
- // init script for tabs
- jQuery(document).ready(function($){
- var tabs = $('.cd-tabs');
- tabs.each(function(){
- var tab = $(this),
- tabItems = tab.find('ul.cd-tabs-navigation'),
- tabContentWrapper = tab.children('ul.cd-tabs-content'),
- tabNavigation = tab.find('nav');
- tabItems.on('click', 'a', function(event){
- event.preventDefault();
- var selectedItem = $(this);
- if( !selectedItem.hasClass('selected') ) {
- var selectedTab = selectedItem.data('content'),
- selectedContent = tabContentWrapper.find('li[data-content="'+selectedTab+'"]'),
- slectedContentHeight = selectedContent.innerHeight();
- tabItems.find('a.selected').removeClass('selected');
- selectedItem.addClass('selected');
- selectedContent.addClass('selected').siblings('li').removeClass('selected');
- //animate tabContentWrapper height when content changes
- tabContentWrapper.animate({
- 'height': slectedContentHeight
- }, 200);
- }
- });
- //hide the .cd-tabs::after element when tabbed navigation has scrolled to the end (mobile version)
- checkScrolling(tabNavigation);
- tabNavigation.on('scroll', function(){
- checkScrolling($(this));
- });
- });
- $(window).on('resize', function(){
- tabs.each(function(){
- var tab = $(this);
- checkScrolling(tab.find('nav'));
- tab.find('.cd-tabs-content').css('height', 'auto');
- });
- });
- function checkScrolling(tabs){
- var totalTabWidth = parseInt(tabs.children('.cd-tabs-navigation').width()),
- tabsViewport = parseInt(tabs.width());
- if( tabs.scrollLeft() >= totalTabWidth - tabsViewport) {
- tabs.parent('.cd-tabs').addClass('is-ended');
- } else {
- tabs.parent('.cd-tabs').removeClass('is-ended');
- }
- }
- });
- </script>
- <div class="cd-tabs">
- <nav>
- <ul class="cd-tabs-navigation">
- <li><a data-content="layout" class="selected" href="#3"><i class="fa fa-columns fa-3x"></i><p>Layout</p></a></li>
- <li><a data-content="content" href="#3"><i class="fa fa-file-text-o fa-3x"></i><p>Content</p></a></li>
- <li><a data-content="video" href="#3"><i class="fa fa-file-video-o k fa-3x"></i></i><p>Video</p></a></li>
- </ul> <!-- cd-tabs-navigation -->
- </nav>
- <!-- Content -->
- <ul class="cd-tabs-content">
- <!-- 1.2.3 >>> Layout -->
- <li data-content="layout" class="selected">
- <div class="main-widget-content">
- <h1>layout</h1>
- <hr>
- <p class="discp">This section allows you to edit middle content of the widget. Select which category you wish to edit and click "done" on the bottom right corner then "update" on the top right corner to save the updated information.</p></br></br>
- <div class="widget-col-left">
- <!-- 1.2.1 >>> Custom Background Image uploader -->
- <div class="widget-input">
- <h3>Upload or Edit your Image</h3>
- <p class="discp">Click below on the 'Select Image" button to add a background image for this section</p>
- <div id="background_image_preview_1" class="preview_placholder">
- <?php
- if ($bg_image_1!='') echo '<img src="' . $bg_image_1 . '" height="auto" width="100%" align="middle"/>';
- ?>
- </div>
- <p class="discp">URL Link</p>
- <input class="background_image upld-crtl" id="<?php echo $this->get_field_id( 'background_image_1' ); ?>"
- name="<?php echo $this->get_field_name( 'background_image_1' ); ?>" value="<?php echo $bg_image_1 ?>" type="text" readonly>
- <button id="background_image_button" class="button btn-crtl" onclick="image_button_click('Choose Background Image','Select Image','image','background_image_preview_1','<?php echo $this->get_field_id( 'background_image_1' ); ?>');"><i class="fa fa-upload fa-2x"></i></button>
- </div>
- </div>
- <div class="widget-col-right">
- <!-- 1.2.1 >>> Custom Background Image uploader -->
- <div class="widget-input">
- <h3>Upload or Edit your Image</h3>
- <p class="discp">Click below on the 'Select Image" button to add a background image for this section</p>
- <div id="background_image_preview_2" class="preview_placholder">
- <?php
- if ($bg_image_2!='') echo '<img src="' . $bg_image_2 . '" height="auto" width="100%" align="middle"/>';
- ?>
- </div>
- <p class="discp">URL Link</p>
- <input class="background_image upld-crtl" id="<?php echo $this->get_field_id( 'background_image_2' ); ?>"
- name="<?php echo $this->get_field_name( 'background_image_2' ); ?>" value="<?php echo $bg_image_2 ?>" type="text" readonly>
- <button id="background_image_button" class="button btn-crtl" onclick="image_button_click('Choose Background Image','Select Image','image','background_image_preview_2','<?php echo $this->get_field_id( 'background_image_2' ); ?>');"><i class="fa fa-upload fa-2x"></i></button>
- </div>
- </div>
- </div>
- </li>
- <li data-content="content" >
- <div class="main-widget-content">
- <h1>Content</h1>
- <hr>
- <p class="discp">This section allows you to edit middle content of the widget. Select which category you wish to edit and click "done" on the bottom right corner then "update" on the top right corner to save the updated information.</p></br></br>
- <div class="widget-col-left">
- <!-- 1.2.3 >>> Title Text Area -->
- <div class="widget-input">
- <h3>Title</h3>
- <p class="discp">Type in the title text in the text area below to wish to display in this section</p>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('title1') ?>" name="<?php echo $this->get_field_name('title1') ?>" value="<?php echo esc_textarea($instance['title1']) ?>" type="text" />
- </div>
- <div class="widget-input">
- <h3>Sub Title</h3>
- <p class="discp">Type in the title text in the text area below to wish to display in this section</p>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('subtitle1') ?>" name="<?php echo $this->get_field_name('subtitle1') ?>" value="<?php echo esc_textarea($instance['subtitle1']) ?>" type="text" />
- </div>
- <!-- 1.2.3 >>> Link Attribute -->
- <div class="widget-input">
- <h3>Link</h3>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('link_1') ?>" name="<?php echo $this->get_field_name('link_1') ?>" value="<?php echo $link_1; ?>" type="text" />
- </div>
- <!-- 1.2.3 >>> Backgroun Colour -->
- <div class="widget-input">
- <h3>Section Colour</h3>
- <p class="discp">Type in the Hex colour code to colour this section. Hex colour codes can be found at <a target="_blank" href="https://www.w3schools.com/colors/colors_picker.asp">here.</a> </p>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('sec_colour1') ?>" name="<?php echo $this->get_field_name('sec_colour1') ?>" value="<?php echo esc_textarea($instance['sec_colour1']) ?>" type="text" />
- </div>
- </div>
- <div class="widget-col-right">
- <!-- 1.2.3 >>> Title Text Area -->
- <div class="widget-input">
- <h3>Title</h3>
- <p class="discp">Type in the title text in the text area below to wish to display in this section</p>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('title2') ?>" name="<?php echo $this->get_field_name('title2') ?>" value="<?php echo esc_textarea($instance['title2']) ?>" type="text" />
- </div>
- <div class="widget-input">
- <h3>Sub Title</h3>
- <p class="discp">Type in the title text in the text area below to wish to display in this section</p>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('subtitle2') ?>" name="<?php echo $this->get_field_name('subtitle2') ?>" value="<?php echo esc_textarea($instance['subtitle2']) ?>" type="text" />
- </div>
- <!-- 1.2.3 >>> Link Attribute -->
- <div class="widget-input">
- <h3>Link</h3>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('link_2') ?>" name="<?php echo $this->get_field_name('link_2') ?>" value="<?php echo $link_2; ?>" type="text" />
- </div>
- <!-- 1.2.3 >>> Backgroun Colour -->
- <div class="widget-input">
- <h3>Section Colour</h3>
- <p class="discp">Type in the Hex colour code to colour this section. Hex colour codes can be found at <a target="_blank" href="https://www.w3schools.com/colors/colors_picker.asp">here.</a> </p>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('sec_colour2') ?>" name="<?php echo $this->get_field_name('sec_colour2') ?>" value="<?php echo esc_textarea($instance['sec_colour2']) ?>" type="text" />
- </div>
- </div>
- </div>
- </li>
- <li data-content="video" >
- <div class="main-widget-content">
- <h1>Video</h1>
- <hr>
- <p></p>
- <div class="widget-col-left">
- <div class="widget-input">
- <h3>Upload or Edit your Image</h3>
- <p class="discp">Click below on the 'Select Image" button to add a background image for this section</p>
- <div id="video_image_preview" class="preview_placholder">
- <?php
- if ($video_phdr!='') echo '<img src="' . $video_phdr . '" height="auto" width="100%" align="middle"/>';
- ?>
- </div>
- <p class="discp">URL Link</p>
- <input class="background_image upld-crtl" id="<?php echo $this->get_field_id( 'video_phdr' ); ?>"
- name="<?php echo $this->get_field_name( 'video_phdr' ); ?>" value="<?php echo $video_phdr ?>" type="text" readonly>
- <button id="background_image_button" class="button btn-crtl" onclick="image_button_click('Choose Background Image','Select Image','image','background_image_preview','<?php echo $this->get_field_id( 'video_phdr' ); ?>');"><i class="fa fa-upload fa-2x"></i></button>
- </div>
- </div>
- <div class="widget-col-right">
- <!-- 1.2.3 >>> Video URL link -->
- <div class="widget-input">
- <h3>Video Link</h3>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('video_link') ?>" name="<?php echo $this->get_field_name('video_link') ?>" value="<?php echo $video_link; ?>" type="text" />
- </div>
- </div>
- </div>
- </li>
- </ul>
- </div>
- <?php
- }
- // Update Custom functions
- function update($new_instance, $old_instance) {
- $instance = $old_instance;
- // Update Fields
- $instance['title'] = strip_tags($new_instance['title']);
- $instance['link_1'] = strip_tags($new_instance['link_1']);
- $instance['link_2'] = strip_tags($new_instance['link_2']);
- $instance['subtitle'] = strip_tags($new_instance['subtitle']);
- $instance['sec_colour'] = strip_tags($new_instance['sec_colour']);
- $instance['thematic'] = strip_tags($new_instance['thematic']);
- $instance['textarea'] = strip_tags($new_instance['textarea']);
- $instance['video_link'] = strip_tags($new_instance['video_link']);
- $instance['read_more'] = strip_tags($new_instance['read_more']);
- $instance['sub_title'] = strip_tags($new_instance['sub_title']);
- $instance['background_image_1'] = strip_tags($new_instance['background_image_1']);
- $instance['background_image_2'] = strip_tags($new_instance['background_image_2']);
- return $instance;
- }
- //>>> 1.1 - wollaston S2: widget decloration
- //-------------------------------------------------------------*/
- public function widget( $args, $instance ) {
- wp_enqueue_style('wtc-home-sec-ten-style', get_stylesheet_directory_uri(). '/widgets/components/wtc_home/wtc_h10/lib/css/wtc-h10.style.css' );
- $bg_image_1 = ! empty( $instance['background_image_1'] ) ? $instance['background_image_1'] : false;
- $bg_image_2 = ! empty( $instance['background_image_2'] ) ? $instance['background_image_2'] : false;
- $title1 = $instance['title1'];
- $title2 = $instance['title2'];
- $link_1 = $instance['link_1'];
- $link_2 = $instance['link_2'];
- $subtitle1 = $instance['subtitle1'];
- $subtitle2 = $instance['subtitle2'];
- $sec_colour1 = $instance['sec_colour1'];
- $sec_colour2 = $instance['sec_colour2'];
- //Video Control
- $video_phdr = ! empty( $instance['video_phdr'] ) ? $instance['video_phdr'] : false;
- $video_link = $instance['video_link'];
- echo $args['before_widget'];
- $upload_dir = wp_upload_dir();
- ?>
- <section class="ad-waypoint" data-animate-down="site-primary-menu-med" data-animate-up="site-primary-menu-med">
- <div class="sec-one-wrapper">
- <div class="fg-no-gutter">
- <div class="fg6 ">
- <div class="sec-ten-one-left" style="background: url(<?php echo $bg_image_1 ?>) no-repeat center center; background-size:cover;">
- <a target="_blank" href="<?php echo $link_1; ?>">
- <div class="sec-ten-top-wrapper" style="background-color:<?php echo $sec_colour1; ?>">
- <h3> <?php echo $title1; ?></h3>
- <p> <?php echo $subtitle1; ?> </p>
- </div>
- </a>
- </div>
- </div>
- <div class="fg6 ">
- <div class="sec-ten-one-left" style="background: url(<?php echo $bg_image_2 ?>) no-repeat center center; background-size:cover;">
- <a target="_blank" href="<?php echo $link_2; ?>">
- <div class="sec-ten-top-wrapper" style="background-color:<?php echo $sec_colour2; ?>">
- <h3> <?php echo $title2; ?></h3>
- <p> <?php echo $subtitle2; ?> </p>
- </div>
- </a>
- </div>
- </div>
- </div>
- </div>
- </section>
- <?php
- echo $args['after_widget'];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment