<?php
if ( !class_exists('WP_Widget_Info') ) {
  class WP_Widget_MABP_Info extends WP_Widget {

      // Constructor
    function WP_Widget_MABP_Info() {

      $widget_ops   = array('description' => __('Displays information in the footer site.', 'myarcadetheme'));

      $this->WP_Widget('MABP_Info', __('MyArcadeTheme Info', 'myarcadetheme'), $widget_ops);
    }

      // Display Widget
    function widget($args, $instance) {
      extract($args);

      $title = apply_filters('widget_title', esc_attr($instance['title']));
      echo $before_widget.$before_title.$title.$after_title;
      ?>
      <div class="logo" itemscope itemtype="http://schema.org/Organization">
        <a href="<?php echo home_url(); ?>" title="<?php bloginfo('name');?>" itemprop="url">
          <?php
          $logoft = myarcadetheme_get_option( 'logoft' );
          if ( ! empty( $logoft['url'] ) ) : ?>
            <img src="<?php echo $logoft['url']; ?>" alt="<?php bloginfo('blogname'); ?>" itemprop="logo">
          <?php else: ?>
            <?php bloginfo('blogname'); ?>
          <?php endif; ?>
        </a>
      </div>

      <?php echo $instance['code']; ?>
      <ul class="lst-social">
        <?php get_template_part( "partials/social", "share" ); ?>
      </ul>
      <?php
      echo $after_widget;
    }

      // Update Widget
    function update($new_instance, $old_instance) {

      $instance = $old_instance;
      $instance['title'] = strip_tags($new_instance['title']);
      $instance['code'] = $new_instance['code'];

      return $instance;
    }

      // Display Widget Control Form
    function form($instance) {
      global $wpdb;

      $instance = wp_parse_args((array) $instance, array('title' => __('MyArcadeTheme', 'myarcadetheme'), 'code' => '<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>'));

      $title = esc_attr($instance['title']);
      $code = $instance['code'];

      ?>

      <p>
        <label for="<?php echo $this->get_field_id('title'); ?>">
          <?php _e('Title', 'myarcadetheme'); ?>
          <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
        </label>
      </p>

      <p>
        <label for="<?php echo $this->get_field_id('code'); ?>">
          <?php _e('Text', 'myarcadetheme'); ?>
          <textarea rows="10" class="widefat" id="<?php echo $this->get_field_id('code'); ?>"  name="<?php echo $this->get_field_name('code'); ?>"><?php echo $code; ?></textarea>
        </label>
      </p>

      <?php
    }
  }
}
?>