Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Category_Tabs_Widget extends WP_Widget {
- function __construct() {
- parent::__construct(
- // base ID of the widget
- 'category_tabs_widget',
- // name of the widget
- __('Categpry Tabs', 'custom' ),
- // widget options
- array (
- 'description' => __( 'Creates tabs based on selected widgets and returns 4 posts.', 'custom' )
- )
- );
- }
- function form( $instance ) {
- if( $instance )
- $select = $instance['select'];
- else
- $select ='';
- // markup for form
- ?>
- <p>
- <label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php _e('Title:', 'thstlang') ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name('select'); ?>" value="<?php echo $instance['title']; ?>" />
- </p>
- <!-- Category Select Menu -->
- <p>
- <select id="<?php echo $this->get_field_id('select'); ?>" name="<?php echo $this->get_field_name('select'); ?>[]" class="widefat" style="width:100%;" multiple="multiple">
- <?php foreach(get_terms('product_cat','hide_empty=1') as $term) { ?>
- <option <?php selected( $instance['select'], $term->term_id ); ?> value="<?php echo $term->term_id; ?>"><?php echo $term->name; ?></option>
- <?php } ?>
- </select>
- </p>
- <?php
- }
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['select'] = esc_sql( $new_instance['select'] );
- return $instance;
- }
- function widget( $args, $instance ) {
- // kick things off
- extract( $args );
- echo $before_widget;
- print_r();
- // echo $before_title . 'In this section:' . $after_title;
- // run a query if on a page
- ?>
- <div class="wpb_tabs wpb_content_element" data-interval="0">
- <div class="wpb_wrapper wpb_tour_tabs_wrapper ui-tabs vc_clearfix ui-widget ui-widget-content ui-corner-all">
- <ul class="wpb_tabs_nav ui-tabs-nav vc_clearfix ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist"><li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tab-1407172281-1-37" aria-labelledby="ui-id-1" aria-selected="false" aria-expanded="false"><a href="#tab-1407172281-1-37" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-1">Tab 1</a></li><li class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tab-1407172423209-2-9" aria-labelledby="ui-id-2" aria-selected="false" aria-expanded="false"><a href="#tab-1407172423209-2-9" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-2">Tab 2</a></li><li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="tab-1407172430389-2-4" aria-labelledby="ui-id-3" aria-selected="true" aria-expanded="true"><a href="#tab-1407172430389-2-4" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-3">Tab 3</a></li></ul>
- <div id="tab-1407172281-1-37" class="wpb_tab ui-tabs-panel wpb_ui-tabs-hide vc_clearfix ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-1" role="tabpanel" aria-hidden="true" style="display: none;">
- <div class="wpb_text_column wpb_content_element ">
- <div class="wpb_wrapper">
- <p>Lorem ipsum pharetra lorem felis. Aliquam egestas consectetur elementum class aptentea taciti sociosqu ad litora torquent perea conubia nostra lorem consectetur adipiscing elit. Donec vestibulum justo a diam ultricies pellentesque.</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php
- echo $after_widget;
- }
- }
- ?>
- <?php
- function category_tabs_widget_regiseter() {
- register_widget( 'Category_Tabs_Widget' );
- }
- add_action( 'widgets_init', 'category_tabs_widget_regiseter' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement