Advertisement
Guest User

Untitled

a guest
Mar 9th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. <?php if ( ! defined( 'ABSPATH' ) ) { die( 'Tranquility - the highest manifestation of power!' ); }
  2.  
  3. class Fw_Theme_Widget_OurFriends extends WP_Widget {
  4.  
  5.     private
  6.         $options;
  7.     /**
  8.      * Widget constructor.
  9.      */
  10.     function __construct() {
  11.  
  12.         $widget_ops = array( 'description' => __( 'Display your friendly websites.', 'unyson' ) );
  13.         parent::__construct( false, __( 'Kronos / Our friends', 'unyson' ), $widget_ops );
  14.  
  15.         $this->options = array(
  16.             'widget-title' => array(
  17.                 'type'  =>  'text',
  18.                 'label' =>  __('Title', 'unyson'),
  19.                 'placeholder'   =>  ''
  20.             ),
  21.             'widget-text' => array(
  22.                 'type'  =>  'textarea',
  23.                 'label' =>  __('Title', 'unyson'),
  24.                 'help'  =>  __('Widget title', 'unyson'),
  25.                 'placeholder'   =>  ''
  26.             ),
  27.             'widget-check' => array(
  28.                 'type'  =>  'checkbox',
  29.                 'label' =>  __('Title', 'unyson'),
  30.                 'help'  =>  __('Widget title', 'unyson')
  31.             ),
  32.             'widget-repeatable' => array(
  33.                 'type'  =>  'repeatable',
  34.                 'label' =>  __('REPEATABLE', 'unyson'),
  35.                 'help'  =>  __('Testing? :)', 'unyson'),
  36.                 'values'    =>  array(
  37.                     array(
  38.                         'type'  =>  'text',
  39.                         'label' =>  __('test', 'unyson'),
  40.                         'help'  =>  'yey!'
  41.                     ),
  42.                     array(
  43.                         'type'  =>  'textarea',
  44.                         'label' =>  __('test 2', 'unyson'),
  45.                         'help'  =>  'yey!'
  46.                     ),
  47.                     array(
  48.                         'type'  =>  'checkbox',
  49.                         'label' =>  __('test 3', 'unyson'),
  50.                         'help'  =>  'yey!'
  51.                     )
  52.                 )
  53.             ),
  54.         );
  55.  
  56.     }
  57.  
  58.     function widget( $args, $instance ) {
  59.         extract( $args );
  60.         $params = array();
  61.  
  62.         foreach ( $instance as $key => $value ) {
  63.             $params[ $key ] = $value;
  64.         }
  65.  
  66.         $title = $before_title . $params['widget-title'] . $after_title;
  67.         unset( $params['widget-title'] );
  68.  
  69.         $filepath = dirname( __FILE__ ) . '/views/widget.php';
  70.  
  71.         $instance      = $params;
  72.         $before_widget = str_replace( 'class="', 'class="windy-wrapper ', $before_widget );
  73.  
  74.         if ( file_exists( $filepath ) ) {
  75.             include( $filepath );
  76.         }
  77.     }
  78.  
  79.     function update( $new_instance, $old_instance ) {
  80.  
  81.         $builder = new PrilerWidgetOptionsFramework($this->options);
  82.         $values = $builder->get_values();
  83.  
  84.         $instance = wp_parse_args( (array) $new_instance, $old_instance );
  85.         $instance = array_merge($instance, $values);
  86.  
  87.         return $instance;
  88.     }
  89.  
  90.     function form( $instance ) {
  91.  
  92.         $builder = new PrilerWidgetOptionsFramework($this->options, $instance);
  93.         $builder->render_options();
  94.  
  95.     }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement